CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
ros2
middleware
IPublisherMiddleware.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB).
2
// This work is licensed under the terms of the MIT license.
3
// For a copy, see <https://opensource.org/licenses/MIT>.
4
5
#pragma once
6
7
#include <string>
8
9
#include "
carla/ros2/middleware/QosProfile.h
"
10
11
namespace
carla
{
12
namespace
ros2
{
13
14
/// Type-erased abstract interface for a publisher middleware.
15
/// Concrete implementations handle all vendor-specific entity creation,
16
/// type registration, and data writing.
17
///
18
/// Contract: when an implementation establishes its process-wide transport
19
/// context (a DDS DomainParticipant, a Zenoh session, ...) it must honor
20
/// carla::ros2::MiddlewareConfig::GetDomainId(), mapping kUnsetDomainId to its
21
/// own native default. This keeps the ROS 2 domain id configurable and
22
/// middleware-agnostic (see MiddlewareConfig.h).
23
class
IPublisherMiddleware
{
24
public
:
25
virtual
~IPublisherMiddleware
() =
default
;
26
27
/// Initialize the underlying middleware entities.
28
/// @param topic_name Full topic name including "rt/" prefix.
29
/// @return true on success.
30
virtual
bool
Init
(
const
std::string& topic_name) = 0;
31
32
/// Initialize with an explicit per-topic QoS profile (see QosProfile.h).
33
/// The default implementation ignores the profile and falls back to the
34
/// QoS-less Init so test fakes and QoS-agnostic middlewares keep working;
35
/// concrete backends override this to honor the profile.
36
virtual
bool
Init
(
const
std::string& topic_name,
const
QosProfile
& qos) {
37
(void)qos;
38
return
Init
(topic_name);
39
}
40
41
/// Serialize and write a message to the network.
42
/// @param message_data Pointer to the message object (type-erased, cast internally).
43
/// @return true if the write succeeded.
44
virtual
bool
Publish
(
void
* message_data) = 0;
45
46
/// @return true if at least one subscriber is matched.
47
virtual
bool
IsAlive
()
const
= 0;
48
49
/// @return The topic name this publisher is bound to.
50
virtual
std::string
GetTopicName
()
const
= 0;
51
};
52
53
}
// namespace ros2
54
}
// namespace carla
QosProfile.h
carla::ros2::IPublisherMiddleware
Type-erased abstract interface for a publisher middleware.
Definition
IPublisherMiddleware.h:23
carla::ros2::IPublisherMiddleware::Publish
virtual bool Publish(void *message_data)=0
Serialize and write a message to the network.
carla::ros2::IPublisherMiddleware::GetTopicName
virtual std::string GetTopicName() const =0
carla::ros2::IPublisherMiddleware::Init
virtual bool Init(const std::string &topic_name, const QosProfile &qos)
Initialize with an explicit per-topic QoS profile (see QosProfile.h).
Definition
IPublisherMiddleware.h:36
carla::ros2::IPublisherMiddleware::~IPublisherMiddleware
virtual ~IPublisherMiddleware()=default
carla::ros2::IPublisherMiddleware::Init
virtual bool Init(const std::string &topic_name)=0
Initialize the underlying middleware entities.
carla::ros2::IPublisherMiddleware::IsAlive
virtual bool IsAlive() const =0
carla::ros2
Definition
AutowareSteeringCompensation.h:15
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
carla::ros2::QosProfile
Middleware-neutral QoS profile passed to IPublisherMiddleware::Init / ISubscriberMiddleware::Init whe...
Definition
QosProfile.h:27
Generated by
1.18.0