mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
|
A helper class for easy publishing of ROS messages for debugging purposes. More...
#include <dynamic_publisher.h>
Public Member Functions | |
DynamicPublisher () | |
A no-parameter constructor. More... | |
DynamicPublisher (const ros::NodeHandle &nh) | |
The main constructor. More... | |
template<class T > | |
void | publish (const std::string name, const T &msg) |
Publishes a message to a topic, advertising the topic if necessary. More... | |
A helper class for easy publishing of ROS messages for debugging purposes.
This class enables you to just call the publish() method with a topic name and a message without the need to advertise the topic.
mrs_lib::DynamicPublisher::DynamicPublisher | ( | ) |
A no-parameter constructor.
This overload will use a ros::NodeHandle with default arguments for advertising new topics, so remappings, namespaces etc. will be ignored.
mrs_lib::DynamicPublisher::DynamicPublisher | ( | const ros::NodeHandle & | nh | ) |
The main constructor.
This overload uses the ros::NodeHandle that you provided for advertising new topics. The recommended way of constructing a DynamicPublisher.
void mrs_lib::DynamicPublisher::publish | ( | const std::string | name, |
const T & | msg | ||
) |
Publishes a message to a topic, advertising the topic if necessary.
The topic is advertised with the type of the first message published to it. If you try to publish a different type of message on the topic, it will be ignored.