18 #ifndef VEHICLE_INTERFACE__SAFETY_STATE_MACHINE_HPP_ 19 #define VEHICLE_INTERFACE__SAFETY_STATE_MACHINE_HPP_ 22 #include <autoware_auto_msgs/msg/vehicle_control_command.hpp> 23 #include <autoware_auto_msgs/msg/vehicle_odometry.hpp> 24 #include <autoware_auto_msgs/msg/vehicle_state_command.hpp> 25 #include <autoware_auto_msgs/msg/vehicle_state_report.hpp> 26 #include <vehicle_interface/visibility_control.hpp> 28 #include <experimental/optional> 39 namespace vehicle_interface
41 using MaybeStateCommand = std::experimental::optional<autoware_auto_msgs::msg::VehicleStateCommand>;
43 using Odometry = autoware_auto_msgs::msg::VehicleOdometry;
44 using StateReport = autoware_auto_msgs::msg::VehicleStateReport;
53 : m_control{control}, m_state{state} {}
90 : m_min{min}, m_max{max}, m_threshold{threshold}
93 throw std::domain_error{
"min >= max"};
97 T min() const noexcept {
return m_min;}
98 T max() const noexcept {
return m_max;}
103 const auto value_raw = value;
104 value = std::min(std::max(m_min, value_raw), m_max);
105 return std::abs(value - value_raw) >= m_threshold;
119 using AccelT = decltype(BasicControlCommand::long_accel_mps2);
143 const VelocityT gear_shift_velocity_threshold,
146 const std::chrono::nanoseconds time_step,
147 const AccelT timeout_accel_mps2,
148 const std::chrono::nanoseconds state_transition_timeout,
149 const AccelT auto_gear_shift_accel_deadzone_mps2
152 VelocityT gear_shift_velocity_threshold() const noexcept;
155 std::chrono::nanoseconds time_step() const noexcept;
156 AccelT timeout_acceleration() const noexcept;
157 std::chrono::nanoseconds state_transition_timeout() const noexcept;
158 AccelT auto_gear_shift_accel_deadzone() const noexcept;
161 VelocityT m_gear_shift_velocity_threshold;
164 std::chrono::nanoseconds m_time_step;
165 AccelT m_timeout_acceleration;
166 std::chrono::nanoseconds m_state_transition_timeout;
167 AccelT m_auto_gear_shift_accel_deadzone;
176 using Reports = std::vector<StateMachineReport>;
190 Command timeout_commands() const noexcept;
192 const
Reports & reports() const noexcept;
198 using MaybeEnum = std::experimental::optional<decltype(VSC::blinker)>;
204 std::chrono::system_clock::time_point stamp{std::chrono::system_clock::time_point::min()};
206 struct StateChangeRequests
208 ValueStamp<decltype(VSC::gear)> gear;
209 ValueStamp<decltype(VSC::blinker)> blinker;
210 ValueStamp<decltype(VSC::wiper)> wiper;
211 ValueStamp<decltype(VSC::headlight)> headlight;
212 ValueStamp<decltype(VSC::mode)> mode;
213 ValueStamp<decltype(VSC::hand_brake)> hand_brake;
214 ValueStamp<decltype(VSC::horn)> horn;
224 const VSC & state)
const;
237 StateChangeRequests m_requests{};
244 #endif // VEHICLE_INTERFACE__SAFETY_STATE_MACHINE_HPP_ bool8_t clamp_warn(T &value) const noexcept
Clamps value to max/min range; return true if value is threshold past limits.
Definition: safety_state_machine.hpp:101
autoware_auto_msgs::msg::VehicleStateReport StateReport
Definition: safety_state_machine.hpp:44
StateMachineReport
Definition: safety_state_machine.hpp:67
T
Definition: catr_diff.py:22
Clamped a command that was way out of bounds.
const BasicControlCommand & control() const noexcept
Getter.
Definition: safety_state_machine.hpp:56
#define VEHICLE_INTERFACE_PUBLIC
Definition: drivers/vehicle_interface/include/vehicle_interface/visibility_control.hpp:44
Turn on headlights because you turned on wipers.
Converted gear command to GEAR_NO_COMMAND because you're going too fast.
bool bool8_t
Definition: types.hpp:33
Definition: motion_common.hpp:255
This file includes common type definition.
decltype(Odometry::velocity_mps) VelocityT
Definition: safety_state_machine.hpp:118
Steering has high frequency components.
A state command was not one of the specified constants.
std::vector< StateMachineReport > Reports
Definition: safety_state_machine.hpp:176
T max() const noexcept
Definition: safety_state_machine.hpp:98
Acceleration has high frequency components.
autoware_auto_msgs::msg::VehicleControlCommand BasicControlCommand
Definition: safety_state_machine.hpp:42
Configuration class for SafetyStateMachine.
Definition: safety_state_machine.hpp:115
autoware_auto_msgs::msg::VehicleControlCommand VehicleControlCommand
Definition: pure_pursuit.hpp:41
T clamp(T val, T min, T max)
Standard clamp implementation.
Definition: motion_common.hpp:142
#define VEHICLE_INTERFACE_LOCAL
Definition: drivers/vehicle_interface/include/vehicle_interface/visibility_control.hpp:45
Command(const BasicControlCommand &control=BasicControlCommand{}, const MaybeStateCommand &state=MaybeStateCommand{})
Constructor.
Definition: safety_state_machine.hpp:50
Simple wrapper for control command and state command together.
Definition: safety_state_machine.hpp:46
Reported steering has high frequency components.
Reported velocity has high frequency components.
Commanded state transition didn't happen.
std::experimental::optional< autoware_auto_msgs::msg::VehicleStateCommand > MaybeStateCommand
Definition: safety_state_machine.hpp:41
T threshold() const noexcept
Definition: safety_state_machine.hpp:99
Definition: safety_state_machine.hpp:173
T min() const noexcept
Definition: safety_state_machine.hpp:97
decltype(BasicControlCommand::long_accel_mps2) AccelT
Definition: safety_state_machine.hpp:119
const MaybeStateCommand & state() const noexcept
Getter.
Definition: safety_state_machine.hpp:58
Limits(T min, T max, T threshold)
Definition: safety_state_machine.hpp:89
Definition: safety_state_machine.hpp:84
autoware_auto_msgs::msg::VehicleOdometry Odometry
Definition: safety_state_machine.hpp:43
This file defines the lanelet2_map_provider_node class.
Definition: quick_sort.hpp:24