From 21b3b2e6d01941beedf6fed4194d486f9a0a4884 Mon Sep 17 00:00:00 2001 From: JetsonHacksNano <49042112+JetsonHacksNano@users.noreply.github.com> Date: Sat, 4 Sep 2021 15:18:32 -0700 Subject: [PATCH 1/5] Update ROS GPG Key --- installROS.sh | 90 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 78 insertions(+), 12 deletions(-) diff --git a/installROS.sh b/installROS.sh index d6de0f7..c6cb014 100755 --- a/installROS.sh +++ b/installROS.sh @@ -1,5 +1,35 @@ #!/bin/bash -# Install Robot Operating System (ROS) on NVIDIA Jetson Nano Developer Kit +# Install ROS on NVIDIA Jetson Developer Kits +# Copyright (c) JetsonHacks, 2019-2021 + +# MIT License +# Maintainer of ARM builds for ROS is http://answers.ros.org/users/1034/ahendrix/ +# Information from: +# http://wiki.ros.org/melodic/Installation/UbuntuARM + +# Get code name of distribution +# lsb_release gets the Ubuntu Description Release and Code name +DISTRIBUTION_CODE_NAME=$( lsb_release -sc ) + +case $DISTRIBUTION_CODE_NAME in + "xenial" ) + echo "This Ubuntu distribution is Ubuntu Xenial (16.04)" + echo "This install is not the ROS recommended version for Ubuntu Xenial." + echo "ROS Bionic is the recommended version." + echo "This script installs ROS Melodic. You will need to modify it for your purposes." + exit 0 + ;; + "bionic") + echo "This Ubuntu distribution is Ubuntu Bionic (18.04)" + echo "Installing ROS Melodic" + ;; + *) + echo "This distribution is $DISTRIBUTION_CODE_NAME" + echo "This script will only work with Ubuntu Xenial (16.04) or Bionic (18.04)" + exit 0 +esac + +# Install Robot Operating System (ROS) on NVIDIA Jetson Developer Kit # Maintainer of ARM builds for ROS is http://answers.ros.org/users/1034/ahendrix/ # Information from: # http://wiki.ros.org/melodic/Installation/UbuntuARM @@ -8,7 +38,7 @@ # Green is 2 # Reset is sgr0 -function usage +usage () { echo "Usage: ./installROS.sh [[-p package] | [-h]]" echo "Install ROS Melodic" @@ -22,7 +52,7 @@ function usage echo "-h | --help This message" } -function shouldInstallPackages +shouldInstallPackages () { tput setaf 1 echo "Your package list did not include a recommended base package" @@ -87,9 +117,9 @@ sudo apt-add-repository restricted # Setup sources.lst sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' # Setup keys -sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 -# 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. -# Installation +sudo apt install curl +curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - + tput setaf 2 echo "Updating apt-get" tput sgr0 @@ -120,9 +150,6 @@ tput setaf 2 echo "Installing rosdep" tput sgr0 sudo apt-get install python-rosdep -y -# Certificates are messed up on earlier version Jetson for some reason -# Do not know if it is an issue with the Nano, test by commenting out -# sudo c_rehash /etc/ssl/certs # Initialize rosdep tput setaf 2 echo "Initializaing rosdep" @@ -130,15 +157,54 @@ tput sgr0 sudo rosdep init # To find available packages, use: rosdep update -# Environment Setup - Don't add /opt/ros/melodic/setup.bash if it's already in bashrc +# Environment Setup - source melodic setup.bash +# Don't add /opt/ros/melodic/setup.bash if it's already in bashrc grep -q -F 'source /opt/ros/melodic/setup.bash' ~/.bashrc || echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc source ~/.bashrc # Install rosinstall tput setaf 2 echo "Installing rosinstall tools" tput sgr0 -sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential -y + +# Install useful ROS dev tools +sudo apt-get install -y python-rosinstall \ + python-rosinstall-generator \ + python-wstool \ + build-essential + +# Use ip to get the current IP addresses of eth0 and wlan0; parse into form xx.xx.xx.xx +ETH0_IPADDRESS=$(ip -4 -o addr show eth0 | awk '{print $4}' | cut -d "/" -f 1) +WLAN_IPADDRESS=$(ip -4 -o addr show wlan0 | awk '{print $4}' | cut -d "/" -f 1) + +if [ -z "$ETH0_IPADDRESS" ] ; then + echo "Ethernet (eth0) is not available" +else + echo "Ethernet (eth0) is $ETH0_IPADDRESS" +fi +if [ -z "$WLAN_IPADDRESS" ] ; then + echo "Wireless (wlan0) is not available" +else + echo "Wireless (wlan0) ip address is $WLAN_IPADDRESS" +fi + +# Default to eth0 if available; wlan0 next +ROS_IP_ADDRESS="" +if [ ! -z "$ETH0_IPADDRESS" ] ; then + ROS_IP_ADDRESS=$ETH0_IPADDRESS +else + ROS_IP_ADDRESS=$WLAN_IPADDRESS +fi +if [ ! -z "$ROS_IP_ADDRESS" ] ; then + echo "Setting ROS_IP in ${HOME}/.bashrc to: $ROS_IP_ADDRESS" +else + echo "Setting ROS_IP to empty. Please change ROS_IP in the ${HOME}/.bashrc file" +fi + +#setup ROS environment variables +grep -q -F ' ROS_MASTER_URI' ~/.bashrc || echo 'export ROS_MASTER_URI=http://localhost:11311' | tee -a ~/.bashrc +grep -q -F ' ROS_IP' ~/.bashrc || echo "export ROS_IP=${ROS_IP_ADDRESS}" | tee -a ~/.bashrc tput setaf 2 + echo "Installation complete!" +echo "Please setup your Catkin Workspace and ~/.bashrc file" tput sgr0 - From 64a80aec498ab3ad5e2f78815935ea929fb94a2c Mon Sep 17 00:00:00 2001 From: JetsonHacksNano <49042112+JetsonHacksNano@users.noreply.github.com> Date: Sat, 4 Sep 2021 15:21:59 -0700 Subject: [PATCH 2/5] Add help to setupCatkinWorkspace --- setupCatkinWorkspace.sh | 59 +++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 23 deletions(-) diff --git a/setupCatkinWorkspace.sh b/setupCatkinWorkspace.sh index e1aacc5..23db436 100755 --- a/setupCatkinWorkspace.sh +++ b/setupCatkinWorkspace.sh @@ -1,33 +1,46 @@ #!/bin/bash -# Create a Catkin Workspace and setup ROS environment variables -# Usage setupCatkinWorkspace.sh dirName +# Create a Catkin Workspace +# Copyright (c) JetsonHacks, 2019-2021 + +# MIT License +# Maintainer of ARM builds for ROS is http://answers.ros.org/users/1034/ahendrix/ +# Information from: +# http://wiki.ros.org/melodic/Installation/UbuntuARM +# source /opt/ros/melodic/setup.bash -DEFAULTDIR=~/catkin_ws -CLDIR="$1" -if [ ! -z "$CLDIR" ]; then - DEFAULTDIR=~/"$CLDIR" -fi -if [ -e "$DEFAULTDIR" ] ; then - echo "$DEFAULTDIR already exists; no action taken" + +# Usage setupCatkinWorkspace.sh dirName +help_usage () +{ + echo "Usage: ./setupCatkinWorkspac.sh " + echo " Setup a Catkin Workspace at the path indicated" + echo " Default path is ~/catkin_ws" + echo " -h | --help This message" + exit 0 +} + +CATKIN_DIR="" + case $1 in + -h | --help) help_usage ;; + *) CATKIN_DIR="$1" ;; + esac + + +CATKIN_DIR=${CATKIN_DIR:="${HOME}/catkin_ws"} + +if [ -e "$CATKIN_DIR" ] ; then + echo "$CATKIN_DIR already exists; no action taken" exit 1 else - echo "Creating Catkin Workspace: $DEFAULTDIR" + echo "Creating Catkin Workspace: $CATKIN_DIR" fi -echo "$DEFAULTDIR"/src -mkdir -p "$DEFAULTDIR"/src -cd "$DEFAULTDIR"/src +echo "$CATKIN_DIR"/src +mkdir -p "$CATKIN_DIR"/src +cd "$CATKIN_DIR"/src catkin_init_workspace -cd "$DEFAULTDIR" +cd .. catkin_make -#setup ROS environment variables -grep -q -F ' ROS_MASTER_URI' ~/.bashrc || echo 'export ROS_MASTER_URI=http://localhost:11311' | tee -a ~/.bashrc -grep -q -F ' ROS_IP' ~/.bashrc || echo "export ROS_IP=$(hostname -I)" | tee -a ~/.bashrc -echo "export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH" >> ~/.bashrc - -echo "The Catkin Workspace has been created" -echo "Please modify the placeholders for ROS_MASTER_URI and ROS_IP placed into the file ${HOME}/.bashrc" -echo "to suit your environment." - +echo "Catkin workspace: $CATKIN_DIR created" From f05fe5413029195d7111df541b96f82d6b164b06 Mon Sep 17 00:00:00 2001 From: JetsonHacksNano <49042112+JetsonHacksNano@users.noreply.github.com> Date: Sat, 4 Sep 2021 15:26:45 -0700 Subject: [PATCH 3/5] Update README --- README.md | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 3b825ed..13dff66 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # installROS -Install Robot Operating System (ROS) on NVIDIA Jetson Nano Developer Kit +Install Robot Operating System (ROS) Melodic on NVIDIA Jetson Developer Kits -These scripts will install Robot Operating System (ROS) on the NVIDIA Jetson Nano Developer Kit. +These scripts will install Robot Operating System (ROS) Melodic on the NVIDIA Jetson Developer Kits. + +Jetson Nano, Jetson AGX Xavier, Jetson Xavier NX, Jetson TX2, Jetson TX1 The script is based on the Ubuntu ARM install of ROS Melodic: http://wiki.ros.org/melodic/Installation/Ubuntu @@ -24,35 +26,40 @@ Default is ros-melodic-ros-base if no packages are specified. Example Usage: -$ ./installROS.sh -p ros-melodic-desktop -p ros-melodic-rgbd-launch +`$ ./installROS.sh -p ros-melodic-desktop -p ros-melodic-rgbd-launch` This script installs a baseline ROS environment. There are several tasks: - +* Enable repositories universe, multiverse, and restricted +* Adds the ROS sources list +* Sets the needed keys +* Loads specified ROS packages, defaults to ros-melodic-base-ros if none specified +* Initializes rosdep +* Sets up `ROS_MASTER_URI` and `ROS_IP` in the `~/.bashrc` file + +_**Note:** You will need to check your `~/.bashrc` file to make sure the ROS_MASTER_URI and ROS_IP are setup correctly for your environment. During configuration, a best guess is made which should be considered a placeholder._ You can edit this file to add the ROS packages for your application. -setupCatkinWorkspace.sh +**setupCatkinWorkspace.sh** Usage: -$ ./setupCatkinWorkspace.sh [optionalWorkspaceName] +`$ ./setupCatkinWorkspace.sh [_optionalWorkspaceName_]` -where optionalWorkspaceName is the name of the workspace to be used. The default workspace name is catkin_ws. This script also sets up some ROS environment variables. Refer to the script for details. - -Note: On June 7, 2019 the GPG key for ROS was changed due to security issues. If you have ROS installed on your system before this, you should delete the GPG key: - -
-$ sudo apt-key del 421C365BD9FF1F717815A3895523BAEEB01FA116
-
+where _optionalWorkspaceName_ is the name and path of the workspace to be used. The default workspace name is `~/catkin_ws`. ## Release Notes + +### September, 2021 +* v1.1 +* Tested on L4T 32.6.1 (JetPack 4.6) +* Update ROS GPG Key +* Setup ROS_IP more intelligently +* Setup ROS_MASTER_URI and ROS_IP in installROS script instead of setupCatkinWorkspace +* Script wrangling and cleanup +* Should be the same as JetsonHacks/installROS + October 2019 * vL4T32.2.1 * L4T 32.2.1 (JetPack 4.2.2) @@ -74,7 +81,7 @@ $ sudo apt-key del 421C365BD9FF1F717815A3895523BAEEB01FA116 ## License MIT License -Copyright (c) 2017-2019 JetsonHacks +Copyright (c) 2017-2021 JetsonHacks Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From a968ea8d391ffffa7a53ed51714616d40a96a162 Mon Sep 17 00:00:00 2001 From: JetsonHacksNano <49042112+JetsonHacksNano@users.noreply.github.com> Date: Sat, 4 Sep 2021 15:35:50 -0700 Subject: [PATCH 4/5] Move apt update --- installROS.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/installROS.sh b/installROS.sh index c6cb014..759b0ce 100755 --- a/installROS.sh +++ b/installROS.sh @@ -113,6 +113,10 @@ tput sgr0 sudo apt-add-repository universe sudo apt-add-repository multiverse sudo apt-add-repository restricted +tput setaf 2 +echo "Updating apt list" +tput sgr0 +sudo apt update # Setup sources.lst sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' @@ -120,10 +124,6 @@ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main sudo apt install curl curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - -tput setaf 2 -echo "Updating apt-get" -tput sgr0 -sudo apt-get update tput setaf 2 echo "Installing ROS" tput sgr0 From f4bf7b3c940de9c30d89f06fb6f8a145845ee723 Mon Sep 17 00:00:00 2001 From: JetsonHacksNano <49042112+JetsonHacksNano@users.noreply.github.com> Date: Sat, 4 Sep 2021 16:24:50 -0700 Subject: [PATCH 5/5] Update apt list 2x --- installROS.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/installROS.sh b/installROS.sh index 759b0ce..7d46ba2 100755 --- a/installROS.sh +++ b/installROS.sh @@ -124,6 +124,11 @@ sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main sudo apt install curl curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add - +tput setaf 2 +echo "Updating apt list" +tput sgr0 +sudo apt update + tput setaf 2 echo "Installing ROS" tput sgr0