In this video, we're going to be building ROS from Source. 2 2
The version which we're going to be using is ROS 2 Foxy 3 3
and we will be building for Source for the Linux distribution 4 4
for Ubuntu 20 5 5
If we scroll down, we can just go along and follow along 6 6
with the steps listed out in this guide. 7 7
I'll go ahead and put this off to the side. 8 8
We'll open up a terminal and we can see the first thing we need 9 9
to do is set our local by default. 10 10
This should already be set correctly to UTF-8, which 11 11
it is. 12 12
So then we'll move on to adding our ROS2 apt repository. 13 13
Put these commands in one at a time since there's a pseudo 14 14
in front of it which will prompt you for your password. 15 15
Alright, then we'll run the curl part of this command. 16 16
We can see that it got added correctly and then we'll add 17 17
the repository to our sources list and we should be good 18 18
to go on that. 19 19
Now we can go ahead and install the development tools and 20 20
ROS tools which we're going to be using. 21 21
Most of these may have gotten pre installed if you installed 22 22
ROS2 from the binaries, but just to make sure we'll go 23 23
ahead and rerun these commands to make sure they are installed. 24 24
Alright, Let's move on to installing the Python modules. 25 25
Then we'll install our Fast RTS dependencies which is for 26 26
our security configurations. 27 27
And then we will also install Cyclone DDS dependencies. 28 28
Okay, great. 29 29
We went ahead and install our dependencies. 30 30
So now we'll go ahead and actually grab our ROS2 code 31 31
from the GitHub repository and we'll go ahead and download 32 32
it and build it from source. 33 33
So here we can see we need to make a ROS2 Foxy Workspace 34 34
directory rather than putting it in my home folder like it 35 35
tells me to. 36 36
Instead I'm going to put it in my Workspace folder which 37 37
I have here in my home directory which we have been using 38 38
throughout the course. 39 39
And here you can see our Udemy ROS2 workspace. 40 40
So I will go ahead and add to this by running similar commands 41 41
to what they have there. 42 42
So I'll go ahead and make a directory for ROS2 underscore 43 43
Foxy and Source. 44 44
And we don't want to forget the Dash P flag so that we can 45 45
make both of these directories at the same time. 46 46
And now I have a new Workspace folder, so I'll go ahead and 47 47
CD into it and we will go ahead and use wget command to 48 48
get the repos that we need for us to. 49 49
Alright. 50 50
And then we can go ahead and actually import them into our 51 51
Source folder. 52 52
Okay, great. 53 53
So just to give you an explanation of what we just did here, 54 54
if I go ahead and open up my Workspace directory, ROS Foxy 55 55
Workspace. And now if I look into my source folder, we can 56 56
see all the prerequisite packages that we will be utilizing 57 57
to build ROS2. 58 58
Alright, with that we can move on. 59 59
So we'll go ahead and install our dependencies that are related 60 60
to rosdep. 61 61
For the most part, this will most likely have been set when 62 62
we installed ROS to Foxy from our binaries. 63 63
However, if you have not done this before, then you can go 64 64
ahead and do it again. 65 65
Alright, so we've gone ahead and initialize our rosdep. 66 66
So Let's go ahead and update it. 67 67
All right. 68 68
And now we can go ahead and install our other dependencies 69 69
that we need to with rosdep. 70 70
Alright, now that that's out of the way, we can go ahead 71 71
and install additional DDS implementations. 72 72
I'm not going to because I only plan on using Fast RTPS for 73 73
any of my security configurations. 74 74
So now we can move on to building our code in the workspace. 75 75
Now, one thing to note is you need to make sure that your 76 76
computer has enough space on the hard drive to complete the 77 77
compilation. I recommend having at least 10 gigabytes free. 78 78
You can go ahead and check how much space you have by using 79 79
the disk usage analyzer. 80 80
So here you can see I have 106 gigabytes available on this 81 81
volume, so I should be good to go. 82 82
So within my workspace directory, I will now run Colcon Build 83 83
simlink install. 84 84
I'll actually tag on one more thing and that additional argument 85 85
will be --cmake-args and we're going to pass it. 86 86
-DSECURITY=ON in all capital. 87 87
I'll expand this terminal window just so you can see the 88 88
full command. 89 89
And what this will tell our compiler when we're building 90 90
is it will tell us to build the security plugins that we 91 91
will be needing to use the security configurations on our 92 92
nodes later on. 93 93
With that though, you can go ahead and begin building. 94 94
Alright, so we see that it started building 12 of 309 complete 95 95
so far, so this process will take a long time for my computer. 96 96
It takes approximately an hour. 97 97
That will be less or more depending on your CPU speed. 98 98
So for the time being, I'll go ahead and pause this video 99 99
and I'll come back when the build is complete. 100 100
Alright, so here we are. 101 101
We went ahead and the install finish in about 41 minutes. 102 102
So just a little bit under an hour for me and we can see 103 103
we installed 309 packages. 104 104
And here it will list all the packages that we've gone through. 105 105
So with that, the next thing we're going to have to do is 106 106
now source this new ROS to installation instead of our binary 107 107
that we installed earlier. 108 108
And so if we Scroll down, it talks about the environment 109 109
set up, so we'll pretty much be doing the same thing. 110 110
And in this case, I'll go ahead and edit my bash RC file. 111 111
And so here you can see I'm already sourced to the binaries 112 112
that I installed earlier for ROS Foxy. 113 113
So what I'm going to do is comment them out. 114 114
And instead, source my new ROS2 Foxy build that we just 115 115
completed. So that's currently located in Source then 116 116
~/Workspaces/ros2_foxy/install/setup.bash 117 117
And I'll go ahead and save it. 118 118
And this is basically the same command that we can see here 119 119
that they're running. 120 120
Where source 121 121
And dot do the same exact thing. 122 122
And we include our workspaces director here so that we're 123 123
matching this directory that we followed and did the install 124 124
in. All right. 125 125
So now, since my bashrc file is saved with this new source 126 126
directory, we can go ahead and test this out anytime we open 127 127
a new terminal window. 128 128
So I'll go ahead and open a new one with 129 129
Control alt T 130 130
I'll go ahead and minimize the other one that we just built 131 131
in. And now, if I type in, whereis ROS2? 132 132
You can see it's actually located in my workspaces folder. 133 133
And so that's how, you know, it's sourcing the installation 134 134
that we built from Source rather than the binary that we 135 135
installed earlier. 136 136
And I can go ahead and test out to make sure that this is 137 137
working properly by running some of the demo nodes. 138 138
So here we'll run the talker node, and we can see that seems 139 139
to be working just fine. 140 140
And just to make sure we'll do ros2 topic list, we can 141 141
see our chatter topic, and we can do ros2 topic echo /chatter. 142 142
And we can see the data coming over just fine. 143 143
Great. 144 144
With that I'll hit control in both of these terminals. 145 145
And with that, you have successfully installed ROS2 from 146 146
source.