WEBVTT

00:00.110 --> 00:07.130
Now that we know what YAML configuration files are and what they are used for, let's see how we can

00:07.130 --> 00:14.330
create a new file that contains the configuration parameters for the Ros2 control library for our robot.

00:14.480 --> 00:20.060
Since this configuration file will contain specific parameters for configuring the control system of

00:20.060 --> 00:24.980
our robot, let's create it inside a new package in our workspace.

00:24.980 --> 00:28.130
So first we need to create a new package.

00:28.280 --> 00:34.310
So let's go to the workspace and to the source folder in which we have already created several packages

00:34.310 --> 00:35.330
for our robot.

00:35.330 --> 00:41.120
And here let's create a new package with the Ros2 package create.

00:41.150 --> 00:44.570
Then let's select the build type.

00:44.570 --> 00:53.360
And for this case let's use the AMD CMake as we are going to insert both Python and C plus plus code

00:53.360 --> 01:00.620
in this package here, and let's call it Arduino bot controller.

01:00.650 --> 01:02.630
So let's press enter.

01:02.630 --> 01:07.670
And now as you can see we have a new package that is called Arduino Bot Controller.

01:07.670 --> 01:14.720
Also we can build the workspace with Colgan Build in order to compile also the new package that we have

01:14.720 --> 01:15.380
created.

01:15.380 --> 01:17.240
So the Arduino bot controller.

01:17.270 --> 01:24.170
Now back in Visual Studio Code, here we have the Arduino bot controller package that we have just created.

01:24.170 --> 01:30.320
And here we can see that we have already some folders, empty folders and the CMake list, and the package

01:30.320 --> 01:33.590
dot XML files that were automatically generated.

01:33.590 --> 01:40.040
And here inside this package let's create a new folder that is called config.

01:40.040 --> 01:50.540
And within this config folder let's create a new file that is called Arduino bot controllers dot YAML.

01:50.570 --> 01:51.170
Perfect.

01:51.200 --> 01:55.790
And so this configuration file here will contain the configuration.

01:55.790 --> 02:03.110
So the parameters for the Ros2 control library as I mentioned in the theoretical lessons about configuration

02:03.110 --> 02:03.710
files.

02:03.740 --> 02:10.490
A YAML file always starts with the name of the node to which the configuration parameter refers.

02:10.520 --> 02:20.360
In our case, we are configuring the node called controller manager and so we are configuring it Ross.

02:22.340 --> 02:25.010
So the Ross parameters of this node.

02:25.010 --> 02:29.210
And let's start now by setting the Ross parameters that we want to set.

02:29.240 --> 02:36.110
So here we can list now all the configuration parameters that we want to set for the controller manager

02:36.110 --> 02:42.560
node, starting with the update rate that we can set to ten.

02:42.590 --> 02:44.900
So we can set it to ten hertz.

02:44.900 --> 02:51.800
And then so this parameter here indicates the frequency at which the control loop will be updated and

02:51.800 --> 02:52.820
executed.

02:52.970 --> 02:58.430
And then let's also add the names of the controllers that we want the controller manager to use for

02:58.430 --> 02:59.330
our robot.

02:59.330 --> 03:07.850
And actually we are just going to use two controllers, One for the arm that is called ARM controller.

03:07.880 --> 03:08.720
Perfect.

03:08.780 --> 03:16.100
And then another one for the gripper that is called gripper Controller.

03:16.130 --> 03:16.700
Perfect.

03:16.700 --> 03:18.350
And now for both of them.

03:18.350 --> 03:25.250
So for these two controllers we need to specify their type, which determines the logic that is going

03:25.250 --> 03:27.800
to be used for the control system.

03:27.800 --> 03:39.500
So here for the ARM controller let's set the type perfect to be a joint.

03:41.570 --> 03:45.320
Trajectory controller.

03:45.320 --> 03:52.790
And so from this package here we want to use the class joint trajectory.

03:55.040 --> 03:56.000
Controller.

03:56.000 --> 03:56.750
Perfect.

03:56.750 --> 04:02.930
And this basically indicates that we want to send trajectory commands to the joints that belongs to

04:02.960 --> 04:03.770
the arm.

04:04.130 --> 04:10.490
So this trajectory here basically will contain a list of points, a list of coordinates in which we

04:10.490 --> 04:13.700
want the joints of the arm to be at any moment in time.

04:13.940 --> 04:16.250
Now for the gripper controller.

04:16.250 --> 04:19.640
So here let's set the type.

04:19.640 --> 04:21.920
So we are also going to use the same type.

04:21.920 --> 04:26.060
We are also going to use this type here for the real robot.

04:26.060 --> 04:29.840
So a controller of type joint trajectory controller.

04:29.870 --> 04:35.780
However for the moment let's do a simple test with a different type.

04:35.780 --> 04:42.380
So we can comment this one here for the moment, and we will uncomment this one in the future.

04:42.380 --> 04:46.490
And let's do a simple test using a different type of controller.

04:46.490 --> 05:01.880
That is the forward command controller of type forward command controller.

05:01.880 --> 05:08.740
So this is a simpler controller that simply will allow us to send just a goal to the gripper.

05:08.740 --> 05:13.480
So to send just a command and the gripper will move to the desired position.

05:13.480 --> 05:19.570
So instead of specifying a full trajectory, we will just specify the goal to the gripper and the gripper

05:19.570 --> 05:21.970
will move to the desired position.

05:22.180 --> 05:28.660
Finally, in addition to these two controllers, the controller manager also needs to load a module

05:28.660 --> 05:32.560
that is called joint state.

05:34.660 --> 05:41.920
Broadcaster and this module is responsible for publishing the current state of the joint of the robot

05:41.920 --> 05:43.120
into a topic.

05:43.150 --> 05:49.360
And so then other nodes, for example, can use this topic in order to read the current position of

05:49.360 --> 05:50.350
the joints of the robot.

05:50.380 --> 05:52.540
And so the current position of the arm.

05:52.630 --> 05:55.210
And let's use the type.

05:55.210 --> 06:02.350
So we are going to use the joint state broadcaster.

06:02.350 --> 06:10.900
So from this package we want to load the joint state broadcaster.

06:10.990 --> 06:12.070
Perfect.

06:12.490 --> 06:15.190
So far, however, for the controller manager.

06:15.190 --> 06:19.240
So for this node here we have only indicated the names.

06:19.240 --> 06:25.690
So this one here and also the types this one here of the controllers that we want to load.

06:25.690 --> 06:27.010
And so the arm controller.

06:27.040 --> 06:30.280
The grip controller and the joint state broadcaster.

06:30.310 --> 06:32.290
Now we also need to specify.

06:32.320 --> 06:35.650
So we also need to configure the single controller.

06:35.650 --> 06:40.660
So we need to configure here the ARM controller and also the gripper controller.

06:40.690 --> 06:42.130
We can do it here.

06:42.130 --> 06:43.690
So within the same file.

06:43.690 --> 06:46.990
And we can do it here at the beginning of this file.

06:46.990 --> 06:51.820
So let's configure the R controller.

06:51.820 --> 06:59.140
And we are configuring the cross parameters of this controller here.

06:59.140 --> 07:02.230
And also we can do the same also for the gripper controller.

07:02.230 --> 07:03.460
So let's copy it.

07:03.460 --> 07:04.660
Let's paste it.

07:04.660 --> 07:09.460
And here we are configuring the gripper controller.

07:09.490 --> 07:10.300
Perfect.

07:10.330 --> 07:14.590
Now here let's start with the parameters of the ARM controller.

07:14.590 --> 07:21.250
And we simply need to indicate the name of the joints that belong to this controller so that this controller

07:21.250 --> 07:22.570
will activate.

07:22.570 --> 07:25.660
And these are the joint one.

07:27.850 --> 07:32.350
The joint two and also the joint three.

07:32.350 --> 07:39.490
So these three joints are actually the ones that will activate the robot instead for the gripper.

07:40.750 --> 07:43.090
The joints that will activate the gripper.

07:45.100 --> 07:46.870
Is actually just one joint.

07:46.870 --> 07:48.700
That is the joint number four.

07:48.700 --> 07:55.780
So actually here we don't need to list the joint number five as the joint number five will simply copy.

07:55.780 --> 07:59.620
So we'll simply mimic the behavior of the joint number four.

07:59.650 --> 08:09.310
Now in both cases also we need to indicate apart from the joints we need to indicate the command interfaces

08:09.310 --> 08:10.900
that these joints are using.

08:10.900 --> 08:19.120
And in both cases the command interface is just a position command interface.

08:19.690 --> 08:23.650
So we can copy this parameter also for the gripper.

08:24.040 --> 08:27.580
So also here and now we also want to specify.

08:27.610 --> 08:34.870
So apart from the command interface we want to specify the state interfaces.

08:34.870 --> 08:40.300
So the interfaces that we are going to use in order to receive the feedback from the motors from the

08:40.300 --> 08:40.960
joints.

08:40.960 --> 08:46.180
And also in this case in both cases it is a position interface.

08:46.180 --> 08:49.900
So we are going to receive the current position of each joint.

08:49.930 --> 08:53.140
So let's copy it also for the gripper.

08:53.170 --> 08:55.330
Now for both of these joints.

08:55.330 --> 08:58.330
So let's start with the ARM controller.

08:58.330 --> 09:05.440
We can set the open loop control to true.

09:05.440 --> 09:12.880
And this is very important because the real motors that we are going to use on the real robot will not

09:12.880 --> 09:17.320
be able to provide a feedback about the current position of the robot.

09:17.320 --> 09:20.950
And so actually we can use an open loop control.

09:20.950 --> 09:25.480
And also let's set another parameter that is the allow

09:27.340 --> 09:30.880
integration in goal.

09:33.070 --> 09:34.300
Trajectories.

09:34.450 --> 09:37.360
And let's also set this parameter to true.

09:37.360 --> 09:40.060
And let's copy also.

09:40.060 --> 09:43.570
So let's set also this one for the gripper controller.

09:43.570 --> 09:49.060
Now for the moment however these are the parameters that we are going to use for the real robot.

09:49.060 --> 09:54.280
So for the real gripper and also the parameters that we are going to use for the simulation of the gripper

09:54.280 --> 09:57.460
in the following lessons for the moment.

09:57.460 --> 10:04.090
So for our very first test that we are going to do, we can just comment all of these for the gripper.

10:04.090 --> 10:07.810
So from the command interfaces to the last parameter.

10:07.810 --> 10:09.250
We can comment all of these.

10:09.280 --> 10:14.860
And instead we can add a new parameter just for the gripper that is called.

10:15.400 --> 10:20.080
Interface name that we can set to position.

10:20.080 --> 10:26.860
And so this is just for the first test that we want to do and which we want to send a command using

10:26.860 --> 10:27.880
this interface here.

10:27.880 --> 10:31.600
So using the forward command controller to the gripper.

10:31.600 --> 10:34.900
And so for this test here we need this parameter here.

10:34.900 --> 10:38.230
But we are going to remove it at the end of this lesson.

10:38.380 --> 10:40.150
So let's save this file.

10:40.150 --> 10:46.330
And with this our configuration file for the controller manager node of the Ros2 control library is

10:46.330 --> 10:47.020
completed.

10:47.020 --> 10:53.920
And as I said, we will come back to modify this file here in order to change here the gripper controller

10:53.920 --> 10:57.430
to be again a joint trajectory controller.

10:57.430 --> 11:02.200
Now for the moment let's just install this folder here.

11:02.200 --> 11:04.660
So the config folder that we have just created.

11:04.660 --> 11:06.940
So let's go to the CMake list.

11:07.000 --> 11:11.080
Here we can delete all the commented rows.

11:11.350 --> 11:22.840
And here after the Findpackage section we can install and the directory that we want to install is the

11:22.840 --> 11:24.040
config folder.

11:24.040 --> 11:25.690
And we want to install this one.

11:25.690 --> 11:32.740
So this directory in the destination that is the share folder.

11:32.740 --> 11:36.220
And within the subfolder that is called as the package itself.

11:36.220 --> 11:38.710
So that is called Arduino bot controller.

11:38.710 --> 11:45.760
And also we can access this name using the variable project name.

11:45.790 --> 11:46.600
Perfect.

11:46.600 --> 11:48.430
Let's save also this file.

11:48.430 --> 11:55.480
And before testing our controller, remember that in the previous lesson when we configured the Urdf

11:55.480 --> 11:56.860
model of our robot.

11:56.860 --> 12:04.660
So here in the Arduino bot description in the Urdf folder and in the Arduino bot gazebo dot csv file.

12:04.660 --> 12:10.000
So here when we load it loaded the plugin for the gazebo Ros2 control library.

12:10.030 --> 12:15.610
Either if you are using Ros2 humble or if you are using Ros2 Jetson here.

12:15.610 --> 12:19.780
As you remember, we didn't set any parameters for this plugin.

12:19.780 --> 12:23.290
And now finally we have this nice configuration file here.

12:23.290 --> 12:28.750
So the Arduino board controller style that we can use here in order to configure the parameters of the

12:28.750 --> 12:30.310
Ros2 control library.

12:30.430 --> 12:39.340
So let's access let's find the Arduino board controller package.

12:39.340 --> 12:50.140
And from this package from the config folder let's open the Arduino board controllers dot YAML file.

12:50.140 --> 12:57.700
And actually this is the same file that we want to load independently on the plugin that you are using.

12:57.700 --> 13:04.360
So this is the same configuration file that you need either if you are on Ros2 chassis or if you are

13:04.420 --> 13:05.290
on Ros2.

13:05.290 --> 13:05.980
Humble.

13:06.490 --> 13:07.000
Perfect.

13:07.020 --> 13:08.580
Let's save all to this file.

13:08.580 --> 13:14.040
And also we need to apply one last change that is here in the launch file.

13:14.040 --> 13:16.410
So in the gazebo dot launch file.

13:16.410 --> 13:20.010
And actually the last change that we need to apply is here.

13:20.010 --> 13:23.640
So when we are creating the robot description variable.

13:23.640 --> 13:28.980
So here as you can see the robot description variable is using the exact command.

13:29.010 --> 13:32.760
This one here in order to convert our model.

13:32.760 --> 13:36.390
So our model that is this one here.

13:36.390 --> 13:42.930
So the Arduino bot dot Urdf dot sacro is using to convert this one into a string, and then is passing

13:42.930 --> 13:45.930
this string here to the robot state publisher node.

13:45.930 --> 13:53.280
And this node here then will be in charge of loading the robot descriptions of making it available in

13:53.280 --> 13:54.540
our Ros two topic.

13:54.660 --> 13:57.300
Now we need to slightly modify this one.

13:57.300 --> 13:59.310
And so we can go here.

13:59.730 --> 14:02.820
And the exact command that we are using.

14:02.820 --> 14:08.970
So we can slightly modify this one here and here after the exact command.

14:08.970 --> 14:10.050
So the exact command.

14:10.080 --> 14:14.100
This one will contain the full path to the Urdf model of our robot.

14:14.610 --> 14:17.910
And here we need to set an additional argument.

14:17.940 --> 14:22.260
That is the is ignition argument.

14:22.260 --> 14:23.910
In fact, as you remember.

14:23.910 --> 14:26.190
So to our Urdf model of our robot.

14:26.190 --> 14:29.490
So to this one here we have set in the previous lesson.

14:29.490 --> 14:33.630
So if we open it here we have set this argument here.

14:33.900 --> 14:39.390
So now we want to set actually a value for this argument depending on the ros2 version that you are

14:39.390 --> 14:40.080
using.

14:40.080 --> 14:47.790
So back in gazebo here, we already know the Ros2 version that is installed on your system by using

14:47.790 --> 14:49.650
the Ros distro variable.

14:49.650 --> 14:55.170
And here we can create a new variable called is ignition.

14:55.170 --> 14:57.120
And we set this one to true.

14:58.500 --> 15:03.660
If your Ros version is humble.

15:05.670 --> 15:13.440
Otherwise if you are on any newer version, let's simply set this variable here to false.

15:13.500 --> 15:19.440
And now that we have here this variable initialized with true or false, depending on the ros2 version

15:19.440 --> 15:24.300
that you are using, we can simply pass it to the command.

15:24.330 --> 15:30.210
So now this exact command will convert our Urdf model using this variable here.

15:30.210 --> 15:32.490
So using this argument here.

15:32.730 --> 15:33.810
Perfect.

15:33.840 --> 15:37.650
So we can save also this file the gazebo launch.py.

15:37.650 --> 15:42.240
And let's finally verify that everything is correctly working.

15:42.360 --> 15:44.400
So let's open a new terminal.

15:45.210 --> 15:47.610
Let's go to the workspace.

15:47.640 --> 15:48.360
Perfect.

15:48.990 --> 15:52.560
And here let's build it with Qualcomm build.

15:53.400 --> 15:54.210
Perfect.

15:54.240 --> 15:58.380
Then in a new window of the terminal let's source the workspace.

15:58.860 --> 16:00.030
So the file setup.

16:00.600 --> 16:05.640
And let's simply start the gazebo simulation of our robot with Ros2.

16:05.670 --> 16:06.660
Launch.

16:07.230 --> 16:09.840
And from the Arduino Description.

16:09.960 --> 16:11.730
Let's start the gazebo.

16:12.000 --> 16:12.900
Launch pi.

16:12.930 --> 16:18.900
So let's press enter and this will start the simulation of our robot in the empty world.

16:18.900 --> 16:22.200
And we can already see that as we spawn our robot.

16:22.230 --> 16:27.120
Now our robot is standing still, so is not falling anymore.

16:27.120 --> 16:29.070
So we can see that it is still.

16:29.070 --> 16:30.360
And this is because.

16:30.360 --> 16:35.730
So this confirms us already that the Ros2 control library has been properly loaded.

16:35.730 --> 16:38.040
And also if we open.

16:38.040 --> 16:44.460
So if we make this terminal a little bit bigger and we go here above, we can see that we have a lot

16:44.460 --> 16:49.020
of logs that are coming from the gazebo Ros2 Control library.

16:49.020 --> 16:54.750
So we can see here that this confirms us, that actually the gazebo Ros2 control library is properly

16:54.750 --> 16:55.470
loaded.

16:55.470 --> 17:01.980
And so our robot now in the simulated environment is properly loading the Ros2 control library, which

17:01.980 --> 17:08.100
we are going to use in the following lesson in order to move the simulated robot here in the simulated

17:08.100 --> 17:08.970
environment.
