CARLA
Loading...
Searching...
No Matches
carla::ros2::FastDDSSubscriberMiddleware< S > Class Template Reference

FastDDS implementation of ISubscriberMiddleware. More...

#include <FastDDSSubscriberMiddleware.h>

Inheritance diagram for carla::ros2::FastDDSSubscriberMiddleware< S >:

Public Types

using msg_type = typename S::msg_type

Public Member Functions

 FastDDSSubscriberMiddleware ()=default
 FastDDSSubscriberMiddleware (const FastDDSSubscriberMiddleware &)=delete
std::string GetTopicName () const override
bool Init (const std::string &topic_name, void *message_ptr, bool *new_message_flag) override
 Initialize the underlying middleware entities.
bool Init (const std::string &topic_name, void *message_ptr, bool *new_message_flag, const QosProfile &qos) override
 Initialize with an explicit per-topic QoS profile (see QosProfile.h).
bool IsAlive () const override
void on_data_available (efd::DataReader *reader) override
void on_subscription_matched (efd::DataReader *reader, const efd::SubscriptionMatchedStatus &info) override
FastDDSSubscriberMiddleware & operator= (const FastDDSSubscriberMiddleware &)=delete
 ~FastDDSSubscriberMiddleware () override
Public Member Functions inherited from carla::ros2::ISubscriberMiddleware
virtual ~ISubscriberMiddleware ()=default

Private Member Functions

bool InitImpl (const std::string &topic_name, void *message_ptr, bool *new_message_flag, const QosProfile *qos)
 Shared Init body.

Private Attributes

std::atomic< bool > _alive { false }
efd::DataReader * _datareader { nullptr }
msg_type * _message_ptr { nullptr }
bool * _new_message_ptr { nullptr }
efd::DomainParticipant * _participant { nullptr }
efd::Subscriber * _subscriber { nullptr }
efd::Topic * _topic { nullptr }
std::string _topic_name
efd::TypeSupport _type { new GenericCdrPubSubType<msg_type>() }

Detailed Description

template<typename S>
class carla::ros2::FastDDSSubscriberMiddleware< S >

FastDDS implementation of ISubscriberMiddleware.

Parameterized on traits type S that provides: S::msg_type — the message type (a carla::ros2::msg::* POD struct) Deserialization is handled by GenericCdrPubSubType<msg_type> via CdrSerialization.h.

Uses FastDDSSharedParticipant for a single refcounted DomainParticipant across all FastDDS endpoints. See FastDDSPublisherMiddleware.h for the rationale.

Sets USER_DATA QoS on the DataReader to the REP-2016 KV payload "typehash=RIHS01_<hex>;" (PID_USER_DATA = 0x002c in DDSI-RTPS v2.5 §9.6.2.2.2) so that Jazzy rmw_cyclonedds_cpp and rmw_fastrtps_cpp can perform REP-2011 type-hash-based endpoint matching without warning.

Definition at line 47 of file FastDDSSubscriberMiddleware.h.

Member Typedef Documentation

◆ msg_type

template<typename S>
using carla::ros2::FastDDSSubscriberMiddleware< S >::msg_type = typename S::msg_type

Definition at line 51 of file FastDDSSubscriberMiddleware.h.

Constructor & Destructor Documentation

◆ FastDDSSubscriberMiddleware() [1/2]

template<typename S>
carla::ros2::FastDDSSubscriberMiddleware< S >::FastDDSSubscriberMiddleware ( )
default

◆ FastDDSSubscriberMiddleware() [2/2]

template<typename S>
carla::ros2::FastDDSSubscriberMiddleware< S >::FastDDSSubscriberMiddleware ( const FastDDSSubscriberMiddleware< S > & )
delete

◆ ~FastDDSSubscriberMiddleware()

Member Function Documentation

◆ GetTopicName()

template<typename S>
std::string carla::ros2::FastDDSSubscriberMiddleware< S >::GetTopicName ( ) const
inlineoverridevirtual
Returns
The topic name this subscriber is bound to.

Implements carla::ros2::ISubscriberMiddleware.

Definition at line 199 of file FastDDSSubscriberMiddleware.h.

References _topic_name.

◆ Init() [1/2]

template<typename S>
bool carla::ros2::FastDDSSubscriberMiddleware< S >::Init ( const std::string & topic_name,
void * message_ptr,
bool * new_message_flag )
inlineoverridevirtual

Initialize the underlying middleware entities.

The middleware writes incoming messages to *message_ptr and sets *new_message_flag = true.

Parameters
topic_nameFull topic name.
message_ptrPointer to the message storage owned by the caller.
new_message_flagPointer to the new-message flag owned by the caller.
Returns
true on success.

Implements carla::ros2::ISubscriberMiddleware.

Definition at line 94 of file FastDDSSubscriberMiddleware.h.

References InitImpl().

◆ Init() [2/2]

template<typename S>
bool carla::ros2::FastDDSSubscriberMiddleware< S >::Init ( const std::string & topic_name,
void * message_ptr,
bool * new_message_flag,
const QosProfile & qos )
inlineoverridevirtual

Initialize with an explicit per-topic QoS profile (see QosProfile.h).

The default implementation ignores the profile and falls back to the QoS-less Init so test fakes and QoS-agnostic middlewares keep working; concrete backends override this to honor the profile.

Reimplemented from carla::ros2::ISubscriberMiddleware.

Definition at line 101 of file FastDDSSubscriberMiddleware.h.

References InitImpl().

◆ InitImpl()

template<typename S>
bool carla::ros2::FastDDSSubscriberMiddleware< S >::InitImpl ( const std::string & topic_name,
void * message_ptr,
bool * new_message_flag,
const QosProfile * qos )
inlineprivate

◆ IsAlive()

template<typename S>
bool carla::ros2::FastDDSSubscriberMiddleware< S >::IsAlive ( ) const
inlineoverridevirtual
Returns
true if at least one publisher is matched.

Implements carla::ros2::ISubscriberMiddleware.

Definition at line 195 of file FastDDSSubscriberMiddleware.h.

References _alive.

◆ on_data_available()

template<typename S>
void carla::ros2::FastDDSSubscriberMiddleware< S >::on_data_available ( efd::DataReader * reader)
inlineoverride

Definition at line 63 of file FastDDSSubscriberMiddleware.h.

References _message_ptr, _new_message_ptr, and _topic_name.

◆ on_subscription_matched()

template<typename S>
void carla::ros2::FastDDSSubscriberMiddleware< S >::on_subscription_matched ( efd::DataReader * reader,
const efd::SubscriptionMatchedStatus & info )
inlineoverride

Definition at line 57 of file FastDDSSubscriberMiddleware.h.

References _alive.

◆ operator=()

Member Data Documentation

◆ _alive

template<typename S>
std::atomic<bool> carla::ros2::FastDDSSubscriberMiddleware< S >::_alive { false }
private

Definition at line 214 of file FastDDSSubscriberMiddleware.h.

Referenced by IsAlive(), and on_subscription_matched().

◆ _datareader

template<typename S>
efd::DataReader* carla::ros2::FastDDSSubscriberMiddleware< S >::_datareader { nullptr }
private

Definition at line 207 of file FastDDSSubscriberMiddleware.h.

Referenced by InitImpl(), and ~FastDDSSubscriberMiddleware().

◆ _message_ptr

template<typename S>
msg_type* carla::ros2::FastDDSSubscriberMiddleware< S >::_message_ptr { nullptr }
private

Definition at line 210 of file FastDDSSubscriberMiddleware.h.

Referenced by InitImpl(), and on_data_available().

◆ _new_message_ptr

template<typename S>
bool* carla::ros2::FastDDSSubscriberMiddleware< S >::_new_message_ptr { nullptr }
private

Definition at line 211 of file FastDDSSubscriberMiddleware.h.

Referenced by InitImpl(), and on_data_available().

◆ _participant

template<typename S>
efd::DomainParticipant* carla::ros2::FastDDSSubscriberMiddleware< S >::_participant { nullptr }
private

Definition at line 204 of file FastDDSSubscriberMiddleware.h.

Referenced by InitImpl(), and ~FastDDSSubscriberMiddleware().

◆ _subscriber

template<typename S>
efd::Subscriber* carla::ros2::FastDDSSubscriberMiddleware< S >::_subscriber { nullptr }
private

Definition at line 205 of file FastDDSSubscriberMiddleware.h.

Referenced by InitImpl(), and ~FastDDSSubscriberMiddleware().

◆ _topic

template<typename S>
efd::Topic* carla::ros2::FastDDSSubscriberMiddleware< S >::_topic { nullptr }
private

Definition at line 206 of file FastDDSSubscriberMiddleware.h.

Referenced by InitImpl(), and ~FastDDSSubscriberMiddleware().

◆ _topic_name

template<typename S>
std::string carla::ros2::FastDDSSubscriberMiddleware< S >::_topic_name
private

Definition at line 213 of file FastDDSSubscriberMiddleware.h.

Referenced by GetTopicName(), InitImpl(), and on_data_available().

◆ _type

template<typename S>
efd::TypeSupport carla::ros2::FastDDSSubscriberMiddleware< S >::_type { new GenericCdrPubSubType<msg_type>() }
private

Definition at line 208 of file FastDDSSubscriberMiddleware.h.

Referenced by InitImpl(), and ~FastDDSSubscriberMiddleware().


The documentation for this class was generated from the following file: