WEBVTT

00:00.170 --> 00:01.400
Hi robotic enthusiast.

00:01.790 --> 00:07.640
In this first laboratory lesson of the course, we will create our first Ros two workspace.

00:08.120 --> 00:14.870
As mentioned in the previous lesson, the workspace is just a folder of our PC that will contain all

00:14.870 --> 00:17.750
the packages with all the software for our robot.

00:17.960 --> 00:27.170
So to create a folder, let's open a new Linux terminal and use the command make directory so mkdir

00:27.200 --> 00:33.350
followed by the flag minus P and then we need to specify the name of the folder we want to create.

00:33.350 --> 00:42.560
So let's call this one Arduino bot workspace and let's also create the source folder within this one.

00:42.710 --> 00:44.510
So let's press enter.

00:44.630 --> 00:51.200
And this command has created the Arduino bot workspace folder within our PC.

00:51.950 --> 01:01.320
For now, if we enter in this folder, this is just a folder in our PC that contains another sub folder

01:01.530 --> 01:03.840
that is called SRC.

01:04.290 --> 01:09.720
And here inside the source folder, we will place all the code for our robot.

01:09.720 --> 01:14.490
So here we will add packages that will contain all the functionalities of the robot.

01:14.850 --> 01:21.600
This will be our Ros two overlay where we will have access to all the functionalities and packages of

01:21.600 --> 01:26.280
Ros two as well as all the new packages that we will develop during the course.

01:26.830 --> 01:31.840
Now let's initialize the workspace so that it is recognized by Ros two.

01:31.960 --> 01:38.680
And so all the new packages and code that we are going to insert here will become available and executable.

01:39.330 --> 01:49.020
So back in the Arduino bot workspace folder, let's use the command called con build and let's press

01:49.020 --> 01:49.800
enter.

01:50.140 --> 01:55.140
Call Con is a build tool that converts the source code and the scripts.

01:55.140 --> 02:01.290
So the one that we are going to develop in C plus Plus or Python or any other programming language into

02:01.290 --> 02:08.190
executable files that can be run, that can be executed as normal applications within the system by

02:08.190 --> 02:11.370
running the call con build command inside the workspace.

02:11.370 --> 02:18.030
So inside the Arduino bot workspace folder, it will automatically generate two more folders that we

02:18.030 --> 02:20.550
can see are build and install.

02:20.550 --> 02:23.910
And it also generated a folder called log.

02:24.710 --> 02:29.990
Interest to our workspace is just a folder with a specific structure.

02:30.140 --> 02:31.370
The source folder.

02:31.370 --> 02:37.610
So the SRC folder contains all the source code and the scripts that we are going to develop during the

02:37.610 --> 02:38.270
course.

02:38.420 --> 02:46.250
Then the build folder and the install folders are automatically generated by the build command based

02:46.250 --> 02:47.300
on the content.

02:47.300 --> 02:53.960
So based on the scripts that we are going to insert within the source folder, the build folder contains

02:53.960 --> 03:00.080
intermediate files and creates a sub folder for each package present in the source folder.

03:00.920 --> 03:06.800
The install folder on the other end is the final destination, so each package is installed there in

03:06.800 --> 03:11.930
the install folder and it contains the executable files for our application.

03:12.990 --> 03:19.020
Now that we have created the structure of the workspace, we can proceed with the creation of the first

03:19.020 --> 03:19.690
package.

03:19.710 --> 03:26.160
So the first container of the source code within the workspace, as mentioned before, this package

03:26.160 --> 03:29.820
should be placed inside the source folder of the workspace.

03:29.820 --> 03:37.020
So let's navigate to the source folder and inside this folder to create a new package, we can use the

03:37.020 --> 03:46.560
command Ros2 package create followed by the desired build tool for creating the package.

03:46.560 --> 03:51.540
So let's use the flag build type.

03:51.690 --> 03:57.630
And this build type depends on the programming language that we want to use in this package.

03:57.720 --> 04:06.900
In this case, as we are going to create a package to include Python code, we use the amend Python

04:06.900 --> 04:11.280
build type and then we also need to provide a name for our package.

04:11.280 --> 04:19.630
For example, let's call it Arduino, but Pi examples.

04:19.630 --> 04:21.730
So let's press enter.

04:21.940 --> 04:28.270
And in this package we are going to include some example code, some templates in Python that you can

04:28.270 --> 04:31.630
use as a starting point for creating your own nodes.

04:31.900 --> 04:37.060
Let's also create another package to provide the same template and the same examples.

04:37.060 --> 04:47.920
Also for Cplusplus still with the rescue package, create command and in this case let's use as a build

04:47.950 --> 04:56.710
type the amend CMake since we are going to develop Cplusplus code in this package and let's name this

04:56.710 --> 05:03.690
package Arduino board CP examples.

05:03.700 --> 05:07.450
So let's press enter to create also this other package.

05:07.450 --> 05:13.780
And now if we take a look to the content of the source folder, we can see that now there are two subfolder.

05:13.780 --> 05:21.670
There's the Arduino CP examples and the Arduino bot Pi examples that were created by the Ros2 package.

05:21.670 --> 05:22.780
Create Command.

05:23.020 --> 05:24.730
Now back to our workspace.

05:24.730 --> 05:29.590
We can run again the command called Build.

05:29.830 --> 05:35.680
And now this command will rebuild the entire workspace, including the two new packages that we just

05:35.680 --> 05:36.520
created.

05:36.520 --> 05:43.000
And in fact, you may notice that the output of the build command is slightly different from what we

05:43.000 --> 05:43.900
saw earlier.

05:43.900 --> 05:51.100
And in fact, this is informing us that we have two new packages in our workspace that are Arduino bot

05:51.100 --> 05:54.730
CP examples and Arduino bot Pi examples.

05:56.070 --> 06:02.860
Now we also need to activate our workspace, which means making the Arduino bot workspace folder.

06:02.860 --> 06:07.570
So this one recognized as an overlay for Ros two.

06:07.780 --> 06:14.830
This way, all the packages that we added and that we are going to add in this workspace will be recognized

06:14.830 --> 06:21.790
as Ros two packages and so we will be able to execute their content, their script with the Ros two

06:21.820 --> 06:22.720
commands.

06:23.470 --> 06:31.510
To do this, we need to source a certain file that is located into the install folder that, if you

06:31.510 --> 06:35.290
remember, was automatically created by the build command.

06:35.830 --> 06:40.390
And we need to source the file that is called setup dot bash.

06:40.390 --> 06:46.540
So we can do this by typing dot setup dot bash.

06:46.990 --> 06:52.960
So let's press enter and by doing this we have made the current terminal.

06:52.960 --> 06:56.160
Remember only the current terminal, the one we are using.

06:56.170 --> 07:04.510
And so to aware about the existence of the Arduino bot workspace and actually to verify that this command

07:04.510 --> 07:11.440
has been successfully executed and that Ros2 recognizes the new to package that we have just created.

07:11.470 --> 07:18.340
Let's get the list of all the currently available packages that are available in Ros2 with the command

07:18.340 --> 07:22.420
Ros2 package list.

07:22.420 --> 07:24.470
So let's press enter.

07:24.650 --> 07:31.140
And among them we can see that there are already many packages that were installed by the default Ros2

07:31.160 --> 07:32.090
installation.

07:32.090 --> 07:35.270
And among them if we go to the letter A.

07:37.680 --> 07:45.600
We can see that there is the Arduino board, CP examples and also the Arduino board Pi examples.

07:47.000 --> 07:52.400
This demonstrates that these two packages have been recognized in the Ros two environment.

07:52.400 --> 07:58.700
And so when we will add some code, some scripts to this folder, we will be able to execute and interface

07:58.700 --> 07:59.930
them with Ros two.

08:00.710 --> 08:07.610
However, note and remember that the source command that we used to make the environment aware of the

08:07.610 --> 08:12.290
new overlay only as effect on the current terminal session.

08:12.290 --> 08:17.180
So on this terminal that we have just opened so only applies for this terminal.

08:17.420 --> 08:23.540
So to demonstrate this, if for example, we open a new terminal where we didn't source the workspace

08:23.540 --> 08:35.150
yet, and if we navigate to our workspace now in this case, if we use again, the command Ros2 package

08:35.150 --> 08:35.750
list.

08:36.800 --> 08:41.060
And again, let's scroll to the letter A.

08:42.650 --> 08:50.330
So we can see that the Arduino CP examples and the Arduino Pi examples are not there.

08:51.330 --> 08:54.540
This is a common issue that you need to pay attention to.

08:54.660 --> 09:00.600
Remember that whenever you open a new terminal before using the packages within your workspace, you

09:00.600 --> 09:02.430
must source the workspace.

09:02.430 --> 09:09.580
So namely, you must source the setup file that is located in the install folder of the workspace.

09:09.660 --> 09:19.130
So let's source it also in this new terminal by typing dot install setup dot bash.

09:19.140 --> 09:20.760
So let's press enter.

09:20.760 --> 09:26.700
And now if we run again the command Ros2 package list.

09:27.000 --> 09:29.910
Let's scroll back to the letter A.

09:31.080 --> 09:33.480
Now we can see that also in this terminal.

09:33.510 --> 09:39.510
Roscoe is aware of the existence of the Arduino board, CP examples and the Arduino board Pi Examples

09:39.510 --> 09:40.260
packages.
