WEBVTT

00:00.050 --> 00:05.630
In the previous section on tools and with nodes and Ros to run, you have seen that you can rename a

00:05.630 --> 00:07.310
node at runtime.

00:07.310 --> 00:11.720
Well, it's also possible to rename a topic and it's pretty simple.

00:11.720 --> 00:12.980
Let's see how to do that.

00:12.980 --> 00:19.040
So first we are going to use the Ros to run with the package name for example my pi pkg.

00:19.040 --> 00:21.950
And let's start the robot new station.

00:21.950 --> 00:25.670
What you have seen so far I'm going to put that a bit bigger.

00:25.670 --> 00:26.960
What you have seen so far.

00:26.960 --> 00:29.990
How to rename a node for example Ros.

00:30.410 --> 00:39.800
You put Ros args and then dash r and then underscore underscore node and let's name it my station okay.

00:39.830 --> 00:43.160
So you run that you see now the node is my station.

00:43.160 --> 00:46.460
So I can do Ros two node list.

00:46.610 --> 00:47.780
It's called my station.

00:47.780 --> 00:52.340
And if I do Ros two topic list.

00:52.340 --> 00:54.740
So the topic is still robot news okay.

00:54.770 --> 00:56.840
We haven't modified the topic.

00:56.960 --> 01:02.300
Now I'm going to stop and I'm going to run the command again.

01:02.390 --> 01:06.280
But this time I'm also going to rename the topic.

01:06.280 --> 01:07.390
So how to do that?

01:07.420 --> 01:13.150
Well, as I told you, you need to put Ros ARGs, but you only need to put that once.

01:13.180 --> 01:13.600
Okay.

01:13.630 --> 01:14.830
So it's already here.

01:14.860 --> 01:20.560
Then we have one remapping for the node with this underscore underscore node.

01:20.680 --> 01:23.980
To add another remapping you just add another dash R.

01:24.070 --> 01:27.940
And then here well we need to provide the name of the topic.

01:27.940 --> 01:32.200
So what is the name of the topic robot news.

01:32.200 --> 01:33.760
We don't need to provide the slash okay.

01:33.790 --> 01:37.060
It's robot news in the code here.

01:37.510 --> 01:38.200
It's.

01:38.200 --> 01:44.410
So if I go to the Python one you see we have created the robot news topic.

01:44.410 --> 01:50.890
So I put this one here and I put colon equal and I put the new name.

01:51.250 --> 01:52.510
So let's say a b c.

01:52.540 --> 01:58.750
If I press enter now I have renamed the node and also the topic.

01:58.750 --> 02:09.570
So if I do Ros two topic lists you see now we have the ABC topic Okay if I do ros2 topic equal a b c.

02:11.400 --> 02:14.520
You see, that's where we receive the data now.

02:14.580 --> 02:15.090
Okay.

02:15.120 --> 02:18.660
So when you do a remapping of the topic you can see that.

02:19.500 --> 02:25.860
So this string here when you do create publisher it's actually not fixed okay.

02:25.890 --> 02:28.350
It can be changed at runtime.

02:28.350 --> 02:35.940
So this name can be overridden at runtime with that dash R and then the name.

02:35.940 --> 02:37.680
So the previous name and the new name.

02:37.680 --> 02:43.110
So now let's for example let's run here Ros to run my.

02:43.140 --> 02:45.450
So you could run the Python one or the C plus plus one.

02:45.450 --> 02:46.440
It doesn't matter.

02:46.470 --> 02:51.450
Let's run the smartphone node which is subscribing to the robot news station.

02:51.450 --> 02:53.610
So to the robot news topic.

02:53.610 --> 02:55.860
And you see we receive nothing.

02:55.860 --> 02:56.760
Why is that.

02:56.760 --> 03:00.510
Because Ros two topic list.

03:01.080 --> 03:05.010
You see that we have the topic ABC here and we have the topic Robot news.

03:05.010 --> 03:09.110
So if we want to be able to receive the information.

03:09.560 --> 03:14.000
We are also going to do a remapping of the topic.

03:14.000 --> 03:17.300
So we do Dash, Dash, Ross, AGS.

03:17.420 --> 03:21.830
And then here I'm not going to rename the node, I'm just going to rename the topic.

03:21.830 --> 03:28.520
So Dash R robot News colon equal ABC.

03:28.790 --> 03:34.610
I press enter and you can see now we receive the data.

03:34.880 --> 03:35.360
Why.

03:35.390 --> 03:41.180
Because this is a subscriber to ABC and this is a publisher to ABC okay.

03:41.210 --> 03:47.030
So this can be very very useful because if you need to match different nodes written by different persons,

03:47.060 --> 03:52.490
or maybe you can't access the code and you can't modify the topic name in the code.

03:52.490 --> 03:56.510
Well, you just remap the topic name at runtime.

03:56.510 --> 03:57.680
And very important.

03:57.680 --> 04:01.250
Again, you only write the Ros args once.

04:01.250 --> 04:09.890
As you can see here we do two remappings, but we only write ros args once and then dash r and the remapping.
