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

In which order are callback functions in a node which offers a service and also subscribes to a topic?

asked 2019-02-24 18:13:10 -0500

eric.valls.grunewald gravatar image

I want to use a node that both offers a service and subscribes to a topic. If, when ros::spin() is called I have both a new message in the topic and a request from the service, which callback function is called first? The service or the subscriber one?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2019-02-24 19:23:43 -0500

updated 2019-03-01 17:49:48 -0500

I'd recommend reading the Callbacks and Spinning page page. Since it sounds like you are calling ros::spin(), then all callbacks get put into a callback queue in the order in which they are received. Then every call to ros::spin() will handle the callback at the front of the queue. So the answer to your question depends on the order in which the service request and the topic were received.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-02-24 18:13:10 -0500

Seen: 763 times

Last updated: Mar 01 '19