WEBVTT

00:00.080 --> 00:06.140
In this lesson, we will experiment with turtle SIM so you can practice more with parameters and discover

00:06.140 --> 00:08.570
more command line tools for ros2 params.

00:08.570 --> 00:14.870
It's also a good opportunity to see how you can interact with parameters from existing nodes, where

00:14.870 --> 00:16.370
you don't have access to the code.

00:16.370 --> 00:18.500
So let's start turtle sim here.

00:18.530 --> 00:24.440
Ros to run turtle sim and turtle sim node.

00:24.470 --> 00:25.760
I just need that one.

00:25.760 --> 00:29.480
We want run the Teleop turtle just that one.

00:29.480 --> 00:33.920
And then in that terminal I'm going to run Ros two param list.

00:33.920 --> 00:39.680
So we've already seen that command is going to list all of the parameters for actually all of the nodes.

00:39.680 --> 00:42.800
So you can see we have the turtle SIM node here.

00:42.800 --> 00:46.640
If I do Ros two node list you see we have turtle sim.

00:46.640 --> 00:51.290
So for each node you will get the name of the node and then a colon.

00:51.290 --> 00:53.090
And then you have all the parameters.

00:53.090 --> 00:56.030
So you might see some that we've already seen before.

00:56.060 --> 00:59.840
For example use SIM time start type description service.

00:59.840 --> 01:03.800
Those parameters will exist for all the nodes that you start.

01:03.800 --> 01:08.930
And then we also have this shows Cuz of the rights that we have seen in the C plus plus node.

01:08.930 --> 01:11.360
So basically those parameters.

01:11.390 --> 01:15.650
Well, we exist for almost every node and we can just ignore them for now.

01:15.650 --> 01:22.010
And we can see that in the application in the code itself we have those four parameters okay.

01:22.040 --> 01:22.700
Background.

01:22.730 --> 01:23.750
B background.

01:23.780 --> 01:25.100
G background.

01:25.130 --> 01:30.560
Uh so that's going to be basically to set the background color with a red, green and blue.

01:30.560 --> 01:37.700
And also that one now well once we have all those parameters how can you get the value for one parameter.

01:37.700 --> 01:41.000
Well you have the Ros2 param get.

01:41.000 --> 01:43.010
And you need to provide two things.

01:43.010 --> 01:44.630
First the name of the node.

01:44.630 --> 01:47.810
So the name of the node is slash turtle sim.

01:47.810 --> 01:50.090
And you can use the autocompletion of course.

01:50.090 --> 01:53.270
And then you need to provide the name of the parameter.

01:53.270 --> 01:55.820
So let's say I want that one.

01:56.180 --> 02:02.870
So ros2 get name of the node, the complete name including the slash here, and the name of the parameter.

02:04.040 --> 02:06.800
And you can see we have first the type.

02:06.800 --> 02:12.190
It's an integer value is and you can see it's 86.

02:12.220 --> 02:14.470
Let's do the same thing with the B.

02:14.590 --> 02:17.680
And so the blue and the red.

02:19.270 --> 02:21.580
So you can see we have a red green.

02:21.580 --> 02:26.920
So we have an RGB value for the screen for the background of the screen.

02:26.920 --> 02:31.360
And it seems that it's a number between 0 and 255.

02:31.360 --> 02:34.540
And with this you can see the default values for the parameters.

02:34.540 --> 02:37.870
So actually it means you can modify the value.

02:37.900 --> 02:41.410
You can modify the background color when you start talking.

02:41.440 --> 02:47.350
And by default if you don't provide any parameter, well those values are going to be used because it's

02:47.350 --> 02:52.000
probably what has been declared as default values in the code.

02:52.030 --> 02:54.340
Now let's stop this.

02:54.340 --> 02:55.510
Let's run again.

02:55.540 --> 03:01.660
Let's do ros args, then dash p and let's provide one parameter value.

03:01.660 --> 03:05.500
For example, let's set the background value to zero.

03:05.500 --> 03:10.690
So background underscore b is equal to zero.

03:10.690 --> 03:15.130
If I do this it means that I'm only going to change that parameter here.

03:15.130 --> 03:15.820
And the rest.

03:15.850 --> 03:19.000
So the two other ones will stay at their default values.

03:19.030 --> 03:21.430
I could change all three if I wanted to.

03:22.630 --> 03:25.600
And you can see now the color is completely different.

03:25.630 --> 03:28.330
Well, because I have removed the blue part.

03:28.360 --> 03:34.360
Now if I do so the r you see is still the same.

03:35.230 --> 03:38.140
And then the green is still the same.

03:38.890 --> 03:43.030
And the blue now is zero.

03:43.060 --> 03:45.100
You can see it was 255.

03:45.130 --> 03:47.050
But then I provided a value.

03:47.050 --> 03:48.670
So now it's zero.

03:48.670 --> 03:49.330
And then what.

03:49.330 --> 03:51.610
You can also add another dash.

03:51.640 --> 03:54.850
Be back ground.

03:55.990 --> 03:57.220
Let's say r.

03:58.030 --> 04:00.280
Let's put this one to I don't know 200.

04:00.580 --> 04:03.040
And you can see we have yet another color.

04:03.040 --> 04:08.200
So you can basically choose any color you want with any combination of red, green and blue.

04:08.200 --> 04:13.570
And you can see that's very useful because first of all we didn't need to compile any code again.

04:13.570 --> 04:17.800
And secondly, we actually didn't even need to check the code.

04:17.800 --> 04:19.450
We don't know what's the code of turtles.

04:19.630 --> 04:21.400
We just know they have parameters.

04:21.400 --> 04:24.130
And with those two param lists we can see the list.

04:24.160 --> 04:25.960
We can then get their values.

04:25.960 --> 04:32.020
And we can basically know what we need to provide so that we can start the same node, but with a different

04:32.020 --> 04:32.980
configuration.

04:33.010 --> 04:38.740
Now there is one more thing I'm going to come back to if I do Ros2 service list.

04:38.770 --> 04:40.570
If I list the services.

04:40.810 --> 04:43.360
So those are all the services from the same node.

04:43.390 --> 04:43.660
Okay.

04:43.780 --> 04:45.130
This is just one node.

04:45.130 --> 04:52.720
And you can see that we have all those services, most of them actually using you see parameter stuff.

04:52.720 --> 04:56.680
So I told you that those are services to interact with the parameter functionality.

04:56.710 --> 04:59.710
And now that we are there let's actually see what it is.

04:59.710 --> 05:04.450
So you have a service for example list parameters.

05:05.260 --> 05:12.580
Let's do Ros2 service type to see what is the type of this parameter.

05:13.210 --> 05:17.590
The type is what RCL interfaces service list parameter.

05:17.590 --> 05:20.860
So that's yet a new package that we haven't used yet.

05:20.860 --> 05:32.770
We can do Ros2 interface show with that one and what you see quite a lot of stuff, but basically what

05:32.770 --> 05:38.020
you can just provide an empty request and it's going to return the name.

05:38.020 --> 05:39.730
So the list of all parameters.

05:39.730 --> 05:51.670
So if I do Ros2 service call, the name was turtle sim slash list parameters.

05:51.760 --> 05:58.810
If I forgot to type I just press tab twice I see RCL, so I type RCL okay.

05:58.810 --> 06:02.290
And then I'm just going to omit the request here.

06:03.610 --> 06:10.210
And you see we have a request and the response you see list parameters and we see the background B background

06:10.240 --> 06:12.010
g background R okay.

06:12.040 --> 06:14.890
So you can also use those services.

06:14.890 --> 06:20.620
And that's going to do the same thing as Ros2 param list in this case.

06:21.850 --> 06:24.670
Now you might think why do you want to use those services.

06:24.670 --> 06:26.710
It's much easier with the command line.

06:26.710 --> 06:29.860
Well that's true if you are using the terminal.

06:29.890 --> 06:35.490
But let's say you want to interact within a node with the parameters of another node.

06:35.490 --> 06:39.930
Then you can use the service so you know what's the name of the service.

06:39.960 --> 06:44.370
You know, what's the interface you have seen previously how to create a service client.

06:44.370 --> 06:50.160
So then if you ever want to interact with the parameters of a node from another node, you could do

06:50.160 --> 06:53.370
that using those services here.

06:53.370 --> 06:56.520
So Ros2 service list.

06:56.550 --> 07:03.060
You see we have services for each node so you can interact programmatically with the parameters.

07:03.060 --> 07:06.180
So I just mentioned this here quite quickly.

07:06.180 --> 07:09.960
You will actually not really need to use that that often okay.

07:09.990 --> 07:11.910
I basically almost never use it.

07:11.910 --> 07:16.530
So I would say it's not the most important thing to focus at the beginning, but it's good to know that

07:16.530 --> 07:17.370
you can do that.

07:17.400 --> 07:17.820
All right.

07:17.820 --> 07:23.100
So that's going to be it for the tutorial and parameters I encourage you to practice a bit more okay.

07:23.130 --> 07:27.270
To run the node with different parameters, try different values.

07:27.270 --> 07:33.150
Maybe try to call some of the service here to get, maybe get some parameters and then see the values

07:33.150 --> 07:34.410
for all those parameters here.

07:34.410 --> 07:36.930
Well, you can experiment a bit more on your own.
