版本
系统版本:ubuntu22.04
ROS2版本:humble
Moveit版本:moveit2-humble
安装 ROS 2 和 Colcon
如果您在接下来的几个步骤中遇到错误,一个好的开始是返回并确保您已正确安装 ROS 2。用户通常忘记的一个是获取 ROS 2 安装本身。
source /opt/ros/humble/setup.bash
安装rosdep以安装系统依赖项:
sudo apt install python3-rosdep
安装 ROS 2 后,请确保您拥有最新的软件包:
sudo rosdep init
rosdep update
sudo apt update
sudo apt dist-upgrade
这里如果出错,把rosdep换成rosdepc
sudo apt-get install python3-pip
sudo pip3 install rosdepc
使用mixin安装Colcon ROS 2 构建系统:
sudo apt install python3-colcon-common-extensions
sudo apt install python3-colcon-mixin
colcon mixin add default https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
colcon mixin update default
如果报错:Connection refused> (https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml)>
https://www.guyuehome.com/37844
如果还是不行,就换成gitee的链接:
colcon mixin add default2 https://gitee.com/zhenshenglee/colcon-mixin-repository/raw/master/index.yaml
colcon mixin update default2
https://blog.csdn.net/weixin_41131063/article/details/123171717
安装vcstool:
sudo apt install python3-vcstool
创建 Colcon 工作区并下载教程
对于教程,您需要有一个colcon工作区设置。
mkdir -p ~/ws_moveit2/src
进入您的 Colcon 工作区并拉取 MoveIt 教程源:
cd ~/ws_moveit2/src
sudo apt install git
git clone https://github.com/ros-planning/moveit2_tutorials -b humble --depth 1
接下来我们将下载 MoveIt 其余部分的源代码:
vcs import < moveit2_tutorials/moveit2_tutorials.repos
这里如果出错是网络问题,github DDS受到污染。
打开/home/**/ws_moveit2/src/moveit2_tutorials.repos
repositories:
launch_param_builder:
type: git
url: https://github.com/PickNikRobotics/launch_param_builder
version: main
moveit2:
type: git
url: https://github.com/ros-planning/moveit2
version: humble
moveit_resources:
type: git
url: https://github.com/ros-planning/moveit_resources
version: ros2
moveit_task_constructor:
type: git
url: https://github.com/ros-planning/moveit_task_constructor.git
version: ros2
moveit_visual_tools:
type: git
url: https://github.com/ros-planning/moveit_visual_tools
version: ros2
rosparam_shortcuts:
type: git
url: https://github.com/PickNikRobotics/rosparam_shortcuts
version: ros2
srdfdom:
type: git
url: https://github.com/ros-planning/srdfdom.git
version: ros2
在src目录下分别用git clone ***下载到7个文件夹内。可以尝试在网址前面加上:https://ghproxy.com/ ,后面加 -ros2/-humble。
(实践发现:如果有-humble分支最好用这个,没有的话用ros2)
git clone https://ghproxy.com/https://github.com/PickNikRobotics/launch_param_builder -b main
git clone https://ghproxy.com/https://github.com/ros-planning/moveit2 -b humble
git clone https://ghproxy.com/https://github.com/ros-planning/moveit_resources -b humble
git clone https://ghproxy.com/https://github.com/ros-planning/moveit_task_constructor.git -b humble
git clone https://ghproxy.com/https://github.com/ros-planning/moveit_visual_tools -b ros2
git clone https://ghproxy.com/https://github.com/PickNikRobotics/rosparam_shortcuts -b ros2
git clone https://ghproxy.com/https://github.com/ros-planning/srdfdom.git -b ros2
构建Colcon 工作区
以下将从 Debian 安装任何不在您的工作区中的软件包依赖项。这是将安装 MoveIt 及其所有依赖项的步骤:
sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y
下一个命令将配置您的 Colcon 工作区:
cd ~/ws_moveit2
colcon build --mixin release
此构建命令可能需要很长时间(20 分钟以上),具体取决于您的计算机速度和可用 RAM 量(我们建议 32 GB)。如果您的计算机内存不足,或者您的构建通常很难在您的计算机上完成,您可以将参数附加到上面的 colcon 命令。–parallel-workers 1
如果 mixin 报错了,可以换一种编译方式:
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
这一步出错:ERROR:colcon:colcon build: Duplicate package names not supported。因为重名了,删掉一个。
https://www.guyuehome.com/bubble/detail/id/66980
https://blog.csdn.net/shanpenghui/article/details/89210049
因为你在没有删除vcstool import的情况下重复import了一次,解决方法:把src文件夹里面你从ros2的github下载的东西都删除,再做一次。 无效。是因为重名了,删掉一个。
这里在用树莓派4B(4G)编译时,会卡死。需要增加swap交换空间。期间会在编译过程中自动退出,需要多编译几次。
树莓派编译工作空间卡死
我把交换空间设置为8G,还是会卡死或崩溃,发现swap并没有充分利用,而是自带内存满了导致的(和CPU关系不太大)。
尝试使用如下命令编译:
colcon build --mixin release --executor sequential
https://answers.ros.org/question/368249/colcon-build-number-of-threads/
https://answers.ros.org/question/407554/colcon-build-freeze-a-raspberry-pi/
崩溃时,尝试卸载占用RAM较大的桌面,完成后再安装。
sudo apt autoremove ubuntu-desktop
sudo apt install ubuntu-desktop
树莓派4B尝试数次后,才编译成功(以后考虑电脑编译完再拷过去,但没有试)。
设置Colcon 工作区
来源 Colcon 工作区:
source ~/ws_moveit2/install/setup.bash
可选:将上一个命令添加到您的.bashrc:
echo 'source ~/ws_moveit2/install/setup.bash' >> ~/.bashrc
运行样例程序
ros2 launch moveit2_tutorials demo.launch.py rviz_tutorial:=true
添加MotionPlanning后可看到机械臂。
故障问题解决
- struct planning_interface::motionplanresponse has no member named trajectorystruct lanning_interface::motionplanresponse has no member named trajectory
在src删除出错模块,重新下载。
git clone https://ghproxy.com/https://github.com/ros-planning/moveit_task_constructor.git -b ros2
替换为
git clone https://ghproxy.com/https://github.com/ros-planning/moveit_task_constructor.git -b humble
- spawner-6 process has finished cleanly
在Install/moveit2_tutorials/share找到demo.launch.py,nodes_to_starts添加:rviz_node_turorial
https://github.com/ros-planning/moveit2_tutorials/issues/586
参考
https://moveit.picknik.ai/humble/doc/tutorials/getting_started/getting_started.html
https://blog.csdn.net/qq_43557907/article/details/125636298