In this lesson, we are going to start the task server and see how it interacts with the movie API to
move the robot to a predefined position.
In order to do so, let's create a new launch file within the Arduino bot remote package.
So here let's create a new folder called launch.
And here within this folder let's create a new file called Remote interface dot launch dot pi.
Perfect.
And here in this launch file we are going to insert all the functionalities that we are going to create
here within the Arduino bot remote package.
And that will allow our robot to communicate with the Alexa voice assistant.
So here within this remote interface launch dot Pi, we can actually copy all the instructions that
we've used here within the Arduino Bot Pi examples package within the launch folder, and that we've
used for the execution of the simple move it interface.
In fact, also for the task server and especially for the implementation of the Python of the task server,
we are going to use this move it configuration here that we have also used for the simple move with
interface of the Python package, so of the Arduino Pi examples.
So let's copy all of this and let's paste it here.
So within the remote interface launch dot Pi.
And here the thing that we need to do.
So here we need to change this one is fine.
So this is the move it configuration that you are going to use in order to configure the task server.
So let's start the task server node Pi.
So the Python implementation that we have created in the Arduino bot remote package and that we have
called task server dot Pi.
Perfect.
And to this file here we need to import.
So we need to provide this one here.
So the movie configuration that is all of this movie configuration here.
Now here instead of hard coding the value.
True.
So instead of hard coding this value here, let's declare a new launch argument so we can import from
the launch actions the declare launch argument.
And now let's create a new variable that is called is same argument.
And this is an instance of the declare launch argument.
And we can use this one in order to declare a new argument of this launch file that is called easy perfect.
And then we can also assign a default value to this parameter.
And for example, let's set it to true perfect.
So this one here will indicate whether we are starting the remote interface.
So all of these functionalities for the simulated robot or for the real one.
Then let's also declare another argument that is called use Python.
Argument.
Again, this is an instance of the declare launch argument.
And let's give it a name.
Let's call it use Python and by default.
So let's assign a default value.
And by default I'm setting this one to.
False.
So by default I'm going to start the C plus plus implementation of the task server.
Now after this one here.
So after declaring these two parameters let's also read the runtime value.
So the value that actually they have when we execute this launch file.
So from the launch substitutions let's import the launch configuration.
Perfect.
And now we can create two variables of this type.
So two variables of this class here.
The first one is called is sim.
So this is an instance of the launch configuration.
And we want to read this parameter here.
So the value of the ECM argument.
And then also let's create a new one that is called use Python that we want to use in order to read
this argument here.
So the use Python variable perfect.
Now we want to use these two variables.
So the ECM is the one that we can use here.
So instead of hard coding the value of the users in time we can just use the ECM.
And now instead the other variable.
So the use Python.
Here we can use this one in order to start the Python implementation of the task server or the C plus
plus implementation.
So we can import another class, this time from the launch conditions.
We can import the if condition.
And also we can import the unless condition class.
So here this one here is the task server node.
So the implementation of the task server in Python.
And actually we want to start this one.
So we want to start the Python implementation of the task server only when the condition.
So only if the use Python.
Argument is set to true.
So basically this is a conditional node.
And we are going to start this one here only when the use Python is set to true.
Otherwise if this one is set to false we want to start the C plus plus implementation.
So we can copy this one.
And we can paste it.
And let's simply call it task server node.
And again from the Arduino board remote package we want to start the executable called task server.
So this is the C plus plus executable.
And actually it is called task server node.
Perfect.
So this is the name of the executable and we want to start it unless.
So unless the use Python is set to true.
Basically we are saying that we want to.
Start the C plus plus implementation if the use Python is set to false, and in this case, the only
parameter that we need to set to this node is the use sim time that again we can set it equal to the
sim variable.
Perfect.
So with this we have declared all the functions.
So all the actions that we want to execute for the moment with this launch file.
So actually this will just start the task server.
And it will either start the C plus plus implementation or the Python one.
And also if we are starting the Python implementation it will configure it using this class here.
So the move it configuration builder.
Now let's go here.
So in the launch description and let's start by declaring the use Python argument.
Then the easy argument.
And then let's start the task server node pie or the task server node.
So let's start the Python or the C plus plus implementation depending on this value here.
So depending on this variable here perfect.
So we can save this file.
And as we have created a new folder.
So we have created the launch folder within the Arduino bot remote package.
We need to install it.
So let's open the file cmake list.
And here we need a new install instruction.
Perfect.
And we want to install the.
Directory that is the launch folder.
And we want to install it at the destination that is the shared folder.
And within the subfolder that is called as the package itself.
So we can use the project name variable.
And actually this one is a variable that simply contains the name of the package that is Arduino bot
remote.
Perfect.
So we have installed also the launch folder.
So we can save also this file here.
And we can add the missing dependencies also here.
So to the package dot XML.
In fact here we need to add an execution dependency from the Ros2 launch package.
And also we need to add another execution dependency from the Arduino bot.
Move it package.
Perfect.
So let's save also the package dot XML.
And now we can finally start the task server node.
So let's close this and let's open a new terminal here.
Let's go to the workspace.
And let's start by building it.
So we are compiling the new launch file that we have created.
And then let's open a new window of the terminal.
Let's make this one bigger.
And let's start the gazebo simulation of our robot.
So let's source the workspace And let's launch from the Arduino bot description package.
The gazebo launch dot Pi.
Perfect.
So this started the gazebo simulation of our robot.
Now let's also start the control system.
So in a new terminal, let's source the workspace and let's launch from the Arduino bot controller.
The file controller dot launched Pi a perfect.
So we have the confirmation that we are configuring and activating both the ARM controller and also
the gripper controller.
Perfect.
So now we can also start move it.
So in a new window of the terminal again let's source the workspace and let's launch from the Arduino
bot.
Move it.
Let's start the launch file that we have called.
Move it dot dot pi.
Perfect.
So with this we are starting.
Move it.
And also it will start a service with the graphical user interface that we can use in order to move
our robot.
But for the moment, actually we are not interested in this graphical user interface because we want
to move our robot using the task server.
So let's close this one and instead we can start the task server.
So let's open a new window of the terminal.
And here again we can search the workspace.
And we can launch the Arduino robot remote launch file that we have just created.
So we trust to launch.
And from the Arduino robot remote, let's start the launch file that we have called.
So this one here the remote interface dot launch.
So let's press enter.
And this is starting the task server.
Actually this is starting the Cplusplus implementation of the task server.
And if you want to start the Python one here you simply have to use the argument use Python and you
have to set this one to true.
So now I'm going to restart just the C plus plus implementation.
So let's press enter.
So here we have the configuration that our task server is up and running.
And now actually we can like use a new terminal.
So let's open a new terminal.
Perfect.
Like this.
So that we can actually see our robot in gazebo.
And we can actually start interacting within this terminal with the task server.
So the old one is still up and running the old terminal.
But let's make this one a little bit bigger so that we can interact here in this terminal with the task
server.
Now we can first see that actually the task server is up and running with Ros2 action list.
And here we go.
This is our task server.
And now we can finally start it.
So we can finally trigger it.
We can finally send a goal to it.
So first Also in this case we need to go to the workspace and to source it.
Perfect.
And from now on we can use the command Ros2 action send goal.
So we are creating basically with this command, an action client that is sending a goal to the task
server.
So to the action server that is called task server.
Then if we press tab twice, we can see that the task server is accepting messages of this type.
So belonging to this interface here.
So to the Arduino both messages and to the Arduino task.
Perfect.
Then let's use the double quotes.
Let's press tab again.
And here we can see that this one is the only value of the goal message.
So let's type the letter T and then let's press tab.
And for example let's set.
So let's send the robot to execute the task number one.
So let's press enter.
Now we are conducting the task server and we can see that the robot is moving to a peak position.
And so we can see that this one is the hypothetical peak position that we have set.
Now for example, let's move the robot also.
So let's execute the task number zero.
So this will bring again the robot to its initial position.
So to the on position.
And this is it.
So now the robot is in the on position.
And then for example let's try also the last task number that is the task number two.
And so this instead will send the robot to a rest position.
And so this is the rest position of the robot where the robot is bent on itself.
And so with this we have tested the three tasks that we have configured for our robot.
And that we can either call manually.
So with this command here, and that in the following lessons will be triggered by the Alexa voice assistant
Arthur.