默认已经安装好ros2 humble
moveit安装
-
安装mixing
-
sudo apt install python3-colcon-common-extensions sudo apt install python3-colcon-mixin # 用gitee替换官网github colcon mixin add default https://gitee.com/zhenshenglee/colcon-mixin-repository/raw/master/index.yaml colcon mixin update default sudo apt install python3-vcstool
-
创建教程文件夹
mkdir -p ~/ws_moveit/src cd ~/ws_moveit/src git clone -b <branch> https://github.com/moveit/moveit2_tutorials
-
下载依赖文件(官方网方法需要访问github,需要使用镜像站地址)
-
修改链接
# 打开下载文件 vim moveit2_tutorials/moveit2_tutorials.repos # 全局替换 :%s/github.com/githubfast.com/g
-
下载
vcs import --recursive < moveit2_tutorials/moveit2_tutorials.repos
-
输出如下
rm@DC2:~/Documents/moveit_ws/src$ vcs import --recursive < moveit2_tutorials/moveit2_tutorials.repos ..... .E === ./launch_param_builder (git) === 正克隆到 '.'... === ./moveit2 (git) === 正克隆到 '.'... === ./moveit_resources (git) === 正克隆到 '.'... === ./moveit_task_constructor (git) === Could not init/update submodules: 子模组 'core/python/pybind11'(https://github.com/pybind/pybind11)已对路径 'core/python/pybind11' 注册 子模组 'core/src/scope_guard'(https://github.com/ricab/scope_guard)已对路径 'core/src/scope_guard' 注册 正克隆到 '/home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/python/pybind11'... fatal: 无法访问 'https://github.com/pybind/pybind11/':Failed to connect to github.com port 443 after 134720 ms: 连接超时 fatal: 无法克隆 'https://github.com/pybind/pybind11' 到子模组路径 '/home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/python/pybind11' 克隆 'core/python/pybind11' 失败。按计划重试 正克隆到 '/home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/src/scope_guard'... 正克隆到 '/home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/python/pybind11'... fatal: 无法访问 'https://github.com/pybind/pybind11/':Failed to connect to github.com port 443 after 133251 ms: 连接超时 fatal: 无法克隆 'https://github.com/pybind/pybind11' 到子模组路径 '/home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/python/pybind11' 第二次尝试克隆 'core/python/pybind11' 失败,退出 === ./moveit_visual_tools (git) === 正克隆到 '.'... === ./rosparam_shortcuts (git) === 正克隆到 '.'... === ./srdfdom (git) === 正克隆到 '.'...
-
下载未成功代码
# 修改后面的路径为自己的 git clone https://githubfast.com/pybind/pybind11 /home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/python/pybind11
-
再次运行
rm@DC2:~/Documents/moveit_ws/src$ vcs import --recursive < moveit2_tutorials/moveit2_tutorials.repos ....... === ./launch_param_builder (git) === 已经位于 'main' 您的分支与上游分支 'origin/main' 一致。 === ./moveit2 (git) === 已经位于 'humble' 您的分支与上游分支 'origin/humble' 一致。 === ./moveit_resources (git) === 已经位于 'humble' 您的分支与上游分支 'origin/humble' 一致。 === ./moveit_task_constructor (git) === 已经位于 'humble' M core/python/pybind11 M core/src/scope_guard 您的分支与上游分支 'origin/humble' 一致。 子模组路径 'core/python/pybind11':检出 'f4bc71f981d4eb2dd780215fd3c5a7420f1f03aa' === ./moveit_visual_tools (git) === 已经位于 'ros2' 您的分支与上游分支 'origin/ros2' 一致。 === ./rosparam_shortcuts (git) === 已经位于 'ros2' 您的分支与上游分支 'origin/ros2' 一致。 === ./srdfdom (git) === 已经位于 'ros2' 您的分支与上游分支 'origin/ros2' 一致。
-
-
卸载原moveit包
sudo apt remove ros-$ROS_DISTRO-moveit*
-
安装依赖
# 小鱼rosdepc sudo apt update && rosdepc install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y # 原rosdep sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y
-
编译源码
colcon build --mixin release --parallel-workers 4 # 如报错如下 /usr/bin/ld: /usr/local/lib/libfmt.a(format.cc.o): warning: relocation against stdout@@GLIBC_2.2.5' in read-only section .text' /usr/bin/ld: /usr/local/lib/libfmt.a(format.cc.o): relocation R_X86_64_PC32 against symbol stderr@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: 最后的链结失败: bad value # 重新编译fmt包并安装 cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON # 如报错如下 home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/src/task.cpp:49:10: fatal error: scope_guard/scope_guard.hpp: 没有那个文件或目录 49 | #include <scope_guard/scope_guard.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # 下载scope_guard.hpp cd home/rm/Documents/moveit_ws/src/moveit_task_constructor/core/src/scope_guard wget https://githubfast.com/ricab/scope_guard/blob/71a04528184db1749dd08ebbbf4daf3b5dca21fd/scope_guard.hpp
-
添加环境变量
source ./install/setup.bash echo 'source ~/Documents/moveit_ws/install/setup.bash' >> ~/.bashrc