@@ -486,9 +486,6 @@ MapBasedPredictionNode::MapBasedPredictionNode(const rclcpp::NodeOptions & node_
486
486
processing_time_publisher_ =
487
487
std::make_unique<autoware_utils::DebugPublisher>(this , " map_based_prediction" );
488
488
published_time_publisher_ = std::make_unique<autoware_utils::PublishedTimePublisher>(this );
489
- stop_watch_ptr_ = std::make_unique<autoware_utils::StopWatch<std::chrono::milliseconds>>();
490
- stop_watch_ptr_->tic (" cyclic_time" );
491
- stop_watch_ptr_->tic (" processing_time" );
492
489
}
493
490
494
491
if (use_time_keeper) {
@@ -499,13 +496,18 @@ MapBasedPredictionNode::MapBasedPredictionNode(const rclcpp::NodeOptions & node_
499
496
time_keeper_ = std::make_shared<autoware_utils::TimeKeeper>(time_keeper);
500
497
path_generator_->setTimeKeeper (time_keeper_);
501
498
predictor_vru_->setTimeKeeper (time_keeper_);
502
-
503
- // diagnostics handler
504
- diagnostics_interface_ptr_ =
505
- std::make_unique<autoware_utils::DiagnosticsInterface>(this , " map_based_prediction" );
506
- processing_time_tolerance_ms_ = declare_parameter<double >(" processing_time_tolerance_ms" );
507
499
}
508
500
501
+ // diagnostics
502
+ diagnostics_interface_ptr_ =
503
+ std::make_unique<autoware_utils::DiagnosticsInterface>(this , " map_based_prediction" );
504
+ processing_time_tolerance_ms_ = declare_parameter<double >(" processing_time_tolerance_ms" );
505
+
506
+ // stopwatch
507
+ stop_watch_ptr_ = std::make_unique<autoware_utils::StopWatch<std::chrono::milliseconds>>();
508
+ stop_watch_ptr_->tic (" cyclic_time" );
509
+ stop_watch_ptr_->tic (" processing_time" );
510
+
509
511
if (use_debug_marker) {
510
512
pub_debug_markers_ =
511
513
this ->create_publisher <visualization_msgs::msg::MarkerArray>(" maneuver" , rclcpp::QoS{1 });
@@ -562,7 +564,7 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
562
564
std::unique_ptr<ScopedTimeTrack> st_ptr;
563
565
if (time_keeper_) st_ptr = std::make_unique<ScopedTimeTrack>(__func__, *time_keeper_);
564
566
565
- if (stop_watch_ptr_) stop_watch_ptr_->toc (" processing_time" , true );
567
+ stop_watch_ptr_->toc (" processing_time" , true );
566
568
567
569
// take traffic_signal
568
570
{
@@ -670,26 +672,30 @@ void MapBasedPredictionNode::objectsCallback(const TrackedObjects::ConstSharedPt
670
672
// Publish Results
671
673
publish (output, debug_markers);
672
674
675
+ // Processing time
676
+ const auto processing_time_ms = stop_watch_ptr_->toc (" processing_time" , true );
677
+ const auto cyclic_time_ms = stop_watch_ptr_->toc (" cyclic_time" , true );
678
+
679
+ // Diagnostics
680
+ diagnostics_interface_ptr_->clear ();
681
+ bool is_processing_time_exceeds_tolerance = processing_time_ms > processing_time_tolerance_ms_;
682
+ diagnostics_interface_ptr_->add_key_value (
683
+ " is_processing_time_ok" , is_processing_time_exceeds_tolerance);
684
+ if (is_processing_time_exceeds_tolerance) {
685
+ std::ostringstream oss;
686
+ oss << " Processing time exceeded " << processing_time_tolerance_ms_ << " [ms] < "
687
+ << processing_time_ms << " [ms]" ;
688
+ diagnostics_interface_ptr_->update_level_and_message (
689
+ diagnostic_msgs::msg::DiagnosticStatus::WARN, oss.str ());
690
+ }
691
+ diagnostics_interface_ptr_->publish (output.header .stamp );
692
+
673
693
// Publish Processing Time
674
- if (stop_watch_ptr_) {
675
- const auto processing_time_ms = stop_watch_ptr_->toc (" processing_time" , true );
676
- const auto cyclic_time_ms = stop_watch_ptr_->toc (" cyclic_time" , true );
694
+ if (processing_time_publisher_) {
677
695
processing_time_publisher_->publish <autoware_internal_debug_msgs::msg::Float64Stamped>(
678
696
" debug/cyclic_time_ms" , cyclic_time_ms);
679
697
processing_time_publisher_->publish <autoware_internal_debug_msgs::msg::Float64Stamped>(
680
698
" debug/processing_time_ms" , processing_time_ms);
681
-
682
- diagnostics_interface_ptr_->clear ();
683
- bool is_processing_time_ok = processing_time_ms > processing_time_tolerance_ms_;
684
- diagnostics_interface_ptr_->add_key_value (" is_processing_time_ok" , is_processing_time_ok);
685
- if (is_processing_time_ok) {
686
- std::ostringstream oss;
687
- oss << " Processing time exceeded " << processing_time_tolerance_ms_ << " [ms] < "
688
- << processing_time_ms << " [ms]" ;
689
- diagnostics_interface_ptr_->update_level_and_message (
690
- diagnostic_msgs::msg::DiagnosticStatus::WARN, oss.str ());
691
- }
692
- diagnostics_interface_ptr_->publish (output.header .stamp );
693
699
}
694
700
}
695
701
0 commit comments