roscpp publish int32
#includestd_msgs::Int8 msg; msg.data = 17; ROS_INFO("%d", msg.data); chatter_pub.publish(msg);
Here is what the above code is Doing:
1. We’re creating a message of type std_msgs/Int8.
2. We’re setting the data field of the message to 17.
3. We’re printing the data field of the message to the screen.
4. We’re publishing the message to the chatter topic.