Skip to content

Commit 8796045

Browse files
MasatoSaekipre-commit-ci[bot]technolojin
authored
feat(autoware_tracker_object_merger): add diagnostics (#10257)
* add diagnostics Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * style(pre-commit): autofix Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * fix how to check as diag Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * style(pre-commit): autofix Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * delete unnecesary include row Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * change the way to check time Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * pre-commit Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * chore Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * fix warn msg Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * change msg string to int Co-authored-by: Taekjin LEE <technolojin@gmail.com> Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * fix msg Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> * add unit Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> --------- Signed-off-by: MasatoSaeki <masato.saeki@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Taekjin LEE <technolojin@gmail.com>
1 parent 45793cb commit 8796045

File tree

4 files changed

+92
-2
lines changed

4 files changed

+92
-2
lines changed

perception/autoware_tracking_object_merger/config/decorative_tracker_merger.param.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
merge_frame_id: "map"
66
time_sync_threshold: 0.999
77
sub_object_timeout_sec: 0.8
8-
publish_interpolated_sub_objects: true #for debug
8+
publish_interpolated_sub_objects: true # for debug
99

1010
# choose the input sensor type for each object type
1111
# "lidar", "radar", "camera" are available
@@ -25,3 +25,8 @@
2525
# logging settings
2626
enable_logging: false
2727
logging_file_path: "association_log.json"
28+
29+
# diagnostics
30+
delay_main_objects_tolerance: 1.0 # [sec]
31+
duration_empty_main_objects_tolerance: 5.0 # [sec]
32+
delay_sub_objects_tolerance: 5.0 # [sec]

perception/autoware_tracking_object_merger/include/autoware/tracking_object_merger/decorative_tracker_merger_node.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "autoware/tracking_object_merger/association/data_association.hpp"
1919
#include "autoware/tracking_object_merger/utils/tracker_state.hpp"
2020
#include "autoware/tracking_object_merger/utils/utils.hpp"
21+
#include "autoware/universe_utils/ros/diagnostics_interface.hpp"
2122
#include "autoware_utils/ros/debug_publisher.hpp"
2223
#include "autoware_utils/ros/published_time_publisher.hpp"
2324
#include "autoware_utils/system/stop_watch.hpp"
@@ -76,6 +77,7 @@ class DecorativeTrackerMergerNode : public rclcpp::Node
7677
TrackerState createNewTracker(
7778
const MEASUREMENT_STATE input_index, rclcpp::Time current_time,
7879
const autoware_perception_msgs::msg::TrackedObject & input_object);
80+
void updateDiagnostics();
7981

8082
private:
8183
tf2_ros::Buffer tf_buffer_;
@@ -129,6 +131,13 @@ class DecorativeTrackerMergerNode : public rclcpp::Node
129131
bool enable = false;
130132
std::string path;
131133
} logging_;
134+
135+
// diagnostics
136+
std::unique_ptr<autoware::universe_utils::DiagnosticsInterface> diagnostics_interface_ptr_;
137+
double delay_main_objects_tolerance_;
138+
double duration_empty_main_objects_tolerance_;
139+
double delay_sub_objects_tolerance_;
140+
bool is_empty_previous_main_objects_;
132141
};
133142

134143
} // namespace autoware::tracking_object_merger

perception/autoware_tracking_object_merger/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<depend>autoware_object_recognition_utils</depend>
1717
<depend>autoware_perception_msgs</depend>
18-
<depend>autoware_utils</depend>
18+
<depend>autoware_universe_utils</depend>
1919
<depend>eigen</depend>
2020
<depend>glog</depend>
2121
<depend>mussp</depend>

perception/autoware_tracking_object_merger/src/decorative_tracker_merger_node.cpp

+76
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ DecorativeTrackerMergerNode::DecorativeTrackerMergerNode(const rclcpp::NodeOptio
137137
tracker_state_parameter_.decay_rate =
138138
declare_parameter<double>("tracker_state_parameter.decay_rate");
139139
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");
140144

141145
const std::string main_sensor_type = declare_parameter<std::string>("main_sensor_type");
142146
const std::string sub_sensor_type = declare_parameter<std::string>("sub_sensor_type");
@@ -168,6 +172,14 @@ DecorativeTrackerMergerNode::DecorativeTrackerMergerNode(const rclcpp::NodeOptio
168172
stop_watch_ptr_->tic("cyclic_time");
169173
stop_watch_ptr_->tic("processing_time");
170174
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;
171183
}
172184

173185
void DecorativeTrackerMergerNode::set3dDataAssociation(
@@ -200,6 +212,18 @@ void DecorativeTrackerMergerNode::mainObjectsCallback(
200212
const TrackedObjects::ConstSharedPtr & main_objects)
201213
{
202214
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+
}
203227

204228
/* transform to target merge coordinate */
205229
TrackedObjects transformed_objects;
@@ -243,12 +267,16 @@ void DecorativeTrackerMergerNode::mainObjectsCallback(
243267
const auto & tracked_objects = getTrackedObjects(transformed_main_objects->header);
244268
merged_object_pub_->publish(tracked_objects);
245269

270+
// update diagnostics
271+
updateDiagnostics();
272+
246273
published_time_publisher_->publish_if_subscribed(
247274
merged_object_pub_, tracked_objects.header.stamp);
248275
processing_time_publisher_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
249276
"debug/cyclic_time_ms", stop_watch_ptr_->toc("cyclic_time", true));
250277
processing_time_publisher_->publish<autoware_internal_debug_msgs::msg::Float64Stamped>(
251278
"debug/processing_time_ms", stop_watch_ptr_->toc("processing_time", true));
279+
diagnostics_interface_ptr_->publish(tracked_objects.header.stamp);
252280
}
253281

254282
/**
@@ -259,6 +287,9 @@ void DecorativeTrackerMergerNode::mainObjectsCallback(
259287
*/
260288
void DecorativeTrackerMergerNode::subObjectsCallback(const TrackedObjects::ConstSharedPtr & msg)
261289
{
290+
stop_watch_ptr_->toc("delay_sub_objects", true);
291+
diagnostics_interface_ptr_->clear();
292+
262293
/* transform to target merge coordinate */
263294
TrackedObjects transformed_objects;
264295
if (!autoware::object_recognition_utils::transformObjects(
@@ -277,6 +308,11 @@ void DecorativeTrackerMergerNode::subObjectsCallback(const TrackedObjects::Const
277308
return (now - rclcpp::Time(sub_object->header.stamp)).seconds() > sub_object_timeout_sec_;
278309
});
279310
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);
280316
}
281317

282318
/**
@@ -446,6 +482,46 @@ TrackerState DecorativeTrackerMergerNode::createNewTracker(
446482
return new_tracker;
447483
}
448484

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+
449525
} // namespace autoware::tracking_object_merger
450526

451527
#include <rclcpp_components/register_node_macro.hpp>

0 commit comments

Comments
 (0)