In this section you have discovered ROS 2 parameters.

With parameters you don’t need to modify + re-compile your code for each different set of configuration. Just write your code once, and choose your settings at run-time.

Using parameters is one of the first steps to make your application more scalable.


To handle parameters:

You can also store many parameters for one or several nodes, inside a YAML param file. Then, all you need to do is load the YAML file when you start the nodes.


---


Download the complete code for this section (this is the code from all previous sections + the current one).

Now that you can set parameters for your nodes, you might wonder: what if I have to run multiple nodes, each with multiple parameters? It would quickly become really long (and error prone) to always start everything from the terminal. YAML files already help, but there’s more.

In the next section we’ll see how to solve that problem with launch files.