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

Subscribe from service example

asked 2013-01-10 21:44:23 -0500

liborw gravatar image

Hi,

lets say that I have a service that needs some additional resources which is available via topic. Is there some example how this can be implemented?

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2013-01-11 09:04:37 -0500

tfoote gravatar image

The recommended way to do this is to have a subscription to the topic which stores the latest value in a persistent location. Then you can use that value in your service callback.

edit flag offensive delete link more

Comments

I use this approach for saving images from camera, but the topic is output from some point cloud processing, that is computationally expensive. That is why I want to subscribe when the service is called.

liborw gravatar image liborw  ( 2013-01-13 20:44:24 -0500 )edit

You can connect and disconnect at the beginning and end of the sevice. But you will trade off latency for lower cpuusage.

tfoote gravatar image tfoote  ( 2013-03-05 09:51:04 -0500 )edit
0

answered 2013-01-11 02:31:18 -0500

thebyohazard gravatar image

I'm not sure what the best practice is, but I've always used ros::topic::waitForMessage. It gets one message on the topic you specify.

edit flag offensive delete link more

Comments

Thanks for this suggestion, I didn't know about it, but I need to synchronise multiple messages using message_filters.

liborw gravatar image liborw  ( 2013-01-13 20:48:48 -0500 )edit

Question Tools

Stats

Asked: 2013-01-10 21:44:23 -0500

Seen: 561 times

Last updated: Jan 11 '13