WEBVTT

00:00.050 --> 00:02.210
What is a Ros2 parameter?

00:02.630 --> 00:05.720
To understand Ros2 parameters, let's start with the problem.

00:05.720 --> 00:10.040
Let's come back to the camera package I used when explaining packages and nodes.

00:10.040 --> 00:13.220
Inside this package we have a camera driver node.

00:13.220 --> 00:14.870
We will focus on that node.

00:14.870 --> 00:17.660
So what does a camera driver node do?

00:17.690 --> 00:22.910
Well, it is expected to connect to a camera through a hardware interface for example USB.

00:22.910 --> 00:25.550
And then get the images from the camera.

00:25.580 --> 00:29.930
Now inside your nodes you will have some variables for settings.

00:29.930 --> 00:36.920
For example, the name of the USB device, the FPS you want to apply, and if you want to run your node

00:36.920 --> 00:39.200
in a simulation mode or not.

00:39.230 --> 00:41.510
Of course you could have many more settings.

00:41.510 --> 00:47.810
So if you want to run your camera and the USB device name is different than the one in the code, well,

00:47.810 --> 00:53.240
you have to change that setting inside your code and build the package again if needed.

00:53.240 --> 00:59.210
If you want to start your camera with 30 fps instead of 60 fps, well, you will have to change the

00:59.210 --> 00:59.990
code again.

00:59.990 --> 01:06.320
And what if you want to run the node twice, once in simulation mode for a certain camera and once in

01:06.320 --> 01:08.060
real mode for another camera?

01:08.090 --> 01:13.730
You would have to duplicate the entire code so you can see that hardcoding those settings into your

01:13.730 --> 01:16.550
code is definitely not a great option.

01:16.550 --> 01:23.660
And here comes Ros two parameters A Ros two parameter is a configuration value for a node, useful for

01:23.660 --> 01:28.480
any kind of setting, So you first need to declare those parameters in your code.

01:28.480 --> 01:32.110
And then when you start the node, you set the values.

01:32.110 --> 01:35.950
So here for example, we start the node and give some values for the parameters.

01:35.950 --> 01:42.100
When we start it with the Ros two run command in the terminal, those values will be set in the code.

01:42.100 --> 01:43.630
So the node can use them.

01:43.630 --> 01:46.180
And we will see how to do that later in this section.

01:46.180 --> 01:51.970
Now if you want you can kill that node and start it again with a different pH value for example.

01:51.970 --> 01:57.340
Or you can start another node with different settings and of course a different name.

01:57.340 --> 01:59.620
If you have two instances of the same node.

01:59.620 --> 02:04.240
And the best part of all that is that you didn't touch anything in the code of the node.

02:04.240 --> 02:07.330
You don't have to compile, you don't have to build anything.

02:07.360 --> 02:11.620
Again, you just need to provide the parameters values at runtime.

02:11.620 --> 02:18.370
So to recap Ros two parameters are used to provide settings for your nodes and you set their values

02:18.400 --> 02:19.510
at runtime.

02:19.540 --> 02:21.940
A parameter is specific to a node.

02:21.940 --> 02:28.300
It will only live while the node is alive, and two different nodes will have two different sets of

02:28.300 --> 02:28.870
parameters.

02:28.870 --> 02:29.590
Values.

02:29.620 --> 02:33.070
A Ros two parameter has a name and a data type.

02:33.100 --> 02:39.580
Among the most common types you can find booleans, integer numbers, double numbers, strings, and

02:39.580 --> 02:41.800
lists of previous data types.

02:41.830 --> 02:47.080
All right, now you are aware of what Ros two parameters are and why we need them.

02:47.080 --> 02:50.230
Let's practice by diving directly into the code.
