After so much talking about movie two, let's finally see how to integrate our robot with this software
and configure it to be able to directly move the robot's gripper in the three dimensional space and
calculate trajectories that move the robot from an initial configuration to a final one.
Since we are adding new functionalities to the robot, let's start by creating a new package.
So in the terminal, let's go to the workspace and into the SRC sub folder.
And here let's create a new package with the two.
Package create command.
Let's use as a build type, amend CMake and let's name this package Arduino but move it.
And let's press enter to create this package.
So now we can see that we have the Arduino board Movete package.
So let's go back to the workspace folder and let's build it again so that the new package is recognized
and we can start inserting configuration files for move it inside this new package.
So we can see here that the Arduino board moved here, is recognized and compiled now back in Visual
Studio code.
Let's open the Arduino board movete package that we have just created.
And here, let's start by creating some configuration files that we are going to use to customize some
of the movie functionalities for our robot.
By convention, let's put all of these configuration files inside a new folder called config.
And within this folder let's create a new file called Arduino bot dot s r DF.
So let's press enter.
This is still an XML file, so let's use the XML tag and then let's set the version to be the 1.0 and
the encoding to be UTF eight.
Then let's close the XML tag.
This file has a structure that is very similar to the one that we used for our robots RDF model.
In fact, like our RDF model of the robot, it also contains a robot tag and we can still assign it
a name and let's call it Arduino bot and it will contain some additional information to the ones that
are available in the RDF model and that it needs for the planning and for the execution of the trajectories.
First, let's create two separate groups for the robot's joints.
So let's create two containers that are called group and let's create a second one, a second group,
and let's name the first group.
So this one, let's name it the arm group.
And this one will contain the joints that belongs to the robot's arm, including also the virtual joint.
So let's start with the first one.
That is the virtual joint.
And then it also contains the first three movable joints of the arm.
So the joints one, two and three.
So let's add a new joint, and this one is called Joint one.
Then let's copy this one and let's paste it three times.
And so we are saying that the joint one, two and three, so the three of them belong to the ARM group.
And also let's add a new joint.
And this last one is the horizontal arm to clone support.
And this this is horizontal, horizontal arm to close a port.
And as you might remember, this is the last joint of the arm.
So the one that connects actually the arm to the gripper.
So let's define the second group and let's call this one gripper.
And it contains the joints of the gripper.
So basically it contains the joint.
For.
And then let's copy this one and let's paste it.
And also the joint five.
Next.
For each group, we need to define a starting configuration.
So we need to define a starting configuration of the joints of the robot so the joints that belong to
each of these groups.
So let's do so out of the group tags and we need to use the group state tag.
So let's define to group states one of for each of the two groups.
So group state.
Okay, now we have two.
And so the first one, let's call this one name home.
And this refers to the home position for the group arm.
So the group is the arm group.
And now let's just set for the initial configuration, the value of all the joints that belong to the
arm to zero.
So for example, the joint one, let's set the value of the joint 1 to 0 and also let's do the same
for the Joints two entry.
So for all the movable joints that belong to the ARM group.
So let's set their state to zero.
Now for the gripper.
So let's call the initial configuration also home.
And the group which we refer to is the gripper.
And also in this case, we need just to set the initial position of the joint.
That is called joint four and its value.
Let's set also to zero.
So in this case, we don't need to set also the position of the joint five as as we said, for the two
control library, the joint five will copy will mimic the movements of the joint four.
As the final step for this SDF file.
We also need to set up the collisions, so we need to configure the pairs of link among which we want
to disable the collision control that is offered by Moovit.
So this is useful especially for those links that are next to each other.
And so therefore they are, let's say, always in collision or simply they are in contact with each
other.
For example, let's disable the collision.
So disable collision between the link one that is the base link.
And the link to that is the base plate.
This way, basically move it to will not check for the collision among these two links.
And so among the two meshes that are attached to these two links.
And the reason is because they are adjacent.
So at adjacent.
Next, let's copy this one and let's paste it below.
In order to disable the collision between the base link and the forward drive.
Arm and let's never check this collision.
Then let's also copy this one and let's avoid the collision check between this time the base plate and
the forward drive arm and also then the closer port.
And the forward drive arm and then also between the close support.
And the gripper left.
And then the one with the gripper.
Right.
So let's copy this one with the gripper.
Right.
And then also another one between the forward drive arm.
So this one and the gripper left and the forward drive arm and the gripper.
Right.
Then let's also add a new one between the forward drive arm and the horizontal arm.
And then still with the gripper left between the gripper left and the horizontal arm.
And then the other one with the gripper.
Right.
So gripper.
Right.
And the horizontal arm.
And then the last one that is between the gripper left and between the gripper.
Right.
Let's save this file.
And this configuration file is completed so we can move on with the next one.
So let's create a new file still within the config folder.
And let's call this one initial positions dot yaml.
So this time this is a Yaml file.
And here for each of the robots movable joint, we need to add a position.
So an initial configuration.
So let's add initial position and for example, let's set all the joints to zero.
So joint 1 to 0 and then let's copy this one.
And let's paste it below.
And so we have joined two, three and four, all set to zero.
And also, let's save this file and we can create another configuration file.
So still here.
And let's call this one joint limits.
Still, this is a Yaml file.
And in this file, as you might have guessed from the name, we need to specify the kinematic limit
for each movable joint.
So let's start by setting the default velocity scaling factor.
So default velocity scaling factor to 0.1 and the default acceleration scaling factor again to 0.1.
And this reduces the maximum speed and the maximum acceleration with which the robot will be asked to
move.
And so to follow the trajectories.
Now we can use the joint limits.
So let's set the joint limits to assign some limits to all the movable joints of the robot.
So let's start with the joint one.
And this has velocity limits.
So let's set these velocity limits to true, and then let's set the maximum velocity to ten.
So let's put this one inside because this one belongs to the joint one.
So let's set the max velocity to ten.
And it doesn't have instead acceleration limit.
So let's set these
acceleration limits to false.
And so let's leave the maximum acceleration to zero since it will not be used here.
We're missing the two dots since we are going to use the same motors with the same properties for all
the movable joints of the robot.
We can copy these limits.
So these parameters here also for the other joints.
So let's copy these.
Three more times.
And so let's set the properties for the joint to three and also for the joint four.
And finally the joint five here.
Let's also save this file and let's continue by creating another configuration file.
So still within the config folder, let's create a new file and this one is called kinematic dot Yaml.
In this file we need to declare and configure the kinematic solver that move it has to use for our robot.
So we only need to use a kinematic solver for the group of joints that we called arm that actually compose
the actual arm of the robot and let's use one that is available in the
kinematics.
Plugin package.
And specifically let's use the k d, l kinematics plugin.
Then let's also set the parameter
kinematics solver search resolution to be 0.05.
And also let's set the kinematics solver timeout to be 0.005.
Here the resolution is 0.005.
And finally, let's set one last parameter that is called position only inverse kinematic.
And let's set this one to true.
This parameter is useful since our robot has only three degrees of freedom.
And so we are asking the inverse kinematic solver to define only the position in the space of the robot.
So if the gripper and not its orientation.
So we don't want to specify the orientation of the gripper in the space, since we don't have enough
number of degrees of freedom, we don't have enough actuator for our robot.
So let's save this file and let's add another configuration file.
So let's create here a new configuration file that we can call Move It
controllers.
This is still a Yaml configuration file and we use this configuration file to connect the move library
with the Ros2 control library that we have already configured for our robot and therefore with the controllers
that we used to move the robot's joints.
So let's specify the parameters for the move IT controller manager.
And so we want to use the move it simple
controller Manager.
So from this package we want to use the move it simple controller manager and then let's configure this
simple controller manager.
So let's configure the move it simple controller manager informing that there are two controllers actually
that we want to configure for our robots.
And there are the arm controller and also the gripper controller and these are the names of the two
controllers.
So the arm controller and the gripper controller are the names of the two controllers that we have configured
for our robot using the Ros to control library.
Now regarding the arm controller, this offers an action with the namespace follow joint trajectories.
So let's use the action namespace that is the follow joint
trajectory and the type of the action that it offers is follow joint trajectory as we have defined when
we configured the arm controller for the Ros2 control.
And also let's set the default configuration for this action.
So let's use the true in order to use the default configuration.
And also then we need to set which are the joints that are actuated by this controller.
So the joints that are actuated by the arm controller are the joint one, the joint two and the joint
three.
Now regarding the gripper controller, this also use the same namespace.
So the action namespace is still follow joint trajectory and also it uses the follow joint controller.
And also let's set the default to true.
And this time the joints that are actuated by this one, so by the gripper controller are the joint
four and also the joint five that simply mimics the behavior of the joint four.
Let's save also this file.
And next we need to create one last configuration file.
So here let's create this new file that is called p, l, e, z, Cartesian limits.
And this is a yaml file.
And in this file we need to specify the limits during the Cartesian movements of the robot.
So the ones along the x, y and.
Z-axis so Cartesian limits of the robot and let's set the max translational velocity to be 1.0.
Then the max transactional
acceleration to be 2.25.
Then the maximum transactional deceleration to be minus five.
The maximum maximum rotational velocity to be, for example, 1.57.
Let's also save this last configuration file.
The last configuration that we need for the proper execution of Movie2 is to change the default implementation
of the DDS used by Ros2.
In fact, as we can see from the official wiki of Movie2, they are currently having some issues with
the default implementation that comes with ros2.
So here they suggest to switch to cyclone DDS.
And so in order to do so, let's start by installing this implementation of DDS.
So let's open a new terminal and let's copy this command here.
You need to change with the Ros2 version that you are using.
That in my case is ros2 humble.
So let's press enter in order to install this implementation.
And then in order to start actually using this implementation of DDS, we need to copy this line here
and we need to paste it within the bash RC file.
So let's use vim to modify the file dot bash.
RC And here at the end of the file, let's add this line.
So let's close and save the bash.
RC.
And now from the next time we will open a new terminal Roscoe will use by default cyclone DDS.
So the one suggested by move it to for the communication and the message exchange protocol as this implementation
is fully compatible with move.
For now, this configuration files are all we need for launching and executing.
Move it for our robot.
And so to use the modules of inverse kinematics, trajectory planning and also trajectory execution.
However, before concluding this lesson, I wanted to show you an alternative way to generate the Moovit
configuration for a specific robot.
In fact, instead of manually writing all of these configuration files.
So here that we created inside the Arduino bot Moovit package move, it also offers a graphical interface
called Setup Assistant to configure the features for your robot.
So we can launch this functionality by opening a new terminal and using the command Ros to launch and
from the Moovit setup assistant package.
Let's start the setup assistant dot launch dot pi.
So let's press enter.
And now in this guy you can load, for example, the robot's Urdf model, which will automatically configure
then some parameters such as, for example, automatically ignoring the collisions between the robots
link during the planning or also automatic detect, which are the controllers that are used and so on.
Upon completing then the moovit configuration with this tool, with the setup assistant, all the packages
and all the configuration files are also then created automatically.
However, normally this tool generates many more configuration files with many more parameters which
are deemed unnecessary for the purpose of this tutorial and for the robot's functionalities in order
to offer you a cleaner code and also a cleaner configuration parameters with fewer parameters that you
can easily understand and also that you can easily tune.