WEBVTT

00:00.110 --> 00:03.950
To continue studying the features offered by the TF2 Library.

00:04.070 --> 00:10.160
In this lesson, we will explore some tools and nodes that are already developed and available in this

00:10.160 --> 00:17.060
library, offering additional analytical functionalities for the use and management of reference frames.

00:17.360 --> 00:22.100
To use these tools, let's start by launching the visualization of the robot in our office.

00:22.310 --> 00:25.790
So let's open a new terminal and go to the workspace.

00:25.820 --> 00:33.080
Here, let's source the file setup bash and then let's start the robot visualization in our VS.

00:33.320 --> 00:39.290
So let's launch from the Arduino bot description package.

00:39.320 --> 00:41.900
The display dot launch.

00:42.630 --> 00:45.960
So this will enable the visualization in.

00:47.310 --> 00:54.480
And now that we can correctly visualize the robot and the frames, we can use a node that is available

00:54.480 --> 01:01.780
in the TF2 library that allows us to graphically visualize the frame tree and also its connections.

01:01.800 --> 01:08.610
So if we split a terminal, so let's open a new terminal and we take a look at the list of the currently

01:08.610 --> 01:18.060
available topic in Ros2 with the command Ros2 topic list, we can see that among these topics there

01:18.060 --> 01:26.610
are DTF where the dynamic transformations are published and the TF static topic where the static transformation

01:26.610 --> 01:27.540
and published.

01:27.900 --> 01:32.070
Let's see which nodes are currently interacting with these two topics.

01:32.070 --> 01:36.980
So who is publishing this information that is then visualized in Arviz?

01:36.990 --> 01:41.520
We can use the command Ros2 Topic info.

01:41.520 --> 01:51.480
For example, let's take a look at the topic TF and let's also use the verbose flag to see the names

01:51.480 --> 01:52.560
of the nodes.

01:52.860 --> 01:59.670
So now for example, we can see that there is only one node that is publishing and this is exactly the

01:59.670 --> 02:01.380
robot estate publisher node.

02:01.380 --> 02:08.850
So the one that was reading the Urdf model of our robot was interpreting it and is publishing the respective

02:08.880 --> 02:10.020
transformations.

02:11.370 --> 02:17.310
We can also see, which are the messages that currently the robot estate publisher is publishing within

02:17.310 --> 02:25.780
the TF and the TF static topic and we can use the command Ros2 topic echo.

02:26.190 --> 02:29.640
And for example, let's read for the moment the TF topic.

02:30.360 --> 02:32.550
Let's make this one a little bigger.

02:36.360 --> 02:42.360
And so in this topic, we can see that constantly are published messages that define the position of

02:42.360 --> 02:45.690
each reference frame relative to the previous one.

02:45.780 --> 02:49.290
So let's stop this one for a moment for a little bit.

02:49.320 --> 02:52.400
In order to examine the structure of these messages.

02:52.410 --> 02:58.740
So each message that is published within the topic contains a list of transformation.

02:58.740 --> 03:01.680
So here it begins, a new message.

03:01.890 --> 03:05.310
So as we can see, it begins with an header.

03:05.310 --> 03:07.710
And so it has a list of headers.

03:07.710 --> 03:09.960
So there is a list of transformation.

03:10.200 --> 03:17.670
For example, we can see this one that expresses the transformation between the base plate and the base

03:17.670 --> 03:18.330
link.

03:18.330 --> 03:22.320
And so we can also see that here there are the rotation values.

03:22.320 --> 03:30.060
So this is basically the rotation matrix that expresses how the base plate is oriented with respect

03:30.060 --> 03:35.040
to the base link and also the translation that is the translation vector.

03:35.810 --> 03:39.470
We can see that the rotation that is representing the orientation.

03:39.470 --> 03:45.580
So this one has four components that are X, Y, Z, and W.

03:45.590 --> 03:53.480
So actually, this is because the convention that is used in TF2 library and in general in Ros2 is expressing

03:53.480 --> 03:57.920
the orientation of any two reference frames using the quaternion.

03:57.920 --> 04:01.370
And this is a topic that we will study later on in the course.

04:01.790 --> 04:09.260
For the moment, let's use another node from the TF2 Tools library that allows us to graphically visualize

04:09.260 --> 04:12.890
the frames and their connection in a tree structure.

04:13.280 --> 04:20.300
So let's use the command Ros to run and from the TF2 Tools library.

04:20.300 --> 04:24.130
Let's start the node that is called view frames.

04:24.140 --> 04:31.040
So let's press enter and this node will listen for all the frames that are published within the TF and

04:31.040 --> 04:38.370
TF static topic for a few seconds and will generate a graph that contains all the frames and also their

04:38.370 --> 04:39.330
connections.

04:39.330 --> 04:44.400
So once it finished we can see that it created two new files.

04:44.730 --> 04:47.970
So it created these two files.

04:47.970 --> 04:51.810
And also we can take a look at how this file looks likes.

04:51.810 --> 04:54.870
So let's use the evidence.

04:55.080 --> 04:59.820
And as this is a PDF, let's open it in this file.

04:59.820 --> 05:01.620
Let's zoom a little bit back.

05:01.650 --> 05:08.520
We have a simple and immediate and intuitive visualization of all the frames that are currently available

05:08.520 --> 05:09.120
in Ros.

05:09.330 --> 05:14.820
So all the frames that are published both in the TF and in the TF static topic.

05:15.880 --> 05:18.640
For example, we can see that the base link.

05:18.640 --> 05:26.620
So this one is connected to the base plate and that the note that is in charge of publishing this transformation

05:26.620 --> 05:30.130
is publishing it with a rate of ten hertz.

05:30.130 --> 05:33.450
So this is the average rate at which they are published.

05:33.490 --> 05:39.490
Also, we can see that, for example, the transformation between the word and the base link is published

05:39.490 --> 05:42.640
with an incredibly high average rate.

05:42.640 --> 05:46.450
This is because actually this is a static transform.

05:46.450 --> 05:53.500
So as you will see, all the transform that are published in the static topic in this graph will have

05:53.500 --> 05:55.750
an average rate of 10,000.

05:55.930 --> 06:02.950
Let's close this PDF and now let's take a look to another useful tool that is available in the TF2 library

06:02.950 --> 06:04.510
that is called Echo.

06:05.340 --> 06:12.310
This allows us to display the transformation matrix between any two frames in the Tree of Connections.

06:12.330 --> 06:16.470
So to launch it, let's use the command Ros to run.

06:16.680 --> 06:28.140
And from the TF2 Ros package, let's start the TF to echo Node and we need to provide to this node the

06:28.140 --> 06:33.420
names of the two reference frame from which we want to know the transformation matrix.

06:33.420 --> 06:41.850
For example, we want the one from the base link to the horizontal arm.

06:42.150 --> 06:43.980
So let's press enter.

06:43.980 --> 06:50.850
And here in the terminal we can see that the translation and the rotation values of the transformation

06:50.850 --> 06:56.880
between the two frames that we have indicated are continuously printed in the terminal at our regular

06:56.880 --> 06:58.080
time intervals.

06:58.080 --> 07:00.240
And also we can see that the rotation.

07:00.240 --> 07:09.100
So here the rotation is expressed in terms of quaternion, in terms of rpy, both in radians and in

07:09.100 --> 07:12.760
degrees, if we take a look again.

07:13.090 --> 07:15.700
So if we open again the pdf.

07:16.940 --> 07:18.530
That was created.

07:20.280 --> 07:23.610
So this one with Evans.

07:24.000 --> 07:25.770
And let's open the PDF.

07:26.640 --> 07:31.170
We can see that the two frames from which we asked to transform from.

07:31.170 --> 07:38.730
So basically the base link and the horizontal arm, this one and this one are not directly connected

07:38.730 --> 07:40.200
by a transformation.

07:40.500 --> 07:42.270
However, there is a chain.

07:42.480 --> 07:46.820
There is a chain that is connecting the base link and the horizontal arm.

07:46.830 --> 07:52.770
And this chain passes through the base plate, the forward drive arm, and then reaches the horizontal

07:52.770 --> 07:53.070
arm.

07:54.530 --> 08:00.770
This is possible because behind the scenes, the TF2 library and also all the necessary calculations

08:00.770 --> 08:07.490
to compose intermediate transformation matrices and returns the resulting transformation matrix.

08:08.520 --> 08:14.190
As long as there is a chain or a sequence of transformation matrices that connects one reference frame

08:14.190 --> 08:19.650
to another, the TF2 library can calculate the resulting transformation matrix.

08:19.860 --> 08:27.150
So basically, to solve the forward kinematic problem, it becomes as simple as running again the command

08:27.600 --> 08:36.780
TF2 ACO, and this time asking for the transformation between the world reference frame and the low

08:38.940 --> 08:40.810
support reference frame.

08:40.830 --> 08:46.950
So as we press enter, so with this, basically we are solving the forward kinematic problem.

08:46.950 --> 08:50.340
And here we can also see the full transformation matrix.

08:50.340 --> 08:57.120
So this is the rotation, this is the translation vector and this is the full transformation matrix.

08:58.260 --> 09:02.940
Also, we can see that if we take the joint state publisher.

09:02.940 --> 09:05.370
So let's take the joint state publisher.

09:05.730 --> 09:10.010
Let's keep this node running and let's move a little bit.

09:10.020 --> 09:12.330
The robot with the joint state publisher.

09:12.570 --> 09:19.560
We can see that while we move the robot, the values of the transformation are changing and so are constantly

09:19.560 --> 09:20.430
update.

09:20.610 --> 09:28.710
And so if we move the position of the joints, we are moving, of course, the position of the gripper.

09:28.710 --> 09:31.560
And so the transformation is updated.

09:31.560 --> 09:37.590
And so the transformation matrix is recalculated with the new values of the joint angles.

09:38.790 --> 09:45.150
In this way with a bit of mathematics and the help of the TF2 library, we have solved the problem of

09:45.150 --> 09:50.940
the forward kinematics and we can determine at any moment in time the position of the gripper of the

09:50.940 --> 09:52.290
robot in the space.
