rospy version of spinOnce

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

rospy version of spinOnce

Adam Stambler
Hi,

I am having a bit of trouble figuring out when rospy calls the
callback functions for subscribers. In roscpp, I know that you need to
call either spin or spinOnce for Ros to handle all the callback
functions.  However, in rospy, there is spin but no spinOnce.

Is there an equivalent to spinOnce in rospy?

Thank you for the help,
Adam Stambler

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
ros-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ros-users
Reply | Threaded
Open this post in threaded view
|

Re: rospy version of spinOnce

Josh Faust
Hi Adam,

The rospy callbacks are always called from a non-main thread.  Ken can correct me if I'm wrong, but I believe each subscribed topic gets its own thread.  rospy's spin() is more of a no-op (just sleeping until rospy.is_shutdown() is true).  roscpp's callbacks used to follow the same model, and in the transition away spin()/spinOnce() should probably have been renamed to avoid confusion, but were not (my fault).

Josh

On Sun, Jan 31, 2010 at 2:31 PM, Adam Stambler <[hidden email]> wrote:
Hi,

I am having a bit of trouble figuring out when rospy calls the
callback functions for subscribers. In roscpp, I know that you need to
call either spin or spinOnce for Ros to handle all the callback
functions.  However, in rospy, there is spin but no spinOnce.

Is there an equivalent to spinOnce in rospy?

Thank you for the help,
Adam Stambler

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
ros-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ros-users


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
ros-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ros-users
Reply | Threaded
Open this post in threaded view
|

Re: rospy version of spinOnce

Adam Stambler
Thank you for the explanation.

I updated the rospy tutorial for subscribers and publishers so that it
explains this more clearly (at least to me).

I changed the final paragraph explaining rospy.spin() to:

The final addition, rospy.spin() simply keeps your node from exiting
until the node has been shutdown. Unlike roscpp, rospy.spin() does not
effect the subscriber callback functions, it simply puts the node to
sleep until it has been shut down. In rospy, each subscriber has its
own thread which handles its callback functions automatically.

Thank you again for the help,
Adam

On Sun, Jan 31, 2010 at 5:43 PM, Josh Faust <[hidden email]> wrote:

> Hi Adam,
>
> The rospy callbacks are always called from a non-main thread.  Ken can
> correct me if I'm wrong, but I believe each subscribed topic gets its own
> thread.  rospy's spin() is more of a no-op (just sleeping until
> rospy.is_shutdown() is true).  roscpp's callbacks used to follow the same
> model, and in the transition away spin()/spinOnce() should probably have
> been renamed to avoid confusion, but were not (my fault).
>
> Josh
>
> On Sun, Jan 31, 2010 at 2:31 PM, Adam Stambler <[hidden email]> wrote:
>>
>> Hi,
>>
>> I am having a bit of trouble figuring out when rospy calls the
>> callback functions for subscribers. In roscpp, I know that you need to
>> call either spin or spinOnce for Ros to handle all the callback
>> functions.  However, in rospy, there is spin but no spinOnce.
>>
>> Is there an equivalent to spinOnce in rospy?
>>
>> Thank you for the help,
>> Adam Stambler
>>
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term contracts
>> Personal 24x7 support from experience hosting pros just a phone call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> ros-users mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/ros-users
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> ros-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/ros-users
>
>

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
ros-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/ros-users