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