This example may be run after building mrs_lib by executing rosrun mrs_lib subscribe_handler_simple_example
.
#include <std_msgs/String.h>
int main(int argc, char **argv)
{
const std::string node_name = "subscribe_handler_simple_example";
ros::init(argc, argv, node_name);
ros::NodeHandle nh;
const std::string topic_name = "test_topic";
shopts,
topic_name
);
ros::Duration d(0.1);
while (ros::ok())
{
ROS_INFO_STREAM_THROTTLE(1.0, "[" << node_name << "]: Spinning");
ros::spinOnce();
ROS_INFO_STREAM(
"[" << node_name <<
"]: Got a new message: " << handler.
getMsg()->data);
d.sleep();
}
}