Provides a client to access parameters on remote ROS 2 nodes via the standard parameter services.
Inspired by rclpy.parameter_client.AsyncParameterClient. A client must be
started on a local node before it can communicate with the parameter
services of a remote (server) node.
This module follows the rule of "one process per service client": when a parameter client is started, six service clients are registered on the given local (client) node, one for each parameter service:
~/get_parameters~/set_parameters~/set_parameters_atomically~/list_parameters~/describe_parameters~/get_parameter_types
Summary
Functions
Describe parameter_names on the remote node. If parameter_names is
empty, all parameters are described.
Get the parameter types of parameter_names on the remote node.
Get the values of parameter_names from the remote node.
List parameters on the remote node.
Returns true if the remote parameter services are available, false
otherwise. Returns {:error, :not_found} if the parameter client has not
been started.
Set parameters on the remote node, one by one.
Set parameters on the remote node atomically: either all set successfully or none change.
Start the six parameter service clients on the given local node, all
pointing at the parameter services of the remote server_node_name (in
server_namespace).
Stop all parameter service clients previously started by start/3 for the
given server_node_name/client_node_name pair.
Functions
@spec describe_parameters( server_node_name :: String.t(), parameter_names :: [String.t()], client_node_name :: String.t(), opts :: keyword() ) :: {:ok, [struct()]} | {:error, term()}
Describe parameter_names on the remote node. If parameter_names is
empty, all parameters are described.
Returns {:ok, [%ParameterDescriptor{}]} on success.
@spec get_parameter_types( server_node_name :: String.t(), parameter_names :: [String.t()], client_node_name :: String.t(), opts :: keyword() ) :: {:ok, [non_neg_integer()]} | {:error, term()}
Get the parameter types of parameter_names on the remote node.
Returns {:ok, [integer]} on success, where each integer matches the
ROS 2 ParameterType constants (e.g. parameter_integer).
@spec get_parameters( server_node_name :: String.t(), parameter_names :: [String.t()], client_node_name :: String.t(), opts :: keyword() ) :: {:ok, [{String.t(), term()}]} | {:error, term()}
Get the values of parameter_names from the remote node.
Returns {:ok, [{name, value}, ...]} on success, where value is the
Elixir-side decoded value (or nil if the parameter is not set on the
server). Returns {:error, reason} on failure.
Options
:namespace(client node namespace, default"/"):server_namespace(default"/"):timeout(seconds, float; defaultnilfor infinite)
@spec list_parameters( server_node_name :: String.t(), client_node_name :: String.t(), opts :: keyword() ) :: {:ok, %{names: [String.t()], prefixes: [String.t()]}} | {:error, term()}
List parameters on the remote node.
Options
:prefixes— list of prefix strings to filter by. Defaults to[](no filtering).:depth— recursion depth. Defaults to0(unlimited).:namespace,:server_namespace,:timeout— as elsewhere.
Returns {:ok, %{names: [...], prefixes: [...]}} on success.
@spec service_available?( server_node_name :: String.t(), client_node_name :: String.t(), opts :: keyword() ) :: boolean() | {:error, :not_found}
Returns true if the remote parameter services are available, false
otherwise. Returns {:error, :not_found} if the parameter client has not
been started.
By default, the check is performed against get_parameters. All six
services are typically registered together by the server, so this is
representative.
@spec set_parameters( server_node_name :: String.t(), parameters :: [{String.t(), term()} | struct()], client_node_name :: String.t(), opts :: keyword() ) :: {:ok, [struct()]} | {:error, term()}
Set parameters on the remote node, one by one.
parameters is a list of {name, value} tuples or %Rclex.Pkgs.RclInterfaces.Msg.Parameter{}
structs. Each set is independently validated server-side.
Returns {:ok, [%SetParametersResult{}]} on success.
@spec set_parameters_atomically( server_node_name :: String.t(), parameters :: [{String.t(), term()} | struct()], client_node_name :: String.t(), opts :: keyword() ) :: {:ok, struct()} | {:error, term()}
Set parameters on the remote node atomically: either all set successfully or none change.
Returns {:ok, %SetParametersResult{}} on success.
@spec start( server_node_name :: String.t(), client_node_name :: String.t(), opts :: keyword() ) :: :ok | {:error, term()}
Start the six parameter service clients on the given local node, all
pointing at the parameter services of the remote server_node_name (in
server_namespace).
Options
:namespace— namespace of the local (client) node. Defaults to"/".:server_namespace— namespace of the remote (server) node. Defaults to"/".:qos— service QoS. Defaults toRclex.QoS.profile_services_default/0.
@spec stop( server_node_name :: String.t(), client_node_name :: String.t(), opts :: keyword() ) :: :ok
Stop all parameter service clients previously started by start/3 for the
given server_node_name/client_node_name pair.
Same options as start/3.