#!/bin/bash # The BSD License # Copyright (c) 2014 OROCA and ROS Korea Users Group set -x function usage { # Print out usage of this script. echo >&2 "usage: $0 [catkin workspace name (default:catkin_ws)] [ROS distro (default: kinetic)" echo >&2 " [-h|--help] Print help message." exit 0 } # Parse command line. If the number of argument differs from what is expected, call `usage` function. OPT=`getopt -o h -l help -- $*` if [ $# != 2 ]; then usage fi eval set -- $OPT while [ -n "$1" ] ; do case $1 in -h|--help) usage ;; --) shift; break;; *) echo "Unknown option($1)"; usage;; esac done name_catkinws=$1 name_catkinws=${name_catkinws:="catkin_ws"} name_ros_distro=$2 name_ros_distro=${name_ros_distro:="kinetic"} version=`lsb_release -sc` echo "[Checking the ubuntu version]" case $version in "wily" | "xenial") ;; *) echo "ERROR: This script will only work on Ubuntu Wily(15.10) and Xenial(16.04). Exit." exit 0 esac echo "[Update & upgrade the package]" sudo apt-get update sudo apt-get upgrade echo "[Installing chrony and setting the ntpdate]" sudo apt-get install -y chrony ntpdate sudo ntpdate ntp.ubuntu.com echo "[Add the ROS repository]" if [ ! -e /etc/apt/sources.list.d/ros-latest.list ]; then sudo sh -c "echo \"deb http://packages.ros.org/ros/ubuntu ${version} main\" > /etc/apt/sources.list.d/ros-latest.list" fi echo "[Download the ROS keys]" roskey=`apt-key list | grep "ROS builder"` if [ -z "$roskey" ]; then sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116 fi echo "[Update & upgrade the package]" sudo apt-get update sudo apt-get upgrade echo "[Installing ROS]" sudo apt-get install -y ros-$name_ros_distro-desktop-full ros-$name_ros_distro-rqt-* echo "[rosdep init and python-rosinstall]" sudo sh -c "rosdep init" rosdep update . /opt/ros/$name_ros_distro/setup.sh sudo apt-get install -y python-rosinstall echo "[Making the catkin workspace and testing the catkin_make]" mkdir -p ~/$name_catkinws/src cd ~/$name_catkinws/src catkin_init_workspace cd ~/$name_catkinws/ catkin_make echo "[Setting the ROS evironment]" sh -c "echo \"alias eb='gedit ~/.bashrc'\" >> ~/.bashrc" sh -c "echo \"alias sb='source ~/.bashrc'\" >> ~/.bashrc" sh -c "echo \"alias agi='sudo apt-get install'\" >> ~/.bashrc" sh -c "echo \"alias gs='git status'\" >> ~/.bashrc" sh -c "echo \"alias gp='git pull'\" >> ~/.bashrc" sh -c "echo \"alias cw='cd ~/catkin_ws'\" >> ~/.bashrc" sh -c "echo \"alias cs='cd ~/catkin_ws/src'\" >> ~/.bashrc" sh -c "echo \"alias cm='cd ~/catkin_ws && catkin_make'\" >> ~/.bashrc" sh -c "echo \"source /opt/ros/$name_ros_distro/setup.bash\" >> ~/.bashrc" sh -c "echo \"source ~/$name_catkinws/devel/setup.bash\" >> ~/.bashrc" sh -c "echo \"export ROS_MASTER_URI=http://localhost:11311\" >> ~/.bashrc" sh -c "echo \"export ROS_HOSTNAME=localhost\" >> ~/.bashrc" echo "[Complete!!!]" exec bash exit 0