-
Notifications
You must be signed in to change notification settings - Fork 54
Description
pr2_bringup/calibrate.py has a pyhton for loop on a list, but the elements of the list can be removed during the loop.
def calibrate(controllers):
...
# Sets up callbacks for calibration completion
waiting_for = launched[:]
def calibrated(msg, name): # Somewhat not thread-safe
if name in waiting_for:
waiting_for.remove(name)
for name in waiting_for:
rospy.Subscriber("%s/calibrated" % name, Empty, calibrated, name)
# Waits until all the controllers have calibrated
while waiting_for and not rospy.is_shutdown():
print "Waiting for: %s" % ', '.join(waiting_for)
sleep(0.5)
So if the first controllers in the queue publish something quickly enough, the callback function could be called before the for loop has finished, what results in the last cycle/s not being executed, and thus, the last subscribers not being called. This leads to the subsequent while loop running forever.
I've been using this with custom calibration controllers (not with a pr2 robot but with a Shadow Robot hand). If the calibration controllers take more time to publish on the xxx/calibrated topic, then this problem doesn't happen (in our case it takes a very short time, thus the problem).
trac data:
- Owner: wim
- Reporter: toni-shadow
- Reported at: Tue Nov 6 07:44:52 2012
- URL: https://code.ros.org/trac/wg-ros-pkg/ticket/5211