@@ -110,6 +110,10 @@ LidarCenterPointNode::LidarCenterPointNode(const rclcpp::NodeOptions & node_opti
110
110
diagnostics_interface_ptr_ =
111
111
std::make_unique<autoware_utils::DiagnosticsInterface>(this , " centerpoint_trt" );
112
112
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
+
113
117
pointcloud_sub_ = this ->create_subscription <sensor_msgs::msg::PointCloud2>(
114
118
" ~/input/pointcloud" , rclcpp::SensorDataQoS{}.keep_last (1 ),
115
119
std::bind (&LidarCenterPointNode::pointCloudCallback, this , std::placeholders::_1));
@@ -182,24 +186,52 @@ void LidarCenterPointNode::pointCloudCallback(
182
186
objects_pub_->publish (output_msg);
183
187
published_time_publisher_->publish_if_subscribed (objects_pub_, output_msg.header .stamp );
184
188
}
185
- diagnostics_interface_ptr_->publish (input_pointcloud_msg->header .stamp );
186
189
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_) {
190
191
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
+ }
202
232
}
233
+
234
+ diagnostics_interface_ptr_->publish (input_pointcloud_msg->header .stamp );
203
235
}
204
236
205
237
} // namespace autoware::lidar_centerpoint
0 commit comments