CARLA
Loading...
Searching...
No Matches
AckermannControlSubscriber.cpp
Go to the documentation of this file.
1// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
8
9#include "carla/Logging.h"
14
15namespace carla {
16namespace ros2 {
17
21
23 void *vehicle, std::string base_topic_name, std::string frame_id)
24 : BaseSubscriber(vehicle, std::move(base_topic_name), std::move(frame_id)),
25 _impl(std::make_shared<SubscriberImpl<AckermannControlTraits>>()) {
26 if (!_impl->Init(this->GetBaseTopicName() + "/ackermann_control_cmd")) {
27 log_error("AckermannControlSubscriber failed to initialize on base topic",
28 this->GetBaseTopicName());
29 }
30}
31
33
35 auto message = _impl->GetMessage();
36 return FromAckermannDrive(
37 message.drive.steering_angle,
38 message.drive.steering_angle_velocity,
39 message.drive.speed,
40 message.drive.acceleration,
41 message.drive.jerk);
42}
43
45 if (_impl->HasNewMessage()) {
46 auto control = this->GetMessage();
47 callback(this->GetActor(), control);
48 }
49}
50
51} // namespace ros2
52} // namespace carla
AckermannControlSubscriber(void *vehicle, std::string base_topic_name, std::string frame_id)
std::shared_ptr< SubscriberImpl< AckermannControlTraits > > _impl
void ProcessMessages(ActorCallback callback) override
const std::string & GetBaseTopicName() const noexcept
void * GetActor() const noexcept
std::function< void(void *actor, ROS2CallbackData data)> ActorCallback
AckermannControl FromAckermannDrive(float steering_angle, float steering_angle_velocity, float speed, float acceleration, float jerk)
std::variant< VehicleControl, AckermannControl, VehicleAccelerationControl > ROS2CallbackData
This file contains definitions of common data structures used in traffic manager.
static void log_error(Args &&... args)
Definition Logging.h:110