Publish only when Subscriber Exists
http://wiki.ros.org/rviz/Tutorials/Markers%3A%20Basic%20Shapes
code:c++
while (marker_pub.getNumSubscribers() < 1)
{
if (!ros::ok())
{
return 0;
}
ROS_WARN_ONCE("Please create a subscriber to the marker");
sleep(1);
}
marker_pub.publish(marker);
#Tips