ubuntu18.04 OMPL安装教程
参考:
https://ompl.kavrakilab.org/installation.html
http://acg.cs.tau.ac.il/projects/ompl-instruction
https://github.com/ompl/ompl/issues/808
https://www.guyuehome.com/34317
https://ompl.kavrakilab.org/installation.html
别看网上一堆教程,照着教程做80%几率装不上
前往GitHub下载文件ompl
和omplapp
,本教程用的1.5.0版本。为什么要手动去下?因为有时候你用了科学上网在终端git的时候依然会出问题
安装依赖
castxml
sudo apt-get install castxml
livccd
git clone https://github.com/danfis/libccd.git
cd libccd
cmake .
make
sudo make install
fcl
git clone https://github.com/flexible-collision-library/fcl.git -b fcl-0.5
cd fcl
cmake .
sudo -E make install
python依赖
pip install PyQt5 numpy pyplusplus pygccxml flask celery PyOpenGL PyOpenGL-accelerate
ompl_webapp依赖
https://ompl.kavrakilab.org/webapp.html
sudo apt-get install rabbitmq-server
修改安装脚本文件
脚本文件ompl文件里有也可以去官网下载。需要注意脚本文件需要和前面下载的ompl
和omplapp
放在同一个目录
Download the OMPL installation script. First, make the script executable:
chmod u+x install-ompl-ubuntu.sh
Next, there are several ways to run this script:
-
./install-ompl-ubuntu.sh
will install the latest release of OMPL without Python bindings -
./install-ompl-ubuntu.sh --python
will install the latest release of OMPL with Python bindings -
./install-ompl-ubuntu.sh --app
will install the latest release of OMPL.app with Python bindings -
./install-ompl-ubuntu.sh --github
will install the master branch of OMPL (this can be combined with the other flags above)
我们需要修改
把 wget -O - https://github.com/ompl/${OMPL}/archive/1.5.0.tar.gz | tar zxf -改为 tar zxf ${OMPL}-1.5.0.tar.gz
把 wget -O - https://github.com/ompl/${OMPL}/releases/download/1.5.0/${OMPL}-1.5.0-Source.tar.gz | tar zxf -改为tar zxf $OMPL-1.5.0-Source.tar.gz
注释掉 #git clone --recurse-submodules https://github.com/ompl/${OMPL}.git
事实上你可以对着安装脚本内容,自己手动做完脚本里面容易出错的地方,然后把自己完成了的注释掉。比如下面的脚本我注释掉了不少我已经安装了的内容
#!/bin/bash
set -e
if [ `id -u` == 0 ]; then
SUDO=
export DEBIAN_FRONTEND=noninteractive
apt-get -y install lsb-release
else
SUDO="sudo -H"
fi
ubuntu_version=`lsb_release -rs | sed 's/\.//'`
install_common_dependencies()
{
# install most dependencies via apt-get
#${SUDO} apt-get -y update
#${SUDO} apt-get -y upgrade
# 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++`.
${SUDO} apt-get -y install g++ cmake pkg-config libboost-serialization-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev libboost-test-dev libeigen3-dev libode-dev wget libyaml-cpp-dev
export CXX=g++
export MAKEFLAGS="-j `nproc`"
}
install_python_binding_dependencies()
{
#${SUDO} apt-get -y install python${PYTHONV}-dev python${PYTHONV}-pip
# install additional python dependencies via pip
#${SUDO} pip${PYTHONV} install -vU https://github.com/CastXML/pygccxml/archive/develop.zip pyplusplus
# install castxml
if [[ $ubuntu_version > 1910 ]]; then
${SUDO} apt-get -y install castxml
else
wget -q -O- https://data.kitware.com/api/v1/file/5e8b740d2660cbefba944189/download | tar zxf - -C ${HOME}
export PATH=${HOME}/castxml/bin:${PATH}
fi
${SUDO} apt-get -y install libboost-python-dev
if [[ $ubuntu_version > 1710 ]]; then
${SUDO} apt-get -y install libboost-numpy-dev python${PYTHONV}-numpy
fi
if [[ $ubuntu_version > 1904 ]]; then
${SUDO} apt-get -y install pypy3
fi
}
install_app_dependencies()
{
${SUDO} apt-get -y install python${PYTHONV}-pyqt5.qtopengl freeglut3-dev libassimp-dev python${PYTHONV}-opengl python${PYTHONV}-flask python${PYTHONV}-celery libccd-dev
# install additional python dependencies via pip
#${SUDO} pip${PYTHONV} install -vU PyOpenGL-accelerate
# install fcl
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.6.1.tar.gz | tar zxf -
cd fcl-0.6.1; cmake .; ${SUDO} -E make install; cd ..
fi
fi
}
install_ompl()
{
if [ -z $APP ]; then
OMPL="ompl"
else
OMPL="omplapp"
fi
if [ -z $GITHUB ]; then
if [ -z $APP]; then
tar zxf ${OMPL}-1.5.0.tar.gz
cd ${OMPL}-1.5.0
else
tar zxf $OMPL-1.5.0-Source.tar.gz
cd $OMPL-1.5.0-Source
fi
else
${SUDO} apt-get -y install git
#git clone --recurse-submodules https://github.com/ompl/${OMPL}.git
cd $OMPL
fi
mkdir -p build/Release
cd build/Release
cmake ../.. -DPYTHON_EXEC=/home/kouguozhao/.conda/envs/ompl/bin/python
if [ ! -z $PYTHON ]; then
# Check if the total memory is less than 6GB.
if [ `cat /proc/meminfo | head -1 | awk '{print $2}'` -lt 6291456 ]; then
echo "Python binding generation is very memory intensive. At least 6GB of RAM is recommended."
echo "Proceeding with binding generation using 1 core..."
make -j 1 update_bindings
else
echo "123"
make update_bindings
fi
fi
make
${SUDO} make install
}
for i in "$@"
do
case $i in
-a|--app)
APP=1
PYTHON=1
shift
;;
-p|--python)
PYTHON=1
shift
;;
-g|--github)
GITHUB=1
shift
;;
*)
# unknown option -> show help
echo "Usage: `basename $0` [-p] [-a]"
echo " -p: enable Python bindings"
echo " -a: enable OMPL.app (implies '-p')"
echo " -g: install latest commit from master branch on GitHub"
;;
esac
done
# the default version of Python in 17.10 and above is version 3
if [[ $ubuntu_version > 1704 ]]; then
PYTHONV=3
fi
install_common_dependencies
if [ ! -z $PYTHON ]; then
install_python_binding_dependencies
fi
if [ ! -z $APP ]; then
install_app_dependencies
fi
install_ompl
特别注意一这一行
cmake ../.. -DPYTHON_EXEC=/home/kouguozhao/.conda/envs/ompl/bin/python
官方脚本-DPYTHON_EXEC
是设置的系统默认python路径,这里我改成了自己的,因为我用的anaconda管理python环境。
执行脚本
特别提醒:编译过程比较耗内存,请确保有足够内存,最好16g,并设置较大的swap空间,我的电脑16g的内存,中途因为爆内存编译失败
选择你需要的
-
./install-ompl-ubuntu.sh
will install the latest release of OMPL without Python bindings -
./install-ompl-ubuntu.sh --python
will install the latest release of OMPL with Python bindings -
./install-ompl-ubuntu.sh --app
will install the latest release of OMPL.app with Python bindings -
./install-ompl-ubuntu.sh --github
will install the master branch of OMPL (this can be combined with the other flags above)
测试安装结果
c++测试
运行ompl-1.5.0-Source/build/Release/bin
目录下的demo_RigidBodyPlanning
,如果正常打印结果则c++的库已经编好
python绑定测试
先确保omplapp-1.5.0-Source/build/Release/lib
目录下上面两个文件是否编译成功,否则python会出如下问题
No module named _util
No module named _base
运行omplapp-1.5.0-Source/demos/SE3RigidBodyPlanning
目录下的SE3RigidBodyPlanning.py
,如果正常打印结果则python绑定也弄好了
一些安装过程中的错误
werkzeug
If you want to use the benchmarking facilities of ompl_webapp,
run the "plannerarena" command as well.
Matplotlib or Numpy was not found; disabling plotting capabilities...
Matplotlib or Numpy was not found; disabling plotting capabilities...
Traceback (most recent call last):
File "./omplweb.py", line 47, in <module>
from werkzeug import secure_filename
修改:omplweb.py
第47行from werkzeug import secure_filename
from werkzeug.utils import secure_filename
# from werkzeug.datastructures import FileStorage