A node can advertise and subscribe topics, publish on advertised topics and listen to subscribed topics. More...
#include <transport/transport.hh>
Public Member Functions | |
Node () | |
Constructor. | |
virtual | ~Node () |
Destructor. | |
template<typename M > | |
transport::PublisherPtr | Advertise (const std::string &_topic, unsigned int _queueLimit=1000, double _hzRate=0) |
Adverise a topic. | |
std::string | DecodeTopicName (const std::string &_topic) |
Decode a topic name. | |
std::string | EncodeTopicName (const std::string &_topic) |
Encode a topic name. | |
void | Fini () |
Finalize the node. | |
unsigned int | GetId () const |
Get the unique ID of the node. | |
std::string | GetMsgType (const std::string &_topic) const |
Get the message type for a topic. | |
std::string | GetTopicNamespace () const |
Get the topic namespace for this node. | |
bool | HandleData (const std::string &_topic, const std::string &_msg) |
Handle incoming data. | |
bool | HasLatchedSubscriber (const std::string &_topic) const |
Return true if a subscriber on a specific topic is latched. | |
void | Init (const std::string &_space="") |
Init the node. | |
void | InsertLatchedMsg (const std::string &_topic, const std::string &_msg) |
Add a latched message to the node for publication. | |
void | ProcessIncoming () |
Process incoming messages. | |
void | ProcessPublishers () |
Process all publishers, which has each publisher send it's most recent message over the wire. | |
void | RemoveCallback (const std::string &_topic, unsigned int _id) |
template<typename M , typename T > | |
SubscriberPtr | Subscribe (const std::string &_topic, void(T::*_fp)(const M const *&), T *_obj, bool _latching=false) |
Subscribe to a topic using a class method as the callback. | |
template<typename M > | |
SubscriberPtr | Subscribe (const std::string &_topic, void(*_fp)(const M const *&), bool _latching=false) |
Subscribe to a topic using a bare function as the callback. | |
template<typename T > | |
SubscriberPtr | Subscribe (const std::string &_topic, void(T::*_fp)(const std::string &), T *_obj, bool _latching=false) |
Subscribe to a topic using a class method as the callback. | |
SubscriberPtr | Subscribe (const std::string &_topic, void(*_fp)(const std::string &), bool _latching=false) |
Subscribe to a topic using a bare function as the callback. | |
A node can advertise and subscribe topics, publish on advertised topics and listen to subscribed topics.
gazebo::transport::Node::Node | ( | ) |
Constructor.
|
virtual |
Destructor.
|
inline |
Adverise a topic.
[in] | _topic | The topic to advertise |
[in] | _queueLimit | The maximum number of outgoing messages to queue for delivery |
[in] | _hz | Update rate for the publisher. Units are 1.0/seconds. |
References DecodeTopicName(), and SingletonT< T >::Instance().
std::string gazebo::transport::Node::DecodeTopicName | ( | const std::string & | _topic | ) |
Decode a topic name.
[in] | The | encoded name |
Referenced by Advertise(), and Subscribe().
std::string gazebo::transport::Node::EncodeTopicName | ( | const std::string & | _topic | ) |
Encode a topic name.
[in] | The | decoded name |
void gazebo::transport::Node::Fini | ( | ) |
Finalize the node.
unsigned int gazebo::transport::Node::GetId | ( | ) | const |
std::string gazebo::transport::Node::GetMsgType | ( | const std::string & | _topic | ) | const |
Get the message type for a topic.
[in] | _topic | The topic |
std::string gazebo::transport::Node::GetTopicNamespace | ( | ) | const |
Get the topic namespace for this node.
bool gazebo::transport::Node::HandleData | ( | const std::string & | _topic, |
const std::string & | _msg | ||
) |
Handle incoming data.
[in] | _topic | Topic for which the data was received |
[in] | _msg | The message that was received |
bool gazebo::transport::Node::HasLatchedSubscriber | ( | const std::string & | _topic | ) | const |
Return true if a subscriber on a specific topic is latched.
[in] | _topic | Name of the topic to check. |
void gazebo::transport::Node::Init | ( | const std::string & | _space = "" | ) |
Init the node.
[in] | _space | Set the global namespace of all topics. If left blank, the topic will initialize to the first namespace on the Master |
void gazebo::transport::Node::InsertLatchedMsg | ( | const std::string & | _topic, |
const std::string & | _msg | ||
) |
Add a latched message to the node for publication.
This is called when a subscription is connected to a publication.
[in] | _topic | Name of the topic to publish data on. |
[in] | _msg | The message to publish. |
void gazebo::transport::Node::ProcessIncoming | ( | ) |
Process incoming messages.
void gazebo::transport::Node::ProcessPublishers | ( | ) |
Process all publishers, which has each publisher send it's most recent message over the wire.
This is for internal use only
void gazebo::transport::Node::RemoveCallback | ( | const std::string & | _topic, |
unsigned int | _id | ||
) |
|
inline |
Subscribe to a topic using a class method as the callback.
[in] | _topic | The topic to subscribe to |
[in] | _fp | Class method to be called on receipt of new message |
[in] | _obj | Class instance to be used on receipt of new message |
[in] | _latching | If true, latch latest incoming message; otherwise don't latch |
References DecodeTopicName(), GetId(), SingletonT< T >::Instance(), and gazebo::transport::Subscriber::SetCallbackId().
|
inline |
Subscribe to a topic using a bare function as the callback.
[in] | _topic | The topic to subscribe to |
[in] | _fp | Function to be called on receipt of new message |
[in] | _latching | If true, latch latest incoming message; otherwise don't latch |
References DecodeTopicName(), GetId(), SingletonT< T >::Instance(), and gazebo::transport::Subscriber::SetCallbackId().
|
inline |
Subscribe to a topic using a class method as the callback.
[in] | _topic | The topic to subscribe to |
[in] | _fp | Class method to be called on receipt of new message |
[in] | _obj | Class instance to be used on receipt of new message |
[in] | _latching | If true, latch latest incoming message; otherwise don't latch |
References DecodeTopicName(), GetId(), gazebo::transport::SubscribeOptions::Init(), SingletonT< T >::Instance(), and gazebo::transport::Subscriber::SetCallbackId().
|
inline |
Subscribe to a topic using a bare function as the callback.
[in] | _topic | The topic to subscribe to |
[in] | _fp | Function to be called on receipt of new message |
[in] | _latching | If true, latch latest incoming message; otherwise don't latch |
References DecodeTopicName(), GetId(), gazebo::transport::SubscribeOptions::Init(), SingletonT< T >::Instance(), and gazebo::transport::Subscriber::SetCallbackId().