ros-tooling/generate_parameter_library
Declarative ROS 2 Parameters
What it solves
ROS 2 nodes need to declare, read, validate, and sometimes dynamically update their parameters. Writing this boilerplate by hand is tedious and error-prone. This project generates all of that code automatically from a simple YAML description, so you get consistent, validated parameter handling without duplicating logic.
How it works
You write a YAML file that describes each parameter: its type, default value, description, and validation rules (like bounds or allowed values). The build system reads that file and generates either a C++ header with a struct or a Python module. At runtime, a generated ParamListener class declares the parameters on your node, fetches their values, and validates them. If anything is invalid or a required parameter is missing, an exception is thrown. You then call get_params() to get a snapshot struct (or object) with all values, easily accessed as nested fields. For dynamic parameters, you can check if any changed or attach a callback that fires on each update.
Who it’s for
This is for ROS 2 developers who want to manage node parameters in C++ or Python without writing repetitive code. It suits both simple setups and more complex ones that need custom validation, nested parameter structures, or parameter maps keyed by other parameters.
Highlights
- Write parameters in clean YAML; get C++ or Python code automatically.
- Built-in validators: bounds, one_of, unique, size, not_empty, and more.
- Custom C++ validators can be added and referenced in YAML.
- Dynamic parameter updates are easy with a simple
is_old()check or a user callback. - Automatically generate parameter documentation for your node.
Related
- Project
- Project
- Project
- Project