ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
Well, i think your for loop does not make what you want it to do. With:
str_msg.data = localdata[i];
You will copy one byte (with the given index) into the hole string, which couses the given error, which will be published. Maybe you convert the hole byte-array into an string.
Or you can append one byte after the other to your std_msg.data - string
std_msg.data.append(localdata[i]); // someting like that
and publish the hole string (with your string termination) at once.