ros2 param — read and change parameters while a node runs
Atlasbot · 17/8/2026 · 10 min read
The Parameters in ROS2 article explained how to declare parameters in code. This command-line toolkit works with those parameters after the node has started, without code changes or restarts.
Key concepts
ros2 param list # which parameters each node has
ros2 param get /motor_node max_speed # read the current value
ros2 param set /motor_node max_speed 1.2 # change the value immediately
ros2 param dump /motor_node # export everything as YAML
ros2 param load /motor_node config.yaml # load from a YAML file
ros2 param set only has a practical effect if the node has registered add_on_set_parameters_callback() (see the Parameter article). Without this callback, the parameter value still changes in the system, but the node's code does not know about it and cannot respond, leading to the confusing situation of "I set it, but nothing happened".
In short:
ros2 param setchanges a value immediately without restarting the node, but it is useful only if the node's code actually listens for that change. If you see no effect, first check whether the node hasadd_on_set_parameters_callback, rather than assuming thesetcommand is wrong.
How it works
dump/load — back up the running configuration:
ros2 param dump /motor_node > motor_backup.yaml
This is useful when repeatedly adjusting parameters with set (for example, tuning PID while the robot runs) and finding a good set of values. dump exports the entire current state as correctly formatted YAML that you can reuse in a launch file, without manually copying each value entered through set.
ros2 param load /motor_node motor_backup.yaml
Conversely, load loads the entire YAML file into a running node, much faster than setting parameters individually when restoring a saved configuration.
Technical details
Parameters
A useful extra command for understanding a parameter's constraints before changing it:
ros2 param describe /motor_node max_speed
| Displayed information | Meaning |
|---|---|
| Type | Data type (double, bool, string...) |
| Read only | Whether runtime set operations are allowed |
| Description | Description (if supplied when the node calls declare_parameter) |
| Constraints | Value limits (min/max, if declared) |
Practical applications
Live PID tuning on a physical robot is the classic use of ros2 param: watch the actual speed plot with rqt_plot /odom while repeatedly entering ros2 param set /motor_node kp 2.5 to try different Kp/Ki/Kd values and immediately see the response, without restarting between attempts. Once you find the smoothest values, run ros2 param dump one final time and put that exact configuration into the production launch file's fixed YAML configuration, without remembering and retyping every number from repeated set calls.
Practical example
$ ros2 param describe /motor_node max_speed
Output:
Parameter name: max_speed
Type: double
Description: Tốc độ tối đa cho phép (m/s)
Constraints:
Min value: 0.0
Max value: 2.0
$ ros2 param set /motor_node max_speed 5.0
Output:
Setting parameter failed: Parameter 'max_speed' is out of range (max 2.0)
describe shows the valid range (0.0 - 2.0), explaining exactly why setting 5.0 is rejected — the command syntax is correct, but the value violates a constraint declared in the node's code.
Common mistakes
setis rejected because a parameter isread_only— check withros2 param describebefore suspecting the command. Some parameters (for example, hardware addresses) are deliberately locked against runtime changes.- Mistyping a parameter name during
set— ROS2 usually reports "parameter not declared" clearly, but you may mistake the call for a success if you do not read the output carefully. - A
ros2 param dumpfile has the wrong structure when reused in a launch file — the dump already contains the correct<node_name>: ros__parameters:structure, but manual edits that break YAML indentation prevent the node from reading the values correctly at launch. ros2 param loadoverwrites parameters you did not intend to change — loading a YAML file applies all of its contents, including unwanted old values for other parameters. Check the file carefully before loading it into a running robot node.
Conclusion
ros2 param provides a complete toolkit for reading, changing, backing up and restoring node configurations at runtime, especially valuable for live PID tuning on physical hardware. Always use describe to understand constraints before set, and check for a change callback if set appears ineffective. The next article covers ros2 bag — recording topic data for later replay and analysis.
Get new articles and lessons by email
When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.
Unsubscribe any time with the link in each email. See our Privacy policy.