Installation - Pitt-RAS/iarc7_common GitHub Wiki

Note: The default install instructions for these packages will not work. You can get away with defaults for Ubuntu, ROS Kinetic, and gcc6, but the default install instructions will not work for wstool, Morse, or OpenCV.

Table of Contents

Installation Instructions

Ubuntu 16.04

ROS Kinetic requires ubuntu 16.04

If you don't have Ubuntu installed, install version 16.04 because it's LTS (Long term service). There's a useful tutorial here.

If you already have Ubuntu, but a version different from 16.04, you can install Ubuntu 16.04 in a chroot environment under your existing operating system. To do this, follow the instructions here, but replace every occurence of "Indigo" with "Kinetic" and "trusty" with "xenial".

Installing ROS Kinetic

Run the following (you can copy and paste the whole thing):

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' && \
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 0xB01FA116 && \
sudo apt-get update && \
sudo apt-get install ros-kinetic-ros-base && \
sudo rosdep init && \
rosdep update

Installing gcc6

Run the following, you can copy and paste as one command:

sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-snapshot -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5;

This snippet was originally derived from here: https://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91

Install CUDA (cpu only users can ignore)

Enable NVIDIA drivers (this depends on what GPU you have, you'll need to look up instructions online). Might start here: http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

CPU only users do not need a driver. However, they do need to install CUDA so that opencv3 can build with CUDA, which is necessary to build iarc7_vision.

Download the CUDA 9 package

cd ~/Downloads && \
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run && \
mv cuda_9.0.176_384.81_linux-run cuda_9.0.176_384.81_linux-run.run && \
chmod +x cuda_9.0.176_384.81_linux-run.run && \
sudo ./cuda_9.0.176_384.81_linux-run.run --silent --toolkit --samples --override

Installing OpenCV (cpu only users can ignore)

Switch to gcc5

sudo update-alternatives --set gcc /usr/bin/gcc-5

It is easiest to install OpenCV from source given that we are using a specific version. Use version 3.3.1.

The instructions for install opencv are based off of this guide here.

Download this source tarball

cd ~/iarc7 && \
wget https://github.com/opencv/opencv/archive/3.3.1.tar.gz && \
tar -xvsf 3.3.1.tar.gz;

Install packages

sudo apt-get install build-essential -y && \
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev -y && \
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev -y;

Setup build directory

cd ~/iarc7/opencv-3.3.1 && \
mkdir release && \
cd release && \
cmake -D CMAKE_BUILD_TYPE=Release -D CUDA_FAST_MATH=ON -D CMAKE_INSTALL_PREFIX=/usr/local ..;

In order to not have a super long build time the number of CUDA architectures built needs to be limited.

Install ccmake.

sudo apt-get install cmake-curses-gui

Run ccmake.

cd ~/iarc7/opencv-3.3.1/release && \
ccmake .

Edit the CUDA_ARCH_BIN variable to only contain your gpu architecture (cpu only users can use 5.0 its been tested). Find your gpu's compute capability here.

Press 'c' then 'g' to exit and configure.

Build, replace the number for with the number of cores you have (This will take a hot minute)

make -j4

Install

sudo make install

Remember to switch back to gcc6 once OpenCV is installed.

sudo update-alternatives --set gcc /usr/bin/gcc-6

Setting up a workspace with wstool

First, install ROS's tool for managing workspaces:

sudo apt-get install python-wstool

Then, create a workspace. This folder can be anywhere, but here's how to create one in your home directory:

mkdir -p ~/iarc7/src

Clone the iarc7_common repository:

cd ~/iarc7
git clone https://github.com/Pitt-RAS/iarc7_common.git

Source ros variables:

source /opt/ros/kinetic/setup.bash

Download the repos:

wstool init src iarc7_common/main.rosinstall

CPU USERS ONLY.

You need to remove two repositories related to computer vision and comment out launching the vision node in your launch files.

cd ~/iarc7/src && \
wstool remove iarc7_vision && \
wstool remove vision_opencv && \
rm -rf iarc7_vision vision_opencv

To avoid launching the vision node edit the passive stack launch file

nano ~/iarc7/src/iarc7_launch/launch/passive_stack.launch

Change

<include file="$(find iarc7_vision)/launch/vision_node.launch">
    <arg name="platform" value="$(arg platform)" />
</include>

to

<!-- <include file="$(find iarc7_vision)/launch/vision_node.launch">
    <arg name="platform" value="$(arg platform)" />
</include>-->

END CPU USERS ONLY

Install dependencies:

rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y

Build for the first time

catkin_make

And finally, make your ROS environment be set up automatically in the future:

echo "source ~/iarc7/devel/setup.bash" >> ~/.bashrc && \
source ~/.bashrc;

If you don't do this, you'll have to run source ~/iarc7/devel/setup.bash every time you open a new terminal.

Installing Morse

Install required packages:

sudo apt-get install cmake python3-dev python3-numpy

Download and unzip blender: We need this specific version because it matches the system python version.

cd ~/iarc7 && \
wget http://download.blender.org/release/Blender2.78/blender-2.78c-linux-glibc219-x86_64.tar.bz2 && \
tar xvjf blender-2.78c-linux-glibc219-x86_64.tar.bz2;

Clone the latest morse and build/install it:

cd ~/iarc7 && \
git clone --depth 1 https://github.com/morse-simulator/morse.git && \
cd morse && \
mkdir build && cd build && \
cmake .. && \
sudo make install;

Add blender environment variable, assumes you installed blender in your home directory:

echo "export MORSE_BLENDER="~/iarc7/blender-2.78c-linux-glibc219-x86_64/blender" ">> ~/.bashrc && \
source ~/.bashrc;

Check if everything is ok with:

morse check

Install ROS support for MORSE (Note: DO NOT install python3-rospkg with apt-get)

sudo apt-get install python3-pip && \
pip3 install --ignore-installed --install-option="--prefix=~/iarc7/blender-2.78c-linux-glibc219-x86_64/2.78/python" rospkg catkin_pkg

Download iarc7_simulator (instructions copied from https://github.com/Pitt-RAS/iarc7_simulator)

cd ~/iarc7 && \
wstool merge -t src iarc7_common/simulator.rosinstall;

Update your repos to pull the simulator repository down

wstool update -t src

Now import and compile the sim

cd ~/iarc7 && \
cd src/iarc7_simulator && \
morse import sim && \
cd ~/iarc7 && \
catkin_make;

CPU USERS ONLY

To replace the cameras, enable ground_truth_camera_localization in the simulator.

nano ~/iarc7/src/iarc7_simulator/param/morse.yaml

END CPU USERS ONLY

To launch the simulator (It won't do anything, just render the scene) (It will also put a lot of errors in the terminal. Don't worry about it this is just a test)

roslaunch iarc7_simulator morse.launch

Miscellaneous other notes

SSH Authentication for GitHub

If you wish to use ssh keys instead of http authentication:

cd ~/iarc7
find . -path "./src/*/.git/config" | xargs -n 1 sed -i "s/https:\/\/github.com\//[email protected]:/"
sed -i "s/https:\/\/github.com\//[email protected]:/" ./src/.rosinstall

Updating on Changed Dependencies

When new packages are added to the rosinstall files in this repository, run the following to update:

cd ~/iarc7/iarc7_common && \
git pull && \
cd ~/iarc7 && \
wstool merge -t src iarc7_common/main.rosinstall && \
wstool update -t src

If you're using ssh authentication, run the snippet under SSH Authentication for GitHub again after running the above.

⚠️ **GitHub.com Fallback** ⚠️