Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

calibrate.py waiting forever in certain cases (ros ticket #5211) #222

Open
ahendrix opened this issue Mar 12, 2013 · 0 comments
Open

calibrate.py waiting forever in certain cases (ros ticket #5211) #222

ahendrix opened this issue Mar 12, 2013 · 0 comments

Comments

@ahendrix
Copy link
Member

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant