40 return control.HasNewMessage() ||
41 gear.HasNewMessage() ||
50 void *vehicle, std::string frame_id)
52 _impl(
std::make_shared<
Impl>()) {
57 ok &=
_impl->control.Init(
"rt/control/command/control_cmd", qos);
58 ok &=
_impl->gear.Init(
"rt/control/command/gear_cmd", qos);
59 ok &=
_impl->turn_indicators.Init(
"rt/control/command/turn_indicators_cmd", qos);
60 ok &=
_impl->hazard_lights.Init(
"rt/control/command/hazard_lights_cmd", qos);
61 ok &=
_impl->emergency.Init(
"rt/control/command/emergency_cmd", qos);
62 ok &=
_impl->engage.Init(
"rt/vehicle/engage", qos);
64 log_error(
"AutowareControlSubscriber: failed to initialize one or more command readers");
75 const auto control_in =
_impl->control.GetMessage();
76 (void)
_impl->gear.GetMessage();
77 (void)
_impl->turn_indicators.GetMessage();
78 (void)
_impl->hazard_lights.GetMessage();
79 (void)
_impl->emergency.GetMessage();
80 (void)
_impl->engage.GetMessage();
87 control_out.
acceleration = control_in.longitudinal.acceleration;
91 const float raw_steering = -control_in.lateral.steering_tire_angle;
97 control_out.steer_speed = 0.0f;
98 if (control_in.lateral.is_defined_steering_tire_rotation_rate) {
99 control_out.steer_speed = -control_in.lateral.steering_tire_rotation_rate;
106 if (
_impl->HasNewMessage()) {
108 callback(this->
GetActor(), control);
SubscriberImpl< AutowareEmergencyCmdTraits > emergency
SubscriberImpl< AutowareHazardLightsCmdTraits > hazard_lights
SubscriberImpl< AutowareGearCmdTraits > gear
SubscriberImpl< AutowareEngageTraits > engage
SubscriberImpl< AutowareTurnIndicatorsCmdTraits > turn_indicators
SubscriberImpl< AutowareControlCmdTraits > control
~AutowareControlSubscriber() override
AutowareControlSubscriber(void *vehicle, std::string frame_id)
void ProcessMessages(ActorCallback callback) override
Drains the six command topics once per frame (called from ROS2::SetFrame like every BaseSubscriber).
ROS2CallbackData GetMessage() override
std::shared_ptr< Impl > _impl
void * GetActor() const noexcept
float GetSteeringInput(const float output_angle)
Target (actual) tire angle -> vehicle input that produces it.
std::function< void(void *actor, ROS2CallbackData data)> ActorCallback
std::variant< VehicleControl, AckermannControl, VehicleAccelerationControl > ROS2CallbackData
This file contains definitions of common data structures used in traffic manager.
static void log_error(Args &&... args)
Middleware-neutral QoS profile passed to IPublisherMiddleware::Init / ISubscriberMiddleware::Init whe...
static QosProfile ReliableTransientLocal()
RELIABLE / TRANSIENT_LOCAL / KEEP_LAST depth 1 — the profile tier4 uses for the Autoware command subs...
Control decoded from Autoware's /control/command/control_cmd: longitudinal acceleration [m/s^2] + ste...
autoware_control_msgs/msg/Control