本文在 AlphaCatOvO【ROS】在 Ubuntu 20.04 安装 ROS 的详细教程 基础上,根据实际安装经验,稍微进行补充。
一、安装Ubuntu20.04
假设已经正确安装。
二、安装 ROS noetic
2.1 换源
执行
sudo apt update
sudo mv /etc/apt/sources.list /etc/apt/sources_default.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
执行
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
否则报错
E: Unable to locate package ros-noetic-desktop-full
执行
sudo apt update
1.2 下载
sudo apt install ros-noetic-desktop-full
按照 鱼香ROS 的教程
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update
执行
sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
1.3 编译与配置
执行
sudo rosdep init && rosdep update
如果报错 ERROR: default sources list file already exists: 执行
sudo mv /etc/ros/rosdep/sources.list.d/20-default.list /etc/ros/rosdep/sources.list.d/20-default-default.list
执行
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
1.4 测试
第一个窗口执行
roscore
第二个窗口执行
rosrun turtlesim turtlesim_node
第三个窗口运行
rosrun turtlesim turtle_teleop_key
就可以用键盘的按键控制小海龟前后左右了~
三、安装 MAVROS
仅针对要进行PX4开发的人员,其他不做飞控开发无需安装。
执行
sudo apt-get install ros-noetic-mavros ros-noetic-mavros-extras
sudo /opt/ros/noetic/lib/mavros/install_geographiclib_datasets.sh
——完——