To register the Arduino Bot interface class we have been developing in the previous lesson as a plugin
of the Ros2 Control library and consequently as an hardware interface.
We need to import the plugin lib module.
So still here in the cplusplus file that we have been creating the Arduino bot interface dot cpp.
Let's include from the plugin lib package the class list macros dot php.
And now at the end of our script.
So here after the namespace, let's export this class.
So the Arduino board interface as a plugin within the plugin lib library so we can use the macro plugin
lib export class.
And to this one, we need to pass the Arduino board interface class.
So this is in the Arduino board controller namespace and let's pass the Arduino board interface class.
Then also we need to indicate which is the base class.
So which is the base class of the plugin from which we are inheriting.
And if you remember this is the hardware interface and we are inheriting from the system interface.
So the base class of the Arduino board interface that we have implemented is the system interface.
Additionally, to register this class as a Ros2 control plugin, we need to add a new file, so here
to the Arduino controller package.
And so let's create a new file and let's call this one Arduino bot controller dot XML.
Within this file, let's declare our plugin with the tag library.
So this is an XML file.
And then let's define the path where our library is declared.
And so this is the Arduino bot controller folder.
And then let's define the class name.
So the name of the class which implements the plugin.
So the name is in the Arduino bot controller namespace and is called Arduino Bot Interface.
And then let's also set the type.
So here.
Let's set the type.
And so this is the Arduino board controller.
And from this namespace still.
The Arduino board interface is the type of the class.
Let's also indicate which is the base class, which is the base class from which the Arduino board interface
class is inheriting.
And so let's indicate with base class type.
And this is from the hardware interface.
The base class is the system interface.
Let's also add that description to this plugin so that all the other users will know what is this about.
And so let's simply indicate that this is the Arduino hardware interface.
Let's save this file.
And to conclude this lesson, let's declare all the dependencies that we have used within the Arduino
board controller package in order to create the Arduino board interface.
And also let's install this library.
So this hardware interface that we have called Arduino board interface.
To do so, let's open the file Cmakelist here.
Let's remove the commented lines so that it is more readable.
And then let's add the dependency.
So with a new find package instruction from the hardware interface library, then another one from the
plugin lib library.
And then from the SQL CPP life cycle.
Then from the Rql CPP.
And then we need to declare also the dependency from the serial library.
So from the lib serial.
So let's add a dependency from the package config and then let's use this one for using the instruction
package check modules.
So check the serial module.
And this is the lib serial that we have installed.
Let's continue by adding a new library.
So here, after the package check module's instruction, let's add a new library and let's add a new
library to this project.
So this library will have the same name as the package itself.
So the Arduino board controller and we can access to this name through the project name variable and
then the source code of this library.
So is in the SRC folder and is called Arduino board interface dot CPP.
Then let's also use the instruction target include.
Directories.
And so still from the library that we called this one as the package.
So Arduino board controller.
Let's add the private instruction and then let's add the include folder.
So that also the include folder will be added to the build of our package.
And then let's also add the serial library.
So let's use the double quotes and then let's use the variable serial include directories.
So dirs, and then let's also use another instruction that is the target link libraries still for the
Arduino board controller library.
So let's copy this variable here and let's add the lib serial.
So still using the double quotes, let's use the variable this time that is serial l d flex.
Then let's also use the instruction and target
dependencies still for the Arduino board controller library.
And let's add the dependencies that this library is going to need.
So the hardware interface, the plugin lib, the CPP and the CPP life cycle.
Now to compile and register a plugin for the Ros2 control library, we use the instruction.
Login lib export plugin.
Description file.
And so within this instruction, we need to export it as an hardware interface.
And then let's indicate the name of the file which provides the description of the plugin.
And so this is the Arduino board controller dot XML file that we have just created.
So this file contains the definition of the plugin.
And so let's indicate that this is called Arduino board controller dot XML.
Now let's install also this library.
So here let's add a new install instruction.
And so let's install the target that we want to install is the library.
So this one Arduino board controller.
So let's still use the project name variable and the destination.
So we want to install this one within the lib folder.
Let's also install the directory include.
So with a new install instruction and the directory is the include.
So basically this directory here which contains the declaration of the Arduino bot interface.
So the header file.
And so let's install this one.
The destination is still the include folder next.
So here after the install, let's use the instruction amend.
Export.
Include
directories and let's use this one to export the include directories.
And then finally, let's also use the last instruction that is the amend export.
Libraries to export the Arduino board controller library that we have created.
So this one here.
And also we need to amend export.
Dependencies to declare the dependencies that we want to export for this library, which are the hardware
interface, the plugin lib, the RCL, CP and the RCL CP.
Life cycle.
We can save this file and now we can move on to declare the dependencies that we have added to the cmakelist.
Also to the file package dot XML.
So here, let's start by adding a new dependency from the hardware interface library.
Then.
Another one from the CPP
and another one from the CPP.
Life cycle.
And then also another one from the plugin lib library.
And also since we used the lib serial, let's add the dependency from the lib serial dev.
Let's conclude this lesson by building our workspace.
So to compile the new library and to register it as a plugin of the Ros2 Control library and also to
check that actually everything went well and so that there are no errors.
To do so, let's open a new terminal and let's go into the workspace.
And here let's run the command called Build.
We can see that there are no errors, just some warnings about some unused variables.
And in the next lesson, we are going to see how this new hardware interface that we have created is
activated and is used to send comments to the robot.