-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Interfaces (topics, services, actions) #6326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kscottz
merged 12 commits into
ros2:rolling
from
keithkirkwood-3di:interfaces-topics-services-actions
May 14, 2026
+138
−44
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9781c05
OPENR-64: Create first draft of Interfaces topic
keithkirkwood-3di 13159bd
OPENR-64: Update short description and metadata formatting.
keithkirkwood-3di b16e869
OPENR-64: Adding mermaid diagrams and cross refs
keithkirkwood-3di 006cb8f
OPENR-64: TOC changes for Interfaces
keithkirkwood-3di b0c6509
Merge branch 'rolling' into interfaces-topics-services-actions
kscottz 2b330af
Update source/Concepts/Basic/Interfaces-Topics-Services-Actions.rst
keithkirkwood-3di 5832112
OPENR-64: Minor updates.
keithkirkwood-3di 26f19e2
OPENR-64: More updates to Summary and Statistics
keithkirkwood-3di 80f4ed9
Update source/Concepts/Basic/Interfaces-Topics-Services-Actions.rst
keithkirkwood-3di c89a34e
Merge branch 'rolling' into interfaces-topics-services-actions
keithkirkwood-3di d0ff0c6
Update source/Concepts/Basic/Interfaces-Topics-Services-Actions.rst
ahcorde 01cbe17
Merge branch 'rolling' into interfaces-topics-services-actions
ahcorde File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
source/Concepts/Basic/Interfaces-Topics-Services-Actions.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| .. redirect-from:: | ||
|
|
||
| How-To-Guides/Topics-Services-Actions | ||
|
|
||
| .. _interfaces-topics-services-actions: | ||
|
|
||
| Interfaces (topics, services, actions) | ||
| ====================================== | ||
|
|
||
| Interfaces in ROS define how nodes exchange data. | ||
| This article explains the different types of ROS interface and the differences between them. | ||
| With this information, you'll be able to select the right interfaces for your purposes. | ||
|
|
||
| **Area: ROS-framework | Content-type: concept | Experience: beginner** | ||
|
|
||
| .. contents:: Table of Contents | ||
| :depth: 2 | ||
| :local: | ||
|
|
||
| .. toctree:: | ||
| :hidden: | ||
|
|
||
| About-Interfaces | ||
| About-Topics | ||
| About-Services | ||
| About-Actions | ||
|
|
||
| Summary | ||
| ------- | ||
|
|
||
| ROS nodes typically communicate through the following three types of interfaces: | ||
|
|
||
| * Topics: For continuous data streams. | ||
| * Services: For synchronous request/response interactions (short tasks which happen immediately). | ||
| * Actions: For long-running tasks with feedback (tasks that may take some time to complete). | ||
|
|
||
| For consistent communication, each interface uses definitions provided in ``.msg``, ``.srv``, or ``.action`` files. | ||
|
|
||
| :doc:`Learn more about nodes <About-Nodes>` | ||
|
|
||
| Topics | ||
| ------ | ||
|
|
||
| The topic interface is meant for continuous data streams, for example, streaming sensor data or the status of your robot. | ||
| Topic definitions are stored in ``.msg`` files. | ||
| Topics implement a publish/subscribe pattern. | ||
| A node publishes data to a topic, and other nodes subscribe to receive that data. | ||
| This interface type has the following main characteristics: | ||
|
|
||
| * Asynchronous, one-way communication | ||
| * Multiple publishers and subscribers can share the same topic | ||
|
|
||
| .. mermaid:: | ||
|
|
||
| flowchart LR | ||
| P[Publisher node] -->|Publishes messages| T[Topic] | ||
| T -->|Delivers messages| S1[Subscriber node] | ||
| T -->|Delivers messages| S2[Subscriber node] | ||
|
|
||
| Topic keys identify individual publishers on a topic so nodes and tools can distinguish where messages come from. | ||
| Each topic key makes it easier to track data sources when several publishers share the same topic. | ||
|
|
||
| Topic statistics | ||
| ---------------- | ||
| Topic statistics are built-in measurements that help you understand how messages behave when a subscription receives them. | ||
| When enabled, they automatically track two things: | ||
|
|
||
| :Message age: How old a message is when it arrives, based on its timestamp. | ||
| :Message period: The time between incoming messages. | ||
|
|
||
| For both message age and period, ROS calculates the average, minimum, maximum, standard deviation, and the number of samples, using a moving window that updates every time a new message arrives. | ||
| These calculations run in constant time and memory using the dedicated utilities. | ||
| When you enable topic statistics for a subscription, ROS publishes the collected data at regular intervals as a ``MetricsMessage`` on a statistics topic. | ||
| This gives you a clear view of timing patterns, delays, and irregularities, making it easier to assess system performance or diagnose problems related to the message flow. | ||
|
|
||
| .. tip:: | ||
|
|
||
| The default interval is 1 second. | ||
| The default statistics topic is ``/statistics``. | ||
|
|
||
| :doc:`Learn how to enable topic statistics </Tutorials/Advanced/Topic-Statistics-Tutorial/Topic-Statistics-Tutorial>` | ||
|
|
||
| Services | ||
| -------- | ||
|
|
||
| The service interface is meant for synchronous request/response interactions, for example, when you want to send a query requesting the configuration of a specific robot. | ||
| Service definitions are stored in ``.srv`` files. | ||
| Services implement a request/response pattern. | ||
| A client sends a request, and a server replies with a response. | ||
| This interface type has the following main characteristics: | ||
|
|
||
| * Synchronous communication | ||
| * Ideal for short-lived operations that require confirmation, or provide a result in response to a request | ||
|
|
||
| .. mermaid:: | ||
|
|
||
| sequenceDiagram | ||
| participant Service client | ||
| participant Service server | ||
| Service client->>Service server: Request | ||
| Service server-->>Service client: Response | ||
|
|
||
| Actions | ||
| ------- | ||
|
|
||
| The action interface is meant for long-running tasks with feedback, for example, moving a robot to a specific position, or asking the robot to perform a complex motion. | ||
| Action definitions are stored in ``.action`` files. | ||
| Actions allow clients to send goals, receive feedback during the execution, cancel if needed, and return a result if available. | ||
| This interface type has the following main characteristics: | ||
|
|
||
| * Asynchronous, with feedback and result | ||
| * Suitable for operations that take time | ||
|
|
||
| .. mermaid:: | ||
|
|
||
| sequenceDiagram | ||
| participant Action client | ||
| participant Action server | ||
| Client->>Action Server: Sends a goal | ||
| Action server-->>Action client: Provides feedback (periodic) | ||
| Action server-->>Action client: Sends a result | ||
|
|
||
| Key differences between ROS interfaces | ||
| -------------------------------------- | ||
|
|
||
| All three interfaces enable communication between nodes, but each serves a different purpose. | ||
| The table below summarizes the differences between ROS interface types: | ||
|
|
||
| +--------------+----------------------+-----------------------+-----------------+--------------------+---------------+ | ||
| | | Pattern | Direction | Provided result | Typical use case | Cancellation | | ||
| +==============+======================+=======================+=================+====================+===============+ | ||
| | **Topics** | Publish/Subscribe | One-way | No | Continuous data | Not supported | | ||
| +--------------+----------------------+-----------------------+-----------------+--------------------+---------------+ | ||
| | **Services** | Request/Response | Two-way | Yes | Quick queries | Not supported | | ||
| +--------------+----------------------+-----------------------+-----------------+--------------------+---------------+ | ||
| | **Actions** | Goal/Feedback/Result | Two-way with feedback | Yes | Long-running tasks | Supported | | ||
| +--------------+----------------------+-----------------------+-----------------+--------------------+---------------+ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.