Skip to content

Commit

Permalink
updated parameter management docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JMoore5353 committed Jun 18, 2024
1 parent 7e6b66f commit 739867f
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions docs/developer-guide/rosplane/parameter-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ To use the `param_manager` to define your own parameters, do the following:

1. Declare an instance of `param_manager` in your class, or ensure that a parent class has a public or protected instance of `param_manager`.
2. Initialize the `param_manager` object with a pointer to the ROS2 node object associated with the parameters.
3. Use `param_manager::declare_param(std::string <PARAM_NAME>, <PARAM>)` to declare parameters of type double, bool, or string, where `<PARAM>` is the default value for the parameter.
3. In the constructor, use `param_manager::declare_param(std::string <PARAM_NAME>, <PARAM>)` to declare parameters of type double, bool, or string, where `<PARAM>` is the default value for the parameter.
- Use `param_manager::declare_int(std::string <PARAM_NAME>, <PARAM>)` to declare an integer parameter.
4. In the constructor, use `param_manager::set_parameters()` to load any parameters that have changed on launch to the `param_manager` object.
!!! note
The `param_manager::set_parameters()` call is important when a node is loaded with parameters from a file on launch.
Not making this call will mean that the parameters stored in the `param_manager` object are out of sync with the ROS2 parameters.

These steps will register your parameters with ROS2, allowing you to change them dynamically or load them from a launch file.

Expand All @@ -52,4 +56,14 @@ This file can be loaded at launch time so that all parameters are updated with t
This means you don't have to change the default values in code (which would require a rebuild) to make sure a node gets launched with the correct values.

To do this, add the `parameters=["/path/to/parameter/file"]` to a node's launch argument.
See `rosplane.launch.py` for an example.
See `rosplane.launch.py` for an example.

## Updating Parameters
Parameters can be updated from the command line using normal ROS2 commands.
See the [ROS2 parameter CLI tools](https://docs.ros.org/en/humble/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Parameters/Understanding-ROS2-Parameters.html) documentation for more information on how to interface with these parameters from the command line.

!!! note
Be sure to create a callback for your parameter changes, especially if you use a `param_manager` object.
ROS2 will send a list of changed parameters to this callback when the parameters are changed, allowing you to update the internally stored value in the `param_manager`.
Otherwise, your internally stored values will be out of sync with the ROS2 parameters, and it will likely not function correctly.
See the `controller_base` or `estimator_base` or `path_planner` code for an example of the callbacks.

0 comments on commit 739867f

Please sign in to comment.