Ubuntu20.04 源码安装 OMPL 与 Moveit

发布于:2024-08-14 ⋅ 阅读:(200) ⋅ 点赞:(0)


需求:

因为在命令行终端以binary安装的Moveit,规划算法都是封装好的,无法自定义算法,所以需要ompl源码安装,之后自定义ompl算法,再将ompl配置进Moveit,故moveit也需要源码安装。

之前已有 Ubuntu18.04 melodic 版本教程,现使用Ubuntu系统为 Ubuntu20.04 noetic,故针对此开篇新文档。

一、源码安装OMPL

1.1  先检查是否已安装二进制 ompl


//进入到如下目录下
cd /opt/ros/noetic/

// 查找
find ./ -name "libompl*"
find ./ -name "ompl*"

查询结果类似如下:

在这里插入图片描述
————————————————
 

1.2 若已经提前安装二进制,需先行卸载


// 执行卸载指令
sudo apt-get purge ros-noetic-ompl

在这里插入图片描述
————————————————
 

1.3 OMPL官网安装教程

官网教程链接在此!

在这里插入图片描述

  • 创建一个文件夹用来存放 ompl

mkdir ws_ompl
cd ws_ompl

  • 下载并安装脚本

把官方安装链接下载的 install-ompl-ubuntu.sh 脚本文件 【下载地址在此】存储在文件夹 ws_ompl 下,并执行如下指令:


// 给脚本文件赋予权限
chmod u+x install-ompl-ubuntu.sh

//执行安装
./install-ompl-ubuntu.sh

在这里插入图片描述

by_the_way:这个过程中,因为会下载源码,所以最好科学上网。有兴趣的小伙伴可以看看脚本内容,包括下载源码,安装依赖项,编译的过程。

————————————————

 
 

二、源码安装 moveit

安装部分可以直接参考 【官网教程】 或者 【博客链接
 

2.1 先检查是否已安装二进制Moveit


//可以尝试能否在任意终端下 正确打开moveit 助手界面
roslaunch moveit_setup_assistant setup_assistant.launch


// 可以通过指令的方式安装二进制moveit  【本教程不必执行此指令】
sudo apt-get install ros-noetic-moveit

若 已安装了二进制Moveit,需要提前卸载后安装源码Moveit,卸载方式如下:


sudo apt-get remove ros-melodic-moveit-*

————————————————
 

2.2 源码安装 Moveit

 

2.2.1、更新软件包


rosdep update
sudo apt-get update
sudo apt-get dist-upgrade

 

2.2.2、安装依赖


sudo apt install python3-wstool python3-catkin-tools python3-rosdep

 

2.2.3、创建Moveit工作空间


mkdir ~/ws_moveit
cd ~/ws_moveit

 

2.2.4、加载环境变量


source /opt/ros/noetic/setup.bash

 

2.2.5、下载moveit源码,先不急着编译【将ompl源码配置进moveit源码后统一编译】


wstool init src
wstool merge -t src https://raw.githubusercontent.com/ros-planning/moveit/master/moveit.rosinstall
wstool update -t src
rosdep install -y --from-paths src --ignore-src --rosdistro noetic
catkin config --extend /opt/ros/noetic --cmake-args -DCMAKE_BUILD_TYPE=Release
sudo catkin build       // 先别着急编译
    

可能的问题:在进行 wstool merge -t src https://raw.githubusercontent.com/ros-planning/moveit/master/moveit.rosinstall报错:


ERROR in config: Unable to download URL [https://raw.githubusercontent.com/ros-planning/moveit/master/moveit.rosinstall]: <urlopen error [Errno 110] Connection timed out>

类似解决方案
在操作 rosdep update 时报超时错误

出现 访问 https://raw.githubusercontent.com/ 超时 导致 总是更新不成功,提示错误
ERROR: error loading sources list: The read operation timed out


解决方法:
出现这类错误的问题可能是raw.githubusercontent.com网站被墙了;
一般这种情况,你可以打开百度,但是无法访问该网站;
所以只需要修改hosts文档,添加这个网站的IP地址。
#打开hosts文件
sudo vi /etc/hosts
#在最后面插入一句
199.232.28.133 raw.githubusercontent.com
#保存后退出,继续执行之前的指令rosdep update
————————————————
解决方案 解决:ERROR: error loading sources list: The read operation timed out

参考链接
 


// 执行此指令后,会在src路径下出现两个隐藏文件,
wstool merge -t src https://raw.githubusercontent.com/ros-planning/moveit/master/moveit.rosinstall 

// 可以通过crtl+h 使其可视化,并作出如下调整:

在这里插入图片描述

此处参考【 博文链接


// 执行此指令,依次下载上述功能包
wstool update -t src