Gazebo Transport

API Reference

14.0.0

Private data for the Node class. This class should not be directly used. You should use the Node class. More...

#include <gz/transport/NodeShared.hh>

Classes

struct  HandlerInfo
 HandlerInfo contains information about callback handlers which is useful for local publishers and message receivers. You should only retrieve a HandlerInfo by calling CheckHandlerInfo(const std::string &_topic) const. More...
 
struct  HandlerWrapper
 This struct wraps up the two different types of subscription handlers: normal (deserialized) and raw (serialized). This wrapper keeps the two sets of subscription handlers coordinated while allowing them to act independently when necessary. More...
 
struct  SubscriberInfo
 This struct provides information about the Subscribers of a Publisher. It should only be retrieved using CheckSubscriberInfo(const std::string&, const std::string&) const. The relevant subscriber info is a superset of the relevant HandlerInfo so we extend that struct. More...
 

Public Member Functions

void AddGlobalRelay (const std::string &_relayAddress)
 Adds a unicast relay IP. All nodes in this process will send UDP unicast traffic to the address to connect networks when UDP multicast traffic is not forwarded. It's also possible to use the environment variable GZ_RELAY to add relays.
 
bool AdvertisePublisher (const ServicePublisher &_publisher)
 Pass through to bool Advertise(const Pub &_publisher)
 
HandlerInfo CheckHandlerInfo (const std::string &_topic) const
 Get information about the local and raw subscribers that are attached to this NodeShared.
 
SubscriberInfo CheckSubscriberInfo (const std::string &_topic, const std::string &_msgType) const
 Get information about the nodes that are subscribed to the publishers of this NodeShared.
 
bool DiscoverService (const std::string &_topic) const
 Pass through to bool Discovery::Discover(const std::string &_topic) const.
 
void EnableStats (const std::string &_topic, bool _enable, std::function< void(const TopicStatistics &_stats)> _cb)
 Turn topic statistics on or off.
 
std::vector< std::stringGlobalRelays () const
 Gets the relay addresses configured for all nodes in this process.
 
void OnEndRegistration (const MessagePublisher &_pub)
 Callback executed when a remote subscriber unregisters.
 
void OnNewConnection (const MessagePublisher &_pub)
 Callback executed when the discovery detects new topics.
 
void OnNewDisconnection (const MessagePublisher &_pub)
 Callback executed when the discovery detects disconnections.
 
void OnNewRegistration (const MessagePublisher &_pub)
 Callback executed when a remote subscriber connects.
 
void OnNewSrvConnection (const ServicePublisher &_pub)
 Callback executed when the discovery detects a new service call.
 
void OnNewSrvDisconnection (const ServicePublisher &_pub)
 Callback executed when a service call is no longer available.
 
void OnSubscribers ()
 Callback executed when a SUBSCRIBERS request is received.
 
bool Publish (const std::string &_topic, char *_data, const size_t _dataSize, DeallocFunc *_ffn, const std::string &_msgType)
 Publish data.
 
int RcvHwm ()
 Get the capacity of the buffer (High Water Mark) that stores incoming Gazebo Transport messages. Note that this is a global queue shared by all subscribers within the same process.
 
void RecvMsgUpdate ()
 Method in charge of receiving the topic updates.
 
void RecvSrvRequest ()
 Method in charge of receiving the service call requests.
 
void RecvSrvResponse ()
 Method in charge of receiving the service call responses.
 
void RunReceptionTask ()
 Receive data and control messages.
 
void SendPendingRemoteReqs (const std::string &_topic, const std::string &_reqType, const std::string &_repType)
 Try to send all the requests for a given service call and a pair of request/response types.
 
int SndHwm ()
 Get the capacity of the buffer (High Water Mark) that stores outgoing Gazebo Transport messages. Note that this is a global queue shared by all publishers within the same process.
 
bool TopicPublishers (const std::string &_topic, SrvAddresses_M &_publishers) const
 Pass through to bool Publishers(const std::string &_topic, Addresses_M<Pub> &_publishers) const.
 
std::optional< TopicStatisticsTopicStats (const std::string &_topic) const
 Get the current statistics for a topic. Statistics must have been enabled using the EnableStatistics function, otherwise the return value will be std::nullopt.
 
void TriggerCallbacks (const MessageInfo &_info, const std::string &_msgData, const HandlerInfo &_handlerInfo)
 Call the SubscriptionHandler callbacks (local and raw) for this NodeShared.
 

Static Public Member Functions

static NodeSharedInstance ()
 NodeShared is a singleton. This method gets the NodeShared instance shared between all the nodes.
 

Public Attributes

std::string discoveryIP = "239.255.0.7"
 Default IP address used by the message discovery layer.
 
std::string hostAddr
 IP address of this host.
 
HandlerWrapper localSubscribers
 
int msgDiscPort = kDefaultMsgDiscPort
 Port used by the message discovery layer.
 
std::recursive_mutex mutex
 Mutex to guarantee exclusive access between all threads.
 
std::string myAddress
 My pub/sub address.
 
std::string myControlAddress
 My pub/sub control address.
 
std::string myReplierAddress
 My replier service call address.
 
std::string myRequesterAddress
 My requester service call address.
 
std::string pUuid
 Process UUID.
 
TopicStorage< MessagePublisherremoteSubscribers
 Remote subscribers.
 
Uuid replierId
 Replier socket identity.
 
HandlerStorage< IRepHandlerrepliers
 Service call repliers.
 
HandlerStorage< IReqHandlerrequests
 Pending service call requests.
 
Uuid responseReceiverId
 Response receiver socket identity.
 
int srvDiscPort = kDefaultSrvDiscPort
 Port used by the service discovery layer.
 
std::thread threadReception
 thread in charge of receiving and handling incoming messages.
 
int verbose
 Print activity to stdout.
 

Static Public Attributes

static const int kDefaultMsgDiscPort = 10317
 Default port used by the message discovery layer.
 
static const int kDefaultSrvDiscPort = 10318
 Default port used by the service discovery layer.
 

Protected Member Functions

 NodeShared ()
 Constructor.
 
virtual ~NodeShared ()
 Destructor.
 

Detailed Description

Private data for the Node class. This class should not be directly used. You should use the Node class.

Constructor & Destructor Documentation

◆ NodeShared()

NodeShared ( )
protected

Constructor.

◆ ~NodeShared()

virtual ~NodeShared ( )
protectedvirtual

Destructor.

Member Function Documentation

◆ AddGlobalRelay()

void AddGlobalRelay ( const std::string _relayAddress)

Adds a unicast relay IP. All nodes in this process will send UDP unicast traffic to the address to connect networks when UDP multicast traffic is not forwarded. It's also possible to use the environment variable GZ_RELAY to add relays.

Parameters
[in]_relayAddressIPv4 address of the relay to add.

◆ AdvertisePublisher()

bool AdvertisePublisher ( const ServicePublisher _publisher)

Pass through to bool Advertise(const Pub &_publisher)

Parameters
[in]_publisherPublisher's information to advertise.
Returns
True if the method succeed or false otherwise (e.g. if the discovery has not been started).
See also
Pass through to bool Advertise(const Pub &_publisher)

◆ CheckHandlerInfo()

HandlerInfo CheckHandlerInfo ( const std::string _topic) const

Get information about the local and raw subscribers that are attached to this NodeShared.

Parameters
[in]_topicInformation will only be returned for handlers that are subscribed to the given topic name.
Returns
Information about local subscription handlers that are held by this NodeShared.

◆ CheckSubscriberInfo()

SubscriberInfo CheckSubscriberInfo ( const std::string _topic,
const std::string _msgType 
) const

Get information about the nodes that are subscribed to the publishers of this NodeShared.

Parameters
[in]_topicOnly information about subscribers to this topic will be returned.
[in]_msgTypeIf there are no remote subscribers listening for this message type, then SubscriberInfo::haveRemote will be false in the return value of this function.
Returns
Information about subscribers.

◆ DiscoverService()

bool DiscoverService ( const std::string _topic) const

Pass through to bool Discovery::Discover(const std::string &_topic) const.

Parameters
[in]_topicService name.
Returns
True if the method succeeded or false otherwise (e.g. if the discovery has not been started).
See also
bool Discovery::Discover(const std::string &_topic) const

◆ EnableStats()

void EnableStats ( const std::string _topic,
bool  _enable,
std::function< void(const TopicStatistics &_stats)>  _cb 
)

Turn topic statistics on or off.

Parameters
[in]_topicThe name of the topic on which to enable or disable statistics.
[in]_enableTrue to enable statistics, false to disable.
[in]_cbCallback that is triggered whenever statistics are updated.

◆ GlobalRelays()

std::vector< std::string > GlobalRelays ( ) const

Gets the relay addresses configured for all nodes in this process.

Returns
The relay addresses.

◆ Instance()

static NodeShared * Instance ( )
static

NodeShared is a singleton. This method gets the NodeShared instance shared between all the nodes.

Returns
Pointer to the current NodeShared instance.

◆ OnEndRegistration()

void OnEndRegistration ( const MessagePublisher _pub)

Callback executed when a remote subscriber unregisters.

Parameters
[in]_pubInformation of the remote subscriber.

◆ OnNewConnection()

void OnNewConnection ( const MessagePublisher _pub)

Callback executed when the discovery detects new topics.

Parameters
[in]_pubInformation of the publisher in charge of the topic.

◆ OnNewDisconnection()

void OnNewDisconnection ( const MessagePublisher _pub)

Callback executed when the discovery detects disconnections.

Parameters
[in]_pubInformation of the publisher in charge of the topic.

◆ OnNewRegistration()

void OnNewRegistration ( const MessagePublisher _pub)

Callback executed when a remote subscriber connects.

Parameters
[in]_pubInformation of the remote subscriber.

◆ OnNewSrvConnection()

void OnNewSrvConnection ( const ServicePublisher _pub)

Callback executed when the discovery detects a new service call.

Parameters
[in]_pubInformation of the publisher in charge of the service.

◆ OnNewSrvDisconnection()

void OnNewSrvDisconnection ( const ServicePublisher _pub)

Callback executed when a service call is no longer available.

Parameters
[in]_pubInformation of the publisher in charge of the service.

◆ OnSubscribers()

void OnSubscribers ( )

Callback executed when a SUBSCRIBERS request is received.

◆ Publish()

bool Publish ( const std::string _topic,
char *  _data,
const size_t  _dataSize,
DeallocFunc _ffn,
const std::string _msgType 
)

Publish data.

Parameters
[in]_topicTopic to be published.
[in,out]_dataSerialized data. Note that this buffer will be automatically deallocated by ZMQ when all data has been published.
[in]_dataSizeData size (bytes).
[in,out]_ffnDeallocation function. This function is executed by ZeroMQ when the data is published. This function deallocates the buffer containing the published data.
See also
http://zeromq.org/blog:zero-copy
Parameters
[in]_msgTypeMessage type in string format.
Returns
true when success or false otherwise.

◆ RcvHwm()

int RcvHwm ( )

Get the capacity of the buffer (High Water Mark) that stores incoming Gazebo Transport messages. Note that this is a global queue shared by all subscribers within the same process.

Returns
The capacity of the buffer storing incoming messages (units are messages). A value of 0 indicates an unlimited buffer and -1 that the socket cannot be queried. The default buffer size is contained in the kDefaultRcvHwm variable. If the buffer is set to unlimited, then your buffer will grow until you run out of memory (and probably crash). If your buffer reaches the maximum capacity data will be dropped.

◆ RecvMsgUpdate()

void RecvMsgUpdate ( )

Method in charge of receiving the topic updates.

◆ RecvSrvRequest()

void RecvSrvRequest ( )

Method in charge of receiving the service call requests.

◆ RecvSrvResponse()

void RecvSrvResponse ( )

Method in charge of receiving the service call responses.

◆ RunReceptionTask()

void RunReceptionTask ( )

Receive data and control messages.

◆ SendPendingRemoteReqs()

void SendPendingRemoteReqs ( const std::string _topic,
const std::string _reqType,
const std::string _repType 
)

Try to send all the requests for a given service call and a pair of request/response types.

Parameters
[in]_topicTopic name.
[in]_reqTypeType of the request in string format.
[in]_repTypeType of the response in string format.

◆ SndHwm()

int SndHwm ( )

Get the capacity of the buffer (High Water Mark) that stores outgoing Gazebo Transport messages. Note that this is a global queue shared by all publishers within the same process.

Returns
The capacity of the buffer storing outgoing messages (units are messages). A value of 0 indicates an unlimited buffer and -1 that the socket cannot be queried. The default buffer size is contained in the kDefaultSndHwm variable. If the buffer is set to unlimited, then your buffer will grow until you run out of memory (and probably crash). If your buffer reaches the maximum capacity data will be dropped.

◆ TopicPublishers()

bool TopicPublishers ( const std::string _topic,
SrvAddresses_M _publishers 
) const

Pass through to bool Publishers(const std::string &_topic, Addresses_M<Pub> &_publishers) const.

Parameters
[in]_topicService name.
[out]_publishersCollection of service publishers.
Returns
True if the service is found and
See also
bool Publishers(const std::string &_topic, Addresses_M<Pub> &_publishers) const

◆ TopicStats()

std::optional< TopicStatistics > TopicStats ( const std::string _topic) const

Get the current statistics for a topic. Statistics must have been enabled using the EnableStatistics function, otherwise the return value will be std::nullopt.

Parameters
[in]_topicThe name of the topic to get statistics for.
Returns
A TopicStatistics class, or std::nullopt if statistics were not enabled.

◆ TriggerCallbacks()

void TriggerCallbacks ( const MessageInfo _info,
const std::string _msgData,
const HandlerInfo _handlerInfo 
)

Call the SubscriptionHandler callbacks (local and raw) for this NodeShared.

Parameters
[in]_infoMessage information.
[in]_msgDataThe raw serialized data for the message
[in]_handlerInfoInformation for the handlers of this node, as generated by CheckHandlerInfo(const std::string&) const

Member Data Documentation

◆ discoveryIP

std::string discoveryIP = "239.255.0.7"

Default IP address used by the message discovery layer.

◆ hostAddr

std::string hostAddr

IP address of this host.

◆ kDefaultMsgDiscPort

const int kDefaultMsgDiscPort = 10317
static

Default port used by the message discovery layer.

◆ kDefaultSrvDiscPort

const int kDefaultSrvDiscPort = 10318
static

Default port used by the service discovery layer.

◆ localSubscribers

HandlerWrapper localSubscribers

◆ msgDiscPort

int msgDiscPort = kDefaultMsgDiscPort

Port used by the message discovery layer.

◆ mutex

std::recursive_mutex mutex
mutable

Mutex to guarantee exclusive access between all threads.

◆ myAddress

std::string myAddress

My pub/sub address.

◆ myControlAddress

std::string myControlAddress

My pub/sub control address.

◆ myReplierAddress

std::string myReplierAddress

My replier service call address.

◆ myRequesterAddress

std::string myRequesterAddress

My requester service call address.

◆ pUuid

std::string pUuid

Process UUID.

◆ remoteSubscribers

TopicStorage<MessagePublisher> remoteSubscribers

Remote subscribers.

◆ replierId

Uuid replierId

Replier socket identity.

◆ repliers

Service call repliers.

◆ requests

Pending service call requests.

◆ responseReceiverId

Uuid responseReceiverId

Response receiver socket identity.

◆ srvDiscPort

int srvDiscPort = kDefaultSrvDiscPort

Port used by the service discovery layer.

◆ threadReception

std::thread threadReception

thread in charge of receiving and handling incoming messages.

◆ verbose

int verbose

Print activity to stdout.


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