Ubuntu 20.04安装ROS2
参考ROS2官方安装文档,安装ROS2。安装过程中会遇到如下问题
报错 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
- 解决方案:
-
使用工具,找到raw.githubusercontent.com对应的ip地址185.199.110.133
-
sudo vim /etc/hosts,在最后添加 185.199.110.133 raw.githubusercontent.com
127.0.0.1 localhost
127.0.1.1 dc-virtual-machine# The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 185.199.110.133 raw.githubusercontent.com
-
重新执行
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg -
如果还是不行,打开手机热点,pc连接手机热点之后重新执行。
-
报错 2
运行
rosdep update
时报错:
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: error loading sources list:
The read operation timed out
- 解决方案
-
sudo vim /etc/ros/rosdep/sources.list.d/20-default.list修改文件,添加https://ghproxy.com/前缀
# os-specific listings first
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx# generic yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml gbpdistro https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
-
重新执行
rosdep update -
如果还是不行,打开手机热点,pc连接手机热点之后重新执行。
-
也可以运行以下脚本,直到rosdep update运行成功。
#!/bin/bashfor (( ;; )) do rosdep update if(($? == 0)) then exit fi done
-
报错 3
运行
. ~/ros2_galactic/ros2-linux/setup.bash
时报错:
[connext_cmake_module] Warning: The location at which Connext was found when the workspace was built [[/opt/rti.com/rti_connext_dds-5.3.1]] does not point to a valid directory, and the NDDSHOME environment variable has not been set. Support for Connext will not be available.
- 解决方案:
- 安装RTI Connext
sudo apt install -q -y rti-connext-dds-5.3.1 - 导入设置文件设置 NDDSHOME 环境变量
cd /opt/rti.com/rti_connext_dds-5.3.1/resource/scripts && source ./rtisetenv_x64Linux3gcc5.4.0.bash; cd - - 重新执行
. ~/ros2_galactic/ros2-linux/setup.bash
- 安装RTI Connext