Parameters

ROS 2 uses a node-scoped parameter system where parameters belong to specific nodes. The OLO client provides parameter access methods that handle both simple parameter names and full node paths.

listNodeParameters(nodeName, options)

List parameter names for a specific ROS 2 node.

Parameters:

  • nodeName (string) - Node name (e.g., '/robot_state_publisher')
  • options (object) - Optional configuration:
    • depth (number) - Recursion depth (0 = all parameters, default)
    • prefixes (array) - List of parameter prefixes to filter

Returns: Promise<Array<string>> - Array of parameter names

JS
// List all parameters for a node const params = await oloClient.core.listNodeParameters('/robot_state_publisher'); console.log(`Found ${params.length} parameters:`); params.forEach(p => console.log(` ${p}`)); // List parameters with specific prefix const qosParams = await oloClient.core.listNodeParameters('/robot_state_publisher', { prefixes: ['qos_overrides'] }); // Iterate all nodes and list their parameters const nodes = await oloClient.core.listNodes(); for (const node of nodes) { try { const nodeParams = await oloClient.core.listNodeParameters(node, { depth: 0 }); console.log(`${node}: ${nodeParams.length} parameters`); } catch (e) { console.log(`${node}: Unable to list parameters`); } }

getParameter(paramName)

Get ROS 2 parameter value with automatic discovery.

Parameters:

  • paramName (string) - Parameter name or full path
    • Simple name: 'robot_description' (searches across all nodes)
    • Full path: '/robot_state_publisher/robot_description' (direct node access)

Returns: Promise<any> - Parameter value

JS
// Get parameter by simple name (searches all nodes) const robotDesc = await oloClient.core.getParameter('robot_description'); // Get parameter by full path (direct access) const robotDesc = await oloClient.core.getParameter('/robot_state_publisher/robot_description'); // Get a boolean parameter const simTime = await oloClient.core.getParameter('use_sim_time');

getNodeParameter(nodeName, paramName)

Get parameter value from a specific ROS 2 node.

Parameters:

  • nodeName (string) - Node name (e.g., '/robot_state_publisher')
  • paramName (string) - Parameter name (e.g., 'robot_description')

Returns: Promise<any> - Parameter value

JS
// Direct node parameter access const robotDesc = await oloClient.core.getNodeParameter('/robot_state_publisher', 'robot_description'); const simTime = await oloClient.core.getNodeParameter('/move_group', 'use_sim_time');

setParameter(paramPath, value)

Set ROS 2 parameter value using full node path.

Parameters:

  • paramPath (string) - Full parameter path (e.g., '/robot_state_publisher/my_param')
  • value (any) - Parameter value (boolean, number, string, or arrays)

Returns: Promise<Object> - Set parameter result

JS
// Set different parameter types await oloClient.core.setParameter('/my_node/enable_feature', true); // boolean await oloClient.core.setParameter('/my_node/max_velocity', 0.5); // double await oloClient.core.setParameter('/my_node/retry_count', 3); // integer await oloClient.core.setParameter('/my_node/robot_name', 'my_robot'); // string await oloClient.core.setParameter('/my_node/joint_names', ['joint1', 'joint2']); // string array

setNodeParameter(nodeName, paramName, value)

Set parameter value on a specific ROS 2 node.

Parameters:

  • nodeName (string) - Node name (e.g., '/robot_state_publisher')
  • paramName (string) - Parameter name
  • value (any) - Parameter value

Returns: Promise<Object> - Set parameter result

JS
// Set parameter on specific node await oloClient.core.setNodeParameter('/my_node', 'max_velocity', 0.5);

deleteParameter(paramPath)

Delete ROS 2 parameter (not supported).

Note: ROS 2 does not support parameter deletion in the same way as ROS 1. Parameters are managed by their respective nodes and cannot be deleted externally.

Parameters:

  • paramPath (string) - Full parameter path

Returns: Promise - Throws error as deletion is not supported

JS
// This will throw an error try { await oloClient.core.deleteParameter('/my_node/my_param'); } catch (error) { console.log(error.message); // "Parameter deletion is not supported in ROS 2" }

Parameter Discovery Methods

listNodeParameters(nodeName, options)

List parameter names for a specific node.

Parameters:

  • nodeName (string) - Node name
  • options (object, optional) - List options
    • depth (number) - Parameter depth (default: 0 = all)
    • prefixes (Array) - Parameter name prefixes to filter

Returns: Promise<Array<string>> - Parameter names for the node

JS
// List all parameters for a node const params = await oloClient.core.listNodeParameters('/robot_state_publisher'); console.log('Available parameters:', params); // List parameters with specific prefix const robotParams = await oloClient.core.listNodeParameters('/move_group', { prefixes: ['robot_description'] });

ROS 2 Parameter Types

ROS 2 supports the following parameter types:

TypeJavaScript TypeExample Value
PARAMETER_BOOLbooleantrue, false
PARAMETER_INTEGERnumber (integer)42, -10
PARAMETER_DOUBLEnumber (float)3.14, -0.5
PARAMETER_STRINGstring"hello", "robot_name"
PARAMETER_BYTE_ARRAYUint8Arraynew Uint8Array([1, 2, 3])
PARAMETER_BOOL_ARRAYArray<boolean>[true, false, true]
PARAMETER_INTEGER_ARRAYArray<number>[1, 2, 3, 4]
PARAMETER_DOUBLE_ARRAYArray<number>[1.1, 2.2, 3.3]
PARAMETER_STRING_ARRAYArray<string>["joint1", "joint2"]

Parameter Naming Conventions

Node-Scoped Parameters:

  • All ROS 2 parameters belong to specific nodes
  • Parameter names are local to their node
  • Access via full path: /node_name/parameter_name

Common Parameter Examples:

JS
// Robot description (URDF) await oloClient.core.getParameter('/robot_state_publisher/robot_description'); // Simulation time flag await oloClient.core.getParameter('/move_group/use_sim_time'); // Planning parameters await oloClient.core.getParameter('/move_group/planner_configs/RRTConnectkConfigDefault/range'); // Controller parameters await oloClient.core.getParameter('/joint_trajectory_controller/joints');

Best Practices

1. Use Simple Names for Discovery:

JS
// Let the client find the parameter across nodes const robotDesc = await oloClient.core.getParameter('robot_description');

2. Use Full Paths for Performance:

JS
// Direct access when you know the node const robotDesc = await oloClient.core.getParameter('/robot_state_publisher/robot_description');

3. Handle Parameter Not Found:

JS
try { const value = await oloClient.core.getParameter('my_parameter'); console.log('Parameter value:', value); } catch (error) { if (error.message.includes('not found')) { console.log('Parameter does not exist'); } else { console.error('Failed to get parameter:', error); } }

4. Check Node Existence Before Setting:

JS
const nodes = await oloClient.core.listNodes(); if (nodes.includes('/my_node')) { await oloClient.core.setParameter('/my_node/my_param', 'value'); } else { console.log('Node /my_node not found'); }