1.1设置sources.list(官方源)
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
若下载速度缓慢,推荐就近选择一个镜像源替换上面的命令。
1.11USTC
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
1.12Tsinghua University
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
1.13Beijing Foreign Studies University
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.bfsu.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
1.14Shanghai Jiao Tong University
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.sjtug.sjtu.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
1.2设置密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
若无法连接到密钥服务器,可以尝试替换上面命令中的 hkp://keyserver.ubuntu.com:80 为 hkp://pgp.mit.edu:80 。
你也可以使用curl命令替换apt-key命令,这在使用代理服务器的情况下比较有用:
sudo apt install curl # if you haven't already installed curl
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
1.3安装
首先,确保你的 Debian 包索引是最新的:
sudo apt update
在 ROS 中有很多不同的库和工具。我们提供了四种默认选项供你开始。你也可以单独安装 ROS 的软件包。
Desktop-Full Install: (Recommended) 桌面完整版(推荐): : 包含 ROS、rqt、rviz、机器人通用库、2D/3D 模拟器、导航以及 2D/3D 感知包。
sudo apt install ros-melodic-desktop-full
Desktop Install: ROS,桌面版: 包含 ROS,rqt,rviz 和机器人通用库
sudo apt install ros-melodic-desktop
ROS-Base: (Bare Bones) ROS-基础包: 包含 ROS 包,构建和通信库。没有图形界面工具
sudo apt install ros-melodic-ros-base
1.4设置环境
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
If you have more than one ROS distribution installed, ~/.bashrc must only source the setup.bash for the version you are currently using.If you just want to change the environment of your current shell, instead of the above you can type:(如果你不只安装了一个 ROS 发行版, ~/.bashrc 只能使用你需要的 ROS 版本的 setup.bash 。
如果你只想设置当前 bash 会话的 ROS 环境变量,只需要输入)
source /opt/ros/melodic/setup.bash
If you use zsh instead of bash you need to run the following commands to set up your shell:(如果你使用 zsh,那么你需要将上述命令改为)
1.5初始化 rosdep
初始化rosdep在使用许多ROS工具之前,您需要初始化rosdepp。rosdep使您能够轻松地为想要编译的源代码安装系统依赖项,并且需要在ROS中运行一些核心组件。如果您还没有安装rosdepp,请按照以下步骤安装。
sudo apt install python-rosdep
初始化 rosdep
sudo rosdep init
rosdep update
1.6Dependencies for building packages构建工厂依赖
sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
如果在初始化时遇到报错可以参考链接
(122条消息) 乌班图18.04安装ros melodic 按照以及rosdep update 超时失败_东北大学生的博客-CSDN博客