ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
2

Does ros::Duration::sleep spin?

asked 2015-02-25 02:44:08 -0500

HassanNadeem gravatar image

If I do ros::Duration::sleep does ros spin and are callback functions called?

If not is there a way to pause the program while still managing callbacks?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2015-02-25 03:56:39 -0500

Adolfo Rodriguez T gravatar image

If I do ros::Duration::sleep does ros spin and are callback functions called?

No. Sleep just sleeps the thread for the specified duration.

If not is there a way to pause the program while still managing callbacks?

You can have a loop that alternates sleeping and spinning, as exemplified in this roscpp tutorial, or you can have separate spinner threads. I recommend reading the ROS wiki page on callbacks and spinning.

edit flag offensive delete link more

Comments

If your question is answered, could you post, for the record, which approached you ended up using?.

Adolfo Rodriguez T gravatar image Adolfo Rodriguez T  ( 2015-03-02 07:38:56 -0500 )edit

So if I have an image callback and a service callback and do sleep in the service callback, will the image callback be blocked too?

Mehdi. gravatar image Mehdi.  ( 2019-03-14 10:04:48 -0500 )edit

@mehdi: With the standard single-threaded ros::spin: yes

knxa gravatar image knxa  ( 2019-10-07 06:26:49 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2015-02-25 02:44:08 -0500

Seen: 4,980 times

Last updated: Feb 25 '15