1
1

00:00:01,070  -->  00:00:05,190
Let's learn how to install ROS 2 on Mac OS.
2

2

00:00:05,580  -->  00:00:11,820
We will be installing ROS 2 Foxy on Mac OS Mojave, which
3

3

00:00:11,830  -->  00:00:14,520
is Mac OS version 10.14.
4

4

00:00:15,020  -->  00:00:20,610
Note that ROS 2 Foxy only officially supports Mac OS 10.14
5

5

00:00:20,970  -->  00:00:25,060
so other Mac OS versions may not be compatible.
6

6

00:00:25,280  -->  00:00:29,330
You may be able to use ROS 2 on the system, but you may
7

7

00:00:29,330  -->  00:00:32,340
run into issues along the way or may need to build ROS2
8

8

00:00:32,350  -->  00:00:35,220
from Source to get it work on your particular version.
9

9

00:00:35,400  -->  00:00:39,240
Note that this computer has a brand new install of Mac OS
10

10

00:00:39,240  -->  00:00:43,110
10.14 with only the default programs installed on it.
11

11

00:00:43,220  -->  00:00:46,790
Here on my dock, you can see I have a System Preferences
12

12

00:00:46,910  -->  00:00:57,310
notification. If I were to click on it, we would find my
13

13

00:00:57,320  -->  00:00:59,680
Mac is letting me know I can upgrade my OS.
14

14

00:01:00,260  -->  00:01:04,459
I will not upgrade as I may run into issues with ROS later
15

15

00:01:04,470  -->  00:01:05,060
down the line
16

16

00:01:05,069  -->  00:01:10,340
if I am not using Mac OS version 10.14. So to make it so
17

17

00:01:10,350  -->  00:01:13,130
that this notification is not constantly bugging me, I will
18

18

00:01:13,140  -->  00:01:18,230
simply remove it from Dock. If you have a newer version of
19

19

00:01:18,240  -->  00:01:21,730
Mac and still want to learn ROS without worrying about OS
20

20

00:01:21,730  -->  00:01:25,810
support, you may want to use a virtual machine, so feel free
21

21

00:01:25,820  -->  00:01:29,230
to go to the video on installing a virtual machine, where we
22

22

00:01:29,240  -->  00:01:32,560
will learn how to create in a Ubuntu virtual machine, which
23

23

00:01:32,570  -->  00:01:36,250
is Unix based like Mac and has similar terminal commands.
24

24

00:01:36,260  -->  00:01:40,240
With all that out of the way, Let's get to installing ROS 2.
25

25

00:01:40,300  -->  00:01:45,620
Open a browser and navigate to the ROS 2 Foxy installation
26

26

00:01:45,680  -->  00:01:50,480
page. We will be installing Mac OS from the Binary Packages
27

27

00:01:50,490  -->  00:01:54,010
section. Please be careful as to not Select in the build
28

28

00:01:54,020  -->  00:01:54,910
from Source section,
29

29

00:01:55,120  -->  00:01:58,300
As building ROS 2 from Source can take several hours to
30

30

00:01:58,310  -->  00:02:02,200
compile. So from the list I will Select Mac OS.
31

31

00:02:02,920  -->  00:02:06,010
Here we can see a list of what we will be doing to install
32

32

00:02:06,020  -->  00:02:06,550
ROS 2.
33

33

00:02:06,840  -->  00:02:10,860
The first thing we will need to do is install our prerequisites.
34

34

00:02:13,570  -->  00:02:17,540
Note that these are terminal commands, so we'll need to go
35

35

00:02:17,550  -->  00:02:20,940
ahead and open up a terminal, so go to the search bar on
36

36

00:02:20,950  -->  00:02:21,570
the top right.
37

37

00:02:22,600  -->  00:02:31,870
I'm going to search up terminal now.
38

38

00:02:32,020  -->  00:02:35,260
By default, the terminal has a white background with a black
39

39

00:02:35,290  -->  00:02:38,630
text. For the purposes of these videos, I'm actually going
40

40

00:02:38,640  -->  00:02:41,570
to change the color scheme to a black background with white
41

41

00:02:41,580  -->  00:02:44,300
text, which is generally easier for your eyes to look at.
42

42

00:02:44,560  -->  00:02:48,250
So go up to terminal on the top left bar, select Preferences
43

43

00:02:50,220  -->  00:02:55,560
and under the Profile tab I will Select the Profile color setting,
44

44

00:02:56,300  -->  00:02:58,830
and here you can see an example of that.
45

45

00:02:59,040  -->  00:03:03,060
This is much better, although the semi transparent background
46

46

00:03:03,070  -->  00:03:06,420
can be distracting, so I'll go ahead and adjust the color
47

47

00:03:06,430  -->  00:03:19,350
so the opacity is 1. Once done, I can close this window
48

48

00:03:19,360  -->  00:03:23,310
and in my profile window, set the Pro version as the default.
49

49

00:03:24,530  -->  00:03:27,060
Now, every time I open a new terminal.
50

50

00:03:27,070  -->  00:03:28,230
It will have this theme.
51

51

00:03:33,120  -->  00:03:36,730
Besides just coloring, there are more steps we need to take
52

52

00:03:36,740  -->  00:03:37,810
to configure our terminal.
53

53

00:03:37,960  -->  00:03:41,740
Those of you who are used to developing on Linux are familiar
54

54

00:03:41,750  -->  00:03:45,520
with a ".bashrc" file, which we use to source and configure
55

55

00:03:45,530  -->  00:03:46,660
our terminal environment.
56

56

00:03:46,720  -->  00:03:50,710
You may not have a bash RC file by default on your Mac system.
57

57

00:03:50,840  -->  00:03:55,460
You can check by running the "LS -la" command in your home directory
58

58

00:03:55,740  -->  00:03:58,980
which you will be at by default when first opening the terminal.
59

59

00:03:59,120  -->  00:04:04,640
Here you can see I do not have a ".bashrc" file, nor a file
60

60

00:04:04,670  -->  00:04:08,030
name bash profile, so I will have to create them.
61

61

00:04:08,040  -->  00:04:10,070
I can do that with the "Touch" command.
62

62

00:04:12,020  -->  00:04:18,459
Now if I run that same command, I now have the files bashrc
63

63

00:04:18,610  -->  00:04:19,540
and bash profile.
64

64

00:04:20,070  -->  00:04:24,530
Now we need to edit our bash profile which I recommend doing
65

65

00:04:24,540  -->  00:04:25,460
with a code editor.
66

66

00:04:25,470  -->  00:04:29,920
I do not have one installed since this is a new Mac OS install,
67

67

00:04:29,930  -->  00:04:34,110
so I'll just use the open command to open the file in a text
68

68

00:04:34,120  -->  00:04:44,990
editor. Now I can type the following code snip it in which
69

69

00:04:45,000  -->  00:04:48,820
will look for the Bash RC file and source it every time we
70

70

00:04:48,830  -->  00:04:49,840
open a new terminal.
71

71

00:04:50,490  -->  00:04:54,340
Note that the Mac text editor has spelling correcting on
72

72

00:04:54,350  -->  00:04:58,380
by default, so I will have to fix these to be lowercase as
73

73

00:04:58,390  -->  00:05:06,290
I had originally typed them. And I can go ahead and save the
74

74

00:05:06,300  -->  00:05:11,210
file. To test that this works,
75

75

00:05:11,400  -->  00:05:21,090
I will open our Bash RC file and Echo "Bash RC sourced".
76

76

00:05:21,580  -->  00:05:23,930
Now I'll go ahead and save this.
77

77

00:05:24,660  -->  00:05:28,500
Now if I open a new terminal, you can see our bashrc source
78

78

00:05:28,500  -->  00:05:30,030
message prints to the screen.
79

79

00:05:30,220  -->  00:05:33,460
If you do not see this message, check the spelling of the
80

80

00:05:33,470  -->  00:05:35,050
code Snippet and your file names.
81

81

00:05:35,740  -->  00:05:39,770
Okay, with our terminal configured, Let's get back to installing
82

82

00:05:39,780  -->  00:05:44,640
ROS. We will be using a program called Brew to help us install
83

83

00:05:44,640  -->  00:05:48,210
packages. We can check if we have it installed by going into
84

84

00:05:48,220  -->  00:05:51,760
our terminal and typing in through on this computer.
85

85

00:05:51,770  -->  00:05:54,700
I do not have it installed and we get a command not found
86

86

00:05:54,710  -->  00:05:58,210
error. So I will right click on this link and open it in
87

87

00:05:58,220  -->  00:06:06,360
a new tab right here on the home screen.
88

88

00:06:06,370  -->  00:06:08,400
We are given a terminal command to run.
89

89

00:06:08,640  -->  00:06:13,230
You will copy it and paste it into our terminal and hit enter.
90

90

00:06:13,760  -->  00:06:17,150
We don't have the prompt to put in our password since we're
91

91

00:06:17,160  -->  00:06:18,170
installing a new program.
92

92

00:06:18,320  -->  00:06:19,790
So go ahead and put that in.
93

93

00:06:20,150  -->  00:06:24,530
It won't show on the screen and we will press Enter to continue.
94

94

00:06:25,300  -->  00:06:29,460
Note that Brew may take a while to install based on your
95

95

00:06:29,470  -->  00:06:32,960
Internet speed and computer processor, so feel free to pause
96

96

00:06:32,970  -->  00:06:36,320
the video now and come back once the install finishes.
97

97

00:06:37,250  -->  00:06:38,250
Alright.
98

98

00:06:38,260  -->  00:06:41,540
So Brew has installed on our system and we can test it out
99

99

00:06:41,550  -->  00:06:43,070
by typing Brew help.
100

100

00:06:44,380  -->  00:06:47,540
And here we can see the documentation for Brew.
101

101

00:06:47,740  -->  00:06:52,260
Go ahead and clear back to our browser.
102

102

00:06:52,270  -->  00:06:56,250
We will be using Brew to install several different dependencies
103

103

00:06:56,260  -->  00:06:57,090
and prerequisites.
104

104

00:06:57,560  -->  00:07:01,290
The first thing we're going to install is Python version
105

105

00:07:01,300  -->  00:07:05,280
3.8, so copy that and paste it into our terminal.
106

106

00:07:09,860  -->  00:07:13,560
We will continue to go down this list of things to install.
107

107

00:07:13,800  -->  00:07:17,280
Note that the lines with Pound symbols are comments explaining
108

108

00:07:17,290  -->  00:07:19,770
the command, and will not do anything within the terminal.
109

109

00:07:20,140  -->  00:07:23,750
So go ahead and unlink Python.
110

110

00:07:27,340  -->  00:07:32,730
I did not have a previous version of Python link, so I received
111

111

00:07:32,740  -->  00:07:33,180
an error.
112

112

00:07:33,190  -->  00:07:36,390
I can simply ignore it and continue on with the rest of the
113

113

00:07:36,400  -->  00:07:37,260
commands in this list.
114

114

00:07:38,830  -->  00:07:42,950
These downloads will take a while so I will go ahead and
115

115

00:07:42,960  -->  00:07:46,310
speed up the video just so you can see what my terminal output
116

116

00:07:46,320  -->  00:07:48,080
looked like throughout the installation.
117

117

00:07:48,300  -->  00:07:50,340
Jump to this time stamp.
118

118

00:07:50,350  -->  00:07:53,010
If you want to get to the next phase of the installation
119

119

00:08:19,470  -->  00:08:23,530
next we will need to disable System Integrity Protection,
120

120

00:08:23,880  -->  00:08:27,360
which allows processes to inherit environment dynamic linking
121

121

00:08:27,370  -->  00:08:31,670
libraries. Click on the link takes us to an Apple Instructions
122

122

00:08:31,730  -->  00:08:39,039
page. We can check if SIP is enabled on our computer by running
123

123

00:08:39,049  -->  00:08:42,159
the following command in the terminal, so go ahead and click
124

124

00:08:42,169  -->  00:08:47,330
the screen and run CSR util status.
125

125

00:08:48,920  -->  00:08:53,920
Mine is enabled so I will need to disable it. In order to
126

126

00:08:53,930  -->  00:08:54,640
disable SIP,
127

127

00:08:55,000  -->  00:08:58,750
we have to restart our Mac computer and hold command R during
128

128

00:08:58,750  -->  00:09:01,580
startup. So Let's go ahead and do that now.
129

129

00:09:19,410  -->  00:09:21,400
This is the screen you get.
130

130

00:09:21,410  -->  00:09:25,440
If you held "command R" during startup. From here I'm going
131

131

00:09:25,450  -->  00:09:35,700
to Select English, and then we're going to go to the Utilities
132

132

00:09:35,710  -->  00:09:38,000
tab at the top, and Select 'Terminal'.
133

133

00:09:39,800  -->  00:09:45,200
We can then run the following command to disable SIP.
134

134

00:09:46,610  -->  00:09:49,500
Now we can go ahead and restart the computer.
135

135

00:09:49,680  -->  00:09:53,730
I will just type in reboot in the terminal to do so.
136

136

00:10:00,680  -->  00:10:04,820
We are now going to actually download and install ROS.
137

137

00:10:05,180  -->  00:10:09,740
We will click on the link to get to the Releases page and
138

138

00:10:09,750  -->  00:10:12,680
we will be looking for the latest version of ROS Foxy.
139

139

00:10:13,200  -->  00:10:16,980
In this case, the latest version for me is ROS
140

140

00:10:17,040  -->  00:10:19,620
Foxy Patch release four.
141

141

00:10:19,880  -->  00:10:23,330
If a newer version is available, feel free to download that
142

142

00:10:23,340  -->  00:10:23,810
one instead.
143

143

00:10:24,410  -->  00:10:28,650
Once here we will click on the Assets Dropdown and Select
144

144

00:10:28,660  -->  00:10:30,780
the Mac OS version of ROS Foxy.
145

145

00:10:31,200  -->  00:10:34,650
This may take some time to download based on your Internet
146

146

00:10:34,660  -->  00:10:37,910
speed, so feel free to pause the video and come back once
147

147

00:10:37,920  -->  00:10:38,960
you finish your download.
148

148

00:10:39,040  -->  00:10:43,030
All right, once it finishes downloading, Let's head back
149

149

00:10:43,040  -->  00:10:48,100
to our instructions page and here we can see we need to unpack
150

150

00:10:48,110  -->  00:10:49,180
this ROS installation.
151

151

00:10:49,420  -->  00:11:00,330
So first off we're going to make a new directory... change into
152

152

00:11:00,340  -->  00:11:06,390
that directory... and then unpack the ROS 2 download.
153

153

00:11:08,950  -->  00:11:11,960
Alright, if you just tried to copy and paste that command
154

154

00:11:11,970  -->  00:11:14,980
and like I just did and notice that you're saying error opening
155

155

00:11:14,990  -->  00:11:18,280
archive fail to open that's because this is a generic command
156

156

00:11:18,290  -->  00:11:20,950
and we'll have to make sure we get the correct name on our
157

157

00:11:20,960  -->  00:11:25,000
particular download file, so I'll just run the command "tar XF
158

158

00:11:25,750  -->  00:11:31,470
Tilde slash", which means our home directory... "downloads" and
159

159

00:11:31,480  -->  00:11:33,240
then "ROS 2 release".
160

160

00:11:33,270  -->  00:11:36,450
And if I hit the tab button, it'll auto complete for us.
161

161

00:11:36,600  -->  00:11:40,380
So it gives us the correct distribution, date, and the rest
162

162

00:11:40,390  -->  00:11:43,600
of the name of the file and the rest of the name of the file
163

163

00:11:43,610  -->  00:11:44,440
that we just downloaded.
164

164

00:11:44,480  -->  00:11:46,010
So I'll go ahead and hit enter.
165

165

00:11:48,580  -->  00:11:55,600
If we head back to our installation instructions we can see
166

166

00:11:55,610  -->  00:11:59,560
in order to use ROS2, we must source our environment using
167

167

00:11:59,570  -->  00:12:00,850
the source command.
168

168

00:12:00,860  -->  00:12:05,110
You will source it in our ROS 2 Foxy folder...
169

169

00:12:05,590  -->  00:12:10,480
ROS 2 OSX... set up dot bash... and hit enter.
170

170

00:12:11,360  -->  00:12:15,970
After sourcing my ROS "set up dot bash" file, I get a warning
171

171

00:12:15,980  -->  00:12:19,580
saying the Connext directory is not valid, so Connext will
172

172

00:12:19,590  -->  00:12:20,300
not be available.
173

173

00:12:20,560  -->  00:12:24,620
Connext has to do with utilizing different DDS communication
174

174

00:12:24,630  -->  00:12:28,990
methods. The default DDS communication for ROS2 does not
175

175

00:12:29,000  -->  00:12:32,740
need Connext, so you don't have to worry about this warning.
176

176

00:12:32,900  -->  00:12:37,130
It is worth noting that ROS is now installed and we can
177

177

00:12:37,140  -->  00:12:38,660
go about running the demo nodes.
178

178

00:12:39,140  -->  00:12:42,430
But before we do that, Let's take care of some issues you
179

179

00:12:42,440  -->  00:12:46,300
might experience along the lines using ROS 2 on Mac OS.
180

180

00:12:47,680  -->  00:12:51,770
The first issue you may run into is some of the Python modules
181

181

00:12:51,780  -->  00:12:55,530
we installed through Brew may not link properly to our Python.
182

182

00:12:56,400  -->  00:12:59,850
Here I tried running a ROS terminal command but ran into
183

183

00:12:59,860  -->  00:13:03,320
errors saying the modules do not exist so we will have to
184

184

00:13:03,330  -->  00:13:05,300
install them manually through pip3.
185

185

00:13:05,910  -->  00:13:13,970
These modules include ifcfg netifaces, NumPy, and pyyaml,
186

186

00:13:14,210  -->  00:13:17,960
In order to use the ROS 2 terminal commands.
187

187

00:13:18,080  -->  00:13:20,630
Here you can see each instance where I try to use a ROS
188

188

00:13:20,640  -->  00:13:23,350
terminal command, but I was unable to use it because I did not have
189

189

00:13:23,360  -->  00:13:24,790
one of these dependencies installed.
190

190

00:13:27,820  -->  00:13:32,680
If you want to use the RQT visualization tool, you will also
191

191

00:13:32,690  -->  00:13:39,480
need to install PyQt5, PySide2, catkin_pkg, pydot,
192

192

00:13:39,570  -->  00:13:41,850
and PyQtGraph.
193

193

00:13:42,180  -->  00:13:45,750
And here you can see where I try to use each QT instance
194

194

00:13:45,930  -->  00:13:50,210
and where my errors popped up after installing all those
195

195

00:13:50,220  -->  00:13:52,970
dependencies, my RQT works as expected.
196

196

00:13:54,050  -->  00:13:55,440
Alright with that.
197

197

00:13:55,450  -->  00:13:57,270
Out of the way, Let's start with the new terminal.
198

198

00:13:57,300  -->  00:14:00,660
I'll go ahead and source my ROS installation again.
199

199

00:14:03,350  -->  00:14:06,690
Again, we can ignore this warning so I'll go ahead and clear
200

200

00:14:06,700  -->  00:14:09,690
the screen and with that our ROS installation should be
201

201

00:14:09,700  -->  00:14:10,830
active within our terminal.
202

202

00:14:11,100  -->  00:14:13,830
We can verify this by printing out our terminal environment
203

203

00:14:13,860  -->  00:14:17,250
variables and here we can see the environment variables for
204

204

00:14:17,260  -->  00:14:18,270
our ROS installation.
205

205

00:14:18,460  -->  00:14:22,480
Now one thing to note is we will need to source the setup
206

206

00:14:22,490  -->  00:14:25,230
bash script every time we open a new terminal.
207

207

00:14:25,240  -->  00:14:28,690
Instead of having to do that, Let's place this command in
208

208

00:14:28,700  -->  00:14:30,760
our bashrc file we created earlier.
209

209

00:14:30,820  -->  00:14:34,270
That way it will run each time the terminal open.
210

210

00:14:34,770  -->  00:14:38,290
You can also go ahead and get rid of the Echo bash source
211

211

00:14:38,300  -->  00:14:39,490
that we had created earlier.
212

212

00:14:39,500  -->  00:14:40,870
So I'll go ahead and delete that.
213

213

00:14:42,500  -->  00:14:46,290
And right below our export, we can just put in the same command
214

214

00:14:46,500  -->  00:14:48,240
that we had in our terminal.
215

215

00:14:51,620  -->  00:14:54,120
Which sources or ROS installation.
216

216

00:15:00,190  -->  00:15:03,710
And since we always get a warning message every time we source,
217

217

00:15:03,980  -->  00:15:07,280
I'll just go ahead and have it clear the screen after sourcing.
218

218

00:15:07,880  -->  00:15:10,490
Go ahead and save the file.
219

219

00:15:13,880  -->  00:15:18,050
Now, every time we open a new terminal our ROS 2 installation
220

220

00:15:18,110  -->  00:15:18,980
will be sourced.
221

221

00:15:19,310  -->  00:15:21,500
I can test that out here in the new terminal.
222

222

00:15:26,910  -->  00:15:31,450
We can indeed see our ROS version is two, and our ROS is
223

223

00:15:31,460  -->  00:15:33,370
Ros Foxy as it was in our other terminal.
224

224

00:15:33,420  -->  00:15:36,060
With this out of the way, we can go ahead and run the sample
225

225

00:15:36,070  -->  00:15:39,230
nodes that are within the installation instructions. I'll
226

226

00:15:39,240  -->  00:15:40,400
go ahead and clear my screen.
227

227

00:15:43,000  -->  00:15:49,030
The first one is a ROS publisher, in this case called Talker,
228

228

00:15:49,560  -->  00:15:53,480
so I'll go ahead and run it using the ROS 2 run command and
229

229

00:15:53,490  -->  00:15:54,080
hit enter.
230

230

00:15:55,100  -->  00:15:58,400
And here we can see publishing Hello World, and a counter
231

231

00:15:58,410  -->  00:15:59,090
which increments.
232

232

00:15:59,220  -->  00:16:04,380
We can then run this subscriber node called Listener in a
233

233

00:16:04,380  -->  00:16:09,090
different terminal, and you see it will copy the Hello World
234

234

00:16:09,100  -->  00:16:11,910
messages which are coming over the ROS DDS services.
235

235

00:16:15,320  -->  00:16:19,430
It doesn't seem like much, but these two nodes are communicating
236

236

00:16:19,440  -->  00:16:22,910
over the ROS 2 framework in which the Talker node is publishing
237

237

00:16:22,920  -->  00:16:26,420
values over ROS, and the subscriber node is receiving those
238

238

00:16:26,430  -->  00:16:28,130
messages coming over the topic.
239

239

00:16:28,320  -->  00:16:31,860
We can stop these nodes by clicking on the corresponding
240

240

00:16:31,870  -->  00:16:34,860
terminal and hitting the control C keystroke.
241

241

00:16:37,090  -->  00:16:38,090
Congratulations.
242

242

00:16:38,220  -->  00:16:42,630
You have successfully installed ROS2 on Your Mac OS machine.
