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

Revision history [back]

You should definitely NOT use time.sleep() .

The ROS way of doing this is:

rate = rospy.Rate(5)
# Do stuff 
rate.sleep()

You should definitely NOT use time.sleep() .

The ROS way of doing this is:

rate = rospy.Rate(5)
rospy.Rate(1) # 1 Hz
# Do stuff 
rate.sleep()

Or the similar:

rospy.sleep(1) # 1 sec

You should definitely NOT use time.sleep() .

The ROS way of doing this is:

rate = rospy.Rate(1) # 1 Hz
# Do stuff 
rate.sleep()
rate.sleep() # Sleeps for  1/rate sec

Or the similar:

rospy.sleep(1) # Sleeps for 1 sec

You should definitely NOT use time.sleep()

The ROS way of doing this is:

rate = rospy.Rate(1) # 1 Hz
# Do stuff 
stuff, maybe in a while loop
rate.sleep() # Sleeps for  1/rate sec

Or the similar:

rospy.sleep(1) # Sleeps for 1 sec

You should definitely NOT use time.sleep()

The ROS way of doing this is:

rate = rospy.Rate(1) # 1 Hz
# Do stuff, maybe in a while loop
rate.sleep() # Sleeps for 1/rate sec

Or the similar:

rospy.sleep(1) # Sleeps for 1 sec

API documentation: http://docs.ros.org/jade/api/rospy/html/rospy.rostime-module.html

You should definitely NOT use time.sleep()

The ROS way of doing this is:

rate = rospy.Rate(1) # 1 Hz
# Do stuff, maybe in a while loop
rate.sleep() # Sleeps for 1/rate sec

Or the similar:

rospy.sleep(1) # Sleeps for 1 sec

In both cases, you'll ofc need to import rospy

Here's the API documentation: http://docs.ros.org/jade/api/rospy/html/rospy.rostime-module.html