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

Reasoning for using Pub/Sub vs Service

asked 2017-01-09 14:03:42 -0600

waspinator gravatar image

I'm struggling to determine when I should use the various communication methods ROS offers, like the publish/subscriber model, service, or action.

I figure, sensors should be publishers, short running processes can be services, and longer running ones should be actions. Do those make sense? Are there other rules of thumb to follow?

For example, I was looking at the rosserial tutorial for controlling a servo motor, and saw it was using a subscriber to move. I would have chosen a service. What would be the reasoning for choosing one over the other?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-01-09 16:58:57 -0600

ahendrix gravatar image

This question explains the reasoning and scenarios for each pretty well:

This is also documented on the ROS Communication Patterns page that is linked from that question.

edit flag offensive delete link more


so for the example of controlling a servo motor, it should be a topic if its continuously updating its position, a service if its a quick movement with discrete move requests, and an action if its slow?

waspinator gravatar image waspinator  ( 2017-01-15 21:55:01 -0600 )edit

Question Tools

1 follower


Asked: 2017-01-09 14:03:42 -0600

Seen: 1,976 times

Last updated: Jan 09 '17