CARLA
Loading...
Searching...
No Matches
CarlaCollisionPublisher.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"
12
13namespace carla {
14namespace ros2 {
15
19
21 std::string base_topic_name, std::string frame_id)
22 : BasePublisher(std::move(base_topic_name), std::move(frame_id)),
23 _impl(std::make_shared<PublisherImpl<CarlaCollisionMsgTraits>>()) {
24 if (!_impl->Init(GetBaseTopicName())) {
25 log_error("CarlaCollisionPublisher: failed to initialise writer for", GetBaseTopicName());
26 }
27}
28
30
32 return _impl->Publish();
33}
34
36 std::int32_t seconds,
37 std::uint32_t nanoseconds,
38 std::uint32_t other_actor_id,
39 float impulse_x,
40 float impulse_y,
41 float impulse_z) {
42 auto *message = _impl->GetMessage();
43 message->header.stamp.sec = seconds;
44 message->header.stamp.nanosec = nanoseconds;
45 message->header.frame_id = GetFrameId();
46
47 message->other_actor_id = other_actor_id;
48 message->normal_impulse.x = impulse_x;
49 message->normal_impulse.y = impulse_y;
50 message->normal_impulse.z = impulse_z;
51 return true;
52}
53
54} // namespace ros2
55} // namespace carla
const std::string & GetBaseTopicName() const noexcept
const std::string & GetFrameId() const noexcept
std::shared_ptr< PublisherImpl< CarlaCollisionMsgTraits > > _impl
CarlaCollisionPublisher(std::string base_topic_name, std::string frame_id)
bool Write(std::int32_t seconds, std::uint32_t nanoseconds, std::uint32_t other_actor_id, float impulse_x, float impulse_y, float impulse_z)
This file contains definitions of common data structures used in traffic manager.
static void log_error(Args &&... args)
Definition Logging.h:110