Service discovery and invocationΒΆ
Use olo.core.Core to discover ROS services and invoke them with
structured request/response payloads.
Note
This is a low-level ROS interoperability API. Use typed OLO services whenever they cover the operation you need. It is recommended to use this API only when no typed SDK equivalent exists.
from olo import Client
from olo.core import ServiceInfo
with Client() as client:
robot = client.robot()
# Call the controller manager's list_parameters service.
service = ServiceInfo(
"controller_manager/list_parameters",
"rcl_interfaces/srv/ListParameters",
)
list_params_request = {"prefixes": [], "depth": 0}
response = robot.core.call_service(service, list_params_request)
# Do something with the response.
names = response.get("result", {}).get("names", [])
print("Parameter names:")
for name in names:
print(f" {name}")
import { connect } from "olo/web";
const client = connect();
const robot = await client.robot();
// Call the controller manager's list_parameters service.
const listParamsRequest = { prefixes: [], depth: 0 };
const response = await robot.core.callService(
{
name: "controller_manager/list_parameters",
serviceType: "rcl_interfaces/srv/ListParameters",
},
listParamsRequest,
);
// Do something with the response.
const names = (response.result as { names?: string[] } | undefined)?.names ?? [];
console.log("Parameter names:");
for (const name of names) {
console.log(` ${name}`);
}