2022-04-05-tips_ros
  1. Ubuntu换源(通过软件和更新换源更简单)
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
  1. 添加ROS软件源

    sudo sh -c '. /etc/lsb-release && echo "deb https://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" >> /etc/apt/sources.list.d/ros-latest.list'
    
  1. 添加密钥

    sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
    
  1. 更新软件源

    sudo apt update//相比于apt-get而言,apt是更新、更为推崇的命令,尽量用这个
    
  1. 安装ROS
sudo apt install ros-melodic-desktop-full
  1. 初始化rosdepc
sudo apt install python3-pip
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update
  1. 添加环境变量

    echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
    source ~/.bashrc
    
  1. 安装rosinstall

    sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
    rosinstall也是ROS中的一个常用工具,可以下载和安装ROS中的功能包程序。
    
  1. 验证

    roscore
    rosrun turtlesim turtlesim_node
    rosrun turtlesim turtle_teleop_key