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 (const std::string &name)
 Default constructor. More...
 
 SynDDSCommunicator (eprosima::fastdds::dds::DomainParticipantQos &qos)
 Set the QoS directly from the constructor. More...
 
virtual ~SynDDSCommunicator ()
 Destructor. More...
 
virtual bool Initialize () override
 Initialization function typically responsible for establishing a connection. More...
 
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. More...
 
virtual void Barrier () override
 This function is responsible for blocking until an action is received or done. More...
 
void Barrier (unsigned int num_participants)
 This function is responsible for blocking until the passed number of participants has been matched. More...
 
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. More...
 
std::shared_ptr< SynDDSTopicCreateTopic (const std::string &topic_name, eprosima::fastdds::dds::TopicDataType *data_type, const std::string &topic_prefix="/syn/")
 Create a topic The topic will be registered with the participant, if desired. More...
 
std::shared_ptr< SynDDSSubscriberCreateSubscriber (std::shared_ptr< SynDDSTopic > topic, std::function< void(void *)> callback, void *message, bool is_synchronous=true)
 Create a subscription to the specified topic Will call the callback when a subscription is received Takes a SynDDSTopic object (see CreateTopic) More...
 
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)
 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) More...
 
std::shared_ptr< SynDDSPublisherCreatePublisher (std::shared_ptr< SynDDSTopic > topic)
 Create a Publisher Returns a publisher handle to be used to publish information Takes a SynDDSTopic object (see CreateTopic) More...
 
std::shared_ptr< SynDDSPublisherCreatePublisher (const std::string &topic_name, eprosima::fastdds::dds::TopicDataType *data_type)
 Create a Publisher Returns a publisher handle to be used to publish information Takes a string and TopicDataType and creates a topic (see CreateTopic) More...
 
- Public Member Functions inherited from chrono::synchrono::SynCommunicator
 SynCommunicator ()
 Default constructor. More...
 
virtual ~SynCommunicator ()
 Destructor. More...
 
void Reset ()
 Reset the communicator Will clear out message buffers. More...
 
void AddOutgoingMessages (SynMessageList &messages)
 Add the messages to the outgoing message buffer. More...
 
void AddIncomingMessages (SynMessageList &messages)
 Add the messages to the incoming message buffer. More...
 
void ProcessBuffer (std::vector< uint8_t > &data)
 Process a data buffer by passing it to the underlying FlatBuffersManager. More...
 
virtual SynMessageList & GetMessages ()
 Get the messages received by the communicator. More...
 

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)

Default constructor.

Parameters
nameThe name to set to the qos

◆ SynDDSCommunicator() [2/2]

chrono::synchrono::SynDDSCommunicator::SynDDSCommunicator ( eprosima::fastdds::dds::DomainParticipantQos &  qos)

Set the QoS directly from the constructor.

Parameters
qosthe Quality of Service to set for the participant

◆ ~SynDDSCommunicator()

chrono::synchrono::SynDDSCommunicator::~SynDDSCommunicator ( )
virtual

Destructor.

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 
)

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

◆ CreatePublisher() [2/2]

std::shared_ptr< SynDDSPublisher > chrono::synchrono::SynDDSCommunicator::CreatePublisher ( std::shared_ptr< SynDDSTopic topic)

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

◆ 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 
)

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)

◆ 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 
)

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)

◆ CreateTopic()

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

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

◆ GetMatchedParticipantNames()

std::vector< std::string > chrono::synchrono::SynDDSCommunicator::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.

◆ Initialize()

bool 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:
  • /builds/uwsbel/chrono/src/chrono_synchrono/communication/dds/SynDDSCommunicator.h
  • /builds/uwsbel/chrono/src/chrono_synchrono/communication/dds/SynDDSCommunicator.cpp