Skip to main content
Use ROS2 services for request/response operations.

Service Interface

When to use a service

Use a service when you need a single request/response interaction (for example “do this now and return success/failure”). Use Topics for continuous streaming and Actions for long-running operations with progress/cancel.

Quick commands

ros2 service list
ros2 service list -t
ros2 service type /mars/arm/goto_js
ros2 interface show mars_msgs/srv/GotoJS
ros2 service call /mars/head/set_ai_position std_srvs/srv/Trigger {}

Common call examples

Set LED color

ros2 service call /light_command mars_msgs/srv/LightCommand \
  "{mode: 1, interval: 0, r: 64, g: 31, b: 251}"

Move arm in joint space

# NOTE: `time` is the motion duration in SECONDS (float), not milliseconds.
# 2.0 means 2 seconds — passing 2000 would command a 2000-second move.
ros2 service call /mars/arm/goto_js mars_msgs/srv/GotoJS \
  "{data: {data: [0.0, -0.8, 1.2, -0.6, 0.0, 0.0]}, time: 2.0}"

Switch navigation mode

ros2 service call /nav/change_mode brain_messages/srv/ChangeNavigationMode \
  "{mode: navigation}"

Topics

Streaming state and command channels.

Actions

Long-running tasks with feedback and cancellation.