WEBVTT

00:00.140 --> 00:06.320
In this laboratory lesson, we will see how to start the simple parameter node and how to use the two

00:06.410 --> 00:12.260
command line interface to interact with the parameters of a node allowing us basically to read them

00:12.260 --> 00:16.760
from the terminal or even to change their values during the execution.

00:17.930 --> 00:18.290
To do.

00:18.290 --> 00:26.720
So let's start by opening a new terminal and go into the workspace and let's source the file setup dot

00:26.720 --> 00:32.720
bash that is in the source folder, that is in the install folder so that the packages that we created

00:32.720 --> 00:37.550
in this workspace are recognized and we can execute them from this terminal.

00:38.030 --> 00:42.260
So let's start by running our simple parameter node with the command.

00:42.260 --> 00:49.070
Ross to run and then I'm going to launch the C plus plus implementation of the simple parameter node.

00:49.070 --> 00:54.050
So I'm going to launch the one from the Arduino, but CP examples.

00:54.050 --> 01:00.530
But if you want to launch the Python one, you need to launch it from the Arduino dot pi examples.

01:00.530 --> 01:06.380
And from this one we can see that there is the simple parameter executable available.

01:06.830 --> 01:12.170
So let's execute this simple parameter node and let's press enter.

01:12.170 --> 01:19.830
And now our node is up and running and so we can actually see and we can check that actually the parameters

01:19.830 --> 01:21.390
of the node are available.

01:21.390 --> 01:27.000
So the node has two parameters and let's check that those are available with the command.

01:27.120 --> 01:29.910
Ros two param a list.

01:30.750 --> 01:38.190
Just as the Ros2 Topic list command provides a list of all the currently available topics in Ros2.

01:38.370 --> 01:45.000
The Ros2 Param List command provides a list of all the parameters that are available for each node.

01:45.030 --> 01:50.670
In this case, we can see that there is only one node active, so the simple parameter node.

01:50.670 --> 01:58.230
And we can also see that apart from some parameters that were instantiated by default so that ros2 is

01:58.230 --> 02:03.320
passing by default to each node that are the quality of service parameters.

02:03.330 --> 02:08.750
We can also see that there are two more parameters and those are the two ones that we have declared.

02:08.760 --> 02:12.690
So the simple int parameter and the simple string parameter.

02:13.110 --> 02:22.050
We can see the values that are associated with these parameters with the command Ros2 param get followed

02:22.050 --> 02:26.010
by the name of the node from which we want to read the parameters.

02:26.010 --> 02:31.990
And so let's read those of the simple parameter node and followed by the name of the parameter that

02:31.990 --> 02:33.070
we want to read.

02:33.100 --> 02:39.490
For example, let's take the simple int parameter and let's press enter.

02:39.490 --> 02:42.700
And as we can see its value is 28.

02:42.700 --> 02:46.240
So it is an integer and its value is 28.

02:46.240 --> 02:50.620
And this is exactly the default value that we assigned to the parameter.

02:50.620 --> 02:56.350
Since when we started the node, we haven't passed any parameter to the node.

02:56.890 --> 03:04.150
Now, if we stop the execution of the node and this time we restart it, but passing a different value

03:04.150 --> 03:07.110
to the simple int parameter.

03:07.120 --> 03:12.190
And so we can do this with the Ros arcs.

03:12.190 --> 03:24.130
And then let's use the flag minus P to pass a new parameter and let's set the simple int param to be

03:24.280 --> 03:26.260
30 this time for example.

03:26.260 --> 03:28.060
So let's press enter.

03:28.060 --> 03:34.510
And now this means that we are starting the simple parameter node, assigning a value to the simple

03:34.510 --> 03:35.410
int parameter.

03:35.680 --> 03:40.390
Here there is an error, so it should be simple int parameter.

03:40.420 --> 03:41.530
Okay, perfect.

03:41.860 --> 03:48.400
And so we basically with this new value 30 it is overriding the default value that was here.

03:48.400 --> 03:57.380
28 And so if we launch again the Ros two param get on the simple int parameter actually we can see that

03:57.380 --> 03:59.060
its value is 30.

04:00.650 --> 04:08.090
Not only we can change our parameter by relaunching the node, so here we add to restart the node to

04:08.090 --> 04:10.670
assign a value to the simple int parameter.

04:10.700 --> 04:13.910
We can also do so while the node is running.

04:14.000 --> 04:17.870
For example, let's do this with the simple string parameter.

04:18.020 --> 04:27.110
First, let's read its current value with the Ros two param get and from the simple parameter let's

04:27.110 --> 04:31.550
read the simple string parameter.

04:32.570 --> 04:36.560
And now for the moment, we can see that the value is Antonio.

04:36.590 --> 04:42.950
That is a string and is exactly the default value that we assigned to this parameter in the code.

04:43.250 --> 04:51.350
And now to change its value, we can use the command ros2 param set still followed by the name of the

04:51.350 --> 04:54.020
node of which we want to change the parameters.

04:54.440 --> 04:59.720
That is the simple parameter followed by the name of the parameter that we want to change.

05:00.170 --> 05:06.200
And so the simple string parameter.

05:06.200 --> 05:08.660
And then we need to assign a new value.

05:08.660 --> 05:12.170
And so as this is a string, let's print for example.

05:12.170 --> 05:18.380
So let's change its value to I ros two and let's press enter.

05:19.070 --> 05:24.950
As soon as we do so, we can see here that our node so the simple parameter gets notified.

05:24.950 --> 05:33.150
So the callback function gets called and we can see that the new value so it is printing the new value

05:33.150 --> 05:40.080
of the simple string parameter that is the string Ros that we have just assigned to this parameter.

05:40.080 --> 05:47.550
And also if we use for example, the Ros two param get again, we can see that the value of the parameter

05:47.550 --> 05:49.530
is not anymore the string.

05:49.530 --> 05:52.680
Antonio but is the string I Ros two.

05:53.610 --> 06:00.660
The Aroostook Command line interface also offers many other commands to interact with the parameters

06:00.660 --> 06:05.130
and you can see the list of them by typing ros2 param.

06:05.340 --> 06:10.020
And then if you use Tab twice you can see the list of all the commands.

06:10.020 --> 06:17.700
So the list of the available commands that you can use to interact with the parameters of a node.

06:17.850 --> 06:24.390
I encourage you to try out some of these as they are quite self explicative and they will help you to

06:24.390 --> 06:27.840
better understand how the parameter works in Ros to.
