Does the ros publisher publish in bytes?
Hi all, Following is a simple publishing example I copied from the ROS tutorials. Is msg transmitted over TCP as bytes? or as string? For efficient transfer, I would like to know if I need to convert 'count' into bytes before publishing.
std_msgs::String msg;
double count = 12.76578589776736376983983231112;
std::stringstream ss;
ss << "hello world " << count;
msg.data = ss.str();
ROS_INFO("%s", msg.data.c_str());
/**
* The publish() function is how you send messages. The parameter
* is the message object. The type of this object must agree with the type
* given as a template parameter to the advertise<>() call, as was done
* in the constructor above.
*/
chatter_pub.publish(msg);
Not quite sure what you mean by converting "hello world" into bytes before publishing. You can only publish the msg in the correct format (http://www.ros.org/doc/api/std_msgs/html/msg/String.html), which in this case is a string
I am sorry. I meant how many bytes is 'count' converted to? Or in short, how many bytes are published in total?
strlen(msg.data.c_str()) + 1 + some amount of network headers