WEBVTT

00:00.110 --> 00:04.220
In this lesson you will see how to create and setup a roster workspace.

00:04.250 --> 00:09.590
This workspace will be the place where you write all your code for a roster application, and that's

00:09.590 --> 00:13.070
also where you will install and compile this code.

00:13.160 --> 00:16.250
So let's create a workspace for this course.

00:16.250 --> 00:19.340
First let's go to the home directory.

00:19.340 --> 00:22.220
So with CD make sure you are in your home directory.

00:22.220 --> 00:31.970
And in this directory we are going to create another directory so mkdir and let's name it ros2 underscore

00:32.540 --> 00:33.440
aws okay.

00:33.440 --> 00:36.740
So workspace basically is just a directory.

00:36.740 --> 00:38.570
And how to name this workspace.

00:38.570 --> 00:40.430
Well you can use whatever you want.

00:40.430 --> 00:47.180
For example if your application is named ABC you can use the name ABC and then underscore AWS.

00:47.180 --> 00:51.560
Here I'm using Ros2 AWS which is quite common to get started.

00:51.560 --> 00:53.420
So let's create this workspace.

00:53.420 --> 01:01.090
So this directory we are going to go inside this directory and create another one.

01:01.780 --> 01:05.050
Which name is src for source?

01:05.080 --> 01:08.650
Okay, so now we have a ros2 workspace directory.

01:08.650 --> 01:11.350
And inside that we have a source directory.

01:11.350 --> 01:14.770
And that's all you need to initialize your workspace.

01:14.770 --> 01:20.830
And then all the code that we create for the course and for this application will be inside the src

01:20.860 --> 01:21.430
folder.

01:21.430 --> 01:26.560
Now that we have created the workspace we can actually start to build it and to set it up.

01:26.560 --> 01:32.290
So every time we will want to install nodes later in this course we will need to build the workspace.

01:32.290 --> 01:33.520
How to build the workspace.

01:33.520 --> 01:36.250
Well you will first go to this directory.

01:36.250 --> 01:42.940
So if you were somewhere else you go back to the Ros2 workspace directory not in the source okay.

01:42.970 --> 01:45.730
You go to the Ros2 workspace directory.

01:45.730 --> 01:47.890
That's super, super important.

01:47.890 --> 01:53.830
And from that directory you can do kernel code space build okay.

01:53.860 --> 01:56.170
Call clone is the build tool for us to.

01:56.200 --> 01:59.070
And with build you can just build the workspace.

01:59.340 --> 02:02.580
So I press enter and you can see what it was quite quick.

02:02.580 --> 02:05.310
We have zero packages to build.

02:05.310 --> 02:09.120
So you see it was successfully built very quickly.

02:09.120 --> 02:13.500
And now if I do LS again, you can see we still have the source folder.

02:13.500 --> 02:17.700
But we have three new folders build, install and log.

02:17.730 --> 02:17.940
Okay.

02:17.970 --> 02:21.510
That's going to be generated automatically when you run curl build.

02:21.510 --> 02:28.530
Now if the curl command didn't work make sure you have installed the Ros dev tool package.

02:28.530 --> 02:33.870
So with sudo apt install ros dev tools okay.

02:33.900 --> 02:36.360
That's something we have done in the installation section.

02:36.360 --> 02:38.670
But make sure you have this package.

02:40.380 --> 02:46.110
And now that we have built our workspace the first time, let's go inside the install folder here.

02:46.110 --> 02:49.170
And you can see we have a bunch of scripts here.

02:49.170 --> 02:52.410
And there is something similar to what you've seen previously.

02:52.410 --> 02:55.530
You see we have a setup dot bash script.

02:55.530 --> 02:57.820
There is also a local setup that bash.

02:57.850 --> 03:05.530
Okay, so if you remember in the folder where Ros2 was installed in slash opt slash Ros, we had a setup

03:05.680 --> 03:10.720
bash script that we need to source in order to get access to Ros2 functionalities.

03:10.750 --> 03:12.040
Well, here it's the same.

03:12.040 --> 03:18.670
We have a setup bash script that we need to source if we want to get access to our workspace functionalities.

03:18.670 --> 03:25.240
And basically you have a local setup that's just going to source this workspace and setup bash, that's

03:25.240 --> 03:29.230
going to source both the global Ros2 installation and this workspace.

03:29.230 --> 03:31.810
But well, let's keep things simple here.

03:31.810 --> 03:34.090
Let's just use this setup bash okay.

03:34.090 --> 03:37.150
That's a nuance that we don't really need to explore right now.

03:37.150 --> 03:42.340
So if I have installed stuff in my workspace and I want to be able to use it, I need to source this

03:42.340 --> 03:46.900
setup dot bash right here from my workspace.

03:46.900 --> 03:50.020
And as you can guess, that's going to be quite annoying to do it every time.

03:50.020 --> 03:54.280
So we are going to add this inside the bash RC okay, so let's go.

03:54.310 --> 04:00.350
Well we can go to the home directory and just use git dot bash rc.

04:01.760 --> 04:07.820
Okay, so the last line for now is this one to source the global Ros2 installation.

04:07.820 --> 04:14.270
And then we are going to do source with the path to this script.

04:14.270 --> 04:16.400
So it's going to be tilde.

04:16.400 --> 04:23.930
So home directory slash Ros2 workspace slash install I'm just going to copy that here slash.

04:23.930 --> 04:26.180
And let's use the setup dot bash.

04:26.420 --> 04:26.810
All right.

04:26.810 --> 04:31.730
So now in our bashrc we source first the global Ros2 installation and then the workspace.

04:31.760 --> 04:35.330
It's very important that you respect this order okay.

04:35.360 --> 04:37.370
And that's going to be it for the bash RC.

04:37.490 --> 04:40.160
Make sure to save the file okay.

04:40.340 --> 04:42.560
And then let's close that.

04:42.560 --> 04:48.140
So now if I open a new terminal I know that my workspace so Ros2 is correctly source.

04:48.140 --> 04:50.810
And my workspace is correctly sourced as well.

04:50.810 --> 04:52.340
And that's the end of the setup.

04:52.340 --> 04:54.770
Now we can start to create packages.
