一、安装Ubuntu系统
参考Ubuntu20.04安装详细图文教程(双系统),很好装
二、安装Chrome和vpn
Chrome到官网下载安装:谷歌中文网站。vpn安装不再多说。
三、安装ROS2-foxy
不用修改ubuntu的源(source.list),直接开vpn,连个网速快点的网,按照ros2官方安装教程安装即可。
3.1 ROS2安装过程中遇到的问题与解决方法
1、执行 sudo apt update 指令时,报类似 File has unexpected size xxxx, Mirror sync in progress? 的错误,参考这个链接进行解决
解决方法:不用学校的有线校园网,更换为手机网络即可解决
2、执行 sudo apt install ros-foxy-desktop 指令时,报类似Connection failed , Failed to fetch xxxx 错误。
解决方法:将pc机网络更换为手机热点或其他wifi,重新执行sudo apt install ros-foxy-desktop指令,它会接着出错前继续下载
3、执行 sudo apt install ros-foxy-desktop 指令时,进度到100%时,更换pc机网络,依然报下面这个错误:
Err:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 freeglut3 amd64 2.8.1-3 Connection failed [IP: 2620:2d:4000:1::19 80] E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/freeglut/freeglut3_2.8.1-3_amd64.deb Connection failed [IP: 2620:2d:4000:1::19 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
解决方法:google中输入报错的这个链接,手动下载此deb文件:http://archive.ubuntu.com/ubuntu/pool/universe/f/freeglut/freeglut3_2.8.1-3_amd64.deb
然后 sudo dpkg -i freeglut3_2.8.1-3_amd64.deb ,手动安装此文件。之后重新执行 sudo apt install ros-foxy-desktop 即可
四、安装moveit2
打开vpn,直接按照moveit2官方安装教程安装就可以
4.1 moveit2安装过程中遇到的问题与解决方法
1、执行完 sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y 指令后报类似下面这种错误:
ERROR: the following rosdeps failed to install apt: command [sudo -H apt-get install -y ros-foxy-moveit-core] failed apt: command [sudo -H apt-get install -y ros-foxy-moveit-ros-planning] failed apt: command [sudo -H apt-get install -y ros-foxy-moveit-ros-perception] failed apt: command [sudo -H apt-get install -y ros-foxy-moveit-ros-planning-interface] failed
解决方法:
往前翻,找到所有类似这种错误的链接:
Err:1 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcl0.5 amd64 0.5.0-5build1 Connection failed [IP: 91.189.91.38 80] Err:2 http://archive.ubuntu.com/ubuntu focal/universe amd64 libfcl-dev amd64 0.5.0-5build1 Connection failed [IP: 185.125.190.39 80] E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcl/libfcl0.5_0.5.0-5build1_amd64.deb Connection failed [IP: 91.189.91.38 80] E: Failed to fetch http://archive.ubuntu.com/ubuntu/pool/universe/f/fcl/libfcl-dev_0.5.0-5build1_amd64.deb Connection failed [IP: 185.125.190.39 80] E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
像装ros2时遇到这种错误一样,手动下载所有connection failed的deb文件,手动安装,之后再执行sudo apt update && rosdep install -r --from-paths . --ignore-src --rosdistro $ROS_DISTRO -y ,最终成功安装安装 MoveIt 的所有依赖项后,会输出
#All required rosdeps installed successfully
注:手动安装deb时如果报类似下面这种错误
dpkg: error processing package libfcl0.5 (--install): dependency problems - leaving unconfigured Processing triggers for libc-bin (2.31-0ubuntu9.9) ... Errors were encountered while processing: libfcl0.5
则执行一下sudo apt-get install -f 指令,自动安装下缺少的依赖,再手动安装deb文件即可
安装完moveit2后,可以用官方实例测试一下
五、安装ROS1-Noetic
打开vpn,连一个好一点的网络,用Ubuntu20.04自带的源,完全按照ros1官方教程一步步安装即可。过程中有任何报错,参考ros2的问题记录就可以解决
六、安装与验证ros1-bridge,配置ros1和ros2
6.1 安装ros1-bridge
参考此教程,只需下面这两条指令:
sudo apt update
sudo apt install ros-foxy-ros1-bridge
6.2 配置ros1和ros2
参考古月教程和此教程,打开/home目录下的.bashrc文本文件后,在末尾加上如下代码,完成环境变量设置。
#personal new add
echo -n "Input 1、2 or 3,respectively represent source ros1 | ros2+moveit2 | ros1+ros2+moveit2 >>"
read character
if [ "$character" = "1" ]; then
source /opt/ros/noetic/setup.bash
echo [INFO] source ros1 finished
elif [ "$character" = "2" ]; then
source /opt/ros/foxy/setup.bash
source ~/ymm/ros2_pkg/ws_moveit2/install/setup.bash
echo [INFO] source ros2、moveit2 finished
elif [ "$character" = "3" ]; then
source /opt/ros/noetic/setup.bash
source /opt/ros/foxy/setup.bash
source ~/ymm/ros2_pkg/ws_moveit2/install/setup.bash
echo [INFO] source ros2、moveit2 finished
else
echo [INFO] Not source ros1 or ros2
fi
6.3 验证ros1-bridge
按照此教程,开四个终端,source不同的ros,验证即可
七、卸载除ROS1-Noetic之外的所有包
由于需要moveit2中的moveit_hybrid_planning包,所以ros2需要装Galactic版本,moveit2对应更换,ros1_bridge也需要对应更换。
参考此教程,ros2-foxy、ros1_bridge和ros2-foxy-moveit,只需一条指令即可卸载:
sudo apt remove ros-foxy-* && sudo apt autoremove
八、安装ROS-Galactic
进入/etc/apt/sources.list.d文件夹,删除所有ros2开头的文件,然后参考官方教程安装就可
8.1 遇到的问题与解决方法
1、问题:执行指令sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg时, 报错:curl: (7) Failed to connect to raw.githubusercontent.com port 443: Connection refused
解决方法:参考此教程,发现文件已存在,所以不用理会此错误
九、安装ROS-Galactic-moveit2
按照官方教程一步步安装即可
根据官方教程,运行如下指令,检查 moveit_hybrid_planning 包是否能正常使用:
ros2 launch moveit_hybrid_planning hybrid_planning_demo.launch.py
十、安装与验证ros1-bridge,配置ros1和ros2
参考第六节,只需将所有foxy对应换为galactic即可