CARLA
Loading...
Searching...
No Matches
CarlaGNSSPublisher.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<CarlaGnssMsgTraits>>()) {
24 if (!_impl->Init(GetBaseTopicName())) {
25 log_error("CarlaGNSSPublisher: 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 double latitude,
39 double longitude,
40 double altitude) {
41 auto *message = _impl->GetMessage();
42 message->header.stamp.sec = seconds;
43 message->header.stamp.nanosec = nanoseconds;
44 message->header.frame_id = GetFrameId();
45
46 message->latitude = latitude;
47 message->longitude = longitude;
48 message->altitude = altitude;
49 return true;
50}
51
52} // namespace ros2
53} // namespace carla
const std::string & GetBaseTopicName() const noexcept
const std::string & GetFrameId() const noexcept
std::shared_ptr< PublisherImpl< CarlaGnssMsgTraits > > _impl
CarlaGNSSPublisher(std::string base_topic_name, std::string frame_id)
bool Write(std::int32_t seconds, std::uint32_t nanoseconds, double latitude, double longitude, double altitude)
This file contains definitions of common data structures used in traffic manager.
static void log_error(Args &&... args)
Definition Logging.h:110