ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Let me be even more specific. See this link 'Writing a simple Publisher and Subscriber in C++': http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

Now this is part of the code written for the tutorial on how to write a Publisher.

while (ros::ok()) { /** * This is a message object. You stuff it with data, and then publish it. */ std_msgs::String msg;

std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();

ROS_INFO("%s", msg.data.c_str());

Notice how a string object 'ss' is created, and "Hello World" is assigned to 'ss'. Now what I want is, instead of assigning 'Hello World' to this string object, I want to assign information that is being published by the topic /XXX/DATA

I hope my question is clear.

Let me be even more specific. See this link 'Writing a simple Publisher and Subscriber in C++': http://www.ros.org/wiki/ROS/Tutorials/WritingPublisherSubscriber%28c%2B%2B%29

Now this is part of the code written for the tutorial on how to write a Publisher.

while (ros::ok()) (ros::ok())

{ /** * This is a message object. You stuff it with data, and then publish it. */ std_msgs::String msg;

std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();

ROS_INFO("%s", msg.data.c_str());

Notice how a string object 'ss' is created, and "Hello World" is assigned to 'ss'. Now what I want is, instead of assigning 'Hello World' to this string object, I want to assign information that is being published by the topic /XXX/DATA

I hope my question is clear.