In this lecture, we will go over how to build Ros to humble from source on a bone to 22.4.
This is simply a different way to install ROS two humble compared to installing binaries which may be
necessary for installing particular distributions on different versions of a bone to or Linux as well.
If you want to contribute to ROS two and are actively developing code for it, building ROS two from
source does take a lot of time, so realistically leave yourself at least an hour to complete this lecture
as it will also take up about 20 gigabytes of storage space should you choose to follow along.
Again, this is not needed to utilize any of the other main ROS features if you are already using the
ROS to binary installation.
So by all means feel free to skip this lecture.
So the first thing I will do is open up a browser and head over to the installation page for Ros to
humble.
Now instead of installing the Debian package like we did in section two, we're going to scroll down
a little bit and build from source following the Ubuntu Linux guide.
So go ahead and click on that link and here are the steps we will be following.
So we'll be setting up our locale, adding the ROS to repository, downloading all the source code for
us two from GitHub where we will be manually installing dependencies and then building it.
So let's jump in.
So scrolling down you can see some of the system requirements, so you can see some of the distributions
which are supported for building from source.
So in this case we are building on Ubuntu Linux 22.4 but these builds will also work for focal and Debian
bullseye.
Granted, these are tier three systems, so there may not be as much support compared to 22.4.
All right.
So first up is setting up our locale.
Now, unless you're using a special Linux operating system version, your locale settings should already
be correctly set to UTF eight US, which we can verify by opening up a terminal and simply typing in
the locale command.
So our current setup is fine.
We can see the US UTF eight so I can go ahead and add the roster repo.
If you see something different on your output, feel free to run these commands in your terminal to
make sure that you are set to that UTF eight setting.
So let's go ahead and add the RAS to repo.
So the first thing is going to ask us to do is make sure that our APS repository system is allowed to
utilize universal packages.
So again, by default, unless you're doing something special, they should already be set and we can
actually go ahead and check that.
If I go ahead and reopen this terminal and we get that 500 code that we're actually looking for, which
it shows the output of.
So I'm going to go ahead and split the screens so that we can easily see these commands being run.
So like I said, we get this 500 command, which we saw earlier for Ubuntu 2204.
If you don't see that output, then again you'll be running these commands to be able to set your repository
to install the universal group of app repositories.
Now we're going to be adding the RAS to app repository to our system.
So first we're going to be adding our GPG key with APT.
Now notice you may get depreciation warnings when running these commands just because the latest releases
of Ubuntu are trying to get away from the key systems.
But again, we're just going to follow along with the guide.
So you'll be asked to put in your password.
All right.
I'm going to go ahead and clear the screen.
And then run the second command here, which is actually grabbing the keys from their GitHub repository.
And then we are good to go.
So let's go ahead and add the repository to our sources list.
And now we can go ahead and install our development tools.
So just go ahead and copy this.
And so most of these are going to be Python three related dependencies, but also things like git C
make our build essentials and w get.
Okay.
I'm going to go ahead and clear the screen.
And now we're actually going to get the RAS to code from GitHub and download it to our machine.
Keep in mind that the rest of this guide uses a workspace folder called Ras Humble, which is located
in your home directory.
So it's completely up to you how you want to organize this as you could.
Alternatively, keep this organized within the Workspaces folder we have been using, but to keep things
simple so I can easily copy and paste the commands from this guide, I will just follow along with their
convention of just putting this ROS to humble workspace in the home directory.
So let's go ahead and create the workspace and source folders.
So now I can actually go ahead and open up my file Explorer and we now see this RAS two humble directory
with the source directory.
Then we'll change into the to humble directory in our terminal.
And go ahead.
And begin downloading our raw repo.
Okay.
And after a while, we get this output spit out.
So this just shows all the packages which were included when we were downloading our rosti repos.
So now if we go into that source folder, we will see all of these individual RAR dependencies and packages.
Now, keep in mind, I already have Ross two installed on this machine.
Right.
So if I go ahead and do echo Ross distro, right, I get my humble distribution which I installed utilizing
the Debian binaries.
Now we're going to want to make sure that when we're building this package there are no existing Ross
instances source as it may mess up our build process.
So the thing that sourcing our current binary is our bash RC files.
So if I go ahead and open up our bash RC file in V's code.
I'll go ahead and scroll down to the bottom.
And here we see a lot of the environment set up functionality which we implemented when we installed
our RAS two binary instances.
So all we have to do is highlight these and comment them out using the pound symbol.
Or in this case I just hit control forward slash to automatically comment them out, save the file,
which I'll do with control s And now we should no longer have our instances sourced when we open up
a new terminal.
So I'll have to go ahead and.
Close this terminal.
And now if I do something like Ross to Node list, we see Ross to command not found because Ross too
binary installation is not sourced to these terminal environments.
So let's go ahead and continue following along with the guide.
So here it says we're going to be running apt upgrade and then using Ross DEP to install some dependencies.
So I'll go ahead and do that.
Put in your password.
And then we'll go ahead and run raw, step in it.
And since we already installed ROS before, it'll actually say default sources file already exist.
Don't worry about that.
That's fine.
If we want to re initialize it, we could delete it.
But I'm just going to go ahead and leave it as is since I'm working with the same distribution and I
can go ahead and run.
Raw step update.
All right.
I'm not sure why we're getting this error message.
I actually tried this earlier and this didn't occur, but it seems we were able to add our distributions
just fine when running Rasta updates.
So I'm just going to go ahead and ignore that for now.
And we can go ahead and run the step install and we're going to be essentially pointing it to the source
directory from PATH.
So one thing to keep in mind is we're actually supposed to be changed into our workspace directory because
I close out our terminal.
So let's go ahead and do that now.
Workspace directory.
I can go ahead and run the raw step, install command, which points to our source directory.
All right.
So that took about 2 minutes.
So I'll just go ahead and clear the screen and now we can move on to installing additional DDA implementations.
So if you wanted to use different communication protocols other than the default fast IDs, you can
click on the link to install your preferred communication protocol.
But that's an advanced topic which you will most likely never have to go over in most robotics applications.
Now it's time to actually begin building.
Now here you can see the message that we must build this in an environment that does not have another
ROS instant source.
So we already took care of that earlier.
So again, we can double check that by doing ROS to node list or some other ROS do command and we see
the command is not found.
So we're already in our ROS two humble directory.
So let's go ahead and run.
Our code can build Simulink install like we have with our packages that we created in section four.
But this time we're going to be building all of the ROS packages that we have in our source directory,
including ROS itself.
All right, so this is going to take a long time, so feel free to pause the video here and I'll go
ahead and fast forward and I'll see you when the build is finished.
All right.
So that's gone ahead and built.
And as you can see on my computer, it took just under 30 minutes.
Now, you may be concerned that we see 340 packages finished, but 98 packages had standard error outputs.
Now, you don't have to worry about this because sometimes this tracks anything that may have triggered
warnings.
And one of the issues that we've been seeing a lot in Ubuntu 22.4 is some of the depreciation of the
Python tools or commands which are used.
So this just leads to external depreciation warnings.
So it's not necessarily errors which stopped it from building, but simply these warning messages.
But for now, I'm going to go ahead and clear the screen.
And again, just to show you that we're working with this new ROS two installation, if I do ROS two
node list, right, we see Ros two command not found because I have no ROS instances source.
So now what we can do is source the local setup bash file from our build just like we would with our
normal ROS package.
And I'm actually jumping a bit ahead of myself.
This is actually covered in the next part of the documentation.
So here we see they are sourcing the local setup.
Bash period is the same command as source.
So we just go ahead and source this, right?
So our ROS to humble directory install local setup bash.
And now if we try to run Ras to node list.
We get no output because we currently don't have any nodes running, but we don't get this ROS to command
not found because we are currently sourced to this installation which we built from source.
So we see our build, install and log folders.
So we built ROS to humble from source and we are now utilizing this installation for our ROS to tools
so we can actually go ahead and try some examples.
So you can go ahead and run the talker node, which we've run before many times.
So here we see it publishing Hello World.
And again, if I open a new terminal, if I do ROS two node list, you see command not found because
we need to source our installation, which in this case is the one we built from source.
And now if we run the listener, we see.
I heard Hello World.
So we see Ros is indeed working.
But this time, instead of utilizing the binaries, we're utilizing all the code that we had built from
source.
I'll go ahead and stop these.
All right, so here we see we have an operational ROS to humble installation by downloading the ROS
to source code and building it from scratch.
So again, there are only very limited cases which you would do this mainly if you're installing it
on a special operating system or if you wanted to help contribute to the existing ROS two stack.
All right.
So here we see we have an operational ROS to Humble install, which we obtained by downloading the ROS
to source code along with its dependencies and building it ourself.
In most cases, using the ROS installation binaries will work just fine, but it's good to know how
to build ROS from source in case you want to contribute to ROS or in case you are using specialty systems
which Ros may not immediately support.