Re: [ros-users] rospy.sleep() blocking callbacks

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Cedric Pradalier
Date:  
To: ros-users
Subject: Re: [ros-users] rospy.sleep() blocking callbacks
On 07/07/2010 12:05 AM, Dan Lazewatsky wrote:
> I'm writing on a GUI in Python/Tk - I have a subscriber which is
> listening for image messages and setting a class member variable with
> the newest image, and a GUI element that needs to use image (after
> sending a message to move a pan/tilt). On click I use rospy.sleep() to
> wait for the pan/tilt to settle down before using any images. However,
> I've noticed that once I call rospy.sleep() inside the click callback,
> the callback for the image subscriber stops getting called. It was my
> understanding that subscriber callbacks are run asynchronously in
> their own thread, so a sleep in a different thread should have no
> effect. What's going on here? What am I missing?
>
> Thanks,
> -Dan
> _______________________________________________
> ros-users mailing list
>
> https://code.ros.org/mailman/listinfo/ros-users
>

Hi Dan,

Python is sometimes counter-intuitive with his management of threads,
leading sometimes to some global lock where one thread blocks everything.
I'd suggest keeping your in-callback time to a minimum, maybe just
triggering another thread which will do the waiting (or switch to C++,
with real threads).

HTH

--
Cedric - Specialising in cat herding
- http://www.asl.ethz.ch/people/cedricp
- http://www.skybotix.com