WEBVTT

00:00.110 --> 00:06.500
Once we have created the hardware interface and installed it as a plugin for the Ros two Control library,

00:06.530 --> 00:12.770
we can now proceed to use this hardware interface and to ensure that when the robot control system is

00:12.770 --> 00:18.380
started, instead of loading the hardware interface with the simulated motors in Gazebo, we activate

00:18.380 --> 00:20.150
the real hardware interface.

00:20.150 --> 00:23.990
So the Arduino board interface that we have been developing so far.

00:24.790 --> 00:25.560
To do this.

00:25.570 --> 00:32.920
Let's go back in Visual Studio Code modifying the urdf of our robot, which we previously created in

00:32.920 --> 00:35.290
the package Arduino board description.

00:35.290 --> 00:41.050
And for the moment which we have just interfaced with the Ros two Control library in Gazebo.

00:41.050 --> 00:45.040
So basically with the Gazebo Ros two control plugin.

00:45.770 --> 00:51.860
Let's go back to the RDF model and show to the Arduino bot dot Urdf dot Sacro.

00:52.190 --> 00:57.470
And here let's add a new argument to configure the behavior of the Urdf file.

00:57.950 --> 01:02.120
So let's create a new tag called ARG.

01:02.150 --> 01:04.130
That stands for argument.

01:05.840 --> 01:07.370
And let's give it a name.

01:07.910 --> 01:13.340
Let's call this one is seam in order to indicate if we are using.

01:13.340 --> 01:20.600
And so if we are loading the Urdf model for the simulated robot or for the real one, and by default,

01:20.690 --> 01:23.140
let's set this one to true.

01:23.150 --> 01:28.640
So by default, we are always going to load the urdf model for the simulated robot.

01:29.540 --> 01:36.830
We can use this argument to make the urdf model of the robot to behave differently, which means loading

01:36.830 --> 01:42.830
different Ros two plugins depending on whether we are starting the control system for the real robot

01:42.860 --> 01:44.630
or for the simulated one.

01:45.970 --> 01:46.990
Once declared.

01:46.990 --> 01:54.760
So since we have declared this argument here within the Arduino board Urdf, we can also use it in any

01:54.760 --> 01:57.110
of the two files that we are including.

01:57.130 --> 02:02.700
So, for example, let's use this argument here within the Arduino board, Ros, to control.

02:02.710 --> 02:07.990
So let's open this script here in this file, let's add a new group.

02:07.990 --> 02:13.240
So basically a new conditional statement using the tag Sacro.

02:13.930 --> 02:23.260
If so, let's use this group here and let's activate this group only when the value of the argument.

02:24.340 --> 02:29.290
So let's take the argument is sim that you have just created.

02:29.290 --> 02:36.640
So the content all all the tags that you are going to insert here within these two tags will be executed

02:36.640 --> 02:42.190
and so will be loaded only if the argument is sim is set to true.

02:42.580 --> 02:46.100
So in this case, let's use this Arduino interface.

02:46.100 --> 02:49.250
So let's paste it here.

02:49.250 --> 02:55.760
So in this case, if we are using and so we are loading the robot description of the robot, so the

02:55.790 --> 03:00.230
Urdf model for the simulation, then we are going to use this one.

03:00.230 --> 03:03.740
So we are going to use this hardware interface with Gazebo.

03:03.740 --> 03:09.680
So it means that we need to activate the plugins and the interface for the simulated robot.

03:10.410 --> 03:15.260
And within this block, let's also copy the tag for the joint five.

03:15.270 --> 03:20.220
So this one here, so this one is needed only for the simulation.

03:20.220 --> 03:24.720
And this allows the joint five to mimic the behavior of the joint four.

03:24.840 --> 03:32.010
So also this one is only needed for the simulation as in the real robot, there will be an actual transmission.

03:32.010 --> 03:38.400
So there will be an actual system of gears that will make the joint five to mimic the behavior of the

03:38.400 --> 03:39.090
joint four.

03:39.090 --> 03:43.620
So for the real robot, we just need to activate the joint four.

03:44.380 --> 03:50.500
On the other hand, when we are starting the control system for the real robot, so let's use a similar

03:50.500 --> 03:51.130
tag.

03:51.310 --> 03:56.100
So that is called unless.

03:56.500 --> 04:01.900
So unless the argument is SIM is set to true.

04:02.800 --> 04:05.560
So this is quite easy to understand.

04:05.740 --> 04:12.580
So this is only activated if the argument is sim is set to true and this is only activated if the argument

04:12.580 --> 04:14.380
is sim is set to false.

04:14.380 --> 04:21.220
So if we are loading the urdf model for the real robot in this case we want to load a different hardware

04:21.220 --> 04:22.150
interface.

04:22.600 --> 04:25.480
So let's use still the tag hardware.

04:26.300 --> 04:36.830
And in this case we want to load a plugin and the plugin that we want to load is the Arduino boot controller.

04:37.070 --> 04:42.020
And so the one that we called Arduino boot interface.

04:42.350 --> 04:49.460
Regarding this plugin, as you might remember, we have also defined a parameter called port.

04:49.910 --> 04:58.520
So let's set now this parameter that indicates the port to which the Arduino board is connected.

04:58.520 --> 05:03.980
And so the port that the hardware interface has to use for the serial communication.

05:04.160 --> 05:12.920
In my case, this is the port ACM zero and here basically it goes your port.

05:12.920 --> 05:17.210
So the one that you are using to connect the Arduino board to your PC.

05:17.930 --> 05:19.180
For the other joints.

05:19.190 --> 05:25.220
So the configuration of the other joints can remain unchanged since they are going to use the same configuration.

05:25.220 --> 05:28.830
Both in the real robot and also for the simulated one.

05:30.020 --> 05:35.210
Let's conclude also this lesson by updating the controller dot launch dot pi.

05:35.480 --> 05:40.760
So within the Arduino board controller, let's open the controller dot launched file.

05:41.090 --> 05:47.540
And here let's declare an argument that allows us to customize the behavior of this launch file for

05:47.540 --> 05:49.670
the simulation or for the real robot.

05:49.670 --> 05:54.980
So if we are loading the control system for the real robot or for the simulated one.

05:55.760 --> 06:02.330
So let's import a new library from the module actions.

06:02.690 --> 06:07.040
Let's import the declare launch argument.

06:07.400 --> 06:16.100
And let's use it within the generate launch description to create a new object called is same argument.

06:16.100 --> 06:20.930
So to create a new argument for the controller dot launch dot pi file.

06:21.200 --> 06:25.160
So let's create a new instance of the declare launch argument.

06:25.340 --> 06:31.520
The argument is going to be called is sim and by default.

06:32.060 --> 06:34.190
So let's keep the behavior unchanged.

06:34.190 --> 06:36.710
So if we are not passing anything.

06:36.860 --> 06:43.610
Let's set this one to true meaning that we want to activate by default the control system for the simulated

06:43.610 --> 06:44.270
robot.

06:44.900 --> 06:52.160
From now on, when we launch the controller dot launch file, we can also set this argument so we can

06:52.160 --> 06:53.990
set a value for the argument.

06:53.990 --> 06:58.260
Is C Now let's make this launch file to use it.

06:58.260 --> 07:06.300
So to read, which is the value that we assigned to the SIM by importing a new library and from the

07:06.300 --> 07:07.980
launch substitutions.

07:08.550 --> 07:15.210
So from this one, let's import also the launch configuration and let's create a new variable called

07:15.240 --> 07:20.610
is seen as an instance of the launch configuration class.

07:20.610 --> 07:27.150
And so this variable contains the value that is assigned at runtime to the is SIM argument.

07:27.360 --> 07:33.840
So let's take let's read which is the value of the is SIM argument.

07:34.050 --> 07:37.410
Now let's slightly modify this one here.

07:37.410 --> 07:43.410
So this variable here, the robot description as now the urdf model of our robot.

07:43.410 --> 07:47.370
So basically this one also has an argument.

07:47.370 --> 07:53.850
So we also added an argument to this one which indicates which discriminates which type of hardware

07:53.850 --> 07:55.770
interface we want to start.

07:55.950 --> 08:05.520
And so let's set here, let's pass an argument to this command that is the is SIM that we have just

08:05.520 --> 08:06.270
created.

08:06.270 --> 08:09.600
And let's set this one to false.

08:10.760 --> 08:20.570
So let's load the robot description by setting the Is argument to false and also regarding the robot

08:20.570 --> 08:21.680
state publisher.

08:21.710 --> 08:27.890
Now, in the control system, we want to start the robot state PowerShell only if we are using.

08:27.890 --> 08:32.230
So only if we are launching the control system for the real robot.

08:32.240 --> 08:36.770
As if you remember if we launch the simulated robot.

08:36.800 --> 08:43.730
So if we go into the description, launch the gazebo here, it's already started.

08:43.730 --> 08:45.410
The robot state publisher.

08:45.410 --> 08:51.920
So in the controller launch, we want to start the robot state publisher only if this one.

08:51.920 --> 08:56.120
So this argument here, the is SIM argument is set to false.

08:56.480 --> 09:03.290
So now let's import from the launch library and from the conditions module.

09:03.620 --> 09:12.390
Let's import the class unless condition and so let's use it here in order to indicate that we want to

09:12.390 --> 09:13.740
execute this one.

09:14.850 --> 09:24.060
Unless so, let's use the unless condition, unless this node is started with the argument is set to

09:24.090 --> 09:24.600
true.

09:25.050 --> 09:28.320
So let's pass the argument is a C.

09:28.620 --> 09:34.560
So basically what we are saying is that we want to start the robot state publisher only if we are starting

09:34.560 --> 09:38.640
the control system for the real robot in this launch file.

09:38.640 --> 09:45.510
Let's also start a new node and this is the controller.

09:47.400 --> 09:52.020
Manager and this is an instance still of the Node class.

09:52.020 --> 09:56.700
And with this node we want to start from the package.

09:59.370 --> 10:00.630
Controller manager.

10:00.660 --> 10:11.550
From this one, we want to start the executable that is called Ros to control Node.

10:11.760 --> 10:15.900
And also we want to pass the configuration parameters of this node.

10:15.930 --> 10:21.480
So let's pass some parameters and let's include the robot description.

10:21.660 --> 10:24.750
So let's use a dictionary.

10:24.750 --> 10:30.840
So let's pass the robot description to this dictionary.

10:31.080 --> 10:35.310
So here and this is the variable robot description.

10:35.550 --> 10:37.350
Then let's also pass the argument.

10:37.350 --> 10:50.400
Use some time, then let's also pass the use same time argument and let's set this one equal to the

10:50.670 --> 10:51.750
same argument.

10:51.750 --> 10:54.930
So too the argument is same of the launch file.

10:55.680 --> 10:58.170
Also to the controller manager.

10:58.170 --> 11:00.330
We want to pass the directory.

11:00.330 --> 11:03.790
Where is the configuration of the controller manager?

11:03.810 --> 11:07.770
So basically we want to pass this directory here.

11:07.770 --> 11:14.190
So the directory of this file here in which we have defined all the controllers and all the types of

11:14.190 --> 11:18.120
the controllers that we want to start for the arm and for the gripper.

11:18.650 --> 11:24.920
So still here within the controller manager and after here this dictionary.

11:24.950 --> 11:27.500
Let's use the function.

11:28.920 --> 11:32.420
Voice, but join.

11:32.460 --> 11:40.050
So let's use this one to specify that the directory is within the package.

11:41.040 --> 11:43.950
Arduino Board Controller.

11:46.310 --> 11:52.160
Then within the config folder and the file which contains the configuration for the controller manager

11:52.160 --> 11:53.840
is the one that we have called.

11:55.520 --> 11:59.780
Arduino board controller dot yaml.

12:00.260 --> 12:04.000
Anyway, let's also set that we want to start this node.

12:04.010 --> 12:10.850
So we want to start these functionalities only if we are starting the control system for the real robot.

12:10.850 --> 12:12.920
So not for the simulation.

12:12.920 --> 12:23.450
And so let's set the condition to be unless condition, so unless the argument is a sim is set to true.

12:23.450 --> 12:27.320
So we are doing the same as we did for the robot state publisher node.

12:27.410 --> 12:34.580
So with this we are indicating that both of these nodes will be started only if the launch file that

12:34.580 --> 12:40.100
is called controller approach is started with an argument is set to false.

12:40.100 --> 12:43.340
So to start the control system for the real robot.

12:44.080 --> 12:50.370
Let's conclude this lunch file by adding the new nodes and the new instructions that we have used.

12:50.380 --> 12:52.960
So the is SIM ark.

12:54.160 --> 12:57.220
Let's add the declaration of the argument is SIM.

12:57.220 --> 13:00.400
And then also let's start the controller manager.

13:00.400 --> 13:05.320
So here, let's start the one that we called here.

13:05.320 --> 13:06.430
Controller Manager.

13:09.410 --> 13:15.900
Finally to conclude this lesson and to check that we have not made any mistake, let's compile our workspace.

13:15.920 --> 13:23.930
So let's go to the workspace and let's build it with the Qualcomm build.

13:25.770 --> 13:27.660
The build finished correctly.

13:27.660 --> 13:33.930
And so the next lesson, we can start using these new launch files and also the new hardware interface.
