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

Revision history [back]

click to hide/show revision 1
initial version

When you use rospy.spin(), you're telling the program to sit there and wait (i.e. don't exit) until ros is shutdown. It's mainly used when for when your program just launches some subscribers then there's nothing to do except let the callbacks run when new messages come in.

Since you have a while loop there, the program would not be exiting, so you do not need rospy.spin() in this case. I don't think there is ever a case where you would have an endless while loop and need to use a rospy.spin().