在 Ubuntu20 上安装 omplapp

# 安装 omplapp 在 Ubuntu20 上

下载时可以使用脚本,但需要将脚本下载 ompl 部分注释掉(建议只用脚本安装依赖),因为其下载的 release 中代码有错误
参见: https://blog.csdn.net/qq_38606680/article/details/129028660
 

在 Ubuntu20 中执行原始脚本安装的 pygccxml 版本为 2.2.0 并不适合默认 python 版本3.8,需要指定版本为 2.1.0

pip${PYTHONV} install pygccxml==2.1.0 pyplusplus


将下载的 ompl -1aed8改名为 ompl 放入 omplapp
在 omplapp 文件夹下运行
Mkdir -p build/Release
Cd build/Release
Cmake ../..
# Next step is optional
Make -j 4 update_bindings # if you want to use the GUI or Python bindings
Make -j 4 # replace "4" with the number of cores on your machine

最后 sudo make install 即可安装成功,成功import

附上我的安装脚本

#!/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 pygccxml==2.1.0 pyplusplus

    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

            # wget -O - https://github.com/ompl/${OMPL}/archive/1.6.0.tar.gz | tar zxf -

            cd ${OMPL}-1.6.0

        else

            # wget -O - https://github.com/ompl/${OMPL}/releases/download/1.6.0/${OMPL}-1.6.0-Source.tar.gz | tar zxf -

            cd $OMPL-1.6.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 -j 2 ../.. -DPYTHON_EXEC=/usr/bin/python${PYTHONV}

    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

            make -j 2 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 main 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


将 omplapp 可以在虚拟环境运行

另外,上述安装过程在本机环境进行,如果想安装在conda的虚拟环境,只需在本机上安装完成之后,将py-bindings/ompl文件放置到对应虚拟环境下的lib/pythonx.x/site-packages下即可。

希望我的文章能帮助到你。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值