@@ -109,10 +109,15 @@ LidarCenterPointNode::LidarCenterPointNode(const rclcpp::NodeOptions & node_opti
109
109
std::make_unique<CenterPointTRT>(encoder_param, head_param, densification_param, config);
110
110
diagnostics_interface_ptr_ =
111
111
std::make_unique<autoware_utils::DiagnosticsInterface>(this , " centerpoint_trt" );
112
+ diagnostics_processing_delay_ =
113
+ std::make_unique<autoware_utils::DiagnosticsInterface>(this , " node_processing_time_status" );
112
114
113
115
// 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
+ max_allowed_processing_time_ = declare_parameter<double >(" max_allowed_processing_time" );
117
+ max_acceptable_consecutive_delay_ms_ =
118
+ declare_parameter<double >(" max_acceptable_consecutive_delay_ms" );
119
+ const long validation_callback_interval_ms =
120
+ declare_parameter<long >(" validation_callback_interval_ms" );
116
121
117
122
pointcloud_sub_ = this ->create_subscription <sensor_msgs::msg::PointCloud2>(
118
123
" ~/input/pointcloud" , rclcpp::SensorDataQoS{}.keep_last (1 ),
@@ -130,6 +135,12 @@ LidarCenterPointNode::LidarCenterPointNode(const rclcpp::NodeOptions & node_opti
130
135
stop_watch_ptr_->tic (" processing_time" );
131
136
}
132
137
138
+ if (stop_watch_ptr_) {
139
+ diagnostics_processing_time_timer_ = this ->create_wall_timer (
140
+ std::chrono::milliseconds (validation_callback_interval_ms),
141
+ std::bind (&LidarCenterPointNode::diagnosticsTimerCallback, this ));
142
+ }
143
+
133
144
if (this ->declare_parameter (" build_only" , false )) {
134
145
RCLCPP_INFO (this ->get_logger (), " TensorRT engine is built and shutdown node." );
135
146
rclcpp::shutdown ();
@@ -194,24 +205,21 @@ void LidarCenterPointNode::pointCloudCallback(
194
205
if (processing_time_ms > max_allowed_processing_time_) {
195
206
diagnostics_interface_ptr_->add_key_value (" is_processing_time_ms_in_expected_range" , false );
196
207
197
- consecutive_delay_count_++;
208
+ std::stringstream message;
209
+ message << " CenterPoint processing time exceeds the acceptable limit of "
210
+ << max_allowed_processing_time_ << " ms by "
211
+ << (processing_time_ms - max_allowed_processing_time_) << " ms." ;
198
212
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." ;
213
+ diagnostics_interface_ptr_->update_level_and_message (
214
+ diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str ());
204
215
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." );
216
+ // just in case the processing starts with a delayed inference
217
+ if (!last_normal_processing_timestamp_) {
218
+ last_normal_processing_timestamp_ = this ->get_clock ()->now ();
211
219
}
212
220
} else {
213
221
diagnostics_interface_ptr_->add_key_value (" is_processing_time_ms_in_expected_range" , true );
214
- consecutive_delay_count_ = 0 ;
222
+ last_normal_processing_timestamp_ = this -> get_clock ()-> now () ;
215
223
}
216
224
217
225
// add processing time for debug
@@ -234,6 +242,33 @@ void LidarCenterPointNode::pointCloudCallback(
234
242
diagnostics_interface_ptr_->publish (input_pointcloud_msg->header .stamp );
235
243
}
236
244
245
+ // Check the timestamp of consecutively delayed processing
246
+ // If the node is consistently delayed, publish an error diagnostic message
247
+ void LidarCenterPointNode::diagnosticsTimerCallback () {
248
+ // skip if the node has not performed inference yet
249
+ if (last_normal_processing_timestamp_) {
250
+ diagnostics_processing_delay_->clear ();
251
+
252
+ const rclcpp::Time timestamp_now = this ->get_clock ()->now ();
253
+ const double delayed_state_duration =
254
+ std::chrono::duration<double , std::milli>(
255
+ std::chrono::nanoseconds (
256
+ (timestamp_now - last_normal_processing_timestamp_.value ()).nanoseconds ()))
257
+ .count ();
258
+
259
+ if (delayed_state_duration > max_acceptable_consecutive_delay_ms_) {
260
+ diagnostics_processing_delay_->add_key_value (" is_processing_time_ms_in_expected_range" , false );
261
+ diagnostics_processing_delay_->update_level_and_message (
262
+ diagnostic_msgs::msg::DiagnosticStatus::ERROR,
263
+ " CenterPoint processing delay has exceeded the acceptable limit continuously." );
264
+ } else {
265
+ diagnostics_processing_delay_->add_key_value (" is_processing_time_ms_in_expected_range" , true );
266
+ }
267
+
268
+ diagnostics_processing_delay_->publish (timestamp_now);
269
+ }
270
+ }
271
+
237
272
} // namespace autoware::lidar_centerpoint
238
273
239
274
#include < rclcpp_components/register_node_macro.hpp>
0 commit comments