Ask Your Question
2

Does ros::Duration::sleep spin?

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

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
3

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

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 imageAdolfo Rodriguez T ( 2015-03-02 07:38:56 -0600 )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 imageMehdi. ( 2019-03-14 10:04:48 -0600 )edit

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

knxa gravatar imageknxa ( 2019-10-07 06:26:49 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 2,917 times

Last updated: Feb 25 '15