Documented target: Ubuntu 24.04 · ROS 2 Jazzy · Gazebo Harmonic where used. Browser labs tested; ROS/Ubuntu/hardware execution not performed here.
What you will understand
- Choose the right interface.
- Call a simulation service.
- Read an action contract.
Prerequisites: Publish and subscribe with meaningful messages and its stated environment.
The idea, made clear.
Topics suit ongoing data streams. Services suit bounded requests with one response. Actions suit longer tasks that need progress and cancellation, such as navigation. Do not substitute a blocking service for a mission that needs supervision.
An interface is a contract. Service definitions separate request and response with ---. Action definitions have goal, result and feedback sections. Document units and ranges. Custom ROS interfaces need generation metadata and rosidl dependencies in an appropriate package.
Clients must handle unavailability and timeouts. Executors and callbacks affect responsiveness; merely choosing an action interface does not implement cancellation in the server. Inspect actual behavior and failure responses.
Try it, step by step.
Inspect turtlesim
Install turtlesim if absent and run its node.
ros2 run turtlesim turtlesim_node
# Other terminal:
ros2 service list
ros2 interface show turtlesim/srv/SpawnExpected: The /spawn contract.
Spawn a turtle
Call the running simulation.
ros2 service call /spawn turtlesim/srv/Spawn "{x: 3.0, y: 3.0, theta: 0.0, name: learner}"Expected: A named second turtle.
Design an action
Design only; this is not a generated package.
float64 distance_m
---
bool reached
---
float64 remaining_mExpected: Goal, result and feedback with units.
If something goes wrong
- Service waits
- Check that the server is running and the name matches.
- Action does not cancel
- Inspect server cancellation handling.
Check your understanding
Make it yours
Classify a laser stream, reset request and docking task.
Optional progress stays in this browser. No account needed.
Go to the source documentation
Commands are educational examples for the stated environment, not a transcript of local ROS execution. Verify actual behavior on your machine.