Back to the 2025 paper

ROS

20257m

Differentiate between ROS Services and ROS Action.

Worked SolutionAI Assisted

Solution: ROS Services vs ROS Actions

Both ROS Services and Actions provide communication between ROS nodes, but they are designed for different kinds of tasks.

Feature ROS Service ROS Action
Communication Request-response Goal-feedback-result
Task type Short operations Long-running operations
Feedback Normally no continuous feedback Provides continuous feedback
Cancellation Not designed for cancellation Goal can be cancelled/preempted
Result Returned after request Final result returned separately
Example Reset a sensor Navigate to a destination

ROS Service

A service is synchronous request-response communication.

Client → Request → Service Server
Client ← Response ← Service Server

Examples include resetting a controller, requesting a calculation or changing a configuration parameter.

ROS Action

An action is intended for operations that may take significant time.

Client → Goal → Action Server
Client ← Feedback ← Action Server
Client ← Result ← Action Server
        ↑
      Cancel

For example, autonomous navigation may take several seconds or minutes. The client can receive distance/progress feedback and cancel the goal if necessary.

Conclusion

Use a Service for short request-response operations and an Action for long-running, feedback-producing and cancellable tasks.

Similar questions