Skip to content

Commit c7a9c84

Browse files
committed
wip
Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com>
1 parent cbedc0f commit c7a9c84

File tree

3 files changed

+42
-18
lines changed

3 files changed

+42
-18
lines changed

perception/autoware_lidar_centerpoint/config/centerpoint_diagnostics.param.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
max_allowed_processing_time: 200.0 # in milliseconds
66
# If the warning is triggered more than max_consecutive_warn_count times in a row,
77
# an error diagnostic message will be sent.
8-
max_consecutive_warn_count: 10
8+
max_acceptable_consecutive_delay_ms: 1000.0

perception/autoware_lidar_centerpoint/include/autoware/lidar_centerpoint/node.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <autoware_utils/ros/published_time_publisher.hpp>
2525
#include <autoware_utils/system/stop_watch.hpp>
2626
#include <rclcpp/rclcpp.hpp>
27+
#include <std_msgs/msg/header.hpp>
2728

2829
#include <autoware_perception_msgs/msg/detected_object_kinematics.hpp>
2930
#include <autoware_perception_msgs/msg/detected_objects.hpp>
@@ -55,15 +56,18 @@ class LidarCenterPointNode : public rclcpp::Node
5556
std::vector<std::string> class_names_;
5657
bool has_variance_{false};
5758
bool has_twist_{false};
59+
60+
bool is_processing_delayed_{false};
5861
float max_allowed_processing_time_;
59-
int max_consecutive_warn_count_;
60-
int consecutive_delay_count_ = 0;
62+
double max_acceptable_consecutive_delay_ms_;
63+
builtin_interfaces::msg::Time started_delayed_timestamp_;
6164

6265
NonMaximumSuppression iou_bev_nms_;
6366
DetectionClassRemapper detection_class_remapper_;
6467

6568
std::unique_ptr<CenterPointTRT> detector_ptr_{nullptr};
6669
std::unique_ptr<autoware_utils::DiagnosticsInterface> diagnostics_interface_ptr_;
70+
rclcpp::TimerBase::SharedPtr diagnostics_timer_;
6771

6872
// debugger
6973
std::unique_ptr<autoware_utils::StopWatch<std::chrono::milliseconds>> stop_watch_ptr_{nullptr};

perception/autoware_lidar_centerpoint/src/node.cpp

+35-15
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,11 @@ LidarCenterPointNode::LidarCenterPointNode(const rclcpp::NodeOptions & node_opti
112112

113113
// diagnostics parameters
114114
max_allowed_processing_time_ = declare_parameter<float>("max_allowed_processing_time");
115-
max_consecutive_warn_count_ = declare_parameter<int>("max_consecutive_warn_count");
115+
max_acceptable_consecutive_delay_ms_ = declare_parameter<int>("max_acceptable_consecutive_delay_ms");
116+
117+
diagnostics_timer_ = this->create_wall_timer(
118+
std::chrono::milliseconds(100),
119+
std::bind(&LidarCenterPointNode::diagnosticTimerCallback, this));
116120

117121
pointcloud_sub_ = this->create_subscription<sensor_msgs::msg::PointCloud2>(
118122
"~/input/pointcloud", rclcpp::SensorDataQoS{}.keep_last(1),
@@ -194,24 +198,21 @@ void LidarCenterPointNode::pointCloudCallback(
194198
if (processing_time_ms > max_allowed_processing_time_) {
195199
diagnostics_interface_ptr_->add_key_value("is_processing_time_ms_in_expected_range", false);
196200

197-
consecutive_delay_count_++;
201+
if (!is_processing_delayed_) {
202+
started_delayed_timestamp_ = this->get_clock()->now();
203+
is_processing_delayed_ = true;
204+
}
198205

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.";
206+
std::stringstream message;
207+
message << "CenterPoint processing time exceeds the acceptable limit of "
208+
<< max_allowed_processing_time_ << " ms by "
209+
<< (processing_time_ms - max_allowed_processing_time_) << " ms.";
204210

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-
}
211+
diagnostics_interface_ptr_->update_level_and_message(
212+
diagnostic_msgs::msg::DiagnosticStatus::WARN, message.str());
212213
} else {
213214
diagnostics_interface_ptr_->add_key_value("is_processing_time_ms_in_expected_range", true);
214-
consecutive_delay_count_ = 0;
215+
is_processing_delayed_ = false;
215216
}
216217

217218
// add processing time for debug
@@ -234,6 +235,25 @@ void LidarCenterPointNode::pointCloudCallback(
234235
diagnostics_interface_ptr_->publish(input_pointcloud_msg->header.stamp);
235236
}
236237

238+
// Check the timestamp of the processing that has started consecutively delaying,
239+
// and if the node is delayed constantly, publish the error diagnostic message
240+
void LidarCenterPointNode::diagnosticTimerCallback() {
241+
const double delayed_state_duration =
242+
std::chrono::duration<double, std::milli>(
243+
std::chrono::nanoseconds(
244+
(this->get_clock()->now() - started_delayed_timestamp_).nanoseconds()))
245+
.count();
246+
247+
if (delayed_state_duration > max_acceptable_consecutive_delay_ms_) {
248+
diagnostics_interface_ptr_->add_key_value("is_processing_time_ms_in_expected_range", false);
249+
diagnostics_interface_ptr_->update_level_and_message(
250+
diagnostic_msgs::msg::DiagnosticStatus::ERROR,
251+
"CenterPoint processing delay has exceeded the acceptable limit continuously.");
252+
253+
diagnostics_interface_ptr_->publish(input_pointcloud_msg->header.stamp);
254+
}
255+
}
256+
237257
} // namespace autoware::lidar_centerpoint
238258

239259
#include <rclcpp_components/register_node_macro.hpp>

0 commit comments

Comments
 (0)