WEBVTT

00:00.110 --> 00:07.400
In this lesson, we are going to start the task server and see how it interacts with the movie API to

00:07.430 --> 00:10.400
move the robot to a predefined position.

00:10.430 --> 00:16.940
In order to do so, let's create a new launch file within the Arduino bot remote package.

00:16.940 --> 00:21.710
So here let's create a new folder called launch.

00:21.710 --> 00:32.570
And here within this folder let's create a new file called Remote interface dot launch dot pi.

00:32.600 --> 00:33.200
Perfect.

00:33.200 --> 00:38.900
And here in this launch file we are going to insert all the functionalities that we are going to create

00:38.900 --> 00:41.240
here within the Arduino bot remote package.

00:41.240 --> 00:46.640
And that will allow our robot to communicate with the Alexa voice assistant.

00:46.760 --> 00:53.420
So here within this remote interface launch dot Pi, we can actually copy all the instructions that

00:53.420 --> 00:59.390
we've used here within the Arduino Bot Pi examples package within the launch folder, and that we've

00:59.420 --> 01:03.190
used for the execution of the simple move it interface.

01:03.190 --> 01:10.060
In fact, also for the task server and especially for the implementation of the Python of the task server,

01:10.060 --> 01:16.180
we are going to use this move it configuration here that we have also used for the simple move with

01:16.180 --> 01:21.280
interface of the Python package, so of the Arduino Pi examples.

01:21.280 --> 01:24.760
So let's copy all of this and let's paste it here.

01:24.760 --> 01:27.970
So within the remote interface launch dot Pi.

01:28.000 --> 01:30.040
And here the thing that we need to do.

01:30.040 --> 01:33.370
So here we need to change this one is fine.

01:33.370 --> 01:39.190
So this is the move it configuration that you are going to use in order to configure the task server.

01:39.190 --> 01:45.340
So let's start the task server node Pi.

01:45.370 --> 01:53.200
So the Python implementation that we have created in the Arduino bot remote package and that we have

01:53.200 --> 01:57.940
called task server dot Pi.

01:57.970 --> 01:58.690
Perfect.

01:58.690 --> 02:01.360
And to this file here we need to import.

02:01.360 --> 02:03.910
So we need to provide this one here.

02:03.910 --> 02:09.250
So the movie configuration that is all of this movie configuration here.

02:09.280 --> 02:12.610
Now here instead of hard coding the value.

02:12.640 --> 02:13.120
True.

02:13.120 --> 02:21.970
So instead of hard coding this value here, let's declare a new launch argument so we can import from

02:22.780 --> 02:28.900
the launch actions the declare launch argument.

02:28.900 --> 02:35.170
And now let's create a new variable that is called is same argument.

02:35.170 --> 02:38.530
And this is an instance of the declare launch argument.

02:38.530 --> 02:46.540
And we can use this one in order to declare a new argument of this launch file that is called easy perfect.

02:46.540 --> 02:51.310
And then we can also assign a default value to this parameter.

02:51.490 --> 02:55.180
And for example, let's set it to true perfect.

02:55.180 --> 03:00.370
So this one here will indicate whether we are starting the remote interface.

03:00.370 --> 03:05.250
So all of these functionalities for the simulated robot or for the real one.

03:05.280 --> 03:10.770
Then let's also declare another argument that is called use Python.

03:10.800 --> 03:11.730
Argument.

03:11.730 --> 03:15.600
Again, this is an instance of the declare launch argument.

03:15.630 --> 03:17.190
And let's give it a name.

03:17.190 --> 03:21.810
Let's call it use Python and by default.

03:23.220 --> 03:24.960
So let's assign a default value.

03:24.960 --> 03:27.300
And by default I'm setting this one to.

03:27.330 --> 03:27.840
False.

03:27.840 --> 03:33.510
So by default I'm going to start the C plus plus implementation of the task server.

03:33.540 --> 03:35.640
Now after this one here.

03:35.640 --> 03:40.410
So after declaring these two parameters let's also read the runtime value.

03:40.410 --> 03:44.580
So the value that actually they have when we execute this launch file.

03:45.030 --> 03:53.550
So from the launch substitutions let's import the launch configuration.

03:53.580 --> 03:54.150
Perfect.

03:54.150 --> 03:56.910
And now we can create two variables of this type.

03:56.910 --> 03:58.980
So two variables of this class here.

03:59.220 --> 04:01.800
The first one is called is sim.

04:02.100 --> 04:05.170
So this is an instance of the launch configuration.

04:05.170 --> 04:08.140
And we want to read this parameter here.

04:08.140 --> 04:11.260
So the value of the ECM argument.

04:11.260 --> 04:18.580
And then also let's create a new one that is called use Python that we want to use in order to read

04:19.540 --> 04:21.160
this argument here.

04:21.160 --> 04:24.550
So the use Python variable perfect.

04:24.580 --> 04:26.920
Now we want to use these two variables.

04:26.920 --> 04:30.130
So the ECM is the one that we can use here.

04:30.130 --> 04:36.610
So instead of hard coding the value of the users in time we can just use the ECM.

04:36.670 --> 04:39.070
And now instead the other variable.

04:39.070 --> 04:40.510
So the use Python.

04:40.540 --> 04:47.560
Here we can use this one in order to start the Python implementation of the task server or the C plus

04:47.560 --> 04:48.910
plus implementation.

04:49.090 --> 04:55.720
So we can import another class, this time from the launch conditions.

04:57.010 --> 04:59.830
We can import the if condition.

04:59.980 --> 05:03.310
And also we can import the unless condition class.

05:03.390 --> 05:07.440
So here this one here is the task server node.

05:07.440 --> 05:10.140
So the implementation of the task server in Python.

05:10.320 --> 05:12.420
And actually we want to start this one.

05:12.420 --> 05:19.830
So we want to start the Python implementation of the task server only when the condition.

05:21.030 --> 05:25.710
So only if the use Python.

05:27.750 --> 05:29.880
Argument is set to true.

05:29.910 --> 05:32.460
So basically this is a conditional node.

05:32.460 --> 05:37.770
And we are going to start this one here only when the use Python is set to true.

05:37.800 --> 05:43.650
Otherwise if this one is set to false we want to start the C plus plus implementation.

05:43.680 --> 05:45.270
So we can copy this one.

05:45.420 --> 05:46.920
And we can paste it.

05:46.920 --> 05:50.370
And let's simply call it task server node.

05:50.370 --> 05:56.550
And again from the Arduino board remote package we want to start the executable called task server.

05:56.550 --> 05:58.980
So this is the C plus plus executable.

05:58.980 --> 06:02.690
And actually it is called task server node.

06:03.720 --> 06:04.170
Perfect.

06:04.170 --> 06:08.520
So this is the name of the executable and we want to start it unless.

06:09.390 --> 06:13.800
So unless the use Python is set to true.

06:13.800 --> 06:15.540
Basically we are saying that we want to.

06:15.570 --> 06:22.230
Start the C plus plus implementation if the use Python is set to false, and in this case, the only

06:22.230 --> 06:28.140
parameter that we need to set to this node is the use sim time that again we can set it equal to the

06:28.470 --> 06:29.910
sim variable.

06:30.630 --> 06:31.350
Perfect.

06:31.350 --> 06:34.260
So with this we have declared all the functions.

06:34.260 --> 06:38.400
So all the actions that we want to execute for the moment with this launch file.

06:38.400 --> 06:41.730
So actually this will just start the task server.

06:41.730 --> 06:46.650
And it will either start the C plus plus implementation or the Python one.

06:46.650 --> 06:52.980
And also if we are starting the Python implementation it will configure it using this class here.

06:52.980 --> 06:55.170
So the move it configuration builder.

06:55.380 --> 06:56.850
Now let's go here.

06:56.850 --> 07:03.420
So in the launch description and let's start by declaring the use Python argument.

07:03.420 --> 07:05.720
Then the easy argument.

07:05.720 --> 07:11.990
And then let's start the task server node pie or the task server node.

07:11.990 --> 07:17.570
So let's start the Python or the C plus plus implementation depending on this value here.

07:17.570 --> 07:20.990
So depending on this variable here perfect.

07:20.990 --> 07:22.910
So we can save this file.

07:22.910 --> 07:24.890
And as we have created a new folder.

07:24.890 --> 07:29.300
So we have created the launch folder within the Arduino bot remote package.

07:29.300 --> 07:30.590
We need to install it.

07:30.590 --> 07:33.080
So let's open the file cmake list.

07:33.320 --> 07:38.090
And here we need a new install instruction.

07:38.090 --> 07:38.750
Perfect.

07:38.750 --> 07:40.430
And we want to install the.

07:43.280 --> 07:46.310
Directory that is the launch folder.

07:48.020 --> 07:52.580
And we want to install it at the destination that is the shared folder.

07:52.580 --> 07:56.720
And within the subfolder that is called as the package itself.

07:56.750 --> 07:59.780
So we can use the project name variable.

07:59.780 --> 08:05.100
And actually this one is a variable that simply contains the name of the package that is Arduino bot

08:05.130 --> 08:06.060
remote.

08:06.330 --> 08:07.140
Perfect.

08:07.140 --> 08:09.690
So we have installed also the launch folder.

08:09.690 --> 08:11.880
So we can save also this file here.

08:11.880 --> 08:15.420
And we can add the missing dependencies also here.

08:15.420 --> 08:17.640
So to the package dot XML.

08:17.670 --> 08:24.870
In fact here we need to add an execution dependency from the Ros2 launch package.

08:24.870 --> 08:30.300
And also we need to add another execution dependency from the Arduino bot.

08:31.140 --> 08:32.430
Move it package.

08:32.430 --> 08:33.300
Perfect.

08:33.300 --> 08:36.630
So let's save also the package dot XML.

08:36.630 --> 08:40.380
And now we can finally start the task server node.

08:40.530 --> 08:45.690
So let's close this and let's open a new terminal here.

08:45.990 --> 08:47.580
Let's go to the workspace.

08:47.910 --> 08:49.800
And let's start by building it.

08:49.800 --> 08:53.580
So we are compiling the new launch file that we have created.

08:53.580 --> 08:55.890
And then let's open a new window of the terminal.

08:55.890 --> 08:57.660
Let's make this one bigger.

08:57.660 --> 09:01.140
And let's start the gazebo simulation of our robot.

09:01.470 --> 09:09.040
So let's source the workspace And let's launch from the Arduino bot description package.

09:09.040 --> 09:11.260
The gazebo launch dot Pi.

09:15.790 --> 09:16.480
Perfect.

09:16.480 --> 09:19.600
So this started the gazebo simulation of our robot.

09:19.630 --> 09:22.630
Now let's also start the control system.

09:22.660 --> 09:30.220
So in a new terminal, let's source the workspace and let's launch from the Arduino bot controller.

09:30.250 --> 09:35.410
The file controller dot launched Pi a perfect.

09:35.410 --> 09:41.680
So we have the confirmation that we are configuring and activating both the ARM controller and also

09:41.710 --> 09:42.910
the gripper controller.

09:42.940 --> 09:43.630
Perfect.

09:43.630 --> 09:46.120
So now we can also start move it.

09:46.210 --> 09:54.460
So in a new window of the terminal again let's source the workspace and let's launch from the Arduino

09:54.460 --> 09:54.790
bot.

09:54.820 --> 09:55.660
Move it.

09:55.960 --> 09:58.120
Let's start the launch file that we have called.

09:58.120 --> 10:00.010
Move it dot dot pi.

10:00.040 --> 10:00.940
Perfect.

10:00.970 --> 10:02.860
So with this we are starting.

10:02.860 --> 10:03.640
Move it.

10:03.640 --> 10:09.920
And also it will start a service with the graphical user interface that we can use in order to move

10:09.920 --> 10:10.700
our robot.

10:10.700 --> 10:15.980
But for the moment, actually we are not interested in this graphical user interface because we want

10:15.980 --> 10:18.440
to move our robot using the task server.

10:18.440 --> 10:23.720
So let's close this one and instead we can start the task server.

10:23.900 --> 10:26.180
So let's open a new window of the terminal.

10:26.180 --> 10:29.150
And here again we can search the workspace.

10:31.280 --> 10:36.230
And we can launch the Arduino robot remote launch file that we have just created.

10:36.230 --> 10:38.870
So we trust to launch.

10:38.900 --> 10:43.940
And from the Arduino robot remote, let's start the launch file that we have called.

10:43.940 --> 10:48.470
So this one here the remote interface dot launch.

10:48.470 --> 10:49.970
So let's press enter.

10:49.970 --> 10:52.910
And this is starting the task server.

10:52.940 --> 10:57.500
Actually this is starting the Cplusplus implementation of the task server.

10:57.500 --> 11:04.850
And if you want to start the Python one here you simply have to use the argument use Python and you

11:04.850 --> 11:07.080
have to set this one to true.

11:07.110 --> 11:11.280
So now I'm going to restart just the C plus plus implementation.

11:11.310 --> 11:12.960
So let's press enter.

11:12.960 --> 11:17.520
So here we have the configuration that our task server is up and running.

11:17.520 --> 11:21.540
And now actually we can like use a new terminal.

11:22.440 --> 11:25.290
So let's open a new terminal.

11:26.100 --> 11:26.880
Perfect.

11:26.880 --> 11:27.960
Like this.

11:27.960 --> 11:31.650
So that we can actually see our robot in gazebo.

11:31.650 --> 11:35.850
And we can actually start interacting within this terminal with the task server.

11:35.850 --> 11:39.360
So the old one is still up and running the old terminal.

11:39.570 --> 11:47.070
But let's make this one a little bit bigger so that we can interact here in this terminal with the task

11:47.070 --> 11:47.790
server.

11:47.850 --> 11:55.590
Now we can first see that actually the task server is up and running with Ros2 action list.

11:55.770 --> 11:56.820
And here we go.

11:56.850 --> 11:58.890
This is our task server.

11:58.890 --> 12:01.080
And now we can finally start it.

12:01.080 --> 12:02.850
So we can finally trigger it.

12:02.880 --> 12:05.220
We can finally send a goal to it.

12:05.280 --> 12:10.640
So first Also in this case we need to go to the workspace and to source it.

12:10.670 --> 12:11.540
Perfect.

12:11.540 --> 12:17.360
And from now on we can use the command Ros2 action send goal.

12:17.360 --> 12:24.410
So we are creating basically with this command, an action client that is sending a goal to the task

12:24.410 --> 12:25.190
server.

12:26.120 --> 12:28.880
So to the action server that is called task server.

12:28.880 --> 12:35.600
Then if we press tab twice, we can see that the task server is accepting messages of this type.

12:35.600 --> 12:38.060
So belonging to this interface here.

12:39.110 --> 12:42.980
So to the Arduino both messages and to the Arduino task.

12:42.980 --> 12:43.850
Perfect.

12:43.850 --> 12:45.470
Then let's use the double quotes.

12:45.500 --> 12:47.420
Let's press tab again.

12:47.480 --> 12:52.700
And here we can see that this one is the only value of the goal message.

12:52.820 --> 12:57.500
So let's type the letter T and then let's press tab.

12:57.500 --> 12:59.600
And for example let's set.

12:59.630 --> 13:04.160
So let's send the robot to execute the task number one.

13:04.160 --> 13:05.840
So let's press enter.

13:05.870 --> 13:13.080
Now we are conducting the task server and we can see that the robot is moving to a peak position.

13:13.710 --> 13:18.270
And so we can see that this one is the hypothetical peak position that we have set.

13:18.300 --> 13:21.300
Now for example, let's move the robot also.

13:21.300 --> 13:24.330
So let's execute the task number zero.

13:24.330 --> 13:27.930
So this will bring again the robot to its initial position.

13:27.930 --> 13:29.610
So to the on position.

13:32.610 --> 13:33.630
And this is it.

13:33.630 --> 13:36.450
So now the robot is in the on position.

13:36.450 --> 13:42.120
And then for example let's try also the last task number that is the task number two.

13:42.150 --> 13:46.860
And so this instead will send the robot to a rest position.

13:46.860 --> 13:52.020
And so this is the rest position of the robot where the robot is bent on itself.

13:52.020 --> 13:57.570
And so with this we have tested the three tasks that we have configured for our robot.

13:57.570 --> 14:00.420
And that we can either call manually.

14:00.420 --> 14:07.020
So with this command here, and that in the following lessons will be triggered by the Alexa voice assistant

14:07.470 --> 14:08.160
Arthur.
