Parameters in ROS 2 are configuration values of a node, stored as integers, floats, booleans, strings, and lists. Use ros2 param list
to see a node's parameters, ros2 param get
to display a parameter's type and value, ros2 param set
to change a parameter's value, and ros2 param dump
to view and save all parameters. Use ros2 param load
to load parameters from a file, and ros2 run
with --params-file
to start a node with saved parameters.
A parameter is a configuration value of a node. You can think of parameters as node settings. A node can store parameters as integers, floats, Booleans, strings, and lists. In ROS 2, each node maintains its own parameters.
<aside>
💡 Check if /turtlesim
& /teleop_turtle
nodes are active, if not run ros2 run turtlesim turtlesim_node
& ros2 run turtlesim turtle_teleop_key
in separate terminal respectively.
If no node is active, you will not get any output!
</aside>
<aside> 📒 Click on Orange text to learn more about the command
</aside>
To see the parameters belonging to your nodes, open a terminal and enter the command:
ros2 param list
You will see the node namespaces, /teleop_turtle
and /turtlesim
, followed by each node’s parameters:
/teleop_turtle:
qos_overrides./parameter_events.publisher.depth
qos_overrides./parameter_events.publisher.durability
qos_overrides./parameter_events.publisher.history
qos_overrides./parameter_events.publisher.reliability
scale_angular
scale_linear
use_sim_time
/turtlesim:
background_b
background_g
background_r
qos_overrides./parameter_events.publisher.depth
qos_overrides./parameter_events.publisher.durability
qos_overrides./parameter_events.publisher.history
qos_overrides./parameter_events.publisher.reliability
use_sim_time
<aside>
💡 Every node has the parameter use_sim_time
, it’s not unique to turtlesim.
</aside>
<aside>
💡 Make sure you have /turtlesim
node active, if not run ros2 run turtlesim turtlesim_node
If no node is active, you will not get any output!
</aside>
To display the type and current value of a parameter, use the command:
ros2 param get <node_name> <parameter_name>
In the example of getting the parameter value for the /turtlesim
node’s parameter background_g
:
ros2 param get /turtlesim background_g
Which will return the value: