In this lesson you will see how to create and setup a roster workspace.
This workspace will be the place where you write all your code for a roster application, and that's
also where you will install and compile this code.
So let's create a workspace for this course.
First let's go to the home directory.
So with CD make sure you are in your home directory.
And in this directory we are going to create another directory so mkdir and let's name it ros2 underscore
aws okay.
So workspace basically is just a directory.
And how to name this workspace.
Well you can use whatever you want.
For example if your application is named ABC you can use the name ABC and then underscore AWS.
Here I'm using Ros2 AWS which is quite common to get started.
So let's create this workspace.
So this directory we are going to go inside this directory and create another one.
Which name is src for source?
Okay, so now we have a ros2 workspace directory.
And inside that we have a source directory.
And that's all you need to initialize your workspace.
And then all the code that we create for the course and for this application will be inside the src
folder.
Now that we have created the workspace we can actually start to build it and to set it up.
So every time we will want to install nodes later in this course we will need to build the workspace.
How to build the workspace.
Well you will first go to this directory.
So if you were somewhere else you go back to the Ros2 workspace directory not in the source okay.
You go to the Ros2 workspace directory.
That's super, super important.
And from that directory you can do kernel code space build okay.
Call clone is the build tool for us to.
And with build you can just build the workspace.
So I press enter and you can see what it was quite quick.
We have zero packages to build.
So you see it was successfully built very quickly.
And now if I do LS again, you can see we still have the source folder.
But we have three new folders build, install and log.
Okay.
That's going to be generated automatically when you run curl build.
Now if the curl command didn't work make sure you have installed the Ros dev tool package.
So with sudo apt install ros dev tools okay.
That's something we have done in the installation section.
But make sure you have this package.
And now that we have built our workspace the first time, let's go inside the install folder here.
And you can see we have a bunch of scripts here.
And there is something similar to what you've seen previously.
You see we have a setup dot bash script.
There is also a local setup that bash.
Okay, so if you remember in the folder where Ros2 was installed in slash opt slash Ros, we had a setup
bash script that we need to source in order to get access to Ros2 functionalities.
Well, here it's the same.
We have a setup bash script that we need to source if we want to get access to our workspace functionalities.
And basically you have a local setup that's just going to source this workspace and setup bash, that's
going to source both the global Ros2 installation and this workspace.
But well, let's keep things simple here.
Let's just use this setup bash okay.
That's a nuance that we don't really need to explore right now.
So if I have installed stuff in my workspace and I want to be able to use it, I need to source this
setup dot bash right here from my workspace.
And as you can guess, that's going to be quite annoying to do it every time.
So we are going to add this inside the bash RC okay, so let's go.
Well we can go to the home directory and just use git dot bash rc.
Okay, so the last line for now is this one to source the global Ros2 installation.
And then we are going to do source with the path to this script.
So it's going to be tilde.
So home directory slash Ros2 workspace slash install I'm just going to copy that here slash.
And let's use the setup dot bash.
All right.
So now in our bashrc we source first the global Ros2 installation and then the workspace.
It's very important that you respect this order okay.
And that's going to be it for the bash RC.
Make sure to save the file okay.
And then let's close that.
So now if I open a new terminal I know that my workspace so Ros2 is correctly source.
And my workspace is correctly sourced as well.
And that's the end of the setup.
Now we can start to create packages.