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