WEBVTT

00:00.410 --> 00:06.350
To register the Arduino Bot interface class we have been developing in the previous lesson as a plugin

00:06.380 --> 00:11.360
of the Ros2 Control library and consequently as an hardware interface.

00:11.390 --> 00:14.750
We need to import the plugin lib module.

00:14.750 --> 00:21.230
So still here in the cplusplus file that we have been creating the Arduino bot interface dot cpp.

00:23.120 --> 00:32.630
Let's include from the plugin lib package the class list macros dot php.

00:33.640 --> 00:35.560
And now at the end of our script.

00:36.360 --> 00:40.260
So here after the namespace, let's export this class.

00:40.260 --> 00:49.290
So the Arduino board interface as a plugin within the plugin lib library so we can use the macro plugin

00:49.290 --> 00:54.090
lib export class.

00:55.260 --> 00:59.190
And to this one, we need to pass the Arduino board interface class.

00:59.520 --> 01:05.760
So this is in the Arduino board controller namespace and let's pass the Arduino board interface class.

01:06.030 --> 01:09.360
Then also we need to indicate which is the base class.

01:09.360 --> 01:12.990
So which is the base class of the plugin from which we are inheriting.

01:13.710 --> 01:20.190
And if you remember this is the hardware interface and we are inheriting from the system interface.

01:20.190 --> 01:26.580
So the base class of the Arduino board interface that we have implemented is the system interface.

01:27.430 --> 01:34.330
Additionally, to register this class as a Ros2 control plugin, we need to add a new file, so here

01:34.330 --> 01:36.610
to the Arduino controller package.

01:36.850 --> 01:47.200
And so let's create a new file and let's call this one Arduino bot controller dot XML.

01:47.590 --> 01:53.590
Within this file, let's declare our plugin with the tag library.

01:53.590 --> 01:55.600
So this is an XML file.

01:55.840 --> 02:01.360
And then let's define the path where our library is declared.

02:01.360 --> 02:06.940
And so this is the Arduino bot controller folder.

02:07.120 --> 02:09.340
And then let's define the class name.

02:10.150 --> 02:13.720
So the name of the class which implements the plugin.

02:14.200 --> 02:27.460
So the name is in the Arduino bot controller namespace and is called Arduino Bot Interface.

02:27.460 --> 02:29.530
And then let's also set the type.

02:30.040 --> 02:31.150
So here.

02:32.630 --> 02:35.050
Let's set the type.

02:35.090 --> 02:40.670
And so this is the Arduino board controller.

02:40.670 --> 02:42.950
And from this namespace still.

02:45.310 --> 02:49.030
The Arduino board interface is the type of the class.

02:49.720 --> 02:55.570
Let's also indicate which is the base class, which is the base class from which the Arduino board interface

02:55.570 --> 02:57.280
class is inheriting.

02:57.490 --> 03:03.100
And so let's indicate with base class type.

03:04.090 --> 03:10.360
And this is from the hardware interface.

03:10.390 --> 03:16.480
The base class is the system interface.

03:18.040 --> 03:27.430
Let's also add that description to this plugin so that all the other users will know what is this about.

03:27.430 --> 03:32.830
And so let's simply indicate that this is the Arduino hardware interface.

03:38.280 --> 03:39.810
Let's save this file.

03:39.930 --> 03:41.460
Let's save this file.

03:41.580 --> 03:47.160
And to conclude this lesson, let's declare all the dependencies that we have used within the Arduino

03:47.160 --> 03:51.750
board controller package in order to create the Arduino board interface.

03:51.750 --> 03:53.850
And also let's install this library.

03:53.850 --> 03:57.930
So this hardware interface that we have called Arduino board interface.

03:58.230 --> 04:02.160
To do so, let's open the file Cmakelist here.

04:02.160 --> 04:06.930
Let's remove the commented lines so that it is more readable.

04:12.160 --> 04:14.410
And then let's add the dependency.

04:14.440 --> 04:26.650
So with a new find package instruction from the hardware interface library, then another one from the

04:27.820 --> 04:29.440
plugin lib library.

04:29.980 --> 04:36.280
And then from the SQL CPP life cycle.

04:36.520 --> 04:41.620
Then from the Rql CPP.

04:42.370 --> 04:46.930
And then we need to declare also the dependency from the serial library.

04:46.930 --> 04:48.550
So from the lib serial.

04:49.060 --> 04:58.030
So let's add a dependency from the package config and then let's use this one for using the instruction

04:58.120 --> 05:03.430
package check modules.

05:03.460 --> 05:06.580
So check the serial module.

05:08.410 --> 05:11.680
And this is the lib serial that we have installed.

05:12.630 --> 05:14.940
Let's continue by adding a new library.

05:15.090 --> 05:24.270
So here, after the package check module's instruction, let's add a new library and let's add a new

05:24.270 --> 05:25.890
library to this project.

05:25.890 --> 05:29.610
So this library will have the same name as the package itself.

05:29.610 --> 05:39.030
So the Arduino board controller and we can access to this name through the project name variable and

05:39.030 --> 05:41.820
then the source code of this library.

05:42.690 --> 05:51.120
So is in the SRC folder and is called Arduino board interface dot CPP.

05:51.960 --> 05:57.720
Then let's also use the instruction target include.

06:00.320 --> 06:01.400
Directories.

06:02.030 --> 06:07.490
And so still from the library that we called this one as the package.

06:07.490 --> 06:09.590
So Arduino board controller.

06:10.250 --> 06:17.270
Let's add the private instruction and then let's add the include folder.

06:17.270 --> 06:22.190
So that also the include folder will be added to the build of our package.

06:22.280 --> 06:24.650
And then let's also add the serial library.

06:24.650 --> 06:35.330
So let's use the double quotes and then let's use the variable serial include directories.

06:35.330 --> 06:46.160
So dirs, and then let's also use another instruction that is the target link libraries still for the

06:46.160 --> 06:48.200
Arduino board controller library.

06:48.200 --> 06:53.260
So let's copy this variable here and let's add the lib serial.

06:53.270 --> 07:05.120
So still using the double quotes, let's use the variable this time that is serial l d flex.

07:05.630 --> 07:10.370
Then let's also use the instruction and target

07:12.860 --> 07:17.180
dependencies still for the Arduino board controller library.

07:18.080 --> 07:21.560
And let's add the dependencies that this library is going to need.

07:21.560 --> 07:33.140
So the hardware interface, the plugin lib, the CPP and the CPP life cycle.

07:33.860 --> 07:41.330
Now to compile and register a plugin for the Ros2 control library, we use the instruction.

07:43.130 --> 07:49.460
Login lib export plugin.

07:51.940 --> 07:53.920
Description file.

07:54.490 --> 08:01.240
And so within this instruction, we need to export it as an hardware interface.

08:01.330 --> 08:06.610
And then let's indicate the name of the file which provides the description of the plugin.

08:06.610 --> 08:11.890
And so this is the Arduino board controller dot XML file that we have just created.

08:11.890 --> 08:15.310
So this file contains the definition of the plugin.

08:15.700 --> 08:24.550
And so let's indicate that this is called Arduino board controller dot XML.

08:24.580 --> 08:26.740
Now let's install also this library.

08:27.130 --> 08:31.390
So here let's add a new install instruction.

08:31.510 --> 08:37.160
And so let's install the target that we want to install is the library.

08:37.180 --> 08:39.460
So this one Arduino board controller.

08:39.490 --> 08:44.110
So let's still use the project name variable and the destination.

08:44.830 --> 08:48.340
So we want to install this one within the lib folder.

08:49.170 --> 08:51.420
Let's also install the directory include.

08:51.450 --> 09:00.870
So with a new install instruction and the directory is the include.

09:00.870 --> 09:07.110
So basically this directory here which contains the declaration of the Arduino bot interface.

09:07.110 --> 09:08.310
So the header file.

09:08.910 --> 09:11.040
And so let's install this one.

09:12.930 --> 09:17.970
The destination is still the include folder next.

09:17.970 --> 09:23.260
So here after the install, let's use the instruction amend.

09:24.200 --> 09:25.100
Export.

09:27.040 --> 09:28.000
Include

09:30.790 --> 09:36.070
directories and let's use this one to export the include directories.

09:36.280 --> 09:43.420
And then finally, let's also use the last instruction that is the amend export.

09:44.980 --> 09:50.320
Libraries to export the Arduino board controller library that we have created.

09:50.320 --> 09:52.180
So this one here.

09:54.050 --> 10:00.260
And also we need to amend export.

10:02.690 --> 10:09.170
Dependencies to declare the dependencies that we want to export for this library, which are the hardware

10:09.170 --> 10:16.280
interface, the plugin lib, the RCL, CP and the RCL CP.

10:16.430 --> 10:17.510
Life cycle.

10:17.810 --> 10:24.950
We can save this file and now we can move on to declare the dependencies that we have added to the cmakelist.

10:24.950 --> 10:28.040
Also to the file package dot XML.

10:28.610 --> 10:38.120
So here, let's start by adding a new dependency from the hardware interface library.

10:38.540 --> 10:39.350
Then.

10:41.060 --> 10:43.370
Another one from the CPP

10:46.190 --> 10:48.710
and another one from the CPP.

10:50.240 --> 10:51.350
Life cycle.

10:52.730 --> 10:58.640
And then also another one from the plugin lib library.

10:58.940 --> 11:08.210
And also since we used the lib serial, let's add the dependency from the lib serial dev.

11:08.690 --> 11:11.960
Let's conclude this lesson by building our workspace.

11:11.960 --> 11:18.470
So to compile the new library and to register it as a plugin of the Ros2 Control library and also to

11:18.470 --> 11:22.910
check that actually everything went well and so that there are no errors.

11:23.360 --> 11:28.610
To do so, let's open a new terminal and let's go into the workspace.

11:28.610 --> 11:32.870
And here let's run the command called Build.

11:35.320 --> 11:41.710
We can see that there are no errors, just some warnings about some unused variables.

11:41.710 --> 11:47.710
And in the next lesson, we are going to see how this new hardware interface that we have created is

11:47.710 --> 11:51.010
activated and is used to send comments to the robot.
