CARLA
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 }
 
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()

template<typename T >
carla::ros2::FastDDSPublisherMiddleware< T >::~FastDDSPublisherMiddleware ( )
inlineoverride

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 206 of file FastDDSPublisherMiddleware.h.

References carla::ros2::FastDDSPublisherMiddleware< T >::_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 carla::ros2::FastDDSPublisherMiddleware< T >::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 carla::ros2::FastDDSPublisherMiddleware< T >::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 202 of file FastDDSPublisherMiddleware.h.

References carla::ros2::FastDDSPublisherMiddleware< T >::_alive.

◆ on_publication_matched()

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

◆ 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 carla::ros2::FastDDSPublisherMiddleware< T >::_datawriter, carla::ros2::FastDDSPublisherMiddleware< T >::_topic_name, and carla::log_error().

Member Data Documentation

◆ _alive

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

◆ _datawriter

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

◆ _participant

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

◆ _publisher

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

◆ _topic

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

◆ _topic_name

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

◆ _type

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

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