Now that we know what YAML configuration files are and what they are used for, let's see how we can
create a new file that contains the configuration parameters for the Ros2 control library for our robot.
Since this configuration file will contain specific parameters for configuring the control system of
our robot, let's create it inside a new package in our workspace.
So first we need to create a new package.
So let's go to the workspace and to the source folder in which we have already created several packages
for our robot.
And here let's create a new package with the Ros2 package create.
Then let's select the build type.
And for this case let's use the AMD CMake as we are going to insert both Python and C plus plus code
in this package here, and let's call it Arduino bot controller.
So let's press enter.
And now as you can see we have a new package that is called Arduino Bot Controller.
Also we can build the workspace with Colgan Build in order to compile also the new package that we have
created.
So the Arduino bot controller.
Now back in Visual Studio Code, here we have the Arduino bot controller package that we have just created.
And here we can see that we have already some folders, empty folders and the CMake list, and the package
dot XML files that were automatically generated.
And here inside this package let's create a new folder that is called config.
And within this config folder let's create a new file that is called Arduino bot controllers dot YAML.
Perfect.
And so this configuration file here will contain the configuration.
So the parameters for the Ros2 control library as I mentioned in the theoretical lessons about configuration
files.
A YAML file always starts with the name of the node to which the configuration parameter refers.
In our case, we are configuring the node called controller manager and so we are configuring it Ross.
So the Ross parameters of this node.
And let's start now by setting the Ross parameters that we want to set.
So here we can list now all the configuration parameters that we want to set for the controller manager
node, starting with the update rate that we can set to ten.
So we can set it to ten hertz.
And then so this parameter here indicates the frequency at which the control loop will be updated and
executed.
And then let's also add the names of the controllers that we want the controller manager to use for
our robot.
And actually we are just going to use two controllers, One for the arm that is called ARM controller.
Perfect.
And then another one for the gripper that is called gripper Controller.
Perfect.
And now for both of them.
So for these two controllers we need to specify their type, which determines the logic that is going
to be used for the control system.
So here for the ARM controller let's set the type perfect to be a joint.
Trajectory controller.
And so from this package here we want to use the class joint trajectory.
Controller.
Perfect.
And this basically indicates that we want to send trajectory commands to the joints that belongs to
the arm.
So this trajectory here basically will contain a list of points, a list of coordinates in which we
want the joints of the arm to be at any moment in time.
Now for the gripper controller.
So here let's set the type.
So we are also going to use the same type.
We are also going to use this type here for the real robot.
So a controller of type joint trajectory controller.
However for the moment let's do a simple test with a different type.
So we can comment this one here for the moment, and we will uncomment this one in the future.
And let's do a simple test using a different type of controller.
That is the forward command controller of type forward command controller.
So this is a simpler controller that simply will allow us to send just a goal to the gripper.
So to send just a command and the gripper will move to the desired position.
So instead of specifying a full trajectory, we will just specify the goal to the gripper and the gripper
will move to the desired position.
Finally, in addition to these two controllers, the controller manager also needs to load a module
that is called joint state.
Broadcaster and this module is responsible for publishing the current state of the joint of the robot
into a topic.
And so then other nodes, for example, can use this topic in order to read the current position of
the joints of the robot.
And so the current position of the arm.
And let's use the type.
So we are going to use the joint state broadcaster.
So from this package we want to load the joint state broadcaster.
Perfect.
So far, however, for the controller manager.
So for this node here we have only indicated the names.
So this one here and also the types this one here of the controllers that we want to load.
And so the arm controller.
The grip controller and the joint state broadcaster.
Now we also need to specify.
So we also need to configure the single controller.
So we need to configure here the ARM controller and also the gripper controller.
We can do it here.
So within the same file.
And we can do it here at the beginning of this file.
So let's configure the R controller.
And we are configuring the cross parameters of this controller here.
And also we can do the same also for the gripper controller.
So let's copy it.
Let's paste it.
And here we are configuring the gripper controller.
Perfect.
Now here let's start with the parameters of the ARM controller.
And we simply need to indicate the name of the joints that belong to this controller so that this controller
will activate.
And these are the joint one.
The joint two and also the joint three.
So these three joints are actually the ones that will activate the robot instead for the gripper.
The joints that will activate the gripper.
Is actually just one joint.
That is the joint number four.
So actually here we don't need to list the joint number five as the joint number five will simply copy.
So we'll simply mimic the behavior of the joint number four.
Now in both cases also we need to indicate apart from the joints we need to indicate the command interfaces
that these joints are using.
And in both cases the command interface is just a position command interface.
So we can copy this parameter also for the gripper.
So also here and now we also want to specify.
So apart from the command interface we want to specify the state interfaces.
So the interfaces that we are going to use in order to receive the feedback from the motors from the
joints.
And also in this case in both cases it is a position interface.
So we are going to receive the current position of each joint.
So let's copy it also for the gripper.
Now for both of these joints.
So let's start with the ARM controller.
We can set the open loop control to true.
And this is very important because the real motors that we are going to use on the real robot will not
be able to provide a feedback about the current position of the robot.
And so actually we can use an open loop control.
And also let's set another parameter that is the allow
integration in goal.
Trajectories.
And let's also set this parameter to true.
And let's copy also.
So let's set also this one for the gripper controller.
Now for the moment however these are the parameters that we are going to use for the real robot.
So for the real gripper and also the parameters that we are going to use for the simulation of the gripper
in the following lessons for the moment.
So for our very first test that we are going to do, we can just comment all of these for the gripper.
So from the command interfaces to the last parameter.
We can comment all of these.
And instead we can add a new parameter just for the gripper that is called.
Interface name that we can set to position.
And so this is just for the first test that we want to do and which we want to send a command using
this interface here.
So using the forward command controller to the gripper.
And so for this test here we need this parameter here.
But we are going to remove it at the end of this lesson.
So let's save this file.
And with this our configuration file for the controller manager node of the Ros2 control library is
completed.
And as I said, we will come back to modify this file here in order to change here the gripper controller
to be again a joint trajectory controller.
Now for the moment let's just install this folder here.
So the config folder that we have just created.
So let's go to the CMake list.
Here we can delete all the commented rows.
And here after the Findpackage section we can install and the directory that we want to install is the
config folder.
And we want to install this one.
So this directory in the destination that is the share folder.
And within the subfolder that is called as the package itself.
So that is called Arduino bot controller.
And also we can access this name using the variable project name.
Perfect.
Let's save also this file.
And before testing our controller, remember that in the previous lesson when we configured the Urdf
model of our robot.
So here in the Arduino bot description in the Urdf folder and in the Arduino bot gazebo dot csv file.
So here when we load it loaded the plugin for the gazebo Ros2 control library.
Either if you are using Ros2 humble or if you are using Ros2 Jetson here.
As you remember, we didn't set any parameters for this plugin.
And now finally we have this nice configuration file here.
So the Arduino board controller style that we can use here in order to configure the parameters of the
Ros2 control library.
So let's access let's find the Arduino board controller package.
And from this package from the config folder let's open the Arduino board controllers dot YAML file.
And actually this is the same file that we want to load independently on the plugin that you are using.
So this is the same configuration file that you need either if you are on Ros2 chassis or if you are
on Ros2.
Humble.
Perfect.
Let's save all to this file.
And also we need to apply one last change that is here in the launch file.
So in the gazebo dot launch file.
And actually the last change that we need to apply is here.
So when we are creating the robot description variable.
So here as you can see the robot description variable is using the exact command.
This one here in order to convert our model.
So our model that is this one here.
So the Arduino bot dot Urdf dot sacro is using to convert this one into a string, and then is passing
this string here to the robot state publisher node.
And this node here then will be in charge of loading the robot descriptions of making it available in
our Ros two topic.
Now we need to slightly modify this one.
And so we can go here.
And the exact command that we are using.
So we can slightly modify this one here and here after the exact command.
So the exact command.
This one will contain the full path to the Urdf model of our robot.
And here we need to set an additional argument.
That is the is ignition argument.
In fact, as you remember.
So to our Urdf model of our robot.
So to this one here we have set in the previous lesson.
So if we open it here we have set this argument here.
So now we want to set actually a value for this argument depending on the ros2 version that you are
using.
So back in gazebo here, we already know the Ros2 version that is installed on your system by using
the Ros distro variable.
And here we can create a new variable called is ignition.
And we set this one to true.
If your Ros version is humble.
Otherwise if you are on any newer version, let's simply set this variable here to false.
And now that we have here this variable initialized with true or false, depending on the ros2 version
that you are using, we can simply pass it to the command.
So now this exact command will convert our Urdf model using this variable here.
So using this argument here.
Perfect.
So we can save also this file the gazebo launch.py.
And let's finally verify that everything is correctly working.
So let's open a new terminal.
Let's go to the workspace.
Perfect.
And here let's build it with Qualcomm build.
Perfect.
Then in a new window of the terminal let's source the workspace.
So the file setup.
And let's simply start the gazebo simulation of our robot with Ros2.
Launch.
And from the Arduino Description.
Let's start the gazebo.
Launch pi.
So let's press enter and this will start the simulation of our robot in the empty world.
And we can already see that as we spawn our robot.
Now our robot is standing still, so is not falling anymore.
So we can see that it is still.
And this is because.
So this confirms us already that the Ros2 control library has been properly loaded.
And also if we open.
So if we make this terminal a little bit bigger and we go here above, we can see that we have a lot
of logs that are coming from the gazebo Ros2 Control library.
So we can see here that this confirms us, that actually the gazebo Ros2 control library is properly
loaded.
And so our robot now in the simulated environment is properly loading the Ros2 control library, which
we are going to use in the following lesson in order to move the simulated robot here in the simulated
environment.