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

Is there a way to call spinOnce for a specific subscriber?

asked 2017-03-31 19:17:09 -0500

cpagravel gravatar image

Inside my node I have several callbacks. I want to avoid using spinOnce() inside my node as much as possible since the current job should always finish what it is doing before the next callback begins. However, there is one instance which I need to wait on a particular message before continuing. The current solution is to run spinOnce() in a loop, but this is not the way it should be done.

Is there a nice way of doing this? I've read a little about creating my own queuing system, but I would like to find a way that requires the fewest amount of changes.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-03-31 20:56:29 -0500

ahendrix gravatar image

Section 4 in the roscpp callbacks and spinning describes how to assign different subscribers to different callback queues, and then you can spin the one callback queue for your subscriber without invoking callbacks for your other subscribers.

edit flag offensive delete link more

Comments

This is what I ended up doing. Created a separate nodehandle, queue, and used callAvailable on that queue.

cpagravel gravatar image cpagravel  ( 2017-04-03 12:09:02 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2017-03-31 19:17:09 -0500

Seen: 556 times

Last updated: Mar 31 '17