Skip to content

Commit 0c52f1e

Browse files
YoshiRikaigohirao
authored andcommitted
feat(map_based_prediction, etc): publish processing time in various perception nodes (autowarefoundation#6574)
* feat: fix processing time publisher Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com> * feat: add processing_time in detection_by_tracker Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com> * feat: add processing time publisher to shape estimator Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com> * feat: add latency time for association merger Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com> * feat: add processing time publisher for tracker merger Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com> * chore: rename pipeline latency in multi object tracker Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com> --------- Signed-off-by: yoshiri <yoshiyoshidetteiu@gmail.com> Signed-off-by: kaigohirao <kaigo.hirao@proxima-ai-tech.com>
1 parent 5da0e7d commit 0c52f1e

File tree

12 files changed

+104
-23
lines changed

12 files changed

+104
-23
lines changed

perception/detection_by_tracker/include/detection_by_tracker/debugger.hpp

+23
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <euclidean_cluster/voxel_grid_based_euclidean_cluster.hpp>
2121
#include <rclcpp/rclcpp.hpp>
2222
#include <shape_estimation/shape_estimator.hpp>
23+
#include <tier4_autoware_utils/ros/debug_publisher.hpp>
24+
#include <tier4_autoware_utils/system/stop_watch.hpp>
2325

2426
#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
2527
#include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>
@@ -61,6 +63,11 @@ class Debugger
6163
divided_objects_pub_ =
6264
node->create_publisher<autoware_auto_perception_msgs::msg::DetectedObjects>(
6365
"debug/divided_objects", 1);
66+
processing_time_publisher_ =
67+
std::make_unique<tier4_autoware_utils::DebugPublisher>(node, "detection_by_tracker");
68+
stop_watch_ptr_ =
69+
std::make_unique<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>>();
70+
this->startStopWatch();
6471
}
6572

6673
~Debugger() {}
@@ -80,6 +87,19 @@ class Debugger
8087
{
8188
divided_objects_pub_->publish(removeFeature(input));
8289
}
90+
void startStopWatch()
91+
{
92+
stop_watch_ptr_->tic("cyclic_time");
93+
stop_watch_ptr_->tic("processing_time");
94+
}
95+
void startMeasureProcessingTime() { stop_watch_ptr_->tic("processing_time"); }
96+
void publishProcessingTime()
97+
{
98+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
99+
"debug/cyclic_time_ms", stop_watch_ptr_->toc("cyclic_time", true));
100+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
101+
"debug/processing_time_ms", stop_watch_ptr_->toc("processing_time", true));
102+
}
83103

84104
private:
85105
rclcpp::Publisher<autoware_auto_perception_msgs::msg::DetectedObjects>::SharedPtr
@@ -90,6 +110,9 @@ class Debugger
90110
merged_objects_pub_;
91111
rclcpp::Publisher<autoware_auto_perception_msgs::msg::DetectedObjects>::SharedPtr
92112
divided_objects_pub_;
113+
// debug publisher
114+
std::unique_ptr<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
115+
std::unique_ptr<tier4_autoware_utils::DebugPublisher> processing_time_publisher_;
93116

94117
autoware_auto_perception_msgs::msg::DetectedObjects removeFeature(
95118
const tier4_perception_msgs::msg::DetectedObjectsWithFeature & input)

perception/detection_by_tracker/src/detection_by_tracker_core.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ void DetectionByTracker::setMaxSearchRange()
206206
void DetectionByTracker::onObjects(
207207
const tier4_perception_msgs::msg::DetectedObjectsWithFeature::ConstSharedPtr input_msg)
208208
{
209+
debugger_->startMeasureProcessingTime();
209210
autoware_auto_perception_msgs::msg::DetectedObjects detected_objects;
210211
detected_objects.header = input_msg->header;
211212

@@ -250,6 +251,7 @@ void DetectionByTracker::onObjects(
250251
}
251252

252253
objects_pub_->publish(detected_objects);
254+
debugger_->publishProcessingTime();
253255
}
254256

255257
void DetectionByTracker::divideUnderSegmentedObjects(

perception/map_based_prediction/README.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,13 @@ If the target object is inside the road or crosswalk, this module outputs one or
218218

219219
### Output
220220

221-
| Name | Type | Description |
222-
| ------------------------ | ------------------------------------------------------ | ------------------------------------------------------------------------------------- |
223-
| `~/input/objects` | `autoware_auto_perception_msgs::msg::TrackedObjects` | tracking objects. Default is set to `/perception/object_recognition/tracking/objects` |
224-
| `~/output/objects` | `autoware_auto_perception_msgs::msg::PredictedObjects` | tracking objects with predicted path. |
225-
| `~/objects_path_markers` | `visualization_msgs::msg::MarkerArray` | marker for visualization. |
221+
| Name | Type | Description |
222+
| ---------------------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------- |
223+
| `~/input/objects` | `autoware_auto_perception_msgs::msg::TrackedObjects` | tracking objects. Default is set to `/perception/object_recognition/tracking/objects` |
224+
| `~/output/objects` | `autoware_auto_perception_msgs::msg::PredictedObjects` | tracking objects with predicted path. |
225+
| `~/objects_path_markers` | `visualization_msgs::msg::MarkerArray` | marker for visualization. |
226+
| `~/debug/processing_time_ms` | `std_msgs::msg::Float64` | processing time of this module. |
227+
| `~/debug/cyclic_time_ms` | `std_msgs::msg::Float64` | cyclic time of this module. |
226228

227229
## Parameters
228230

perception/map_based_prediction/include/map_based_prediction/map_based_prediction_node.hpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "tier4_autoware_utils/ros/update_param.hpp"
2222

2323
#include <rclcpp/rclcpp.hpp>
24+
#include <tier4_autoware_utils/ros/debug_publisher.hpp>
2425
#include <tier4_autoware_utils/ros/transform_listener.hpp>
2526
#include <tier4_autoware_utils/ros/uuid_helper.hpp>
2627
#include <tier4_autoware_utils/system/stop_watch.hpp>
@@ -33,7 +34,6 @@
3334
#include <geometry_msgs/msg/pose.hpp>
3435
#include <geometry_msgs/msg/pose_stamped.hpp>
3536
#include <geometry_msgs/msg/twist.hpp>
36-
#include <tier4_debug_msgs/msg/string_stamped.hpp>
3737
#include <visualization_msgs/msg/marker_array.hpp>
3838

3939
#include <lanelet2_core/Forward.h>
@@ -125,11 +125,14 @@ class MapBasedPredictionNode : public rclcpp::Node
125125
// ROS Publisher and Subscriber
126126
rclcpp::Publisher<PredictedObjects>::SharedPtr pub_objects_;
127127
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr pub_debug_markers_;
128-
rclcpp::Publisher<StringStamped>::SharedPtr pub_calculation_time_;
129128
rclcpp::Subscription<TrackedObjects>::SharedPtr sub_objects_;
130129
rclcpp::Subscription<HADMapBin>::SharedPtr sub_map_;
131130
rclcpp::Subscription<TrafficSignalArray>::SharedPtr sub_traffic_signals_;
132131

132+
// debug publisher
133+
std::unique_ptr<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
134+
std::unique_ptr<tier4_autoware_utils::DebugPublisher> processing_time_publisher_;
135+
133136
// Object History
134137
std::unordered_map<std::string, std::deque<ObjectData>> objects_history_;
135138
std::map<std::pair<std::string, lanelet::Id>, rclcpp::Time> stopped_times_against_green_;
@@ -196,9 +199,6 @@ class MapBasedPredictionNode : public rclcpp::Node
196199
std::vector<double> distance_set_for_no_intention_to_walk_;
197200
std::vector<double> timeout_set_for_no_intention_to_walk_;
198201

199-
// Stop watch
200-
StopWatch<std::chrono::milliseconds> stop_watch_;
201-
202202
// Member Functions
203203
void mapCallback(const HADMapBin::ConstSharedPtr msg);
204204
void trafficSignalsCallback(const TrafficSignalArray::ConstSharedPtr msg);

perception/map_based_prediction/src/map_based_prediction_node.cpp

+13-12
Original file line numberDiff line numberDiff line change
@@ -646,14 +646,6 @@ ObjectClassification::_label_type changeLabelForPrediction(
646646
}
647647
}
648648

649-
StringStamped createStringStamped(const rclcpp::Time & now, const double data)
650-
{
651-
StringStamped msg;
652-
msg.stamp = now;
653-
msg.data = std::to_string(data);
654-
return msg;
655-
}
656-
657649
// NOTE: These two functions are copied from the route_handler package.
658650
lanelet::Lanelets getRightOppositeLanelets(
659651
const std::shared_ptr<lanelet::LaneletMap> & lanelet_map_ptr,
@@ -816,10 +808,15 @@ MapBasedPredictionNode::MapBasedPredictionNode(const rclcpp::NodeOptions & node_
816808
pub_objects_ = this->create_publisher<PredictedObjects>("~/output/objects", rclcpp::QoS{1});
817809
pub_debug_markers_ =
818810
this->create_publisher<visualization_msgs::msg::MarkerArray>("maneuver", rclcpp::QoS{1});
819-
pub_calculation_time_ = create_publisher<StringStamped>("~/debug/calculation_time", 1);
811+
processing_time_publisher_ =
812+
std::make_unique<tier4_autoware_utils::DebugPublisher>(this, "map_based_prediction");
820813

821814
set_param_res_ = this->add_on_set_parameters_callback(
822815
std::bind(&MapBasedPredictionNode::onParam, this, std::placeholders::_1));
816+
817+
stop_watch_ptr_ = std::make_unique<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>>();
818+
stop_watch_ptr_->tic("cyclic_time");
819+
stop_watch_ptr_->tic("processing_time");
823820
}
824821

825822
rcl_interfaces::msg::SetParametersResult MapBasedPredictionNode::onParam(
@@ -893,7 +890,7 @@ void MapBasedPredictionNode::trafficSignalsCallback(const TrafficSignalArray::Co
893890

894891
void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPtr in_objects)
895892
{
896-
stop_watch_.tic();
893+
stop_watch_ptr_->toc("processing_time", true);
897894
// Guard for map pointer and frame transformation
898895
if (!lanelet_map_ptr_) {
899896
return;
@@ -1116,8 +1113,12 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
11161113
// Publish Results
11171114
pub_objects_->publish(output);
11181115
pub_debug_markers_->publish(debug_markers);
1119-
const auto calculation_time_msg = createStringStamped(now(), stop_watch_.toc());
1120-
pub_calculation_time_->publish(calculation_time_msg);
1116+
const auto processing_time_ms = stop_watch_ptr_->toc("processing_time", true);
1117+
const auto cyclic_time_ms = stop_watch_ptr_->toc("cyclic_time", true);
1118+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
1119+
"debug/cyclic_time_ms", cyclic_time_ms);
1120+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
1121+
"debug/processing_time_ms", processing_time_ms);
11211122
}
11221123

11231124
bool MapBasedPredictionNode::doesPathCrossAnyFence(const PredictedPath & predicted_path)

perception/multi_object_tracker/src/multi_object_tracker_core.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void TrackerDebugger::publishProcessingTime()
148148
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
149149
"debug/processing_time_ms", processing_time_ms);
150150
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
151-
"debug/elapsed_time_from_sensor_input_ms", elapsed_time_from_sensor_input_ * 1e3);
151+
"debug/pipeline_latency_ms", elapsed_time_from_sensor_input_ * 1e3);
152152
}
153153
}
154154

perception/object_merger/include/object_merger/node.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "object_merger/data_association/data_association.hpp"
1919

2020
#include <rclcpp/rclcpp.hpp>
21+
#include <tier4_autoware_utils/ros/debug_publisher.hpp>
22+
#include <tier4_autoware_utils/system/stop_watch.hpp>
2123

2224
#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
2325

@@ -81,6 +83,10 @@ class ObjectAssociationMergerNode : public rclcpp::Node
8183
std::map<int, double> generalized_iou_threshold;
8284
std::map<int /*class label*/, double /*distance_threshold*/> distance_threshold_map;
8385
} overlapped_judge_param_;
86+
87+
// debug publisher
88+
std::unique_ptr<tier4_autoware_utils::DebugPublisher> processing_time_publisher_;
89+
std::unique_ptr<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
8490
};
8591
} // namespace object_association
8692

perception/object_merger/src/object_association_merger/node.cpp

+13
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ ObjectAssociationMergerNode::ObjectAssociationMergerNode(const rclcpp::NodeOptio
118118

119119
merged_object_pub_ = create_publisher<autoware_auto_perception_msgs::msg::DetectedObjects>(
120120
"output/object", rclcpp::QoS{1});
121+
122+
// Debug publisher
123+
processing_time_publisher_ =
124+
std::make_unique<tier4_autoware_utils::DebugPublisher>(this, "object_association_merger");
125+
stop_watch_ptr_ = std::make_unique<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>>();
126+
stop_watch_ptr_->tic("cyclic_time");
127+
stop_watch_ptr_->tic("processing_time");
121128
}
122129

123130
void ObjectAssociationMergerNode::objectsCallback(
@@ -128,6 +135,7 @@ void ObjectAssociationMergerNode::objectsCallback(
128135
if (merged_object_pub_->get_subscription_count() < 1) {
129136
return;
130137
}
138+
stop_watch_ptr_->toc("processing_time", true);
131139

132140
/* transform to base_link coordinate */
133141
autoware_auto_perception_msgs::msg::DetectedObjects transformed_objects0, transformed_objects1;
@@ -215,6 +223,11 @@ void ObjectAssociationMergerNode::objectsCallback(
215223

216224
// publish output msg
217225
merged_object_pub_->publish(output_msg);
226+
// publish processing time
227+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
228+
"debug/cyclic_time_ms", stop_watch_ptr_->toc("cyclic_time", true));
229+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
230+
"debug/processing_time_ms", stop_watch_ptr_->toc("processing_time", true));
218231
}
219232
} // namespace object_association
220233

perception/shape_estimation/src/node.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,17 @@ ShapeEstimationNode::ShapeEstimationNode(const rclcpp::NodeOptions & node_option
5050
RCLCPP_INFO(this->get_logger(), "using boost shape estimation : %d", use_boost_bbox_optimizer);
5151
estimator_ =
5252
std::make_unique<ShapeEstimator>(use_corrector, use_filter, use_boost_bbox_optimizer);
53+
54+
processing_time_publisher_ =
55+
std::make_unique<tier4_autoware_utils::DebugPublisher>(this, "shape_estimation");
56+
stop_watch_ptr_ = std::make_unique<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>>();
57+
stop_watch_ptr_->tic("cyclic_time");
58+
stop_watch_ptr_->tic("processing_time");
5359
}
5460

5561
void ShapeEstimationNode::callback(const DetectedObjectsWithFeature::ConstSharedPtr input_msg)
5662
{
63+
stop_watch_ptr_->toc("processing_time", true);
5764
// Guard
5865
if (pub_->get_subscription_count() < 1) {
5966
return;
@@ -108,6 +115,11 @@ void ShapeEstimationNode::callback(const DetectedObjectsWithFeature::ConstShared
108115

109116
// Publish
110117
pub_->publish(output_msg);
118+
119+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
120+
"debug/cyclic_time_ms", stop_watch_ptr_->toc("cyclic_time", true));
121+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
122+
"debug/processing_time_ms", stop_watch_ptr_->toc("processing_time", true));
111123
}
112124

113125
#include <rclcpp_components/register_node_macro.hpp>

perception/shape_estimation/src/node.hpp

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "shape_estimation/shape_estimator.hpp"
1919

2020
#include <rclcpp/rclcpp.hpp>
21+
#include <tier4_autoware_utils/ros/debug_publisher.hpp>
22+
#include <tier4_autoware_utils/system/stop_watch.hpp>
2123

2224
#include <autoware_auto_perception_msgs/msg/detected_objects.hpp>
2325
#include <tier4_perception_msgs/msg/detected_objects_with_feature.hpp>
@@ -33,6 +35,10 @@ class ShapeEstimationNode : public rclcpp::Node
3335
rclcpp::Publisher<DetectedObjectsWithFeature>::SharedPtr pub_;
3436
rclcpp::Subscription<DetectedObjectsWithFeature>::SharedPtr sub_;
3537

38+
// debug publisher
39+
std::unique_ptr<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
40+
std::unique_ptr<tier4_autoware_utils::DebugPublisher> processing_time_publisher_;
41+
3642
void callback(const DetectedObjectsWithFeature::ConstSharedPtr input_msg);
3743

3844
std::unique_ptr<ShapeEstimator> estimator_;

perception/tracking_object_merger/include/tracking_object_merger/decorative_tracker_merger.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include "tracking_object_merger/utils/utils.hpp"
2121

2222
#include <rclcpp/rclcpp.hpp>
23+
#include <tier4_autoware_utils/ros/debug_publisher.hpp>
24+
#include <tier4_autoware_utils/system/stop_watch.hpp>
2325

2426
#include <autoware_auto_perception_msgs/msg/tracked_objects.hpp>
2527
#include <std_msgs/msg/header.hpp>
@@ -87,6 +89,8 @@ class DecorativeTrackerMergerNode : public rclcpp::Node
8789
rclcpp::Publisher<autoware_auto_perception_msgs::msg::TrackedObjects>::SharedPtr
8890
debug_object_pub_;
8991
bool publish_interpolated_sub_objects_;
92+
std::unique_ptr<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_;
93+
std::unique_ptr<tier4_autoware_utils::DebugPublisher> processing_time_publisher_;
9094

9195
/* handle objects */
9296
std::unordered_map<MEASUREMENT_STATE, std::function<void(TrackedObject &, const TrackedObject &)>>

perception/tracking_object_merger/src/decorative_tracker_merger.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ DecorativeTrackerMergerNode::DecorativeTrackerMergerNode(const rclcpp::NodeOptio
151151
set3dDataAssociation("lidar-radar", data_association_map_);
152152
// radar-radar association matrix
153153
set3dDataAssociation("radar-radar", data_association_map_);
154+
155+
// debug publisher
156+
processing_time_publisher_ =
157+
std::make_unique<tier4_autoware_utils::DebugPublisher>(this, "decorative_object_merger_node");
158+
stop_watch_ptr_ = std::make_unique<tier4_autoware_utils::StopWatch<std::chrono::milliseconds>>();
159+
stop_watch_ptr_->tic("cyclic_time");
160+
stop_watch_ptr_->tic("processing_time");
154161
}
155162

156163
void DecorativeTrackerMergerNode::set3dDataAssociation(
@@ -182,6 +189,7 @@ void DecorativeTrackerMergerNode::set3dDataAssociation(
182189
void DecorativeTrackerMergerNode::mainObjectsCallback(
183190
const TrackedObjects::ConstSharedPtr & main_objects)
184191
{
192+
stop_watch_ptr_->toc("processing_time", true);
185193
// try to merge sub object
186194
if (!sub_objects_buffer_.empty()) {
187195
// get interpolated sub objects
@@ -214,6 +222,10 @@ void DecorativeTrackerMergerNode::mainObjectsCallback(
214222
this->decorativeMerger(main_sensor_type_, main_objects);
215223

216224
merged_object_pub_->publish(getTrackedObjects(main_objects->header));
225+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
226+
"debug/cyclic_time_ms", stop_watch_ptr_->toc("cyclic_time", true));
227+
processing_time_publisher_->publish<tier4_debug_msgs::msg::Float64Stamped>(
228+
"debug/processing_time_ms", stop_watch_ptr_->toc("processing_time", true));
217229
}
218230

219231
/**

0 commit comments

Comments
 (0)