Services and Actions

Imagine you are ordering a meal at a busy restaurant while also trying to track a delivery package arriving at your home. When you ask the waiter for a glass of water, you expect an immediate response, whereas tracking a package requires waiting for updates over several hours. Robots face this same dilemma when they manage internal tasks, needing both instant reactions and long-term processes to function effectively. By using distinct communication tools, robots can balance these different demands without confusing their internal systems or stalling during complex operations.
Understanding Communication Methods
Robotic systems rely on two primary ways to handle tasks, known as services and actions. A service acts like a simple question-and-answer exchange where the robot receives a request and provides an immediate result. This method works well for quick tasks, such as checking a sensor value or toggling a light switch on or off. Because the robot does not need to maintain a long connection, the system remains lightweight and efficient for these brief interactions. Think of this like a quick phone call where you ask a specific question and hang up once you receive the answer.
Key term: Service — a request-reply communication pattern where a client sends a specific command and receives an immediate response from the server.
In contrast, actions provide a way to manage tasks that take a long time to complete, such as moving a robot arm across a room. When a robot performs an action, it needs to provide feedback along the way so the user knows the progress of the task. If the robot encounters an obstacle or needs to stop early, the action system allows the user to cancel the request at any time. This flexibility makes actions essential for complex movements that require constant monitoring and potential adjustments during the execution phase.
Choosing the Right Tool
Selecting the correct communication tool depends on whether the robot needs a fast response or a managed process. You should use a service when the task completes instantly and requires no ongoing updates from the robot. Conversely, you should choose an action whenever the task involves movement, duration, or the possibility of needing a mid-task cancellation. The following table highlights the core differences between these two essential robotic communication tools for your system design:
| Feature | Service Call | Action Goal |
|---|---|---|
| Duration | Instant | Long-running |
| Feedback | None | Continuous |
| Control | Blocking | Cancellable |
| Purpose | Data query | Task execution |
Using the wrong tool can lead to system bottlenecks or unresponsive software, so developers must evaluate the nature of the task carefully. If you attempt to use a service for a task that takes ten seconds, the robot might freeze while waiting for the result, which prevents other processes from running. By properly assigning tasks to either services or actions, you ensure the robot maintains a smooth flow of operations. This separation of concerns allows the robot to handle high-priority sensor checks while simultaneously navigating through a cluttered environment.
When we look at how these tools interact, we see that they form the backbone of modern robotic coordination. A robot might use a service to ask its camera for a single image, then use an action to navigate to a specific coordinate based on that image data. This layered approach ensures that the robot remains responsive to its surroundings while executing high-level goals. Mastering this distinction is a fundamental step in building robots that can operate reliably in unpredictable real-world settings. As you continue your journey into robotics, remember that efficient communication is just as important as the physical hardware itself.
Choosing between services and actions allows a robot to balance immediate data requests with long-term task management for better performance.
The next Station introduces the Parameter Server, which determines how global configuration data works across the entire robot system.