WEBVTT

00:00.260 --> 00:06.750
Using rotation matrices to represent the orientation of an object with the Euler angles.

00:06.770 --> 00:09.170
We need to store nine variables.

00:09.200 --> 00:12.500
The nine elements of the rotation matrix.

00:12.500 --> 00:19.970
And every time we need to compose consecutive rotations, we need to multiply two three by three matrices.

00:19.970 --> 00:25.280
And so we need to perform 27 multiplications and 18 sums.

00:26.670 --> 00:34.020
The quaternion is based on the real and imaginary numbers, and in fact it is an extension of it in

00:34.020 --> 00:37.080
the imaginary numbers we call a.

00:37.110 --> 00:41.160
The real part of the number and B the imaginary one.

00:41.670 --> 00:47.160
The quaternion is an extension of this concept and it is composed by four variables.

00:47.160 --> 00:55.560
So four coefficients that here I called A, B, C, and D, where A is the scalar part of the number.

00:55.650 --> 00:59.070
B, C and D are the vector part.

00:59.460 --> 01:05.580
Although this tool is less intuitive than the Euler angles and the rotation matrices to represent the

01:05.580 --> 01:12.570
orientation of an object, since it is not possible to draw in four dimensions, it offers several advantages

01:12.570 --> 01:17.390
that make it more efficient and therefore preferable to Euler angles.

01:17.400 --> 01:21.750
When it's time to express the orientation of an object in computer science.

01:22.910 --> 01:29.600
The first advantage is clear just by looking at the quaternion equation, it is fully described just

01:29.600 --> 01:31.020
by four components.

01:31.040 --> 01:33.620
The four coefficients of the quaternion.

01:33.620 --> 01:36.230
So the variables A, B, C, and D.

01:37.200 --> 01:38.970
One with the Euler angles.

01:38.970 --> 01:44.700
We needed nine components with the quaternion, we only need to store four variables.

01:44.940 --> 01:50.820
Furthermore, the quaternion also offered other properties that make it more efficient when it's time

01:50.820 --> 01:53.370
to manipulate and compose rotations.

01:54.000 --> 02:01.200
The first property is that the quaternion is unitary, namely, the sum of the squares of its coefficients

02:01.200 --> 02:02.430
is equal to one.

02:03.060 --> 02:09.150
The second property is that it is possible to combine two rotations, each of them represented with

02:09.180 --> 02:12.840
a quaternion simply by multiplying the two quaternions.

02:13.510 --> 02:19.600
Also, when we represent the orientation with Euler angles, it was enough to multiply two rotation

02:19.600 --> 02:22.990
matrices to compose two consecutive rotations.

02:23.170 --> 02:28.540
However, in that case we needed to calculate 27 products and 18 sums.

02:28.660 --> 02:36.610
In this case, when we multiply quaternions, we just need to calculate 16 products and nine sums.

02:37.830 --> 02:45.060
Another property of the quaternion is that the calculation of its inverse is extremely simple and actually

02:45.060 --> 02:46.640
is not even a calculation.

02:46.650 --> 02:51.330
It just needs a change of the sign of the vector part of the quaternion.

02:52.220 --> 02:57.140
The inverse of a quaternion also represents the inverse rotation of an object.

02:57.140 --> 03:00.770
And so the rotation that can sell the previous one.

03:01.680 --> 03:08.760
One can do this also with the rotation matrices and calculate the transpose of the matrix to calculate

03:08.760 --> 03:10.320
the inverse rotation.

03:10.320 --> 03:17.190
But of course, transposing a matrix is a far more expensive calculation than simply changing a sign.

03:18.160 --> 03:22.480
Because of these properties and because of its efficient representation.

03:22.480 --> 03:25.840
The quaternion is commonly used in computer science.

03:26.350 --> 03:32.890
However, as humans it is very complex for us to think about the orientation of an object in terms of

03:32.890 --> 03:39.910
quaternion, and instead it's much easier and intuitive to think in terms of Euler angles and rotation

03:39.910 --> 03:40.720
matrices.

03:41.600 --> 03:47.960
In the following laboratory lessons, we are going to use some useful tool that will let us think about

03:47.960 --> 03:54.230
the orientation in terms of Euler angles, and then we will convert this information in quaternion to

03:54.230 --> 03:55.520
be used in Ros2.
