call_ros2_service
Invoke a ROS 2 service to control robot behavior. Specify service name, type, and optional request payload for actions like setting pen or clearing environment.
Instructions
Calls a ROS 2 service with the specified name, type, and optional request.
Args:
service_name: Name of the service to call.
srv_type: Type of the service (e.g., "std_srvs/srv/Empty").
request: Request payload in string format (e.g., "{r: 255, g: 0, b: 0, width: 2, off: 0}").
If the service type does not require a request (e.g., std_srvs/srv/Empty),
this can be omitted or set to None.
Example:
Call a service without a request:
service_name = "/clear"
srv_type = "std_srvs/srv/Empty"
Call a service with a request:
service_name = "/turtle1/set_pen"
srv_type = "turtlesim/srv/SetPen"
request = "{r: 255, g: 0, b: 0, width: 2, off: 0}"
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| request | No | ||
| srv_type | Yes | ||
| service_name | Yes |