install-ompl-ubuntu.sh 4.84 KB
Newer Older
1 2
#!/bin/bash

3
ubuntu_version=`lsb_release -rs | sed 's/\.//'`
4 5 6 7 8 9 10

install_common_dependencies()
{
    # install most dependencies via apt-get
    sudo apt-get -y update
    sudo apt-get -y upgrade
    # On Ubuntu 14.04 we need to add a PPA to get a recent compiler (g++-4.8 is too old).
11 12 13 14 15 16
    # We also need to specify a Boost version, since the default Boost is too old.
    #
    # We explicitly set the C++ compiler to g++, the default GNU g++ compiler. This is
    # needed because we depend on system-installed libraries built with g++ and linked
    # against libstdc++. In case `c++` corresponds to `clang++`, code will not build, even
    # if we would pass the flag `-stdlib=libstdc++` to `clang++`.
17
    if [[ $ubuntu_version > 1410 ]]; then
18
        sudo apt-get -y install cmake pkg-config libboost-serialization-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev libboost-test-dev libeigen3-dev libode-dev
19
        export CXX=g++
20 21 22 23 24
    else
        # needed for the add-apt-repository command, which was not part of early Trusty releases
        sudo apt-get -y install software-properties-common
        sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
        sudo apt-get -y update
25
        sudo apt-get -y install g++-5 cmake pkg-config libboost-serialization1.55-dev libboost-filesystem1.55-dev libboost-system1.55-dev libboost-program-options1.55-dev libboost-test1.55-dev libeigen3-dev libode-dev
26 27 28 29 30 31 32
        export CXX=g++-5
    fi
    export MAKEFLAGS="-j `nproc`"
}

install_python_binding_dependencies()
{
33
    sudo apt-get -y install python${PYTHONV}-dev python${PYTHONV}-pip
34
    # install additional python dependencies via pip
35
    sudo -H pip${PYTHONV} install -vU pygccxml pyplusplus
36
    # install castxml
37 38 39 40 41 42
    if [[ $ubuntu_version < 1610 ]]; then
        wget -O - https://data.kitware.com/api/v1/file/57b5dea08d777f10f2696379/download | tar zxf - -C ${HOME}
        export PATH=$HOME/castxml/bin:$PATH
    else
        sudo apt-get -y install castxml
    fi
43
    if [[ $ubuntu_version > 1410 ]]; then
44
        sudo apt-get -y install libboost-python-dev
45 46 47
        if [[ $ubuntu_version > 1710 ]]; then
            sudo apt-get -y install libboost-numpy-dev python${PYTHONV}-numpy
        fi
48
    else
49
        sudo apt-get -y install libboost-python1.55-dev
50 51 52 53 54 55
    fi
}

install_app_dependencies()
{
    # We prefer PyQt5, but PyQt4 also still works.
56 57
    if [[ $ubuntu_version > 1410 ]]; then
        sudo apt-get -y install python${PYTHONV}-pyqt5.qtopengl
58 59 60
    else
        sudo apt-get -y install python-qt4-dev python-qt4-gl
    fi
61
    sudo apt-get -y install freeglut3-dev libassimp-dev python${PYTHONV}-opengl python${PYTHONV}-flask python${PYTHONV}-celery
62
    # install additional python dependencies via pip
63
    sudo -H pip${PYTHONV} install -vU PyOpenGL-accelerate
64
    # install libccd
65
    if [[ $ubuntu_version > 1410 ]]; then
66 67 68 69 70 71
        sudo apt-get -y install libccd-dev
    else
        wget -O - https://github.com/danfis/libccd/archive/v2.0.tar.gz | tar zxf -
        cd libccd-2.0; cmake .; sudo -E make install; cd ..
    fi
    # install fcl
72 73 74 75 76 77 78 79
    if ! pkg-config --atleast-version=0.5.0 fcl; then
        if [[ $ubuntu_version > 1604 ]]; then
            sudo apt-get -y install libfcl-dev
        else
            wget -O - https://github.com/flexible-collision-library/fcl/archive/0.5.0.tar.gz | tar zxf -
            cd fcl-0.5.0; cmake .; sudo -E make install; cd ..
        fi
    fi
80 81 82 83 84 85 86 87 88
}

install_ompl()
{
    if [ -z $2 ]; then
        OMPL="ompl"
    else
        OMPL="omplapp"
    fi
89 90
    wget -O - https://bitbucket.org/ompl/ompl/downloads/$OMPL-1.4.2-Source.tar.gz | tar zxf -
    cd $OMPL-1.4.2-Source
91 92
    mkdir -p build/Release
    cd build/Release
93
    cmake ../.. -DPYTHON_EXEC=/usr/bin/python${PYTHONV}
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
    if [ ! -z $1 ]; then
        make update_bindings
    fi
    make
    sudo make install
}

for i in "$@"
do
case $i in
    -a|--app)
        APP=1
        PYTHON=1
        shift
        ;;
    -p|--python)
        PYTHON=1
        shift
        ;;
    *)
        # unknown option -> show help
        echo "Usage: `basename $0` [-p] [-a]"
        echo "  -p: enable Python bindings"
        echo "  -a: enable OMPL.app (implies '-p')"
    ;;
esac
done

122

123 124 125 126 127 128 129 130 131 132 133
if [[ ! -z $PYTHON ]]; then
    if [[ $ubuntu_version < 1510 && `uname -m` == "i386" ]]; then
        echo "There is no pre-built binary of CastXML available for 32-bit Ubuntu 15.04 or older"
        echo "To generate the Python bindings, you first need to compile CastXML from source."
        echo "Alternatively, you could change your OS to either a newer version of Ubuntu or 64-bit Ubuntu."
        exit 1
    fi
    # the default version of Python in 17.10 and above is version 3
    if [[ $ubuntu_version > 1704 ]]; then
        PYTHONV=3
    fi
134 135
fi

136 137 138 139 140 141 142 143
install_common_dependencies
if [ ! -z $PYTHON ]; then
    install_python_binding_dependencies
fi
if [ ! -z $APP ]; then
    install_app_dependencies
fi
install_ompl $PYTHON $APP