@@ -137,6 +137,10 @@ DecorativeTrackerMergerNode::DecorativeTrackerMergerNode(const rclcpp::NodeOptio
137
137
tracker_state_parameter_.decay_rate =
138
138
declare_parameter<double >(" tracker_state_parameter.decay_rate" );
139
139
tracker_state_parameter_.max_dt = declare_parameter<double >(" tracker_state_parameter.max_dt" );
140
+ delay_main_objects_tolerance_ = declare_parameter<double >(" delay_main_objects_tolerance" );
141
+ duration_empty_main_objects_tolerance_ =
142
+ declare_parameter<double >(" duration_empty_main_objects_tolerance" );
143
+ delay_sub_objects_tolerance_ = declare_parameter<double >(" delay_sub_objects_tolerance" );
140
144
141
145
const std::string main_sensor_type = declare_parameter<std::string>(" main_sensor_type" );
142
146
const std::string sub_sensor_type = declare_parameter<std::string>(" sub_sensor_type" );
@@ -168,6 +172,14 @@ DecorativeTrackerMergerNode::DecorativeTrackerMergerNode(const rclcpp::NodeOptio
168
172
stop_watch_ptr_->tic (" cyclic_time" );
169
173
stop_watch_ptr_->tic (" processing_time" );
170
174
published_time_publisher_ = std::make_unique<autoware_utils::PublishedTimePublisher>(this );
175
+
176
+ // diagnostics
177
+ diagnostics_interface_ptr_ = std::make_unique<autoware::universe_utils::DiagnosticsInterface>(
178
+ this , " decorative_object_merger_node" );
179
+ stop_watch_ptr_->tic (" delay_main_objects" );
180
+ stop_watch_ptr_->tic (" duration_empty_main_objects" );
181
+ stop_watch_ptr_->tic (" delay_sub_objects" );
182
+ is_empty_previous_main_objects_ = false ;
171
183
}
172
184
173
185
void DecorativeTrackerMergerNode::set3dDataAssociation (
@@ -200,6 +212,18 @@ void DecorativeTrackerMergerNode::mainObjectsCallback(
200
212
const TrackedObjects::ConstSharedPtr & main_objects)
201
213
{
202
214
stop_watch_ptr_->toc (" processing_time" , true );
215
+ stop_watch_ptr_->toc (" delay_main_objects" , true );
216
+ diagnostics_interface_ptr_->clear ();
217
+
218
+ // check if main objects is empty and duration
219
+ if (main_objects->objects .empty () && is_empty_previous_main_objects_) {
220
+ is_empty_previous_main_objects_ = true ;
221
+ } else if (main_objects->objects .empty () && !is_empty_previous_main_objects_) {
222
+ stop_watch_ptr_->toc (" duration_empty_main_objects" , true );
223
+ is_empty_previous_main_objects_ = true ;
224
+ } else {
225
+ is_empty_previous_main_objects_ = false ;
226
+ }
203
227
204
228
/* transform to target merge coordinate */
205
229
TrackedObjects transformed_objects;
@@ -243,12 +267,16 @@ void DecorativeTrackerMergerNode::mainObjectsCallback(
243
267
const auto & tracked_objects = getTrackedObjects (transformed_main_objects->header );
244
268
merged_object_pub_->publish (tracked_objects);
245
269
270
+ // update diagnostics
271
+ updateDiagnostics ();
272
+
246
273
published_time_publisher_->publish_if_subscribed (
247
274
merged_object_pub_, tracked_objects.header .stamp );
248
275
processing_time_publisher_->publish <autoware_internal_debug_msgs::msg::Float64Stamped>(
249
276
" debug/cyclic_time_ms" , stop_watch_ptr_->toc (" cyclic_time" , true ));
250
277
processing_time_publisher_->publish <autoware_internal_debug_msgs::msg::Float64Stamped>(
251
278
" debug/processing_time_ms" , stop_watch_ptr_->toc (" processing_time" , true ));
279
+ diagnostics_interface_ptr_->publish (tracked_objects.header .stamp );
252
280
}
253
281
254
282
/* *
@@ -259,6 +287,9 @@ void DecorativeTrackerMergerNode::mainObjectsCallback(
259
287
*/
260
288
void DecorativeTrackerMergerNode::subObjectsCallback (const TrackedObjects::ConstSharedPtr & msg)
261
289
{
290
+ stop_watch_ptr_->toc (" delay_sub_objects" , true );
291
+ diagnostics_interface_ptr_->clear ();
292
+
262
293
/* transform to target merge coordinate */
263
294
TrackedObjects transformed_objects;
264
295
if (!autoware::object_recognition_utils::transformObjects (
@@ -277,6 +308,11 @@ void DecorativeTrackerMergerNode::subObjectsCallback(const TrackedObjects::Const
277
308
return (now - rclcpp::Time (sub_object->header .stamp )).seconds () > sub_object_timeout_sec_;
278
309
});
279
310
sub_objects_buffer_.erase (remove_itr, sub_objects_buffer_.end ());
311
+
312
+ // update diagnostics
313
+ updateDiagnostics ();
314
+
315
+ diagnostics_interface_ptr_->publish (transformed_sub_objects->header .stamp );
280
316
}
281
317
282
318
/* *
@@ -446,6 +482,46 @@ TrackerState DecorativeTrackerMergerNode::createNewTracker(
446
482
return new_tracker;
447
483
}
448
484
485
+ void DecorativeTrackerMergerNode::updateDiagnostics ()
486
+ {
487
+ const double delay_main_objects = stop_watch_ptr_->toc (" delay_main_objects" , false ) * 1e-3 ;
488
+ const double duration_empty_main_objects =
489
+ stop_watch_ptr_->toc (" duration_empty_main_objects" , false ) * 1e-3 ;
490
+ const double delay_sub_objects = stop_watch_ptr_->toc (" delay_sub_objects" , false ) * 1e-3 ;
491
+
492
+ diagnostics_interface_ptr_->add_key_value (" delay_main_objects" , delay_main_objects);
493
+ if (delay_main_objects > delay_main_objects_tolerance_) {
494
+ std::stringstream message;
495
+ message << " Main object is delayed for longer than tolerance " << delay_main_objects << " > "
496
+ << delay_main_objects_tolerance_;
497
+ diagnostics_interface_ptr_->update_level_and_message (
498
+ diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str ());
499
+ }
500
+
501
+ if (is_empty_previous_main_objects_) {
502
+ diagnostics_interface_ptr_->add_key_value (
503
+ " duration_empty_main_objects" , duration_empty_main_objects);
504
+ if (duration_empty_main_objects > duration_empty_main_objects_tolerance_) {
505
+ std::stringstream message;
506
+ message << " Main object continues to be empty for longer than tolerance "
507
+ << duration_empty_main_objects << " > " << duration_empty_main_objects_tolerance_;
508
+ diagnostics_interface_ptr_->update_level_and_message (
509
+ diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str ());
510
+ }
511
+ } else {
512
+ diagnostics_interface_ptr_->add_key_value (" duration_empty_main_objects" , 0.0 );
513
+ }
514
+
515
+ diagnostics_interface_ptr_->add_key_value (" delay_sub_objects" , delay_sub_objects);
516
+ if (delay_sub_objects > delay_sub_objects_tolerance_) {
517
+ std::stringstream message;
518
+ message << " Sub object is delayed for longer than tolerance" << delay_sub_objects << " > "
519
+ << delay_sub_objects_tolerance_;
520
+ diagnostics_interface_ptr_->update_level_and_message (
521
+ diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str ());
522
+ }
523
+ }
524
+
449
525
} // namespace autoware::tracking_object_merger
450
526
451
527
#include < rclcpp_components/register_node_macro.hpp>
0 commit comments