11#! /bin/bash
2- # Install Robot Operating System (ROS) on NVIDIA Jetson Nano Developer Kit
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+
32+ # Install Robot Operating System (ROS) on NVIDIA Jetson Developer Kit
333# Maintainer of ARM builds for ROS is http://answers.ros.org/users/1034/ahendrix/
434# Information from:
535# http://wiki.ros.org/melodic/Installation/UbuntuARM
838# Green is 2
939# Reset is sgr0
1040
11- function usage
41+ usage ()
1242{
1343 echo " Usage: ./installROS.sh [[-p package] | [-h]]"
1444 echo " Install ROS Melodic"
@@ -22,7 +52,7 @@ function usage
2252 echo " -h | --help This message"
2353}
2454
25- function shouldInstallPackages
55+ shouldInstallPackages ()
2656{
2757 tput setaf 1
2858 echo " Your package list did not include a recommended base package"
@@ -87,9 +117,9 @@ sudo apt-add-repository restricted
87117# Setup sources.lst
88118sudo sh -c ' echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
89119# 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+
93123tput setaf 2
94124echo " Updating apt-get"
95125tput sgr0
@@ -120,25 +150,61 @@ tput setaf 2
120150echo " Installing rosdep"
121151tput sgr0
122152sudo apt-get install python-rosdep -y
123- # Certificates are messed up on earlier version Jetson for some reason
124- # Do not know if it is an issue with the Nano, test by commenting out
125- # sudo c_rehash /etc/ssl/certs
126153# Initialize rosdep
127154tput setaf 2
128155echo " Initializaing rosdep"
129156tput sgr0
130157sudo rosdep init
131158# To find available packages, use:
132159rosdep update
133- # 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
134162grep -q -F ' source /opt/ros/melodic/setup.bash' ~ /.bashrc || echo " source /opt/ros/melodic/setup.bash" >> ~ /.bashrc
135163source ~ /.bashrc
136164# Install rosinstall
137165tput setaf 2
138166echo " Installing rosinstall tools"
139167tput sgr0
140- 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
141206tput setaf 2
207+
142208echo " Installation complete!"
209+ echo " Please setup your Catkin Workspace and ~/.bashrc file"
143210tput sgr0
144-
0 commit comments