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

When should I use topics vs services vs actionlib actions (vs dynamic_reconfigure)?

asked 2011-11-07 11:37:43 -0500

mmwise gravatar image

updated 2020-11-21 11:15:51 -0500

lucasw gravatar image

Please help in writing up a ROS best practice.

edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
73

answered 2012-09-06 06:18:10 -0500

Lorenz gravatar image

updated 2012-09-06 22:01:32 -0500

  1. Topics should be used for continuous data streams (sensor data, robot state, ...).

  2. Services should be used for remote procedure calls that terminate quickly, e.g. for querying the state of a node or doing a quick calculation such as IK. They should never be used for longer running processes, in particular processes that might be required to preempt if exceptional situations occur and they should never change or depend on state to avoid unwanted side effects for other nodes.

  3. Actions should be used for everything that moves the robot or that runs for a longer time such as perception routines that are triggered by some node and need a couple of seconds to terminate. The most important property of actions is that they can be preempted and preemption should always be implemented cleanly by action servers. Another nice property of actions is that they can keep state for the lifetime of a goal, i.e. if executing two action goals in parallel on the same server, for each client a separate state instance can be kept since the goal is uniquely identified by its id.

edit flag offensive delete link more

Comments

8
jbohren gravatar image jbohren  ( 2013-07-02 17:05:10 -0500 )edit

Man well said thank you. You made me understand litterally in minutes

mr_top gravatar image mr_top  ( 2022-11-29 02:04:22 -0500 )edit
3

answered 2012-09-06 05:53:43 -0500

130s gravatar image

updated 2012-09-06 05:58:57 -0500

I've been wondering the same. I would borrow network terminologies. Correct me if wrong:

  1. topic - UDP broadcast (any node can receive, no connection b/w server established)
  2. service - TCP broadcast (any node can receive, connection b/w server established)
  3. actionlib - TCP multicast (node needs special assignments to receive, connection b/w server established)
edit flag offensive delete link more

Comments

This is the best answer I found. http://answers.ros.org/question/24999...

g_r_rahimi gravatar image g_r_rahimi  ( 2017-04-25 11:17:50 -0500 )edit
23

answered 2012-09-06 06:19:12 -0500

dornhege gravatar image

updated 2012-09-06 06:20:28 -0500

First one should differentiate between topics and service/actionlib.

  • Topics: Continuous data flow. Data might be published and subscribed at any time independent of any senders/receivers. Many to many connection. Callbacks receive data once it is available. The publisher decides when data is sent.

  • Service/Actionlib: On-demand connection for one specific task. Service calls/Actionlib tasks are processed when the client decides to request so. Tasks take time to complete.

Service/Actionlib are thus very similar and can actually be used interchangeably in their functionality. However, they serve different purposes:

  • Service: Simple blocking call. Mostly used for comparably fast tasks as requesting specific data. Semantically for processing requests.

  • Actionlib: More complex non-blocking background processing. Used for longer tasks like execution of robot actions. Semantically for real-world actions.

edit flag offensive delete link more

Comments

2
jbohren gravatar image jbohren  ( 2013-07-02 17:05:22 -0500 )edit

Question Tools

9 followers

Stats

Asked: 2011-11-07 11:37:43 -0500

Seen: 35,603 times

Last updated: Sep 06 '12