Ubuntu18.04-编译安装支持Python运动规划库OMPL

简介

最近需要使用到运动规划库,于是选择使用OMPL。主要原因基于两个点:一、这个库是ROS默认支持的库;二、虽然还有CHOMP和STOMP,对比三者OMPL具有更快更稳定的规划路径。可以参考这里看具体差异。下面介绍如何安装OMPL,这个库支持多个品台,Mac,Windows,Ubuntu等。
这个库安装太多坑了,文章最后可以留言获取我编译好的链接库,可以直接使用。需要的可以留言或者添加公众号(追逐雅克比)获取。

开始安装

1. 坑1 源码安装没有提及依赖项,安装文档相对简单,安装门槛较高。

这个库目前是我安装过最坑爹的库暂时没有之一,大家看看这个安装官方教程,那是相当简单,太有迷惑性了。只需要下载一个安装脚本即可,看着相当简单,其实等你真正安装哭死你。
在这里插入图片描述

2. 坑2 ubutun apt管理源没有支持app和Python binding

本以为可以直接使用apt安装,然后哪一行小小的字提醒你,如果你想用Python,那这是不行的。
在这里插入图片描述

第一步:去官网下载源码包:目前是1.4.2版本。

下载后看到的目录如下:
在这里插入图片描述

第二步:去官网拷贝安装脚本
第三步:开始安装----

如果你这就开始安装,恭喜你,你马上会遇到各种各样的错误。哪怕最后编译成功,也可以看到很多依赖库没有编译完成,尤其是python-bindings这个东东。

第四步:安装依赖
必须要安装依赖:PyQt5 OpenGL numpy pyplusplus pygccxml flask celery fcl libspot ccd boost eigen3 flann pkg-config
可选依赖:
 * pypy, <http://pypy.org>
   Used to speed up the generation of python bindings.
 * Triangle, <http://www.cs.cmu.edu/~quake/triangle.html>
   Used to create triangular decompositions of polygonal 2D environments.
 * MORSE, <https://www.openrobots.org/wiki/morse>
   OMPL includes a plugin for the MORSE Robot Simulation engine.
 * Drawstuff, <http://ode.org>
   Part of the ODE source distribution, used in one demo program.
 * PQP, <http://gamma.cs.unc.edu/SSV/>
   Used as an alternative, additional collision checking library (the default is FCL).
 * Doxygen, <http://doxygen.org>
   Used to create the OMPL documentation (i.e., http://ompl.kavrakilab.org).

上述依赖有的可以使用apt-get 安装,有的使用pip安装,有的安装完前一个,后面的即可自动安装:

  1. 安装libspot ,可以参考这里
    wget -q -O - https://www.lrde.epita.fr/repo/debian.gpg | sudo apt-key add - echo 'deb http://www.lrde.epita.fr/repo/debian/ stable/' >> /etc/apt/sources.list apt-get update apt-get install spot libspot-dev spot-doc python3-spot(这个库可以不装,我没安装也成功了,需要Python版本3.7以上) # Or a subset of those
    其他的都可以使用apt-get安装就不一一写在这里了
第五步:真正开始安装:

在那之前使用如下命令检查一下配置有没有遗漏:

cmake -DOMPL_BUILD_PYBINDINGS=ON . && make update_util_bindings VERBOSE=1

如果没有遗漏,在经过一波操作后会出现如下图所示:
在这里插入图片描述
然后接下来就是漫长的等待,官方告知安装这个库编译需要5-8个小时,可以出去浪一下,让你们感受一下绝望,连库自己都担心你等太久,把程序关了:
在这里插入图片描述

第六步:编译完毕后,检查这个路径下ompl-1.4.2-Source/build/Release/lib,是否有如下文件。

注意:两个红色箭头是后面使用python版本的关键。如果Python-bindings没有正确生成Python调用的依赖的话,你后面会出现两个致命错误,为了解决这两个错误,查看了各种论坛和文档,才解决,不容易啊。

第一个:
No module named _util
第二个:
No module named _base

在这里插入图片描述

第七步:由于需要直接使用我们还希望把动态链接库拷贝到方便调用的地方。我们运行make install。
第八步:去ompl-1.4.2-Source/build/Release/bin下面先测试是否C++ 版本的库已编译好。如下图我们选择demo_RigidBodyPlanning 进行测试:

在这里插入图片描述

第九步:出现已下结果证明已编译成功
OMPL version: 1.4.2
Info:    RRTConnect: Space information setup was not yet called. Calling now.
Debug:   RRTConnect: Planner range detected to be 1.006980
Settings for the state space 'SE3CompoundSpace0'
  - state validity check resolution: 1%
  - valid segment count factor: 1
  - state space:
Compound state space 'SE3CompoundSpace0' of dimension 6 (locked) [
Real vector state space 'RealVectorSpace1' of dimension 3 with bounds: 
  - min: -1 -1 -1 
  - max: 1 1 1 
 of weight 1
SO(3) state space 'SO3Space2' (represented using quaternions)
 of weight 1
]
Registered projections:
  - <default>
Projection of dimension 3
Cell sizes (computed defaults): [0.1 0.1 0.1]

Declared parameters:
longest_valid_segment_fraction = 0.01
projection.cellsize.0 = 0.1
projection.cellsize.1 = 0.1
projection.cellsize.2 = 0.1
projection.cellsize_factor = 0
valid_segment_count_factor = 1
Valid state sampler named uniform with parameters:
nr_attempts = 100
Start states:
Compound state [
RealVectorState [0.180145 -0.00048426 0.686778]
SO3State [0.706146 0.432641 -0.505694 -0.241771]
]
Goal state, threshold = 2.22045e-16, memory address = 0x55d917523fd0, state = 
Compound state [
RealVectorState [-0.564755 0.867481 0.0330055]
SO3State [0.364372 0.697109 -0.366705 0.496789]
]
OptimizationObjective = nullptr
There are 0 solutions
Info:    RRTConnect: Starting planning with 1 states already in datastructure
Info:    RRTConnect: Created 6 states (2 start + 4 goal)
Found solution:
Geometric path with 5 states
Compound state [
RealVectorState [0.180145 -0.00048426 0.686778]
SO3State [0.706146 0.432641 -0.505694 -0.241771]
]
Compound stadishibute [
RealVectorState [0.430851 0.370329 0.617361]
SO3State [0.434015 0.688351 -0.231927 -0.53293]
]
Compound state [
RealVectorState [0.287885 0.441718 0.533449]
SO3State [0.457808 0.747085 -0.274936 -0.395836]
]
Compound state [
RealVectorState [-0.138435 0.654599 0.283227]
SO3State [0.460797 0.809409 -0.359613 0.0565803]
]
Compound state [
RealVectorState [-0.564755 0.867481 0.0330055]
SO3State [0.364372 0.697109 -0.366705 0.496789]
]



Info:    No planner specified. Using default.
Info:    LBKPIECE1: Attempting to use default projection.
Debug:   LBKPIECE1: Planner range detected to be 1.006980
Properties of the state space 'SE3CompoundSpace3'
  - signature: 6 5 6 1 3 3 3 
  - dimension: 6
  - extent: 5.0349
  - sanity checks for state space passed
  - probability of valid states: 1
  - average length of a valid motion: 2.51125
  - average number of samples drawn per second: sampleUniform()=4.55243e+06 sampleUniformNear()=2.65e+06 sampleGaussian()=2.73573e+06
Settings for the state space 'SE3CompoundSpace3'
  - state validity check resolution: 1%
  - valid segment count factor: 1
  - state space:
Compound state space 'SE3CompoundSpace3' of dimension 6 (locked) [
Real vector state space 'RealVectorSpace4' of dimension 3 with bounds: 
  - min: -1 -1 -1 
  - max: 1 1 1 
 of weight 1
SO(3) state space 'SO3Space5' (represented using quaternions)
 of weight 1
]
Registered projections:
  - <default>
Projection of dimension 3
Cell sizes (computed defaults): [0.1 0.1 0.1]

Declared parameters:
longest_valid_segment_fraction = 0.01
projection.cellsize.0 = 0.1
projection.cellsize.1 = 0.1
projection.cellsize.2 = 0.1
projection.cellsize_factor = 0
valid_segment_count_factor = 1
Valid state sampler named uniform with parameters:
nr_attempts = 100
Planner LBKPIECE1 specs:
Multithreaded:                 No
Reports approximate solutions: No
Can optimize solutions:        No
Aware of the following parameters: border_fraction min_valid_path_fraction range
Declared parameters for planner LBKPIECE1:
border_fraction = 0.9
min_valid_path_fraction = 0.5
range = 1.00698
Start states:
Compound state [
RealVectorState [-0.0730456 -0.836679 0.0699345]
SO3State [0.473221 -0.507003 0.0264253 0.719939]
]
Goal state, threshold = 2.22045e-16, memory address = 0x55d917523fd0, state = 
Compound state [
RealVectorState [0.35548 -0.13107 -0.521166]
SO3State [-0.198537 -0.608689 0.0027985 0.768162]
]
OptimizationObjective = nullptr
There are 0 solutions
Info:    LBKPIECE1: Starting planning with 1 states already in datastructure
Info:    LBKPIECE1: Created 187 (93 start + 94 goal) states in 185 cells (92 start (92 on boundary) + 93 goal (93 on boundary))
Info:    Solution found in 0.000627 seconds
Found solution:
Info:    SimpleSetup: Path simplification took 0.002024 seconds and changed from 133 to 2 states
Geometric path with 2 states
Compound state [
RealVectorState [-0.0730456 -0.836679 0.0699345]
SO3State [0.473221 -0.507003 0.0264253 0.719939]
]
Compound state [
RealVectorState [0.35548 -0.13107 -0.521166]
SO3State [-0.198537 -0.608689 0.0027985 0.768162]
]


第十步:去路径:omplapp-1.4.2-Source/ompl-1.4.2-Source/demos下找到RigidBodyPlanning.py,使用如下命令进行测试:
 python RigidBodyPlanning.py
 出现以下证明安装成功:
 Info:    No planner specified. Using default.
Info:    LBKPIECE1: Attempting to use default projection.
Debug:   LBKPIECE1: Planner range detected to be 0.879845
Info:    LBKPIECE1: Starting planning with 1 states already in datastructure
Info:    LBKPIECE1: Created 35 (22 start + 13 goal) states in 32 cells (20 start (20 on boundary) + 12 goal (12 on boundary))
Info:    Solution found in 0.000430 seconds
Info:    SimpleSetup: Path simplification took 0.001344 seconds and changed from 13 to 2 states
Geometric path with 2 states
Compound state [
RealVectorState [0.5 0.521332]
SO2State [0.0343937]
]
Compound state [
RealVectorState [-0.5 0.00545857]
SO2State [-1.72727]
]



Info:    RRTConnect: Space information setup was not yet called. Calling now.
Debug:   RRTConnect: Planner range detected to be 0.879845
Settings for the state space 'SE2CompoundSpace3'
  - state validity check resolution: 1%
  - valid segment count factor: 1
  - state space:
Compound state space 'SE2CompoundSpace3' of dimension 3 (locked) [
Real vector state space 'RealVectorSpace4' of dimension 2 with bounds: 
  - min: -1 -1 
  - max: 1 1 
 of weight 1
SO2 state space 'SO2Space5'
 of weight 0.5
]
Registered projections:
  - <default>
Projection of dimension 2
Cell sizes (computed defaults): [0.1 0.1]

Declared parameters:
longest_valid_segment_fraction = 0.01
projection.cellsize.0 = 0.1
projection.cellsize.1 = 0.1
projection.cellsize_factor = 0
valid_segment_count_factor = 1
Valid state sampler named uniform with parameters:
nr_attempts = 100

Start states:
Compound state [
RealVectorState [-0.690274 0.216669]
SO2State [-1.3863]
]
Goal state, threshold = 2.22045e-16, memory address = 0x55981fa6d9c0, state = 
Compound state [
RealVectorState [-0.98753 -0.931353]
SO2State [-2.71132]
]
OptimizationObjective = nullptr
There are 0 solutions

Info:    RRTConnect: Starting planning with 1 states already in datastructure
Info:    RRTConnect: Created 6 states (2 start + 4 goal)
Found solution:
Geometric path with 5 states
Compound state [
RealVectorState [-0.690274 0.216669]
SO2State [-1.3863]
]
Compound state [
RealVectorState [-0.821073 0.0697578]
SO2State [-0.0200162]
]
Compound state [
RealVectorState [-0.863441 -0.185053]
SO2State [-0.705029]
]
Compound state [
RealVectorState [-0.925485 -0.558203]
SO2State [-1.70817]
]
Compound state [
RealVectorState [-0.98753 -0.931353]
SO2State [-2.71132]
]

  • 注意这里 有可能出现找不到解的情况,这是正常的,多尝试几次即可。

最后

由于有的小伙伴实在不想等那绝望的几个小时,又想直接使用Python版本的ompl可以私信或者留言找我获取编译好的安装包,只需要解压到Python依赖库即可。如果有什么问题也欢迎大家留言,我有时间看到会进行回复。

参考链接

[1] https://bitbucket.org/ompl/ompl/issues/488/no-module-named-_util
[2] https://www.twblogs.net/a/5b83659c2b71776c51e2d839
[3] https://spot.lrde.epita.fr/install.html
[4] http://ubuntuhandbook.org/index.php/2019/02/install-python-3-7-ubuntu-18-04/
[5] https://sourceforge.net/p/ompl/mailman/message/34837507/

  • 6
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 34
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值