Ask Your Question
30

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 2012-09-06 05:55:36 -0500

130s 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
55

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

6
jbohren gravatar imagejbohren ( 2013-07-02 17:05:10 -0500 )edit
19

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

1
jbohren gravatar imagejbohren ( 2013-07-02 17:05:22 -0500 )edit
1

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 imageg_r_rahimi ( 2017-04-25 11:17:50 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

7 followers

Stats

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

Seen: 19,234 times

Last updated: Sep 06 '12