Skip to content

Commit 73645f2

Browse files
feat(control_validator, tier4_diagnostics): sync upstream (#1983)
* feat(control_validator): add diag to check control component latency (autowarefoundation#10240) * feat(control_validator): add diag to check control component latency Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * fix: missing param Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> --------- Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * feat(control_validator)!: add overrun check (autowarefoundation#10236) Signed-off-by: yuki-takagi-66 <yuki.takagi@tier4.jp> * feat(control_validator)!: add acceleration check (autowarefoundation#10326) Signed-off-by: yuki-takagi-66 <yuki.takagi@tier4.jp> * fix(control_validator): fix sign miss and add code test (autowarefoundation#10341) Signed-off-by: yuki-takagi-66 <yuki.takagi@tier4.jp> * fix(control validator): combine callback functions to fix error count increment bug (autowarefoundation#10355) Signed-off-by: yuki-takagi-66 <yuki.takagi@tier4.jp> * refactor(control validaor): refactor control_validator (autowarefoundation#10363) Signed-off-by: yuki-takagi-66 <yuki.takagi@tier4.jp> * feat(control_validator): add over run estimation feature (autowarefoundation#10422) Signed-off-by: Yuki Takagi <yuki.takagi@tier4.jp> * fix(control_validator): fix less trajectory point check (autowarefoundation#10508) Signed-off-by: yuki-takagi-66 <yuki.takagi@tier4.jp> --------- Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> Signed-off-by: yuki-takagi-66 <yuki.takagi@tier4.jp> Signed-off-by: Yuki Takagi <yuki.takagi@tier4.jp> Co-authored-by: Satoshi OTA <44889564+satoshi-ota@users.noreply.github.com>
1 parent 52dea56 commit 73645f2

File tree

9 files changed

+444
-184
lines changed

9 files changed

+444
-184
lines changed

control/autoware_control_validator/README.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ The listed features below does not always correspond to the latest implementatio
1313
| ---------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | :---------------------------------------------------: |
1414
| Inverse velocity: Measured velocity has a different sign from the target velocity. | measured velocity $v$, target velocity $\hat{v}$, and velocity parameter $c$ | $v \hat{v} < 0, \quad \lvert v \rvert > c$ |
1515
| Overspeed: Measured speed exceeds target speed significantly. | measured velocity $v$, target velocity $\hat{v}$, ratio parameter $r$, and offset parameter $c$ | $\lvert v \rvert > (1 + r) \lvert \hat{v} \rvert + c$ |
16+
| Overrun estimation: estimate overrun even if decelerate by assumed rate. | assumed deceleration, assumed delay | |
1617

1718
- **Deviation check between reference trajectory and predicted trajectory** : invalid when the largest deviation between the predicted trajectory and reference trajectory is greater than the given threshold.
1819

@@ -57,9 +58,15 @@ The following parameters can be set for the `control_validator`:
5758

5859
The input trajectory is detected as invalid if the index exceeds the following thresholds.
5960

60-
| Name | Type | Description | Default value |
61-
| :---------------------------------- | :----- | :---------------------------------------------------------------------------------------------------------- | :------------ |
62-
| `thresholds.max_distance_deviation` | double | invalid threshold of the max distance deviation between the predicted path and the reference trajectory [m] | 1.0 |
63-
| `thresholds.rolling_back_velocity` | double | threshold velocity to valid the vehicle velocity [m/s] | 0.5 |
64-
| `thresholds.over_velocity_offset` | double | threshold velocity offset to valid the vehicle velocity [m/s] | 2.0 |
65-
| `thresholds.over_velocity_ratio` | double | threshold ratio to valid the vehicle velocity [*] | 0.2 |
61+
| Name | Type | Description | Default value |
62+
| :---------------------------------------- | :----- | :---------------------------------------------------------------------------------------------------------- | :------------ |
63+
| `thresholds.max_distance_deviation` | double | invalid threshold of the max distance deviation between the predicted path and the reference trajectory [m] | 1.0 |
64+
| `thresholds.rolling_back_velocity` | double | threshold velocity to valid the vehicle velocity [m/s] | 0.5 |
65+
| `thresholds.over_velocity_offset` | double | threshold velocity offset to valid the vehicle velocity [m/s] | 2.0 |
66+
| `thresholds.over_velocity_ratio` | double | threshold ratio to valid the vehicle velocity [*] | 0.2 |
67+
| `thresholds.overrun_stop_point_dist` | double | threshold distance to overrun stop point [m] | 0.8 |
68+
| `thresholds.acc_error_offset` | double | threshold ratio to valid the vehicle acceleration [*] | 0.8 |
69+
| `thresholds.acc_error_scale` | double | threshold acceleration to valid the vehicle acceleration [m] | 0.2 |
70+
| `thresholds.will_overrun_stop_point_dist` | double | threshold distance to overrun stop point [m] | 1.0 |
71+
| `thresholds.assumed_limit_acc` | double | assumed acceleration for over run estimation [m] | 5.0 |
72+
| `thresholds.assumed_delay_time` | double | assumed delay for over run estimation [m] | 0.2 |
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
/**:
22
ros__parameters:
3-
# If the number of consecutive invalid trajectory exceeds this threshold, the Diag will be set to ERROR.
4-
# (For example, threshold = 1 means, even if the trajectory is invalid, Diag will not be ERROR if
5-
# the next trajectory is valid.)
3+
# If the number of consecutive invalid predicted_path exceeds this threshold, the Diag will be set to ERROR.
4+
# (For example, threshold = 1 means, even if the predicted_path is invalid, Diag will not be ERROR if
5+
# the next predicted_path is valid.)
66
diag_error_count_threshold: 0
77

88
display_on_terminal: false # show error msg on terminal
99

1010
thresholds:
1111
max_distance_deviation: 1.0
12+
acc_error_offset: 0.8
13+
acc_error_scale: 0.2
1214
rolling_back_velocity: 0.5
1315
over_velocity_offset: 2.0
1416
over_velocity_ratio: 0.2
17+
overrun_stop_point_dist: 0.8
18+
will_overrun_stop_point_dist: 1.0
19+
assumed_limit_acc: 5.0
20+
assumed_delay_time: 0.2
21+
nominal_latency: 0.01
1522

23+
acc_lpf_gain: 0.97 # Time constant 1.11s
1624
vel_lpf_gain: 0.9 # Time constant 0.33
1725
hold_velocity_error_until_stop: true

control/autoware_control_validator/include/autoware/control_validator/control_validator.hpp

Lines changed: 144 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@
2222

2323
#include <autoware/signal_processing/lowpass_filter_1d.hpp>
2424
#include <autoware_control_validator/msg/control_validator_status.hpp>
25+
#include <autoware_utils/ros/parameter.hpp>
2526
#include <autoware_utils/system/stop_watch.hpp>
2627
#include <rclcpp/rclcpp.hpp>
2728

29+
#include <autoware_control_msgs/msg/control.hpp>
2830
#include <autoware_internal_debug_msgs/msg/float64_stamped.hpp>
2931
#include <autoware_planning_msgs/msg/trajectory.hpp>
3032
#include <diagnostic_msgs/msg/diagnostic_array.hpp>
33+
#include <geometry_msgs/msg/accel_with_covariance_stamped.hpp>
3134
#include <nav_msgs/msg/odometry.hpp>
3235

3336
#include <cstdint>
@@ -38,19 +41,139 @@
3841

3942
namespace autoware::control_validator
4043
{
44+
using autoware_control_msgs::msg::Control;
4145
using autoware_control_validator::msg::ControlValidatorStatus;
4246
using autoware_planning_msgs::msg::Trajectory;
4347
using autoware_planning_msgs::msg::TrajectoryPoint;
4448
using diagnostic_updater::DiagnosticStatusWrapper;
4549
using diagnostic_updater::Updater;
50+
using geometry_msgs::msg::AccelWithCovarianceStamped;
4651
using nav_msgs::msg::Odometry;
4752

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
4977
{
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;
54177
};
55178

56179
/**
@@ -68,23 +191,10 @@ class ControlValidator : public rclcpp::Node
68191
explicit ControlValidator(const rclcpp::NodeOptions & options);
69192

70193
/**
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
82196
*/
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);
88198

89199
private:
90200
/**
@@ -97,27 +207,10 @@ class ControlValidator : public rclcpp::Node
97207
*/
98208
void setup_parameters();
99209

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-
117210
/**
118211
* @brief Publish debug information
119212
*/
120-
void publish_debug_info();
213+
void publish_debug_info(const geometry_msgs::msg::Pose & ego_pose);
121214

122215
/**
123216
* @brief Display validation status on terminal
@@ -134,9 +227,12 @@ class ControlValidator : public rclcpp::Node
134227
DiagnosticStatusWrapper & stat, const bool & is_ok, const std::string & msg) const;
135228

136229
// Subscribers and publishers
137-
rclcpp::Subscription<Trajectory>::SharedPtr sub_predicted_traj_;
230+
rclcpp::Subscription<Control>::SharedPtr sub_control_cmd_;
138231
autoware_utils::InterProcessPollingSubscriber<Odometry>::SharedPtr sub_kinematics_;
139232
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_;
140236
rclcpp::Publisher<ControlValidatorStatus>::SharedPtr pub_status_;
141237
rclcpp::Publisher<visualization_msgs::msg::MarkerArray>::SharedPtr pub_markers_;
142238
rclcpp::Publisher<autoware_internal_debug_msgs::msg::Float64Stamped>::SharedPtr
@@ -145,32 +241,26 @@ class ControlValidator : public rclcpp::Node
145241
// system parameters
146242
int64_t diag_error_count_threshold_ = 0;
147243
bool display_on_terminal_ = true;
148-
149244
Updater diag_updater_{this};
150-
151245
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-
157246
vehicle_info_utils::VehicleInfo vehicle_info_;
158-
159247
/**
160248
* @brief Check if all validation criteria are met
161249
* @param status Validation status
162250
* @return Boolean indicating if all criteria are met
163251
*/
164252
static bool is_all_valid(const ControlValidatorStatus & status);
165253

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_;
171256
autoware_utils::StopWatch<std::chrono::milliseconds> stop_watch;
172257

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};
174264
};
175265
} // namespace autoware::control_validator
176266

control/autoware_control_validator/launch/control_validator.launch.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
<param from="$(var control_validator_param_path)"/>
99

1010
<!-- remap topic name -->
11+
<remap from="~/input/control_cmd" to="/control/command/control_cmd"/>
12+
<remap from="~/input/kinematics" to="/localization/kinematic_state"/>
13+
<remap from="~/input/measured_acceleration" to="/localization/acceleration"/>
1114
<remap from="~/input/reference_trajectory" to="$(var input_reference_trajectory)"/>
1215
<remap from="~/input/predicted_trajectory" to="$(var input_predicted_trajectory)"/>
13-
<remap from="~/input/kinematics" to="/localization/kinematic_state"/>
1416
<remap from="~/output/validation_status" to="~/validation_status"/>
1517
</node>
1618
</launch>

control/autoware_control_validator/msg/ControlValidatorStatus.msg

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@ builtin_interfaces/Time stamp
22

33
# states
44
bool is_valid_max_distance_deviation
5+
bool is_valid_acc
56
bool is_rolling_back
67
bool is_over_velocity
8+
bool has_overrun_stop_point
9+
bool will_overrun_stop_point
10+
bool is_valid_latency
711

812
# values
913
float64 max_distance_deviation
14+
float64 desired_acc
15+
float64 measured_acc
1016
float64 target_vel
1117
float64 vehicle_vel
18+
float64 dist_to_stop
19+
float64 pred_dist_to_stop
20+
float64 nearest_trajectory_vel
21+
float64 latency
1222

1323
int64 invalid_count

control/autoware_control_validator/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<buildtool_depend>autoware_cmake</buildtool_depend>
2121
<build_depend>rosidl_default_generators</build_depend>
2222

23+
<depend>autoware_control_msgs</depend>
2324
<depend>autoware_motion_utils</depend>
2425
<depend>autoware_planning_msgs</depend>
2526
<depend>autoware_signal_processing</depend>

0 commit comments

Comments
 (0)