22
22
23
23
#include < autoware/signal_processing/lowpass_filter_1d.hpp>
24
24
#include < autoware_control_validator/msg/control_validator_status.hpp>
25
+ #include < autoware_utils/ros/parameter.hpp>
25
26
#include < autoware_utils/system/stop_watch.hpp>
26
27
#include < rclcpp/rclcpp.hpp>
27
28
29
+ #include < autoware_control_msgs/msg/control.hpp>
28
30
#include < autoware_internal_debug_msgs/msg/float64_stamped.hpp>
29
31
#include < autoware_planning_msgs/msg/trajectory.hpp>
30
32
#include < diagnostic_msgs/msg/diagnostic_array.hpp>
33
+ #include < geometry_msgs/msg/accel_with_covariance_stamped.hpp>
31
34
#include < nav_msgs/msg/odometry.hpp>
32
35
33
36
#include < cstdint>
38
41
39
42
namespace autoware ::control_validator
40
43
{
44
+ using autoware_control_msgs::msg::Control;
41
45
using autoware_control_validator::msg::ControlValidatorStatus;
42
46
using autoware_planning_msgs::msg::Trajectory;
43
47
using autoware_planning_msgs::msg::TrajectoryPoint;
44
48
using diagnostic_updater::DiagnosticStatusWrapper;
45
49
using diagnostic_updater::Updater;
50
+ using geometry_msgs::msg::AccelWithCovarianceStamped;
46
51
using nav_msgs::msg::Odometry;
47
52
48
- struct ValidationParams
53
+ /* *
54
+ * @class LatencyValidator
55
+ * @brief Validates latency of the control module.
56
+ */
57
+ class LatencyValidator
58
+ {
59
+ public:
60
+ explicit LatencyValidator (rclcpp::Node & node)
61
+ : nominal_latency_threshold{
62
+ autoware_utils::get_or_declare_parameter<double >(node, " thresholds.nominal_latency" )} {};
63
+
64
+ void validate (
65
+ ControlValidatorStatus & res, const Control & control_cmd, rclcpp::Node & node) const ;
66
+
67
+ private:
68
+ const double nominal_latency_threshold;
69
+ };
70
+
71
+ /* *
72
+ * @class TrajectoryValidator
73
+ * @brief Calculate the maximum lateral distance between the reference trajectory and the predicted
74
+ * trajectory.
75
+ */
76
+ class TrajectoryValidator
49
77
{
50
- double max_distance_deviation_threshold;
51
- double rolling_back_velocity;
52
- double over_velocity_ratio;
53
- double over_velocity_offset;
78
+ public:
79
+ explicit TrajectoryValidator (rclcpp::Node & node)
80
+ : max_distance_deviation_threshold{autoware_utils::get_or_declare_parameter<double >(
81
+ node, " thresholds.max_distance_deviation" )} {};
82
+
83
+ void validate (
84
+ ControlValidatorStatus & res, const Trajectory & predicted_trajectory,
85
+ const Trajectory & reference_trajectory) const ;
86
+
87
+ private:
88
+ const double max_distance_deviation_threshold;
89
+ };
90
+
91
+ /* *
92
+ * @class AccelerationValidator
93
+ * @brief Validates deviation between output acceleration and measured acceleration.
94
+ */
95
+ class AccelerationValidator
96
+ {
97
+ public:
98
+ friend class AccelerationValidatorTest ;
99
+ explicit AccelerationValidator (rclcpp::Node & node)
100
+ : e_offset{autoware_utils::get_or_declare_parameter<double >(node, " thresholds.acc_error_offset" )},
101
+ e_scale{autoware_utils::get_or_declare_parameter<double >(node, " thresholds.acc_error_scale" )},
102
+ desired_acc_lpf{autoware_utils::get_or_declare_parameter<double >(node, " acc_lpf_gain" )},
103
+ measured_acc_lpf{autoware_utils::get_or_declare_parameter<double >(node, " acc_lpf_gain" )} {};
104
+
105
+ void validate (
106
+ ControlValidatorStatus & res, const Odometry & kinematic_state, const Control & control_cmd,
107
+ const AccelWithCovarianceStamped & loc_acc);
108
+
109
+ private:
110
+ bool is_in_error_range () const ;
111
+ const double e_offset;
112
+ const double e_scale;
113
+ autoware::signal_processing::LowpassFilter1d desired_acc_lpf;
114
+ autoware::signal_processing::LowpassFilter1d measured_acc_lpf;
115
+ };
116
+
117
+ /* *
118
+ * @class VelocityValidator
119
+ * @brief Validates deviation between target velocity and measured velocity.
120
+ */
121
+ class VelocityValidator
122
+ {
123
+ public:
124
+ explicit VelocityValidator (rclcpp::Node & node)
125
+ : rolling_back_velocity_th{autoware_utils::get_or_declare_parameter<double >(
126
+ node, " thresholds.rolling_back_velocity" )},
127
+ over_velocity_ratio_th{
128
+ autoware_utils::get_or_declare_parameter<double >(node, " thresholds.over_velocity_ratio" )},
129
+ over_velocity_offset_th{
130
+ autoware_utils::get_or_declare_parameter<double >(node, " thresholds.over_velocity_offset" )},
131
+ hold_velocity_error_until_stop{
132
+ autoware_utils::get_or_declare_parameter<bool >(node, " hold_velocity_error_until_stop" )},
133
+ vehicle_vel_lpf{autoware_utils::get_or_declare_parameter<double >(node, " vel_lpf_gain" )},
134
+ target_vel_lpf{autoware_utils::get_or_declare_parameter<double >(node, " vel_lpf_gain" )} {};
135
+
136
+ void validate (
137
+ ControlValidatorStatus & res, const Trajectory & reference_trajectory,
138
+ const Odometry & kinematics);
139
+
140
+ private:
141
+ const double rolling_back_velocity_th;
142
+ const double over_velocity_ratio_th;
143
+ const double over_velocity_offset_th;
144
+ const bool hold_velocity_error_until_stop;
145
+ autoware::signal_processing::LowpassFilter1d vehicle_vel_lpf;
146
+ autoware::signal_processing::LowpassFilter1d target_vel_lpf;
147
+ };
148
+
149
+ /* *
150
+ * @class OverrunValidator
151
+ * @brief Calculate whether the vehicle has overrun a stop point in the trajectory.
152
+ */
153
+ class OverrunValidator
154
+ {
155
+ public:
156
+ explicit OverrunValidator (rclcpp::Node & node)
157
+ : overrun_stop_point_dist_th{autoware_utils::get_or_declare_parameter<double >(
158
+ node, " thresholds.overrun_stop_point_dist" )},
159
+ will_overrun_stop_point_dist_th{autoware_utils::get_or_declare_parameter<double >(
160
+ node, " thresholds.will_overrun_stop_point_dist" )},
161
+ assumed_limit_acc{
162
+ autoware_utils::get_or_declare_parameter<double >(node, " thresholds.assumed_limit_acc" )},
163
+ assumed_delay_time{
164
+ autoware_utils::get_or_declare_parameter<double >(node, " thresholds.assumed_delay_time" )},
165
+ vehicle_vel_lpf{autoware_utils::get_or_declare_parameter<double >(node, " vel_lpf_gain" )} {};
166
+
167
+ void validate (
168
+ ControlValidatorStatus & res, const Trajectory & reference_trajectory,
169
+ const Odometry & kinematics);
170
+
171
+ private:
172
+ const double overrun_stop_point_dist_th;
173
+ const double will_overrun_stop_point_dist_th;
174
+ const double assumed_limit_acc;
175
+ const double assumed_delay_time;
176
+ autoware::signal_processing::LowpassFilter1d vehicle_vel_lpf;
54
177
};
55
178
56
179
/* *
@@ -68,23 +191,10 @@ class ControlValidator : public rclcpp::Node
68
191
explicit ControlValidator (const rclcpp::NodeOptions & options);
69
192
70
193
/* *
71
- * @brief Callback function for the predicted trajectory.
72
- * @param msg Predicted trajectory message
73
- */
74
- void on_predicted_trajectory (const Trajectory::ConstSharedPtr msg);
75
-
76
- /* *
77
- * @brief Calculate the maximum lateral distance between the reference trajectory and predicted
78
- * trajectory.
79
- * @param predicted_trajectory Predicted trajectory
80
- * @param reference_trajectory Reference trajectory
81
- * @return A pair consisting of the maximum lateral deviation and a boolean indicating validity
194
+ * @brief Callback function for the control component output.
195
+ * @param msg Control message
82
196
*/
83
- std::pair<double , bool > calc_lateral_deviation_status (
84
- const Trajectory & predicted_trajectory, const Trajectory & reference_trajectory) const ;
85
-
86
- void calc_velocity_deviation_status (
87
- const Trajectory & reference_trajectory, const Odometry & kinematics);
197
+ void on_control_cmd (const Control::ConstSharedPtr msg);
88
198
89
199
private:
90
200
/* *
@@ -97,27 +207,10 @@ class ControlValidator : public rclcpp::Node
97
207
*/
98
208
void setup_parameters ();
99
209
100
- /* *
101
- * @brief Check if all required data is ready for validation
102
- * @return Boolean indicating readiness of data
103
- */
104
- bool is_data_ready ();
105
-
106
- /* *
107
- * @brief Validate the predicted trajectory against the reference trajectory and current
108
- * kinematics
109
- * @param predicted_trajectory Predicted trajectory
110
- * @param reference_trajectory Reference trajectory
111
- * @param kinematics Current vehicle kinematics
112
- */
113
- void validate (
114
- const Trajectory & predicted_trajectory, const Trajectory & reference_trajectory,
115
- const Odometry & kinematics);
116
-
117
210
/* *
118
211
* @brief Publish debug information
119
212
*/
120
- void publish_debug_info ();
213
+ void publish_debug_info (const geometry_msgs::msg::Pose & ego_pose );
121
214
122
215
/* *
123
216
* @brief Display validation status on terminal
@@ -134,9 +227,12 @@ class ControlValidator : public rclcpp::Node
134
227
DiagnosticStatusWrapper & stat, const bool & is_ok, const std::string & msg) const ;
135
228
136
229
// Subscribers and publishers
137
- rclcpp::Subscription<Trajectory >::SharedPtr sub_predicted_traj_ ;
230
+ rclcpp::Subscription<Control >::SharedPtr sub_control_cmd_ ;
138
231
autoware_utils::InterProcessPollingSubscriber<Odometry>::SharedPtr sub_kinematics_;
139
232
autoware_utils::InterProcessPollingSubscriber<Trajectory>::SharedPtr sub_reference_traj_;
233
+ autoware_utils::InterProcessPollingSubscriber<Trajectory>::SharedPtr sub_predicted_traj_;
234
+ autoware_utils::InterProcessPollingSubscriber<AccelWithCovarianceStamped>::SharedPtr
235
+ sub_measured_acc_;
140
236
rclcpp::Publisher<ControlValidatorStatus>::SharedPtr pub_status_;
141
237
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr pub_markers_;
142
238
rclcpp::Publisher<autoware_internal_debug_msgs::msg::Float64Stamped>::SharedPtr
@@ -145,32 +241,26 @@ class ControlValidator : public rclcpp::Node
145
241
// system parameters
146
242
int64_t diag_error_count_threshold_ = 0 ;
147
243
bool display_on_terminal_ = true ;
148
-
149
244
Updater diag_updater_{this };
150
-
151
245
ControlValidatorStatus validation_status_;
152
- ValidationParams validation_params_; // for thresholds
153
- autoware::signal_processing::LowpassFilter1d vehicle_vel_{0.0 };
154
- autoware::signal_processing::LowpassFilter1d target_vel_{0.0 };
155
- bool hold_velocity_error_until_stop_{false };
156
-
157
246
vehicle_info_utils::VehicleInfo vehicle_info_;
158
-
159
247
/* *
160
248
* @brief Check if all validation criteria are met
161
249
* @param status Validation status
162
250
* @return Boolean indicating if all criteria are met
163
251
*/
164
252
static bool is_all_valid (const ControlValidatorStatus & status);
165
253
166
- Trajectory::ConstSharedPtr current_reference_trajectory_;
167
- Trajectory::ConstSharedPtr current_predicted_trajectory_;
168
-
169
- Odometry::ConstSharedPtr current_kinematics_;
170
-
254
+ // debug
255
+ std::shared_ptr<ControlValidatorDebugMarkerPublisher> debug_pose_publisher_;
171
256
autoware_utils::StopWatch<std::chrono::milliseconds> stop_watch;
172
257
173
- std::shared_ptr<ControlValidatorDebugMarkerPublisher> debug_pose_publisher_;
258
+ // individual validators
259
+ LatencyValidator latency_validator{*this };
260
+ TrajectoryValidator trajectory_validator{*this };
261
+ AccelerationValidator acceleration_validator{*this };
262
+ VelocityValidator velocity_validator{*this };
263
+ OverrunValidator overrun_validator{*this };
174
264
};
175
265
} // namespace autoware::control_validator
176
266
0 commit comments