1
1
#! /bin/bash
2
+ # Install ROS on NVIDIA Jetson Developer Kits
3
+ # Copyright (c) JetsonHacks, 2019-2021
4
+
5
+ # MIT License
6
+ # Maintainer of ARM builds for ROS is http://answers.ros.org/users/1034/ahendrix/
7
+ # Information from:
8
+ # http://wiki.ros.org/melodic/Installation/UbuntuARM
9
+
10
+ # Get code name of distribution
11
+ # lsb_release gets the Ubuntu Description Release and Code name
12
+ DISTRIBUTION_CODE_NAME=$( lsb_release -sc )
13
+
14
+ case $DISTRIBUTION_CODE_NAME in
15
+ " xenial" )
16
+ echo " This Ubuntu distribution is Ubuntu Xenial (16.04)"
17
+ echo " This install is not the ROS recommended version for Ubuntu Xenial."
18
+ echo " ROS Bionic is the recommended version."
19
+ echo " This script installs ROS Melodic. You will need to modify it for your purposes."
20
+ exit 0
21
+ ;;
22
+ " bionic" )
23
+ echo " This Ubuntu distribution is Ubuntu Bionic (18.04)"
24
+ echo " Installing ROS Melodic"
25
+ ;;
26
+ * )
27
+ echo " This distribution is $DISTRIBUTION_CODE_NAME "
28
+ echo " This script will only work with Ubuntu Xenial (16.04) or Bionic (18.04)"
29
+ exit 0
30
+ esac
31
+
2
32
# Install Robot Operating System (ROS) on NVIDIA Jetson Developer Kit
3
33
# Maintainer of ARM builds for ROS is http://answers.ros.org/users/1034/ahendrix/
4
34
# Information from:
8
38
# Green is 2
9
39
# Reset is sgr0
10
40
11
- function usage
41
+ usage ()
12
42
{
13
43
echo " Usage: ./installROS.sh [[-p package] | [-h]]"
14
44
echo " Install ROS Melodic"
@@ -22,7 +52,7 @@ function usage
22
52
echo " -h | --help This message"
23
53
}
24
54
25
- function shouldInstallPackages
55
+ shouldInstallPackages ()
26
56
{
27
57
tput setaf 1
28
58
echo " Your package list did not include a recommended base package"
@@ -87,9 +117,9 @@ sudo apt-add-repository restricted
87
117
# Setup sources.lst
88
118
sudo sh -c ' echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
89
119
# Setup keys
90
- sudo apt-key adv --keyserver ' hkp://keyserver.ubuntu.com:80 ' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
91
- # If you experience issues connecting to the keyserver, you can try substituting hkp ://pgp.mit.edu:80 or hkp://keyserver.ubuntu.com:80 in the previous command.
92
- # Installation
120
+ sudo apt install curl
121
+ curl -s https ://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
122
+
93
123
tput setaf 2
94
124
echo " Updating apt-get"
95
125
tput sgr0
@@ -120,24 +150,61 @@ tput setaf 2
120
150
echo " Installing rosdep"
121
151
tput sgr0
122
152
sudo apt-get install python-rosdep -y
123
- # Certificates are messed up on earlier version Jetson for some reason
124
- # sudo c_rehash /etc/ssl/certs
125
153
# Initialize rosdep
126
154
tput setaf 2
127
155
echo " Initializaing rosdep"
128
156
tput sgr0
129
157
sudo rosdep init
130
158
# To find available packages, use:
131
159
rosdep update
132
- # Environment Setup - Don't add /opt/ros/melodic/setup.bash if it's already in bashrc
160
+ # Environment Setup - source melodic setup.bash
161
+ # Don't add /opt/ros/melodic/setup.bash if it's already in bashrc
133
162
grep -q -F ' source /opt/ros/melodic/setup.bash' ~ /.bashrc || echo " source /opt/ros/melodic/setup.bash" >> ~ /.bashrc
134
163
source ~ /.bashrc
135
164
# Install rosinstall
136
165
tput setaf 2
137
166
echo " Installing rosinstall tools"
138
167
tput sgr0
139
- sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential -y
168
+
169
+ # Install useful ROS dev tools
170
+ sudo apt-get install -y python-rosinstall \
171
+ python-rosinstall-generator \
172
+ python-wstool \
173
+ build-essential
174
+
175
+ # Use ip to get the current IP addresses of eth0 and wlan0; parse into form xx.xx.xx.xx
176
+ ETH0_IPADDRESS=$( ip -4 -o addr show eth0 | awk ' {print $4}' | cut -d " /" -f 1)
177
+ WLAN_IPADDRESS=$( ip -4 -o addr show wlan0 | awk ' {print $4}' | cut -d " /" -f 1)
178
+
179
+ if [ -z " $ETH0_IPADDRESS " ] ; then
180
+ echo " Ethernet (eth0) is not available"
181
+ else
182
+ echo " Ethernet (eth0) is $ETH0_IPADDRESS "
183
+ fi
184
+ if [ -z " $WLAN_IPADDRESS " ] ; then
185
+ echo " Wireless (wlan0) is not available"
186
+ else
187
+ echo " Wireless (wlan0) ip address is $WLAN_IPADDRESS "
188
+ fi
189
+
190
+ # Default to eth0 if available; wlan0 next
191
+ ROS_IP_ADDRESS=" "
192
+ if [ ! -z " $ETH0_IPADDRESS " ] ; then
193
+ ROS_IP_ADDRESS=$ETH0_IPADDRESS
194
+ else
195
+ ROS_IP_ADDRESS=$WLAN_IPADDRESS
196
+ fi
197
+ if [ ! -z " $ROS_IP_ADDRESS " ] ; then
198
+ echo " Setting ROS_IP in ${HOME} /.bashrc to: $ROS_IP_ADDRESS "
199
+ else
200
+ echo " Setting ROS_IP to empty. Please change ROS_IP in the ${HOME} /.bashrc file"
201
+ fi
202
+
203
+ # setup ROS environment variables
204
+ grep -q -F ' ROS_MASTER_URI' ~ /.bashrc || echo ' export ROS_MASTER_URI=http://localhost:11311' | tee -a ~ /.bashrc
205
+ grep -q -F ' ROS_IP' ~ /.bashrc || echo " export ROS_IP=${ROS_IP_ADDRESS} " | tee -a ~ /.bashrc
140
206
tput setaf 2
207
+
141
208
echo " Installation complete!"
142
209
echo " Please setup your Catkin Workspace"
143
210
tput sgr0
0 commit comments