Skip to content

Commit 9653f0b

Browse files
committed
add diagnostics for processing time
Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com>
1 parent da5850e commit 9653f0b

File tree

4 files changed

+61
-15
lines changed

4 files changed

+61
-15
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**:
2+
ros__parameters:
3+
# When the processing time exceeds the max_allowed_processing_time,
4+
# a warning will be triggered.
5+
max_allowed_processing_time: 200.0 # in milliseconds
6+
# If the warning is triggered more than max_consecutive_warn_count times in a row,
7+
# an error diagnostic message will be sent.
8+
max_consecutive_warn_count: 10

perception/autoware_lidar_centerpoint/include/autoware/lidar_centerpoint/node.hpp

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class LidarCenterPointNode : public rclcpp::Node
5555
std::vector<std::string> class_names_;
5656
bool has_variance_{false};
5757
bool has_twist_{false};
58+
float max_allowed_processing_time_;
59+
int max_consecutive_warn_count_;
60+
int consecutive_delay_count_=0;
5861

5962
NonMaximumSuppression iou_bev_nms_;
6063
DetectionClassRemapper detection_class_remapper_;

perception/autoware_lidar_centerpoint/launch/lidar_centerpoint.launch.xml

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<arg name="model_param_path" default="$(find-pkg-share autoware_lidar_centerpoint)/config/$(var model_name).param.yaml"/>
99
<arg name="ml_package_param_path" default="$(var model_path)/$(var model_name)_ml_package.param.yaml"/>
1010
<arg name="class_remapper_param_path" default="$(var model_path)/detection_class_remapper.param.yaml"/>
11+
<arg name="diagnostics_param_path" default="$(find-pkg-share autoware_lidar_centerpoint)/config/centerpoint_diagnostics.param.yaml"/>
1112
<arg name="build_only" default="false" description="shutdown node after TensorRT engine file is built"/>
1213

1314
<arg name="use_pointcloud_container" default="false" description="use pointcloud_container"/>
@@ -21,6 +22,7 @@
2122
<param from="$(var model_param_path)" allow_substs="true"/>
2223
<param from="$(var ml_package_param_path)" allow_substs="true"/>
2324
<param from="$(var class_remapper_param_path)"/>
25+
<param from="$(var diagnostics_param_path)"/>
2426

2527
<!-- This parameter shall NOT be included in param file. See also: https://github.com/autowarefoundation/autoware.universe/pull/6167 -->
2628
<param name="build_only" value="$(var build_only)"/>
@@ -34,6 +36,7 @@
3436
<param from="$(var model_param_path)" allow_substs="true"/>
3537
<param from="$(var ml_package_param_path)" allow_substs="true"/>
3638
<param from="$(var class_remapper_param_path)"/>
39+
<param from="$(var diagnostics_param_path)"/>
3740

3841
<!-- This parameter shall NOT be included in param file. See also: https://github.com/autowarefoundation/autoware.universe/pull/6167 -->
3942
<param name="build_only" value="$(var build_only)"/>

perception/autoware_lidar_centerpoint/src/node.cpp

+47-15
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ LidarCenterPointNode::LidarCenterPointNode(const rclcpp::NodeOptions & node_opti
110110
diagnostics_interface_ptr_ =
111111
std::make_unique<autoware_utils::DiagnosticsInterface>(this, "centerpoint_trt");
112112

113+
// diagnostics parameters
114+
max_allowed_processing_time_ = declare_parameter<float>("max_allowed_processing_time");
115+
max_consecutive_warn_count_ = declare_parameter<int>("max_consecutive_warn_count");
116+
113117
pointcloud_sub_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
114118
"~/input/pointcloud", rclcpp::SensorDataQoS{}.keep_last(1),
115119
std::bind(&LidarCenterPointNode::pointCloudCallback, this, std::placeholders::_1));
@@ -182,24 +186,52 @@ void LidarCenterPointNode::pointCloudCallback(
182186
objects_pub_->publish(output_msg);
183187
published_time_publisher_->publish_if_subscribed(objects_pub_, output_msg.header.stamp);
184188
}
185-
diagnostics_interface_ptr_->publish(input_pointcloud_msg->header.stamp);
186189

187-
// add processing time for debug
188-
if (debug_publisher_ptr_ && stop_watch_ptr_) {
189-
const double cyclic_time_ms = stop_watch_ptr_->toc("cyclic_time", true);
190+
if (stop_watch_ptr_) {
190191
const double processing_time_ms = stop_watch_ptr_->toc("processing_time", true);
191-
const double pipeline_latency_ms =
192-
std::chrono::duration<double, std::milli>(
193-
std::chrono::nanoseconds(
194-
(this->get_clock()->now() - output_msg.header.stamp).nanoseconds()))
195-
.count();
196-
debug_publisher_ptr_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
197-
"debug/cyclic_time_ms", cyclic_time_ms);
198-
debug_publisher_ptr_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
199-
"debug/processing_time_ms", processing_time_ms);
200-
debug_publisher_ptr_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
201-
"debug/pipeline_latency_ms", pipeline_latency_ms);
192+
193+
// check processing time is acceptable
194+
if (processing_time_ms > max_allowed_processing_time_) {
195+
diagnostics_interface_ptr_->add_key_value("is_processing_time_ms_in_expected_range", false);
196+
197+
consecutive_delay_count_++;
198+
199+
if(consecutive_delay_count_ <= max_consecutive_warn_count_){
200+
std::stringstream message;
201+
message << "CenterPoint processing time exceeds the acceptable limit of "
202+
<< max_allowed_processing_time_ << " ms by "
203+
<< (processing_time_ms - max_allowed_processing_time_) << " ms.";
204+
205+
diagnostics_interface_ptr_->update_level_and_message(
206+
diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str());
207+
} else {
208+
diagnostics_interface_ptr_->update_level_and_message(
209+
diagnostic_msgs::msg::DiagnosticStatus::ERROR,
210+
"CenterPoint processing delay has exceeded the acceptable limit continuously.");
211+
}
212+
} else {
213+
diagnostics_interface_ptr_->add_key_value("is_processing_time_ms_in_expected_range", true);
214+
consecutive_delay_count_ = 0;
215+
}
216+
217+
// add processing time for debug
218+
if (debug_publisher_ptr_) {
219+
const double cyclic_time_ms = stop_watch_ptr_->toc("cyclic_time", true);
220+
const double pipeline_latency_ms =
221+
std::chrono::duration<double, std::milli>(
222+
std::chrono::nanoseconds(
223+
(this->get_clock()->now() - output_msg.header.stamp).nanoseconds()))
224+
.count();
225+
debug_publisher_ptr_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
226+
"debug/cyclic_time_ms", cyclic_time_ms);
227+
debug_publisher_ptr_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
228+
"debug/processing_time_ms", processing_time_ms);
229+
debug_publisher_ptr_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
230+
"debug/pipeline_latency_ms", pipeline_latency_ms);
231+
}
202232
}
233+
234+
diagnostics_interface_ptr_->publish(input_pointcloud_msg->header.stamp);
203235
}
204236

205237
} // namespace autoware::lidar_centerpoint

0 commit comments

Comments
 (0)