chrono::synchrono::SynDDSCommunicator Class Reference

Description

Derived communicator used to establish and facilitate communication between nodes.

Uses the Data Distribution Service (DDS) standard

#include <SynDDSCommunicator.h>

Inheritance diagram for chrono::synchrono::SynDDSCommunicator:
Collaboration diagram for chrono::synchrono::SynDDSCommunicator:

Public Member Functions

 SynDDSCommunicator (int node_id, const std::string &prefix=default_prefix)
 
 SynDDSCommunicator (const std::string &name, const std::string &prefix=default_prefix)
 Default constructor.
 
 SynDDSCommunicator (eprosima::fastdds::dds::DomainParticipantQos &qos, const std::string &prefix=default_prefix)
 Set the QoS directly from the constructor.
 
virtual ~SynDDSCommunicator ()
 Destructor.
 
virtual void Initialize () override
 Initialization function typically responsible for establishing a connection.
 
virtual void Synchronize () override
 This function is responsible for continuous synchronization steps This function, depending on it's implementation, could be blocking or non-blocking.
 
virtual void Barrier () override
 This function is responsible for blocking until an action is received or done.
 
void Barrier (unsigned int num_participants)
 This function is responsible for blocking until the passed number of participants has been matched.
 
std::vector< std::string > GetMatchedParticipantNames ()
 Get the matched participant's names A matched participant is defined as a DDSParticipant Entity that has matched with the participant created on this node.
 
std::shared_ptr< SynDDSTopicCreateTopic (const std::string &topic_name, eprosima::fastdds::dds::TopicDataType *data_type, const std::string &topic_prefix)
 Create a topic The topic will be registered with the participant, if desired.
 
std::shared_ptr< SynDDSTopicCreateTopic (const std::string &topic_name, eprosima::fastdds::dds::TopicDataType *data_type)
 Create a topic using the communicator's prefix The topic will be registered with the participant, if desired.
 
std::shared_ptr< SynDDSSubscriberCreateSubscriber (std::shared_ptr< SynDDSTopic > topic, std::function< void(void *)> callback, void *message, bool is_synchronous=true, bool is_managed=false, eprosima::fastdds::dds::DataReaderQos *read_qos=nullptr)
 Create a subscription to the specified topic Will call the callback when a subscription is received Takes a SynDDSTopic object (see CreateTopic)
 
std::shared_ptr< SynDDSSubscriberCreateSubscriber (const std::string &topic_name, eprosima::fastdds::dds::TopicDataType *data_type, std::function< void(void *)> callback, void *message, bool is_synchronous=true, bool is_managed=false)
 Create a subscription to the specified topic Will call the callback when a subscription is received Takes a string and TopicDataType and creates a topic (see CreateTopic)
 
std::shared_ptr< SynDDSPublisherCreatePublisher (std::shared_ptr< SynDDSTopic > topic, bool is_managed=false, eprosima::fastdds::dds::DataWriterQos *write_qos=nullptr)
 Create a Publisher Returns a publisher handle to be used to publish information Takes a SynDDSTopic object (see CreateTopic)
 
std::shared_ptr< SynDDSPublisherCreatePublisher (const std::string &topic_name, eprosima::fastdds::dds::TopicDataType *data_type, bool is_managed=false)
 Create a Publisher Returns a publisher handle to be used to publish information Takes a string and TopicDataType and creates a topic (see CreateTopic)
 
- Public Member Functions inherited from chrono::synchrono::SynCommunicator
 SynCommunicator ()
 Default constructor.
 
virtual ~SynCommunicator ()
 Destructor.
 
void Reset ()
 Reset the communicator Will clear out message buffers.
 
void AddOutgoingMessages (SynMessageList &messages)
 Add the messages to the outgoing message buffer.
 
void AddQuitMessage ()
 Adds a quit message to the queue telling other nodes to end the simulation.
 
void AddIncomingMessages (SynMessageList &messages)
 Add the messages to the incoming message buffer.
 
void ProcessBuffer (std::vector< uint8_t > &data)
 Process a data buffer by passing it to the underlying FlatBuffersManager.
 
virtual SynMessageList & GetMessages ()
 Get the messages received by the communicator.
 

Public Attributes

std::string m_prefix
 

Additional Inherited Members

- Protected Attributes inherited from chrono::synchrono::SynCommunicator
bool m_initialized
 whether the communicator has been initialized
 
SynMessageList m_incoming_messages
 Incoming messages.
 
SynFlatBuffersManager m_flatbuffers_manager
 flatbuffer manager for this rank
 

Constructor & Destructor Documentation

◆ SynDDSCommunicator() [1/2]

chrono::synchrono::SynDDSCommunicator::SynDDSCommunicator ( const std::string & name,
const std::string & prefix = default_prefix )

Default constructor.

Parameters
nameThe name to set to the qos
prefixprefix to use for the participant

◆ SynDDSCommunicator() [2/2]

chrono::synchrono::SynDDSCommunicator::SynDDSCommunicator ( eprosima::fastdds::dds::DomainParticipantQos & qos,
const std::string & prefix = default_prefix )

Set the QoS directly from the constructor.

Parameters
qosthe Quality of Service to set for the participant
prefixprefix to use for the participant

Member Function Documentation

◆ Barrier() [1/2]

void chrono::synchrono::SynDDSCommunicator::Barrier ( )
overridevirtual

This function is responsible for blocking until an action is received or done.

For example, a process may call Barrier to wait until another process has established certain classes and initialized certain quantities. This functionality should be implemented in this function.

Implements chrono::synchrono::SynCommunicator.

◆ Barrier() [2/2]

void chrono::synchrono::SynDDSCommunicator::Barrier ( unsigned int num_participants)

This function is responsible for blocking until the passed number of participants has been matched.

Parameters
num_participantsnumber of participants to block until matched

◆ CreatePublisher() [1/2]

std::shared_ptr< SynDDSPublisher > chrono::synchrono::SynDDSCommunicator::CreatePublisher ( const std::string & topic_name,
eprosima::fastdds::dds::TopicDataType * data_type,
bool is_managed = false )

Create a Publisher Returns a publisher handle to be used to publish information Takes a string and TopicDataType and creates a topic (see CreateTopic)

Parameters
topic_nameThe name associated with the topic
data_typeThe topic data type
is_managedWhether the SynDDSCommunicator is responsible for using the sending/receiving function calls

◆ CreatePublisher() [2/2]

std::shared_ptr< SynDDSPublisher > chrono::synchrono::SynDDSCommunicator::CreatePublisher ( std::shared_ptr< SynDDSTopic > topic,
bool is_managed = false,
eprosima::fastdds::dds::DataWriterQos * write_qos = nullptr )

Create a Publisher Returns a publisher handle to be used to publish information Takes a SynDDSTopic object (see CreateTopic)

Parameters
topicTopic object describing the DDS topic
is_managedWhether the SynDDSCommunicator is responsible for using the sending/receiving function calls
write_qosData Writer Quality of Service. Falls back to default if nullptr

◆ CreateSubscriber() [1/2]

std::shared_ptr< SynDDSSubscriber > chrono::synchrono::SynDDSCommunicator::CreateSubscriber ( const std::string & topic_name,
eprosima::fastdds::dds::TopicDataType * data_type,
std::function< void(void *)> callback,
void * message,
bool is_synchronous = true,
bool is_managed = false )

Create a subscription to the specified topic Will call the callback when a subscription is received Takes a string and TopicDataType and creates a topic (see CreateTopic)

Parameters
topic_nameThe name associated with the topic
data_typeThe topic data type
callbackThe callback called when data is received
messageThe message that is used to parse the returned message
is_synchronousWhether the subscriber synchronously receives data (default: true)
is_managedWhether the SynDDSCommunicator is responsible for using the sending/receiving function calls

◆ CreateSubscriber() [2/2]

std::shared_ptr< SynDDSSubscriber > chrono::synchrono::SynDDSCommunicator::CreateSubscriber ( std::shared_ptr< SynDDSTopic > topic,
std::function< void(void *)> callback,
void * message,
bool is_synchronous = true,
bool is_managed = false,
eprosima::fastdds::dds::DataReaderQos * read_qos = nullptr )

Create a subscription to the specified topic Will call the callback when a subscription is received Takes a SynDDSTopic object (see CreateTopic)

Parameters
topicTopic object describing the DDS topic
callbackThe callback called when data is received
messageThe message that is used to parse the returned message
is_synchronousWhether the subscriber synchronously receives data (default: true)
is_managedWhether the SynDDSCommunicator is responsible for using the sending/receiving function calls
read_qosData Reader Quality of Service. Falls back to default if nullptr

◆ CreateTopic() [1/2]

std::shared_ptr< SynDDSTopic > chrono::synchrono::SynDDSCommunicator::CreateTopic ( const std::string & topic_name,
eprosima::fastdds::dds::TopicDataType * data_type )

Create a topic using the communicator's prefix The topic will be registered with the participant, if desired.

Parameters
topic_nameThe name associated with the topic
data_typeThe topic data type

◆ CreateTopic() [2/2]

std::shared_ptr< SynDDSTopic > chrono::synchrono::SynDDSCommunicator::CreateTopic ( const std::string & topic_name,
eprosima::fastdds::dds::TopicDataType * data_type,
const std::string & topic_prefix )

Create a topic The topic will be registered with the participant, if desired.

The SynDDSCommunicator maintains a list of topics instantiated in the simulation. A topic can only by constructed through this function or indirectly through the CreateSubscriber/CreatePublisher functions

Parameters
topic_nameThe name associated with the topic
data_typeThe topic data type
topic_prefixThe prefix to use

◆ Initialize()

void chrono::synchrono::SynDDSCommunicator::Initialize ( )
overridevirtual

Initialization function typically responsible for establishing a connection.

Although not mandatory, this function should handle initial peer-to-peer communication. This could mean a simple handshake or an actual exchange of information used during the simulation.

Reimplemented from chrono::synchrono::SynCommunicator.

◆ Synchronize()

void chrono::synchrono::SynDDSCommunicator::Synchronize ( )
overridevirtual

This function is responsible for continuous synchronization steps This function, depending on it's implementation, could be blocking or non-blocking.

As in, depending on the derived class implementation, this function could use synchronous or asynchronous function calls to implement a communication interface.

Synchronize will serialize the underlying message buffer if it hasn't yet

Implements chrono::synchrono::SynCommunicator.


The documentation for this class was generated from the following files:
  • C:/M/B/src/chrono-9.0.1/src/chrono_synchrono/communication/dds/SynDDSCommunicator.h
  • C:/M/B/src/chrono-9.0.1/src/chrono_synchrono/communication/dds/SynDDSCommunicator.cpp