CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
ros2
middleware
ISubscriberMiddleware.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 subscriber middleware.
15
/// Concrete implementations write received messages directly into the caller-provided
16
/// storage (message_ptr / new_message_flag) to avoid an extra copy.
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
ISubscriberMiddleware
{
24
public
:
25
virtual
~ISubscriberMiddleware
() =
default
;
26
27
/// Initialize the underlying middleware entities.
28
/// The middleware writes incoming messages to *message_ptr and sets *new_message_flag = true.
29
/// @param topic_name Full topic name.
30
/// @param message_ptr Pointer to the message storage owned by the caller.
31
/// @param new_message_flag Pointer to the new-message flag owned by the caller.
32
/// @return true on success.
33
virtual
bool
Init
(
34
const
std::string& topic_name,
35
void
* message_ptr,
36
bool
* new_message_flag) = 0;
37
38
/// Initialize with an explicit per-topic QoS profile (see QosProfile.h).
39
/// The default implementation ignores the profile and falls back to the
40
/// QoS-less Init so test fakes and QoS-agnostic middlewares keep working;
41
/// concrete backends override this to honor the profile.
42
virtual
bool
Init
(
43
const
std::string& topic_name,
44
void
* message_ptr,
45
bool
* new_message_flag,
46
const
QosProfile
& qos) {
47
(void)qos;
48
return
Init
(topic_name, message_ptr, new_message_flag);
49
}
50
51
/// @return true if at least one publisher is matched.
52
virtual
bool
IsAlive
()
const
= 0;
53
54
/// @return The topic name this subscriber is bound to.
55
virtual
std::string
GetTopicName
()
const
= 0;
56
};
57
58
}
// namespace ros2
59
}
// namespace carla
QosProfile.h
carla::ros2::ISubscriberMiddleware
Type-erased abstract interface for a subscriber middleware.
Definition
ISubscriberMiddleware.h:23
carla::ros2::ISubscriberMiddleware::Init
virtual bool Init(const std::string &topic_name, void *message_ptr, bool *new_message_flag)=0
Initialize the underlying middleware entities.
carla::ros2::ISubscriberMiddleware::IsAlive
virtual bool IsAlive() const =0
carla::ros2::ISubscriberMiddleware::Init
virtual bool Init(const std::string &topic_name, void *message_ptr, bool *new_message_flag, const QosProfile &qos)
Initialize with an explicit per-topic QoS profile (see QosProfile.h).
Definition
ISubscriberMiddleware.h:42
carla::ros2::ISubscriberMiddleware::GetTopicName
virtual std::string GetTopicName() const =0
carla::ros2::ISubscriberMiddleware::~ISubscriberMiddleware
virtual ~ISubscriberMiddleware()=default
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