rclpy.parameter_client module

class rclpy.parameter_client.AsyncParameterClient(node: Node, remote_node_name: str, qos_profile: rclpy.qos.QoSProfile = rclpy.qos.qos_profile_services_default, callback_group: CallbackGroup | None = None)

Bases: object

Create an AsyncParameterClient.

An AsyncParameterClient that uses services offered by a remote node to query and modify parameters in a streamlined way.

Usage example:

import rclpy
from rclpy.parameter import Parameter
node = rclpy.create_node('my_node')

client = AsyncParameterClient(node, 'example_node')

# set parameters on example node
future = client.set_parameters([
    Parameter('int_param', Parameter.Type.INTEGER, 88),
    Parameter('string/param', Parameter.Type.STRING, 'hello world').to_parameter_msg(),
])
self.executor.spin_until_future_complete(future)
results = future.result()  # rcl_interfaces.srv.SetParameters.Response

For more on service names, see: ROS 2 docs.

Parameters:
  • node – Node used to create clients that will interact with the remote node

  • remote_node_name – Name of remote node for which the parameters will be managed

delete_parameters(names: List[str], callback: Callable[[rcl_interfaces.srv.SetParameters.Response], None] | None = None) Future[rcl_interfaces.srv.SetParameters.Response]

Unset parameters with given names.

The result after the returned future is complete will be of type rcl_interfaces.srv.SetParameters.Response.

Note: Only parameters that have been declared as dynamically typed can be unset.

Parameters:
  • names – List of parameter names to unset.

  • callback – Callback function to call when the request is complete.

Returns:

Future with the result of the request.

describe_parameters(names: List[str], callback: Callable[[rcl_interfaces.srv.DescribeParameters.Response], None] | None = None) Future[rcl_interfaces.srv.DescribeParameters.Response]

Describe parameters given names.

The result after the returned future is complete will be of type rcl_interfaces.srv.DescribeParameters.Response.

Parameters:
  • names – List of parameter names to describe

  • callback – Callback function to call when the request is complete.

Returns:

Future with the result of the request.

get_parameter_types(names: List[str], callback: Callable[[rcl_interfaces.srv.GetParameterTypes.Response], None] | None = None) Future[rcl_interfaces.srv.GetParameterTypes.Response]

Get parameter types given names.

The result after the returned future is complete will be of type rcl_interfaces.srv.GetParameterTypes.Response.

Parameter type definitions are given in Parameter.Type

Parameters:
  • names – List of parameter names to get types for.

  • callback – Callback function to call when the request is complete.

Returns:

Future with the result of the request.

get_parameters(names: List[str], callback: Callable[[rcl_interfaces.srv.GetParameters.Response], None] | None = None) Future[rcl_interfaces.srv.GetParameters.Response]

Get parameters given names.

Parameters:
  • names – List of parameter names to get.

  • callback – Callback function to call when the request is complete.

Returns:

Future with the result of the request.

list_parameters(prefixes: List[str] | None = None, depth: int | None = None, callback: Callable[[rcl_interfaces.srv.ListParameters.Response], None] | None = None) Future[rcl_interfaces.srv.ListParameters.Response]

List all parameters with given prefixes.

Parameters:
  • prefixes – List of prefixes to filter by.

  • depth – Depth of the parameter tree to list. None means unlimited.

  • callback – Callback function to call when the request is complete.

Returns:

Future with the result of the request.

load_parameter_file(parameter_file: str, use_wildcard: bool = False, callback: Callable[[rcl_interfaces.srv.SetParameters.Response], None] | None = None) Future[rcl_interfaces.srv.SetParameters.Response]

Load parameters from a yaml file.

Wrapper around rclpy.parameter.parameter_dict_from_yaml_file.

The result after the returned future is complete will be of type rcl_interfaces.srv.SetParameters.Response.

Parameters:
  • parameter_file – Path to the parameter file.

  • use_wildcard – Whether to use wildcard expansion.

Returns:

Future with the result from the set_parameters call.

load_parameter_file_atomically(parameter_file: str, use_wildcard: bool = False, callback: Callable[[rcl_interfaces.srv.SetParameters.Response], None] | None = None) Future[rcl_interfaces.srv.SetParameters.Response]

Load parameters from a yaml file atomically.

Wrapper around rclpy.parameter.parameter_dict_from_yaml_file.

The result after the returned future is complete will be of type rcl_interfaces.srv.SetParameters.Response.

Parameters:
  • parameter_file – Path to the parameter file.

  • use_wildcard – Whether to use wildcard expansion.

Returns:

Future with the result from the set_parameters_atomically call.

on_parameter_event(callback: Callable[[rcl_interfaces.msg.ParameterEvent], None] | Callable[[rcl_interfaces.msg.ParameterEvent, MessageInfo], None], qos_profile: rclpy.qos.QoSProfile = rclpy.qos.qos_profile_parameter_events, *, callback_group: CallbackGroup | None = None, event_callbacks: SubscriptionEventCallbacks | None = None, qos_overriding_options: QoSOverridingOptions | None = None, raw: bool = False) Subscription[rcl_interfaces.msg.ParameterEvent]
services_are_ready() bool

Check if all services are ready.

Returns:

True if all services are available, False otherwise.

set_parameters(parameters: Sequence[Parameter[Any] | rcl_interfaces.msg.Parameter], callback: Callable[[rcl_interfaces.srv.SetParameters.Response], None] | None = None) Future[rcl_interfaces.srv.SetParameters.Response]

Set parameters given a list of parameters.

The result after the returned future is complete will be of type rcl_interfaces.srv.SetParameters.Response.

Parameters:
  • parameters – Sequence of parameters to set.

  • callback – Callback function to call when the request is complete.

Returns:

Future with the result of the request.

set_parameters_atomically(parameters: Sequence[Parameter[Any] | rcl_interfaces.msg.Parameter], callback: Callable[[rcl_interfaces.srv.SetParametersAtomically.Response], None] | None = None) Future[rcl_interfaces.srv.SetParametersAtomically.Response]

Set parameters atomically.

The result after the returned future is complete will be of type rcl_interfaces.srv.SetParametersAtomically.Response.

Parameters:
  • parameters – Sequence of parameters to set.

  • callback – Callback function to call when the request is complete.

Returns:

Future with the result of the request.

wait_for_services(timeout_sec: float | None = None) bool

Wait for all parameter services to be available.

Parameters:

timeout_sec – Seconds to wait. If None, then wait forever.

Returns:

True if all services becomes available, False otherwise.