使用清华大学的镜像源来安装ROS 2
添加GPG密钥并配置APT源列表
-
添加GPG密钥:
sudo mkdir -p /etc/apt/keyrings curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key | sudo tee /etc/apt/keyrings/ros-archive-keyring.gpg > /dev/null
-
配置APT源列表: 编辑或者创建
/etc/apt/sources.list.d/ros2-latest.list
文件:echo "deb [signed-by=/etc/apt/keyrings/ros-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu/ jammy main" | sudo tee /etc/apt/sources.list.d/ros2-latest.list > /dev/null
-
更新APT缓存并安装ROS 2:
sudo apt update sudo apt install ros-humble-desktop
设置ROS 2环境
在安装完成后,设置ROS 2环境变量:
source /opt/ros/humble/setup.bash
测试安装
可以通过以下命令测试安装是否成功:
ros2 run demo_nodes_cpp talker
如果在更新或安装过程中遇到任何问题,请告诉我。