Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 55

Why isn't rospy.Rate.sleep() terminating?

$
0
0
Hi, I have written a python script which takes two tf frames and writes the transform between them to a file. The abbreviated code of the script looks like this: listener = tf.TransformListener() # waiting for first transform between origin and pose listener.waitForTransform(origin, pose, rospy.Time(), rospy.Duration(5.0)) rate = rospy.Rate(10) while not rospy.is_shutdown(): try: now = rospy.Time.now() listener.waitForTransform(origin, pose, now, rospy.Duration(1.0)) (trans, rot) = listener.lookupTransform(origin, pose, now) ... write trans and rot to the file ... # this exception is usually thrown when waitForTransform timed out except tf.Exception as e: break # get out of the loop rate.sleep() ... some last commands before the script terminates ... Usually this script should terminate when no more tf frames are published because I leave the loop when `waitForTransform(...)` throws an exception. When I run this code and start playing a bagfile (`use_sim_time true` and `--clock`) the script does not terminate because it gets stuck at `rate.sleep()` when `rosbag play` is finished. Any ideas why it behaves this way?

Viewing all articles
Browse latest Browse all 55

Trending Articles