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

Revision history [back]

I doubt that the code above would compile. Your advertise call specifies type std_msgs::string, the correct type is std_msgs::String though. Please read the support guidelines before posting. Always copy-paste code and tag your questions.

You publish before rosbag or any other node could register. A quick fix would be either to use a latched topic or publish right after the while loop that checks for the number of publishers to be 0.

To use a latched topic, use the following advertise call:

ros::Publisher chatter_pub = n.advertise<std_msgs::String>("/end", 1000, true);