In this lecture, we'll be going over creating a Ross workspace so we can organize our development files.
So before we do anything on our computer, let's get an illustration of what our file structure should
look like.
First thing to start off our development is to create a workspace directory.
Inside our workspace directory, we will create a source folder, which is where our packages we develop
will go.
Other folders which will also appear in the workspace folder are the build, install and log folders
which will be auto generated once we compile our project.
Let's go ahead and focus more on the source folder since that is where we will be organizing our project
contents.
As I mentioned earlier, the source folder is where our packages will be placed.
Think of packages like individual software bundles generally used for a specific task which can then
be shared and distributed to other developers.
Let's go ahead and see what our package structure looks like.
The first thing we're going to see in our package is another source folder, which is where we would
put our code if we were developing in C++.
Now, since we're developing in Python, we will instead make a folder called Scripts to contain all
of our Python code.
Also in our package are two files that are auto generated when we first create our package.
The first is our package XML file, which contains information about our package such as the ROS packages
and systems we are using as dependencies as well as the author and version number of the package.
The second file is a list text file which has specific instructions on compiling our package.
This will give information to the compiler, such as if we created a custom interface type as well as
any build dependencies.
So if we actually go into our scripts folder, we can see these are just where our Python scripts which
we develop are placed.
You can name your scripts whatever you want and you'll be able to run it directly through the ROS to
run command after we have compiled and source our package.
Now notice we have this init py file which for the purposes of this course we will leave blank.
But this shows you this is organized as a typical Python library.
Now it's worth noting that this is a very simplistic hierarchy which we will generally use for this
course.
But also keep in mind in package folders, you may also find things such as launch folders, custom
message declarations, simulation configurations, and much more.
So as long as it pertains to the purpose of the package, we will go over these in more depth throughout
the course.
All right.
Now that you have a general overview of what our RA workspace file structure should look like, let's
go ahead and create our own workspace.
All right?
We're honorable unto machine and we can open up our file explorer.
Ross workspace is generally live in our home directory, so we would normally create a new folder by
right clicking, hitting new folder.
And if you follow a lot of tutorials on the Ross website, you would call it something along the lines
of dev underscore CSS or workspace.
Now in my experience this is not very descriptive of what this workspace is for, and this will start
to get unorganized if we want to make new separate projects.
Instead, we can call this folder workspaces.
Now, if we go into our Workspaces folder, we can go ahead and make our actual project workspace folder,
which we're going to be using for this course.
So generally this would be named after a particular robot we are working on.
But for the purposes of this course, we are just going to call this the Ross to py w for workspace.
Just so we know this is our workspace where we work on projects related to this Udemy course.
Now we can go into our workspace folder and create our source folder.
Now, instead of creating a new folder for our package, we are instead going to use the Ross to package
create command in the terminal.
So go ahead and open up the source folder.
I'll go ahead and open up my terminal.
And with the terminal open, we will change into our Ross to CME Workspace source folder, which we're
looking at right here.
Once we're here, we will run Ross to package carry.
I will call my package.
Ross to underscore Udemy.
Underscore package.
We will also need to pass a bill type parameter in which we will use a mint.
Make note that you could change the build type to amend python, in which case you would use a setup
script to create your build instructions.
For this course though I will use a mentor make and we'll talk about it a bit later.
After running the command, we can see some text up here on the screen and we can see in our folder
it went ahead and created our package and created some of these default folders and files for us, which
include our see, make list, text file and package XML file we talked about earlier.
So let's take a look at the generated package XML file.
Here we see different fields to describe our package.
You would generally want to fill these fields such as version, description, maintainer and license,
before releasing your package to the public.
We can go back now and take a look at our C list text file.
So by default, this is our see make list text file, which has some things about our project and the
dependencies we're going to be requiring to compile our ROS package.
Now, for the time being, it's not syntax highlighting.
That's because we're in restricted mode because of the way I started up vs code.
So you can just go ahead and trust this workspace.
And there we go.
Now it seems to identify that we are using the make language type and we get this nice syntax highlighting
so we can see the commands such as find package, which we're going to be using throughout this course.
For those of you who have developed in ROS version one, you can see that the default C list text file
has gotten much shorter and cleaner looking.
We will edit this file later in the course to tell the compiler about any dependencies we need for our
ROS package.
The last thing I will do to wrap up our workspace is create a scripts directory so we have a place to
put our python files.
Even though we haven't created any new code yet, we can go ahead and build our workspace to do this.
We can navigate back to our workspace directory within our terminal.
So here I'm in my RA two pi workspace folder.
Right here.
And we can go ahead and run, can build.
So we're running the command.
It begins building our package we've built successfully and it's generated our build, install and log
folders.
If you're having trouble running this command, you get an error.
Sinkhole can build does not exist.
Feel free to check out the following docs page and make sure you have your Python three Culkin Common
Extensions installed.
Now to include our package in our terminal environment.
We need to source the setup bash file within the install directory so we can actually go ahead and look
at that here.
So here in our install directory, we see we have a setup batch file which is going to set up our terminal
environment for us.
Now our terminal is aware of our newly created ROS package and we can check this by running the ROS
to package list command.
And here we can see our ROS two package listed amongst the various packages here that came with our
ROS installation.
Congratulations.
You have successfully created your very own Ross two package, but let's review what we learned.
In this lecture, we learned how to create our Ross workspace.
We created a new ROS to package by creating our workspace and source folders, changing into the source
directory, and then running the ROS to package create command where we gave our package a name and
set the build type to amend see make.
Then we compiled our workspace by running Call can build in the workspace directory.
We could then source the setup bash file in the install directory to make our terminal environment aware
of the new package we created.