前言
这两天换了台电脑装ROS2,按照官网的教程进行安装,发现到如下两步会出现问题,最后把解决的过程记录,便于自己理解
环境
Ubuntu 22.04
ROS2 humble(需要安装)
已经科学上网
流程
按照官网的步骤如下:
官网: https://docs.ros.org/en/humble/Installation/Ubuntu-Install-Debians.html#
Set locale
locale # check for UTF-8
sudo apt update && sudo apt install locales
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
locale # verify settings
Add the ROS2 apt repository
First ensure that the Ubuntu Universe repository is enabled.
sudo apt install software-properties-common
sudo add-apt-repository universe
Now add the ROS 2 GPG key with apt.
sudo apt update && sudo apt install curl
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
Then add the repository to your sources list.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
Install ROS2 bag
扫描二维码关注公众号,回复:
14656400 查看本文章
![](/qrcode.jpg)
sudo apt update
sudo apt upgrade
之后就可以使用sudo apt install
来下载需要的ROS2的包了
sudo apt install ros-humble-desktop
sudo apt install ros-humble-ros-base
sudo apt install ros-dev-tools
问题
在正常的安装流程的这一步sudo add-apt-repository universe
会出现以下问题
Adding component(s) 'universe' to all repositories.
Press [ENTER] to continue or Ctrl-c to cancel.
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:4 http://packages.ros.org/ros2/ubuntu jammy InRelease [4,673 B]
Err:4 http://packages.ros.org/ros2/ubuntu jammy InRelease
The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F42ED6FBAB17C654
Hit:5 http://archive.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done
W: GPG error: http://packages.ros.org/ros2/ubuntu jammy InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY F42ED6FBAB17C654
E: The repository 'http://packages.ros.org/ros2/ubuntu jammy InRelease' is not signed.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
使用搜到的增加PUBKEY的方法无法解决,并且如果在后面,需要增加ros的key时候,会出现连接拒绝的情况
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 after 3 ms: Connection refused
解决
sudo vim etc/hosts
- 添加一行:
185.199.108.133 raw.githubusercontent.com
:wq
保存退出