WEBVTT

00:00.460 --> 00:08.410
In this laboratory lesson, we will use some tools from the TF2 library in Ros2 to create a Python service

00:08.410 --> 00:15.700
server that converts the orientation of an object from its quaternion representation to Euler angles,

00:15.700 --> 00:17.140
and vice versa.

00:17.590 --> 00:20.500
This service can be useful throughout the course.

00:20.500 --> 00:27.070
Whenever you want to know the Euler angles corresponding to a given quaternion, or also vice versa.

00:27.520 --> 00:32.250
Let's create this new tool within a new package in our workspace.

00:32.320 --> 00:39.550
So let's navigate to the workspace and then to the source folder in which we have already created several

00:39.550 --> 00:44.620
packages, and which contains the functionalities that we developed for the robot so far.

00:44.620 --> 00:46.750
And here let's create a new package.

00:46.750 --> 00:53.980
So with the command Ros2 package create let's use as a build type.

00:54.610 --> 00:56.440
Amend CMake.

00:56.440 --> 01:01.240
Since we will be including both Python and C plus plus code in this package.

01:01.240 --> 01:10.150
So let's use CMake as build type and let's name this package Arduino bot utils.

01:10.150 --> 01:13.300
So let's press enter to create this package.

01:13.300 --> 01:15.220
And now back to the workspace.

01:15.220 --> 01:23.110
Let's build the workspace so we can build in order for us to recognize also the newly created package.

01:23.110 --> 01:25.690
So the Arduino bot utils package.

01:27.320 --> 01:30.050
Now we can go back to Visual Studio Code.

01:30.260 --> 01:35.570
And so here we can see that in our workspace there is the Arduino bot utils package.

01:35.960 --> 01:42.350
And conventionally, as we are going to write Python code, this should be placed in a folder within

01:42.350 --> 01:45.860
the package that has the same name of the package itself.

01:46.100 --> 01:52.760
Normally in the previous laboratory lessons, when we developed some Python code, this folder was automatically

01:52.760 --> 01:55.700
created by the build type amend Python.

01:55.820 --> 02:01.610
And so here, for example, for the Arduino Pi examples, we can see that the Arduino bot Pi examples

02:01.610 --> 02:05.870
sub folder was automatically created by the build type that we choose.

02:06.110 --> 02:13.130
Anyway, as for the Arduino bot utils, we are going to include both C plus plus and Python script within

02:13.130 --> 02:14.120
the same package.

02:14.120 --> 02:22.550
So within the Arduino bot utils package we choose cmake as build type and so this is not created automatically.

02:22.550 --> 02:26.210
The folders that we need in order to develop Python code.

02:26.210 --> 02:32.660
So let's start by creating a new folder that is called Arduino bot utils.

02:32.660 --> 02:39.440
And within this folder let's create a new Python file called init dot pi.

02:39.440 --> 02:43.160
And for the moment we can leave this file empty.

02:43.400 --> 02:46.460
And now let's create another Python file.

02:46.460 --> 02:48.260
So the actual node.

02:48.260 --> 02:51.140
So the script that will contain the actual logic of the node.

02:51.440 --> 02:55.790
And so here let's name this one angle.

02:57.830 --> 03:00.080
Conversion dot pi.

03:00.560 --> 03:01.130
Here.

03:01.130 --> 03:05.450
To start the script we need to declare the Python interpreter directory.

03:05.450 --> 03:14.990
Since the CMake build type that we used cannot automatically locate it, so it can be found under the

03:14.990 --> 03:15.920
user.

03:17.130 --> 03:20.220
Been environment.

03:20.220 --> 03:23.160
And the Python version that we are using is Python three.

03:23.310 --> 03:26.520
So Python three.

03:27.340 --> 03:34.030
Now we can proceed as usual in order to create a new two node in which we can instantiate two service

03:34.030 --> 03:41.440
server one will be used for the conversion from quaternion to Euler angles, and the second one will

03:41.440 --> 03:48.130
be used for the conversion between Euler angles to quaternion instead of rewriting the code that we

03:48.130 --> 03:49.210
are already familiar with.

03:49.240 --> 03:55.660
So, for example, the one of the service servers, we can copy directly the contents of the simple

03:55.660 --> 04:00.160
service server that we implemented in the Arduino Pi examples.

04:00.160 --> 04:03.880
And so this script is called the simple service server dot Pi.

04:03.880 --> 04:10.480
So we can copy all the content of this file and we can paste it here.

04:11.050 --> 04:12.880
Let's change the name of the class.

04:12.880 --> 04:18.490
And so let's name this one angles converter.

04:19.450 --> 04:21.990
And then let's also call the node.

04:22.000 --> 04:24.190
So this one angle.

04:26.320 --> 04:27.280
Conversion.

04:29.650 --> 04:31.090
Service server.

04:31.330 --> 04:35.590
And then we need to create two instances of a service server.

04:35.590 --> 04:38.800
So we can copy this instruction here.

04:39.130 --> 04:45.130
And we can paste it below in order to start this node and make it create a new service server.

04:45.930 --> 04:47.340
Let's call the first one.

04:47.340 --> 04:51.300
So this one Euler two.

04:54.110 --> 04:55.010
Quaternion.

04:55.400 --> 05:03.800
And the second one, as you might imagine, quaternion to Euler.

05:04.250 --> 05:05.510
And so the first one.

05:05.510 --> 05:11.960
So the variable Euler to quaternion contains an implementation of a service server that we can call

05:11.990 --> 05:13.550
Euler to quaternion.

05:13.550 --> 05:15.320
So let's copy this one.

05:15.710 --> 05:19.370
And also the name of this server will be Euler to quaternion.

05:19.370 --> 05:25.400
So all the other Ros to nodes and application that want to use this service have to contact it.

05:25.400 --> 05:29.840
So I have to send a request to this service called Yola to quaternion.

05:29.840 --> 05:36.080
And the second one as you might imagine, let's call it quaternion to Euler.

05:36.650 --> 05:40.130
Let's also change the name of the callback function.

05:40.130 --> 05:51.950
So in this case for the Euler to quaternion, the function is the Euler to quaternion callback, and

05:51.950 --> 06:01.790
in the second case we want to execute the quaternion to Euler callback function.

06:01.790 --> 06:08.840
So these are the names of the two callback functions that will be executed when we call the Euler to

06:08.840 --> 06:11.510
quaternion or the quaternion to Euler.

06:11.780 --> 06:15.800
So here let's also change the message that we are printing in the console.

06:15.800 --> 06:19.790
And let's simply say angle.

06:22.190 --> 06:28.610
Conversion services are ready so that we know that both of these services are ready.

06:29.580 --> 06:33.030
Now let's start by defining the callback functions.

06:33.180 --> 06:37.990
So here the one that was called service callback in the example.

06:38.010 --> 06:45.130
Let's name it Yolov2 quaternion and it still receives a request message and our response message.

06:45.150 --> 06:50.760
So for the moment let's leave the content empty.

06:50.910 --> 06:53.100
And let's also define the second one.

06:53.970 --> 06:55.770
So let's define the.

06:56.690 --> 06:59.150
Quaternion to Euler callback.

06:59.270 --> 07:04.580
So this one, and also in this case it receives a request and response message as.

07:04.580 --> 07:05.480
These two are.

07:05.480 --> 07:07.790
Callback function of a service server.

07:08.630 --> 07:12.990
Before moving on to define the logic of the two callback functions.

07:13.010 --> 07:18.200
As you might remember, we have to define the communication interface that the two services use.

07:18.230 --> 07:25.820
That is how the request and response messages are structured for the interaction with these two servers.

07:26.150 --> 07:33.080
We can define these interfaces as we did in the previous lessons in the Arduino bot messages package.

07:33.080 --> 07:38.210
So this package in which we are inserting all the two message interfaces.

07:38.210 --> 07:44.640
And so in the SRV folder in which we have already created the add two interface.

07:44.660 --> 07:54.320
Let's create a new file and let's call this one angular two quaternion dot.

07:56.480 --> 08:02.480
And here let's start by defining the request message of the server.

08:02.480 --> 08:05.630
So the client will send this request message.

08:05.630 --> 08:08.590
And this should contain three Euler angles.

08:08.720 --> 08:12.650
So the three Euler angles that we want to convert into a quaternion.

08:12.650 --> 08:16.060
And so all of these three are decimal numbers.

08:16.070 --> 08:18.500
So let's use float 64.

08:18.710 --> 08:20.150
And these are the roll.

08:23.490 --> 08:24.210
The pitch.

08:26.450 --> 08:28.820
And the yo angles.

08:29.150 --> 08:31.930
And then let's also define the response message.

08:31.940 --> 08:34.310
So let's separate with three dashes.

08:35.390 --> 08:37.790
Let's define the response message.

08:37.790 --> 08:40.730
And this one will contain the converted quaternion.

08:40.730 --> 08:46.310
So this should contain the four elements of the quaternion that are the result of the conversion.

08:46.310 --> 08:48.950
And also these four are decimal numbers.

08:49.220 --> 08:51.950
So let's still use float 64.

08:51.950 --> 08:55.640
And let's call this 1XY.

08:59.960 --> 09:00.470
That.

09:02.050 --> 09:02.740
N.W..

09:03.190 --> 09:11.110
And so this is what we need for the service user to quaternion to convert the Euler angles that we receive

09:11.110 --> 09:15.280
in input in the quaternion that we want to provide as output.

09:15.400 --> 09:17.440
Let's create also the second interface.

09:17.440 --> 09:21.550
So the one for the communication with the quaternion to Euler service.

09:21.550 --> 09:22.270
So still.

09:22.270 --> 09:30.070
Here let's create a new file called quaternion to user dot serve.

09:30.550 --> 09:33.400
And here in the request message.

09:36.920 --> 09:42.890
And this contains the four elements of the quaternion that we want to convert into Euler angles.

09:43.040 --> 09:51.650
So we can, for example, copy the response message of the Euler to quaternion and paste it here.

09:52.040 --> 09:54.770
Then let's also define the response message.

09:57.480 --> 10:02.600
And this should contain the three Euler angles that are the result of the conversion.

10:02.610 --> 10:07.890
So once again let's copy the three Euler angles.

10:07.890 --> 10:09.330
So roll, pitch and yaw.

10:09.810 --> 10:16.770
And with this we have finished with the definition of these two message interfaces with the two service

10:16.770 --> 10:17.400
server.

10:17.880 --> 10:23.060
Finally, we need to make these messages recognized and compiled in Ros two.

10:23.070 --> 10:26.430
And so we need to add them to the cmake list dot.

10:26.430 --> 10:29.880
TXT file of the Arduino bot messages package.

10:29.880 --> 10:35.090
So here what we have already defined the add two service.

10:35.100 --> 10:39.900
Let's define a new service that is the Euler.

10:40.910 --> 10:41.330
To.

10:43.940 --> 10:56.510
quaternion.sv and then another service that is the quaternion to euler.sv.

10:57.050 --> 10:58.790
Let's save this file.

10:59.210 --> 11:06.920
And now before using these two interfaces within our angle conversion service, let's open a new terminal.

11:07.560 --> 11:15.930
And let's go to the workspace and let's build it so that the new interfaces are also built and compiled

11:15.930 --> 11:17.940
and are recognized in Ros two.

11:17.970 --> 11:20.940
And so we can start using them in our nodes.

11:20.940 --> 11:23.670
So in our angle conversion node.

11:23.820 --> 11:27.600
So once this is done we can go back to Visual Studio Code.

11:27.600 --> 11:30.470
And here we can start using the interfaces.

11:30.480 --> 11:37.650
So this time still from the Arduino but messages package from the SRB folder instead of the Arduino.

11:37.830 --> 11:49.590
Let's import the Euler to quaternion and also the quaternion to Euler.

11:50.400 --> 11:52.020
Let's use the first one.

11:52.020 --> 11:54.630
So the Euler to quaternion interface.

11:54.630 --> 11:58.710
In order to define the interface with the first service server.

11:58.710 --> 12:01.710
So the one that we called Euler to quaternion.

12:01.710 --> 12:05.520
And then let's use the second one to define the second interface.

12:05.670 --> 12:10.110
So here the one with the service quaternion to Euler.

12:10.650 --> 12:14.010
Now we can proceed to define the two callback functions.

12:14.010 --> 12:18.090
So the one that will contain the logic for the orientation conversion.

12:18.770 --> 12:24.800
Let's start with the logic for the conversion between Euler angles into a quaternion.

12:24.920 --> 12:31.400
So in the Euler to quaternion callback function, let's first print a message in the terminal.

12:32.210 --> 12:46.730
So with the get logger function, let's print an informative message that says requested to convert

12:47.570 --> 12:53.510
to Euler angles, and then let's print the value of the Euler angle that was requested.

12:53.540 --> 12:56.510
So overall this is a floating number.

12:56.550 --> 12:58.670
Then pitch.

13:00.800 --> 13:01.670
Then you.

13:05.730 --> 13:08.670
And we want to convert this one into a.

13:10.840 --> 13:11.290
Quaternion.

13:12.080 --> 13:19.340
And so let's print then the value of the angles roll pitch and yaw that we want to convert.

13:19.340 --> 13:24.010
And so we can access to these values within the request message.

13:24.020 --> 13:25.880
So let's take the roll.

13:27.080 --> 13:31.460
Then still from the request message, let's take the pitch.

13:33.740 --> 13:37.700
And the you to perform the actual conversion.

13:37.730 --> 13:43.220
We can use a package available in Ros two called TF transformations.

13:43.700 --> 13:51.230
However, we first need to install it in our system and so to do so let's open a new terminal and let's

13:51.230 --> 14:00.170
execute the command sudo apt get install ros followed by the Ros two version that you are using.

14:00.170 --> 14:05.930
So in my case it is humble followed by the name of the package that is the TF.

14:08.360 --> 14:12.920
Train transformations.

14:13.130 --> 14:14.870
So let's press enter.

14:21.180 --> 14:26.850
And this is installing the transformation module for Roscoe Ambel.

14:27.330 --> 14:33.090
Then let's also install another Python library that is called transforms 3D.

14:33.480 --> 14:35.730
And we can install this one with pip.

14:35.730 --> 14:40.980
So the Python package manager with sudo pip three.

14:41.010 --> 14:45.450
Since we are using Python three and let's install.

14:47.840 --> 14:49.220
Transforms.

14:50.650 --> 14:51.090
3D.

14:52.210 --> 14:55.380
Now we can go back to the angles converter node.

14:55.390 --> 14:57.250
So let's close the terminal.

14:57.430 --> 15:02.290
And now we can start using these modules that we have just installed.

15:02.530 --> 15:15.820
So from the TF transformations module let's import the quaternion from Euler function.

15:15.820 --> 15:17.440
And let's use this function.

15:17.440 --> 15:22.270
So the quaternion from Euler within the Euler to quaternion callback.

15:22.270 --> 15:23.590
So here.

15:24.190 --> 15:26.740
So let's call this function.

15:26.740 --> 15:30.910
And this function takes as input the three Euler angles.

15:30.910 --> 15:34.420
So the three variables that we received in the request message.

15:34.420 --> 15:42.170
So request roll request pitch and request your.

15:43.650 --> 15:50.610
This is your story, and it returns the four coefficient of the quaternion, which we can store directly

15:50.610 --> 15:55.500
in the x, y, z and w variables of the response message.

15:55.650 --> 15:59.700
So let's store this one within the response message.

15:59.700 --> 16:05.130
So let's store the x variable then the y variable.

16:06.260 --> 16:12.500
Then the z variable and then the w, so the four coefficients of the quaternion.

16:12.590 --> 16:16.970
Let's finally print also another message in the console in the terminal.

16:20.420 --> 16:32.360
So an informative message that says corresponding quaternion and then the four values so x.

16:35.020 --> 16:35.800
Then why?

16:40.220 --> 16:41.030
Then it.

16:44.310 --> 16:45.710
And then we have W.

16:48.200 --> 16:54.200
And let's finally return also the response message to the client that requested the execution of this

16:54.200 --> 16:54.680
service.

16:54.680 --> 16:58.160
So let's return the response.

16:58.370 --> 17:01.160
Let's continue with the second callback function.

17:01.160 --> 17:03.860
So the quaternion to Euler callbacks.

17:04.070 --> 17:08.600
And here again let's start by printing an informative message in the terminal.

17:10.090 --> 17:22.780
So get longer and let's print an informative message that says requested to convert and then quaternion

17:22.780 --> 17:25.630
followed by the four coefficient of the quaternion.

17:25.900 --> 17:29.710
And so let's print the x the y.

17:32.260 --> 17:33.190
The z.

17:35.300 --> 17:37.730
And the W of the quaternion.

17:38.300 --> 17:42.590
Here we forgot also at the end of the string that we need to print.

17:43.860 --> 17:44.520
All of these.

17:44.520 --> 17:46.830
So we need to print all of these variables.

17:48.510 --> 17:49.110
Okay.

17:49.110 --> 17:51.810
And we need to do the same also here.

17:52.020 --> 17:54.870
So here we need also to print the four coefficient.

17:54.870 --> 18:00.030
But as this is the callback function for the quaternion to Euler service.

18:00.060 --> 18:04.590
Now the four coefficient of the quaternion are in the request message.

18:04.680 --> 18:10.410
So here let's print the four coefficients of the quaternion that are in the request message.

18:10.680 --> 18:19.320
And so let's print the x component, then the y component, then the z component.

18:19.530 --> 18:22.310
And finally also the w component.

18:22.320 --> 18:29.010
And now in order to perform the conversion from a quaternion to Euler angles, we can use another function

18:29.010 --> 18:32.100
still from the tf transformations library.

18:32.100 --> 18:36.450
And this one is called Euler from quaternion.

18:36.450 --> 18:43.230
So let's import this function and let's use it here within the quaternion to Euler callback function.

18:43.230 --> 18:50.160
So let's use the Euler from quaternion function and this one receives as input a vector with the four

18:50.160 --> 18:51.750
components of the quaternion.

18:51.750 --> 18:52.140
And.

18:52.140 --> 18:56.940
So let's pass a vector and the four component are defined here.

18:56.940 --> 18:59.940
So those that are in the request message.

18:59.940 --> 19:06.630
So we can paste it here also in the list that we are passing to the Euler from quaternion function.

19:06.750 --> 19:11.310
And also this function returns the corresponding three Euler angles.

19:11.310 --> 19:17.790
So we can store the three Euler angles that this function returns directly in the response message.

19:17.940 --> 19:30.750
So let's store the role in the response role and then also the pitch and also the yo.

19:30.960 --> 19:37.620
So we are storing the output of this function directly within the response message that the service

19:37.620 --> 19:39.240
server will return.

19:39.450 --> 19:43.050
And now let's print another informative message in the terminal.

19:43.050 --> 19:55.260
So actually we can paste this one here in order to print the corresponding user angles.

19:55.260 --> 19:57.090
And so we want to print the role.

19:59.260 --> 20:03.990
The pitch and also the yo.

20:04.000 --> 20:06.850
So the converted values.

20:07.090 --> 20:12.820
And so now we can print the converted values that we have stored here in the response message.

20:12.820 --> 20:15.910
So let's print those three values.

20:17.320 --> 20:20.020
And finally with this we can return.

20:20.620 --> 20:23.020
So let's return the result.

20:23.050 --> 20:25.720
The response of the service server.

20:26.050 --> 20:30.460
With this we have completed the implementation of the angle converter node.

20:30.460 --> 20:34.810
And now we can proceed to use its functionalities within the main function.

20:34.810 --> 20:37.180
So here that we have already defined.

20:37.330 --> 20:41.470
Here we only need to change the name of the class that we want to instantiate.

20:41.470 --> 20:44.720
That is called angles converter.

20:44.740 --> 20:51.910
Let's also change the name here of the variable into angles converter.

20:51.940 --> 20:53.740
Let's make it spin.

20:54.190 --> 20:58.630
And also let's destroy the node whenever we press Ctrl c.

20:59.380 --> 21:05.620
Now let's save this file and we need to inform the compiler about the existence of this Python node

21:05.620 --> 21:09.880
so that it can be compiled and converted into an executable.

21:10.240 --> 21:17.380
Since we are using CMake as a build type for the Arduino utils package, we need to follow a slightly

21:17.380 --> 21:24.910
different approach for the installation of a node using the Cmakelists.txt file, where we can install

21:24.910 --> 21:27.700
both Python and C plus plus node.

21:27.910 --> 21:34.780
So let's open this file, and let's start by declaring the dependencies that we used in our Python node.

21:34.810 --> 21:39.190
So here where there is the find package instruction.

21:39.190 --> 21:42.190
Let's copy this instruction and let's paste it.

21:42.340 --> 21:48.070
And we are using the RTL Pi library for our Python node.

21:48.160 --> 21:50.920
Also let's paste it again.

21:50.920 --> 21:59.830
And we are using also the Arduino but messages package from which we use the interfaces to quaternion

21:59.830 --> 22:06.820
and quaternion to Euler to talk with the service servers, and then to declare that the Arduino utils

22:06.820 --> 22:09.400
package contains some Python nodes.

22:09.550 --> 22:10.720
We need to use.

22:10.720 --> 22:17.410
So here after the find package we need to insert an amend python.

22:20.080 --> 22:24.070
Install package instruction.

22:24.070 --> 22:30.460
And so we use the name of the package which contains these Python nodes, which is also contained in

22:30.460 --> 22:31.630
the variable.

22:33.430 --> 22:35.980
Project name.

22:36.640 --> 22:39.710
And now we can finally install our Python node.

22:39.730 --> 22:46.710
So after the Python install package let's use the install instruction.

22:46.750 --> 22:48.670
And so let's install a new program.

22:50.530 --> 22:57.400
So programs and here are the script that we want to install is in the Arduino utils sub folder.

22:57.400 --> 23:02.200
So is in this folder that has the same name as the package itself.

23:02.200 --> 23:08.470
And so let's still using the variable project name.

23:08.560 --> 23:13.690
And then we need to declare the name of the script that is the angle.

23:16.550 --> 23:17.630
Conversion.

23:18.700 --> 23:21.760
Dot pi and we want to install this one.

23:21.760 --> 23:28.000
So in the destination of the executable will be the lib folder.

23:28.000 --> 23:31.300
And inside the Arduino board utils sub folder.

23:31.300 --> 23:39.400
So still as this has the same name of the package, let's use the variable project name.

23:40.250 --> 23:44.180
So with this also the file cmake list is done.

23:44.570 --> 23:47.460
Then as we are installing a Python node.

23:47.480 --> 23:48.620
So this one.

23:48.620 --> 23:53.030
Let's also insert the dependency from the build type.

23:53.570 --> 23:56.750
Here I meant cmake python.

23:57.110 --> 24:01.220
So let's add the cmake python.

24:02.180 --> 24:04.580
In order to build Python nodes.

24:05.430 --> 24:09.790
And with this our cmakelists.txt file is ready.

24:09.810 --> 24:13.020
So we have defined all the dependencies.

24:13.020 --> 24:18.120
And also we have defined how the build tool should build and install our Python node.

24:18.490 --> 24:24.960
And so now we can move on and declare also the dependencies that we used in the package dot XML file.

24:25.140 --> 24:28.320
So here let's add a dependency.

24:28.320 --> 24:36.270
So another build tool dependency from the CMake Python that we are going to need to build our Python

24:36.270 --> 24:36.660
node.

24:36.660 --> 24:42.270
And then let's add a dependency from the Rql py library.

24:42.840 --> 24:50.820
Then let's also add another dependency on the Arduino bot messages.

24:51.540 --> 24:57.690
With this we have completed the creation of our node, and so we have instructed the compiler on how

24:57.690 --> 24:59.550
it should make it an executable.

24:59.550 --> 25:03.270
And also we have defined the dependencies that this node needs.

25:03.390 --> 25:07.920
Now we can finally build our workspace and see how this node works.

25:08.070 --> 25:09.810
So let's open a new terminal.

25:10.770 --> 25:16.380
Let's go into the workspace and let's build it with the command called build.

25:16.590 --> 25:18.570
So the build is successful.

25:18.600 --> 25:21.660
This means that we have now an executable for our nodes.

25:21.660 --> 25:23.160
And so let's start them.

25:24.180 --> 25:26.970
So let's open a new window of the terminal here.

25:26.970 --> 25:28.530
Let's search the workspace.

25:28.650 --> 25:32.610
So the file setup dot bash that is in the install folder.

25:32.610 --> 25:35.190
And let's run the node for the angle conversion.

25:35.190 --> 25:45.540
So Ross to run and from the Arduino boot utils package let's start the angle conversion dot pi node.

25:45.570 --> 25:47.580
So let's press enter.

25:47.580 --> 25:53.640
And upon the node start up we can already see that it informs us that the angle conversion services

25:53.640 --> 25:59.310
are correctly running, and so they are ready to process new conversion requests.

25:59.520 --> 26:02.760
We can verify also this by opening a new terminal.

26:02.760 --> 26:09.060
And so if we launch the Command Ross queue service list.

26:09.060 --> 26:14.070
So we get a list of all the services that are currently available in Ross queue.

26:14.070 --> 26:20.550
And apart from the one that were automatically created by the initialization of the Ross to node, we

26:20.550 --> 26:26.220
can see that there are the two services that we called earlier to quaternion and also quaternion to

26:26.250 --> 26:26.730
Euler.

26:27.480 --> 26:30.600
Let's try to send a request to these services.

26:30.600 --> 26:36.360
And to do so we need to source the workspace, which contains the definition of the message interface

26:36.360 --> 26:38.940
that we need to use in order to contact the server.

26:38.940 --> 26:41.400
So in order to send a request to this server.

26:41.670 --> 26:46.440
And so let's use the command Ros2 service call.

26:46.710 --> 26:51.660
And let's for example call the user to quaternion.

26:51.690 --> 26:58.770
We can see that pressing tab twice we get the autocompletion of Ros two that says that this service.

26:58.770 --> 27:03.570
So the user to quaternion requests an interface of this type.

27:03.570 --> 27:09.690
So an interface of type user to quaternion as defined in the Arduino bot messages.

27:09.690 --> 27:11.520
So let's use this interface.

27:11.520 --> 27:13.920
Then let's press again tab twice.

27:13.950 --> 27:15.750
Let's use the double quotes.

27:15.750 --> 27:17.580
Then again let's press tab.

27:17.580 --> 27:20.970
And let's type role and then tab again.

27:20.970 --> 27:24.420
And now we can see that the message is autocompleted.

27:24.570 --> 27:27.420
So now we can send our request.

27:27.420 --> 27:33.540
So basically we can ask the service server to convert a certain Euler angles.

27:33.540 --> 27:36.510
So roll pitch into a quaternion.

27:36.810 --> 27:45.570
For example let's set the roll angle so this 1 to -0.5.

27:45.690 --> 27:49.230
And then let's set the pitch to zero.

27:49.230 --> 27:53.880
And for example let's set this 1 to 1.5.

27:54.510 --> 27:56.340
Let's press enter.

27:56.910 --> 28:00.720
And here we can see that there is an error in our Python script.

28:00.990 --> 28:09.300
So if we go back to the angle conversion actually here we see that we are missing a percentage sign.

28:10.060 --> 28:11.560
And we don't need the comb.

28:11.590 --> 28:12.220
Actually.

28:13.130 --> 28:18.260
Okay, so now we can go back and build again our workspace.

28:19.060 --> 28:20.590
Let's launch again a word note.

28:22.520 --> 28:25.430
And let's send again the request message.

28:25.430 --> 28:28.030
And now the request is successful.

28:28.040 --> 28:35.320
And so we can see that actually the service server response with the corresponding quaternion coefficients.

28:35.330 --> 28:41.540
So these ones that are the result of the conversion between these angles.

28:41.540 --> 28:45.050
So these roll pitch and the into a quaternion.

28:45.050 --> 28:51.260
And also we can see that the client that is this one is receiving the correct response.

28:51.260 --> 28:54.980
So is receiving the four coefficients of the quaternion.

28:55.710 --> 28:58.330
Now let's try to call the second service.

28:58.350 --> 29:02.580
So with the Ros two service call.

29:02.880 --> 29:05.880
And now let's call the quaternion to Euler.

29:06.450 --> 29:13.800
Again we can press tab twice to see that this service is using the quaternion two user interface as

29:13.800 --> 29:15.780
defined in the Arduino board messages.

29:16.440 --> 29:18.060
So let's use this interface.

29:18.060 --> 29:20.010
Then let's use the double quotes.

29:20.040 --> 29:21.600
Let's press tab twice.

29:21.600 --> 29:24.750
Then let's type x and again tab.

29:24.870 --> 29:32.270
And now we get an empty prototype of the request message that this quaternion to Euler service is accepting.

29:32.310 --> 29:37.800
And so now we need to set the quaternion that we want to convert into Euler angles.

29:38.010 --> 29:41.550
For example let's ask to convert the unit quaternion.

29:41.550 --> 29:48.420
So basically the quaternion that has all the components set to zero except for the last one which corresponds

29:48.420 --> 29:49.270
to one.

29:49.290 --> 29:56.610
So let's press enter and we can see that here we have the corresponding Euler angles that corresponds

29:56.610 --> 29:59.580
to this unitary quaternion rotation.

29:59.580 --> 30:05.040
And so this basically indicates that both the service servers are correctly running.
