CARLA
Loading...
Searching...
No Matches
carla::ros2::FastDDSPublisherMiddleware< T > Class Template Reference

FastDDS implementation of IPublisherMiddleware. More...

#include <FastDDSPublisherMiddleware.h>

Inheritance diagram for carla::ros2::FastDDSPublisherMiddleware< T >:

Public Types

using msg_type = typename T::msg_type

Public Member Functions

 FastDDSPublisherMiddleware ()=default
 FastDDSPublisherMiddleware (const FastDDSPublisherMiddleware &)=delete
std::string GetTopicName () const override
bool Init (const std::string &topic_name) override
 Initialize the underlying middleware entities.
bool Init (const std::string &topic_name, const QosProfile &qos) override
 Initialize with an explicit per-topic QoS profile (see QosProfile.h).
bool IsAlive () const override
void on_publication_matched (efd::DataWriter *writer, const efd::PublicationMatchedStatus &info) override
FastDDSPublisherMiddleware & operator= (const FastDDSPublisherMiddleware &)=delete
bool Publish (void *message_data) override
 Serialize and write a message to the network.
 ~FastDDSPublisherMiddleware () override
Public Member Functions inherited from carla::ros2::IPublisherMiddleware
virtual ~IPublisherMiddleware ()=default

Private Member Functions

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

Private Attributes

std::atomic< bool > _alive { false }
efd::DataWriter * _datawriter { nullptr }
efd::DomainParticipant * _participant { nullptr }
efd::Publisher * _publisher { nullptr }
std::atomic< bool > _reported_not_ready { false }
efd::Topic * _topic { nullptr }
std::string _topic_name
efd::TypeSupport _type { new GenericCdrPubSubType<msg_type>() }

Detailed Description

template<typename T>
class carla::ros2::FastDDSPublisherMiddleware< T >

FastDDS implementation of IPublisherMiddleware.

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

Uses FastDDSSharedParticipant for a single refcounted DomainParticipant across all FastDDS endpoints, mirroring CycloneDDS's shared-participant model. This avoids the discovery storm that occurred when N independent participants were destroyed back-to-back on ROS2::Shutdown().

Sets USER_DATA QoS on the DataWriter 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 48 of file FastDDSPublisherMiddleware.h.

Member Typedef Documentation

◆ msg_type

template<typename T>
using carla::ros2::FastDDSPublisherMiddleware< T >::msg_type = typename T::msg_type

Definition at line 52 of file FastDDSPublisherMiddleware.h.

Constructor & Destructor Documentation

◆ FastDDSPublisherMiddleware() [1/2]

template<typename T>
carla::ros2::FastDDSPublisherMiddleware< T >::FastDDSPublisherMiddleware ( )
default

◆ FastDDSPublisherMiddleware() [2/2]

template<typename T>
carla::ros2::FastDDSPublisherMiddleware< T >::FastDDSPublisherMiddleware ( const FastDDSPublisherMiddleware< T > & )
delete

◆ ~FastDDSPublisherMiddleware()

Member Function Documentation

◆ GetTopicName()

template<typename T>
std::string carla::ros2::FastDDSPublisherMiddleware< T >::GetTopicName ( ) const
inlineoverridevirtual
Returns
The topic name this publisher is bound to.

Implements carla::ros2::IPublisherMiddleware.

Definition at line 215 of file FastDDSPublisherMiddleware.h.

References _topic_name.

◆ Init() [1/2]

template<typename T>
bool carla::ros2::FastDDSPublisherMiddleware< T >::Init ( const std::string & topic_name)
inlineoverridevirtual

Initialize the underlying middleware entities.

Parameters
topic_nameFull topic name including "rt/" prefix.
Returns
true on success.

Implements carla::ros2::IPublisherMiddleware.

Definition at line 86 of file FastDDSPublisherMiddleware.h.

References InitImpl().

◆ Init() [2/2]

template<typename T>
bool carla::ros2::FastDDSPublisherMiddleware< T >::Init ( const std::string & topic_name,
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::IPublisherMiddleware.

Definition at line 90 of file FastDDSPublisherMiddleware.h.

References InitImpl().

◆ InitImpl()

template<typename T>
bool carla::ros2::FastDDSPublisherMiddleware< T >::InitImpl ( const std::string & topic_name,
const QosProfile * qos )
inlineprivate

◆ IsAlive()

template<typename T>
bool carla::ros2::FastDDSPublisherMiddleware< T >::IsAlive ( ) const
inlineoverridevirtual
Returns
true if at least one subscriber is matched.

Implements carla::ros2::IPublisherMiddleware.

Definition at line 211 of file FastDDSPublisherMiddleware.h.

References _alive.

◆ on_publication_matched()

template<typename T>
void carla::ros2::FastDDSPublisherMiddleware< T >::on_publication_matched ( efd::DataWriter * writer,
const efd::PublicationMatchedStatus & info )
inlineoverride

Definition at line 58 of file FastDDSPublisherMiddleware.h.

References _alive.

◆ operator=()

template<typename T>
FastDDSPublisherMiddleware & carla::ros2::FastDDSPublisherMiddleware< T >::operator= ( const FastDDSPublisherMiddleware< T > & )
delete

◆ Publish()

template<typename T>
bool carla::ros2::FastDDSPublisherMiddleware< T >::Publish ( void * message_data)
inlineoverridevirtual

Serialize and write a message to the network.

Parameters
message_dataPointer to the message object (type-erased, cast internally).
Returns
true if the write succeeded.

Implements carla::ros2::IPublisherMiddleware.

Definition at line 191 of file FastDDSPublisherMiddleware.h.

References _datawriter, _reported_not_ready, and _topic_name.

Member Data Documentation

◆ _alive

template<typename T>
std::atomic<bool> carla::ros2::FastDDSPublisherMiddleware< T >::_alive { false }
private

Definition at line 227 of file FastDDSPublisherMiddleware.h.

Referenced by IsAlive(), and on_publication_matched().

◆ _datawriter

template<typename T>
efd::DataWriter* carla::ros2::FastDDSPublisherMiddleware< T >::_datawriter { nullptr }
private

Definition at line 223 of file FastDDSPublisherMiddleware.h.

Referenced by InitImpl(), Publish(), and ~FastDDSPublisherMiddleware().

◆ _participant

template<typename T>
efd::DomainParticipant* carla::ros2::FastDDSPublisherMiddleware< T >::_participant { nullptr }
private

Definition at line 220 of file FastDDSPublisherMiddleware.h.

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

◆ _publisher

template<typename T>
efd::Publisher* carla::ros2::FastDDSPublisherMiddleware< T >::_publisher { nullptr }
private

Definition at line 221 of file FastDDSPublisherMiddleware.h.

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

◆ _reported_not_ready

template<typename T>
std::atomic<bool> carla::ros2::FastDDSPublisherMiddleware< T >::_reported_not_ready { false }
private

Definition at line 228 of file FastDDSPublisherMiddleware.h.

Referenced by Publish().

◆ _topic

template<typename T>
efd::Topic* carla::ros2::FastDDSPublisherMiddleware< T >::_topic { nullptr }
private

Definition at line 222 of file FastDDSPublisherMiddleware.h.

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

◆ _topic_name

template<typename T>
std::string carla::ros2::FastDDSPublisherMiddleware< T >::_topic_name
private

Definition at line 226 of file FastDDSPublisherMiddleware.h.

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

◆ _type

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

Definition at line 224 of file FastDDSPublisherMiddleware.h.

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


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