ROS 在 Ubuntu 18.04 安装

配置 Ubuntu 存储库

Ubuntu 存储库配置为允许"restricted"、"universe"和"multiverse"

   

设置源列表

将计算机设置为接受packages.ros.org的软件。

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

   

设置密钥

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

   

安装

首先,请确保您的 Debian 包索引是最新的:

sudo apt update

   

ROS 中有很多不同的库和工具。我们提供了四个默认配置来帮助您入门。您还可以单独安装 ROS 包。

桌面全安装:(推荐): ROS rqt rviz,机器人通用库, 2D/3D 模拟器和 2D/3D 感知

sudo apt install ros-melodic-desktop-full

桌面安装:ROSrqtrviz和机器人通用库

sudo apt install ros-melodic-desktop

   

ROS-Base (裸骨)ROS 包、生成和通信库。无 GUI 工具。

sudo apt install ros-melodic-ros-base

   

单个包:您还可以安装特定的 ROS 包(用包名称的破折号替换下划线):

sudo apt install ros-melodic-PACKAGE

例如。

sudo apt install ros-melodic-slam-gmapping

   

要查找可用包,请使用:

apt search ros-melodic

   

   

环境设置

如果每次启动新 shell 时都会自动将 ROS 环境变量添加到 bash 会话中,则这样做很方便:

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc

source ~/.bashrc

如果安装了多个 ROS 分发,则*/.bashrc必须只为当前使用的版本提供setup.bash。

如果只想更改当前 shell 的环境,可以键入:

source /opt/ros/melodic/setup.bash

   

生成包的依赖项

到目前为止,您已经安装了运行核心 ROS 包所需的内容。要创建和管理自己的 ROS 工作区,可以单独分发各种工具和要求。例如,rosinstall是一个常用的命令行工具,使您能够使用一个命令轻松下载许多 ROS 包的源树。

要安装此工具和其他用于构建 ROS 包的依赖项,请运行:

sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential

   

初始化 rosdep

在可以使用许多 ROS 工具之前,您需要初始化rosdep。rosdep 使您能够轻松为要编译的源安装系统依赖项,并且需要在 ROS 中运行某些核心组件。如果您尚未安装 rosdep,请按照以下方式操作。

sudo apt install python-rosdep

   

使用以下功能,您可以初始化 rosdep。

   

sudo rosdep init

rosdep update

   

Q&A:

错误描述:

ming@ming:~$ rosdep update

reading in sources list data from /etc/ros/rosdep/sources.list.d

ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:

    <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)

ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:

    <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)

ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:

    <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)

ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml]:

    <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml)

Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml

Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml

Add distro "ardent"

ERROR: error loading sources list:

    <urlopen error <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/ardent/distribution.yaml)>

   

   

解决方法:

sudo gedit /etc/resolv.conf

将原有的nameserver这一行注释,并添加以下两行:

nameserver 8.8.8.8

nameserver 8.8.4.4

   

保存退出,执行

sudo  apt-get update

rosdep update

   

原文地址:https://www.cnblogs.com/li3807/p/13033978.html