CARLA
Loading...
Searching...
No Matches
CarlaClockPublisher.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 : BasePublisher("rt/clock"),
22 _impl(std::make_shared<PublisherImpl<CarlaClockMsgTraits>>()) {
23 if (!_impl->Init(GetBaseTopicName())) {
24 log_error("CarlaClockPublisher: failed to initialise writer for rt/clock");
25 }
26}
27
29
31 return _impl->Publish();
32}
33
34bool CarlaClockPublisher::Write(std::int32_t seconds, std::uint32_t nanoseconds) {
35 auto *message = _impl->GetMessage();
36 message->clock.sec = seconds;
37 message->clock.nanosec = nanoseconds;
38 return true;
39}
40
41} // namespace ros2
42} // namespace carla
const std::string & GetBaseTopicName() const noexcept
std::shared_ptr< PublisherImpl< CarlaClockMsgTraits > > _impl
bool Write(std::int32_t seconds, std::uint32_t nanoseconds)
This file contains definitions of common data structures used in traffic manager.
static void log_error(Args &&... args)
Definition Logging.h:110