WEBVTT

00:00.050 --> 00:05.900
In your roster application, you may want to launch the same node multiple times, but with a different

00:05.900 --> 00:06.920
configuration.

00:06.950 --> 00:12.320
For example, if you have a node that you've written for a temperature sensor and if you have five temperature

00:12.320 --> 00:17.450
sensors, then you will want to launch the same node five times and of course with a different name

00:17.450 --> 00:18.830
for each sensor.

00:18.860 --> 00:24.590
Because what I just told you in the previous lesson is that you cannot have two nodes with the same

00:24.590 --> 00:25.160
name.

00:25.190 --> 00:26.960
Actually, let's try that first.

00:26.960 --> 00:33.080
So I'm going to run my pi node executable from the Python package in this terminal.

00:33.080 --> 00:35.810
And then I'm going to run it again in that terminal.

00:35.810 --> 00:37.040
And let's see what happens.

00:37.040 --> 00:38.360
So I run it here.

00:38.360 --> 00:39.260
It works.

00:39.830 --> 00:41.030
I run it here.

00:41.030 --> 00:42.800
And it also works.

00:42.800 --> 00:44.780
We don't have any error here.

00:44.780 --> 00:49.160
But then let's do a ros2 node list.

00:49.160 --> 00:52.190
And you see we have here a warning.

00:52.190 --> 00:58.670
Be aware that there are nodes in the graph that share an exact name, which can have unintended side

00:58.670 --> 00:59.150
effects.

00:59.180 --> 01:03.140
Okay, so you might have weird errors if you have stuff like this.

01:03.170 --> 01:06.830
Okay, so better to avoid it and how to solve that.

01:06.860 --> 01:12.740
Well, very simply you can rename the node at runtime when you start it with Ros2 run.

01:12.890 --> 01:13.100
Okay.

01:13.130 --> 01:14.150
So that's what we're going to do.

01:14.180 --> 01:19.250
So let's clear that first and how to rename a node.

01:19.250 --> 01:22.160
Well let's go back to that command Ros2.

01:22.190 --> 01:25.910
Run package name and executable name.

01:25.910 --> 01:33.680
Then we can add arguments after this command with dash dash ros dash args.

01:34.010 --> 01:34.520
Okay.

01:34.520 --> 01:37.550
So every time we add arguments we're going to see later.

01:37.550 --> 01:45.500
Also for parameters and other stuff you will first need to add ros args once only once after the ros

01:45.530 --> 01:45.860
args.

01:45.890 --> 01:50.120
Now let's do a renaming or also called a remapping.

01:50.120 --> 01:53.750
So to do that you need to provide a dash R option.

01:53.930 --> 02:02.120
And then to rename a node you need to do underscore underscore node like that colon equal.

02:02.120 --> 02:03.470
And then the new name.

02:03.470 --> 02:06.710
So for example let's name it a, b, c.

02:06.950 --> 02:11.900
Okay, so if I press enter here, you see that the node is started.

02:11.900 --> 02:14.300
But this time you see the name is ABC.

02:14.390 --> 02:21.920
If I do a ros2 node list I have ABC and I can start, for example, the other one with no renaming.

02:21.920 --> 02:26.120
And this time we have py test and ABC.

02:26.120 --> 02:29.120
So we have no name conflicts okay.

02:29.150 --> 02:33.200
And then I can do Ctrl c again here and let's come back to this.

02:33.200 --> 02:39.080
So the dash R is actually the small variation for the dash dash remap okay.

02:39.110 --> 02:42.590
So that's gonna also work okay.

02:42.620 --> 02:47.180
So you can use dash dash remap or just dash R.

02:47.210 --> 02:50.990
And here let's say that it's going to be a temperature sensor node okay.

02:51.020 --> 02:54.050
Let's imagine you have written a temperature sensor node.

02:54.050 --> 03:00.620
And let's say you want to name it temperature sensor one okay.

03:00.620 --> 03:04.400
And you're going to run that one with.

03:04.910 --> 03:16.560
So you're going to do this and then dash dash Ross AGS dash r underscore underscore node and temperature

03:16.860 --> 03:18.150
sensor two.

03:18.180 --> 03:18.570
Okay.

03:18.600 --> 03:21.210
So you can run the two like that.

03:21.210 --> 03:26.070
And you see now we have temperature sensor one and temperature sensor two.

03:26.100 --> 03:30.720
So that's an example of what you can do if you have a sensor like that.

03:30.720 --> 03:37.230
So as you can see renaming a node at runtime is quite useful because first while you don't have to change

03:37.230 --> 03:40.440
anything in the code okay, the value we have written in the code.

03:40.440 --> 03:41.970
So here it's by test.

03:42.090 --> 03:44.970
This value is not completely hardcoded okay.

03:45.000 --> 03:47.130
You can change it at runtime.

03:47.130 --> 03:52.230
So it's quite dynamic and you don't need to reinstall or recompile any code.

03:52.230 --> 03:59.010
And we're going to come back often to this Ross args and all the arguments we can add after here during

03:59.010 --> 03:59.550
this course.

03:59.550 --> 04:02.160
Because we can also rename more things.

04:02.160 --> 04:03.750
We can rename communications.

04:03.750 --> 04:07.320
So topics services etc. we can also add parameters.

04:07.320 --> 04:10.230
So we're going to come back to this all along the course.
