WEBVTT

00:00.080 --> 00:06.260
Let's experiment a bit more with topics using the total SIM package and the 2D robot simulation.

00:06.260 --> 00:08.600
So let's start by running total sim.

00:08.600 --> 00:17.240
So we use Ros to run total sim and total sim node okay.

00:17.270 --> 00:22.850
So this we have done already in the previous section that's going to start this window.

00:24.260 --> 00:31.910
Let's actually re size here so we can put the window on the side.

00:34.130 --> 00:34.670
Okay.

00:34.700 --> 00:44.750
And I'm going to start here Ros to run total SIM with total Teleop key okay.

00:44.780 --> 00:48.320
So we can you can see we can control the robot here.

00:48.320 --> 00:54.770
And so what we have guessed previously we could only guess that is that this node here is going to communicate

00:54.770 --> 00:55.700
with that one.

00:55.700 --> 01:03.110
Because if we press the keyboard here and the robot is moving, it means that this node must receive

01:03.110 --> 01:04.640
something from that node.

01:04.670 --> 01:05.780
Let's just run.

01:05.790 --> 01:10.560
our cute graph and you can see.

01:10.560 --> 01:19.770
So we have nodes and topics all here that yes the Teleop turtle is you see sending a command velocity

01:19.800 --> 01:20.580
topic here.

01:20.610 --> 01:22.290
Turtle one Cmdvel.

01:22.290 --> 01:23.160
So that's a topic.

01:23.160 --> 01:26.340
And this one is sending data to that topic.

01:26.340 --> 01:28.230
And then this one is a subscriber.

01:28.260 --> 01:32.280
We have more stuff here that we don't need to worry about that for now.

01:32.280 --> 01:35.250
But you can see this is what's interesting for us.

01:35.250 --> 01:37.020
That topic here.

01:37.020 --> 01:39.450
And that's how the two nodes communicate.

01:39.450 --> 01:40.890
So I can close that.

01:40.890 --> 01:44.310
And I can find the same information using the command line.

01:44.310 --> 01:52.260
So Ros2 node list I have my two nodes and then ros2 node info for example with the turtle sim.

01:53.460 --> 02:03.090
And you can see you can see here in the subscribers we have turtle one Cmdvel plus the type okay.

02:03.120 --> 02:05.100
So geometry message.

02:05.130 --> 02:06.030
Twist.

02:06.030 --> 02:09.600
So that's yet another package with messages okay.

02:09.630 --> 02:21.940
And if I do Ross to node info with Teleop turtle, then you can see for that one we have a publisher

02:21.940 --> 02:28.240
that's turtle one Cmdvel with the same data type, so we can find the publisher and the subscriber.

02:28.330 --> 02:34.420
Now I can also do Ross two topic list.

02:34.780 --> 02:37.540
You see we still have the parameter events and the Ross out.

02:37.540 --> 02:41.650
I told you we will always have those and we have three more topics.

02:41.650 --> 02:44.620
But the one that's interesting for us here is that one.

02:44.920 --> 02:51.370
Ross two topic info with Cmdvel.

02:52.300 --> 02:56.830
You see, we have one publisher, one subscriber, so it's the publisher and the subscriber here.

02:56.830 --> 03:05.410
And we also have the type if you want to see the exact data type of that interface, you do Ross two

03:06.250 --> 03:12.760
interface show and you just provide this and you can see here.

03:12.760 --> 03:18.380
So we have this comment, but it's a bit more complex because we have a vector three.

03:18.380 --> 03:19.520
So that's a linear.

03:19.520 --> 03:26.240
And inside this linear field we have x y and z field which are float numbers.

03:26.270 --> 03:26.780
Okay.

03:26.780 --> 03:35.210
So we have linear x linear y linear z and then angular dot x y and z.

03:35.240 --> 03:35.690
Great.

03:35.690 --> 03:38.510
And you can see that we just run those two nodes.

03:38.510 --> 03:42.470
And with our graph you could already get a good idea of what's going on.

03:42.470 --> 03:47.960
And then with the command line tools, we wrote to node and wrote to topic and also wrote to interface.

03:47.960 --> 03:53.810
You can get all the information you need so that you can then create any publisher or subscriber to

03:53.840 --> 03:54.440
that topic.

03:54.470 --> 04:00.200
Okay, you have the name, you have the interface, and you know what's inside the interface.

04:00.380 --> 04:05.720
Just as an additional as a bonus step here, I'm going to also try to publish because now we know what

04:05.720 --> 04:06.230
we have.

04:06.230 --> 04:12.020
So I'm going to publish using Ros2 topic pub.

04:12.110 --> 04:13.790
Let's say I want to publish.

04:13.790 --> 04:16.700
So Dash r I want to publish twice per second.

04:16.850 --> 04:18.230
What's the topic.

04:18.260 --> 04:23.690
The topic is Turtle one Cmdvel.

04:23.690 --> 04:24.980
What is the interface?

04:24.980 --> 04:27.650
The interface is geometry.

04:27.680 --> 04:31.730
Message twist okay, so that's all the information that we found.

04:31.730 --> 04:35.390
And then then what do we need to provide.

04:35.390 --> 04:38.630
So I'm just going to what I'm going to stop that one.

04:38.960 --> 04:49.400
And I'm just going to do this again Ros2 interface show with geometry messages and twist.

04:51.830 --> 04:52.070
Okay.

04:52.100 --> 04:53.660
So this time it's a bit more complex.

04:53.660 --> 04:57.800
So we have the double quotes and then curly brackets.

04:57.800 --> 05:01.880
And we're going to provide for example linear like this.

05:01.880 --> 05:06.980
And we need to put a colon and then another set of curly brackets okay.

05:07.010 --> 05:09.200
Because it's the linear field.

05:09.200 --> 05:12.050
But inside the linear field we have more stuff.

05:12.080 --> 05:17.690
And then I can do x and provide a value for example 1.0.

05:17.690 --> 05:22.340
So here I'm going to send the command so that the turtle can just do a circle.

05:22.340 --> 05:31.260
To do a circle we just need to send a Uh, linear x command and angular z command that are constant.

05:31.350 --> 05:31.560
Okay.

05:31.590 --> 05:33.450
Because here we are in 2D.

05:33.750 --> 05:36.660
So this is a 3D vector okay.

05:36.690 --> 05:42.660
And just to keep things simple here, well x just means that we are going to go forward and backward.

05:42.660 --> 05:47.430
So we only need to go forward and backward and then to make it rotate on itself.

05:47.460 --> 05:47.940
Okay.

05:47.940 --> 05:53.970
We are not going to flip the turtle on the y axis in 3D because what here doesn't exist.

05:53.970 --> 05:56.910
And we cannot also elevate the turtle here.

05:56.910 --> 05:59.580
So the y and z axis don't exist.

05:59.580 --> 06:03.870
And for the angular rotation the x and y rotation also don't exist.

06:03.870 --> 06:06.270
It's only the z rotation.

06:06.300 --> 06:09.330
Okay I'm going to come back to this in the final project.

06:09.360 --> 06:12.600
I'm going to explain also the right hand rule if you don't know that.

06:12.600 --> 06:15.240
So there will be more explanation in the final project.

06:15.240 --> 06:20.310
For now you just have to know that if you want to to move the turtle, you just need to provide the

06:20.310 --> 06:22.290
linear X and the angular Z.

06:22.290 --> 06:28.650
And if you omit some fields, it's okay because the default value is simply going to be zero.

06:28.650 --> 06:32.680
So I can just put x x1 and then after this one.

06:32.680 --> 06:40.360
So I have linear x1 I'm going to put angular and then like that.

06:40.360 --> 06:45.490
So you see it starts to be a bit more complicated as you have a more complex interface.

06:45.490 --> 06:47.860
And I'm going to put Z.

06:48.010 --> 06:55.120
So actually inside the if I change the side here like that okay.

06:55.600 --> 06:58.210
So Z let's say 1.0.

06:58.240 --> 06:58.810
All right.

06:58.810 --> 07:04.540
So make sure you correctly open and close all the curly brackets because it can be a bit tricky.

07:04.540 --> 07:06.850
And with this we should press enter.

07:06.850 --> 07:08.500
And it should work.

07:09.340 --> 07:11.200
You see now the turtle is moving.

07:11.740 --> 07:13.930
It should move in a circle okay.

07:14.050 --> 07:17.950
And if I press ctrl C it's going to stop.

07:17.980 --> 07:18.550
All right.

07:18.550 --> 07:23.530
And so what happened here is that I created a publisher directly from the terminal.

07:23.530 --> 07:28.750
And because I have a subscriber already here, then this node with the subscriber is going to receive

07:28.750 --> 07:30.280
the data from the publisher.

07:30.280 --> 07:32.620
And then here it's going to make the turtle move.

07:32.620 --> 07:35.170
And we can easily see that it's working.
