Ubuntu22.04基于ROS2-Humble安装moveit2教程(亲测)

一、安装ROS2-Humble

1、参考:Ubuntu22.04安装ROS2-humble-CSDN博客

2、确保安装完成

source /opt/ros/humble/setup.bash

方法一:二进制安装

sudo apt install ros-humble-moveit*

方法二:安装源码编译

一、卸载二进制安装包

sudo apt autoremove ros-humble-moveit*

二、安装moveit2_tutorials及其相关的安装包

1、创建文件夹

mkdir -p ~/ws_moveit/src
cd ~/ws_moveit2/src

2、下载moveit2_tutorials(humble版本)

git clone https://github.com/ros-planning/moveit2_tutorials -b humble
若git clone拉取失败,可进入https://github.com/ros-planning/moveit2_tutorials下载
免费的github加速器下载:Ubuntu安装Watt Toolkit加速器-CSDN博客
:下载后解压到src目录,且命名为moveit2_tutorials,防止其他错误

3、下载vcstool——该工具可以自动读取repo文件并克隆其中的代码。

sudo apt install python3-vcstool

4、进入src目录,下载其他包

vcs import < moveit2_tutorials/moveit2_tutorials.repos
若拉取失败,同上,进入github下载对应包,进行手动解压
进入moveit2_tutorials目录可看到moveit2_tutorials.repos文件
依次复制链接进入下载,一定要核对版本是否正确后再下载,不然后续步骤可能出错
比如以下方式进行选择版本 

博主帮你们整理了相关的链接以及版本
launch_param_builder:

    https://github.com/PickNikRobotics/launch_param_builder
    #版本: main
moveit2:

    https://github.com/ros-planning/moveit2
    #版本: humble
moveit_resources:

    https://github.com/ros-planning/moveit_resources
    #版本: humble
moveit_task_constructor:

    https://github.com/ros-planning/moveit_task_constructor
    #版本: humble
moveit_visual_tools:

    https://github.com/ros-planning/moveit_visual_tools
    #版本: ros2
rosparam_shortcuts:

    https://github.com/PickNikRobotics/rosparam_shortcuts
    #版本: ros2
srdfdom:

    https://github.com/ros-planning/srdfdom
    #版本: ros2

三、安装依赖

1、安装rosdep

sudo apt install python3-rosdep
sudo rosdep init
rosdep update
sudo apt update
sudo apt dist-upgrade
如果发生报错,安装rosdepc (也可参考小鱼的一键安装)
sudo apt-get install python3-pip
sudo pip3 install rosdepc

2、安装依赖

cd ws_moveit/
rosdep install --from-path src --ignore-src -r -y  #若安装的是rosdep
rosdepc install --from-path src --ignore-src -r -y  #若安装的是rosdepc

四、编译源码

cd ws_moveit/
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
echo 'source ~/ws_moveit/install/setup.bash' >> ~/.bashrc#每次打开自动source

五、个人编译过程中出现的报错以及解决方法

1、主要是moveit_task_constructor编译过程中的报错

(还有些错误忘记了,所以没有记录,如果有新错误的小伙伴可在评论区进行反馈,也算帮助博主完善了)
(1)找不到pybind这个包,进入提示目录进行查看,发现目录为空,我们手动去下载压缩包
下载地址
(2)将安装包放入~/ws_moveit2/src/moveit_task_constructor/core/python/pybind文件夹
重新编译,发现找不到smart_holder头文件,进入提示目录查看,确实是空的,手动下载:下载地址
解压过后,放入~/ws_moveit2/src/moveit_task_constructor/core/python/src文件夹,该替换的选择替换,该合并的选择合并就行了
:大部分错误都是安装包版本的问题,一定要看仔细了再下载!!!

2、编译卡死问题

博主已经总结过了,点击链接参考
关于colcon编译卡死的解决办法-CSDN博客
有新问题记得评论区及时反馈哦!