1. 更换清华源
输入下面的命令
sudo apt update# 将 sources.list 拷贝到桌面
cp /etc/apt/sources.list ~/Desktop # 打开 sources.list 进行编辑
sudo gedit /etc/apt/sources.list
打开文件后,将里面的所有内容替换为之前网页内文本框里的内容,例如
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
2. 添加安装ROS的软件源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
3.添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
4.更新软件源
sudo apt update
5. 安装ROS
sudo apt install ros-noetic-desktop-full
sudo apt install python3-pip
sudo pip3 install rosdepc
sudo rosdepc initrosdepc update
6. 设置环境变量
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrcsource ~/.bashrc
7. 安装rosinstall
sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool
8. 测试roscore
roscore
出现下面这样的就是正确的
打开第二个终端窗口,输入:
rosrun turtlesim turtlesim_node
小海龟测试成功
参考如下:
【ROS】在 Ubuntu 20.04 安装 ROS 的详细教程
ROS1 基础与常用命令