ROS Melodic安装教程

在Ubuntu18.04上安装ROS Melodic

一、换源

换成国内源

二、安装Melodic

中科大源

  1. 配置ROS软件源()
sudo sh -c 'echo "deb https://mirrors.ustc.edu.cn/ros/ubuntu $(lsb_release -sc) 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
  1. 安装Melodic
sudo apt install ros-melodic-desktop-full
  1. 初始化rosdep
sudo rosdep init
rosdep update

若出现问题,则输入

sudo apt-get -y install python-rosdep

再重新初始化rosdep

若rosdep update超时,有两种方法,文章底部为第二种方法,这里是第一种方法

sudo gedit /etc/resolv.conf

注释掉原有的nameserver,添加

nameserver 8.8.4.4
nameserver 8.8.8.8
  1. 用户环境设置
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
  1. 安装包编译依赖
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
  1. 验证安装
rosversion -d

终端显示melodic即为安装成功

sudo apt-get update密钥报错

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

解决rosdep update慢的问题

把所有的h1c换成自己的用户名!

将rosdistro clone到/home

git clone git@gitee.com:c1h2/rosdistro.git
# 或使用以下两个任意一个:
# git clone https://github.com/ros/rosdistro.git
# git clone https://gitee.com/c1h2/rosdistro.git
cd /home/h1c/rosdistro/rosdep/sources.list.d/

20-default.list的所有内容替换为

# os-specific listings first
yaml file:///home/h1c/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///home/h1c/rosdistro/rosdep/base.yaml
yaml file:///home/h1c/rosdistro/rosdep/python.yaml
yaml file:///home/h1c/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/h1c/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

第二个文件

cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit gbpdistro_support.py
FUERTE_GBPDISTRO_URL = 'file:///home/h1c/rosdistro/' \
    'releases/fuerte.yaml'

第三个文件

cd /usr/lib/python2.7/dist-packages/rosdep2/
sudo gedit rep3.py
REP3_TARGETS_URL = 'file:///home/h1c/rosdistro/releases/targets.yaml'

第四个文件

cd /usr/lib/python2.7/dist-packages/rosdistro/
sudo gedit __init__.py
DEFAULT_INDEX_URL = 'file:///home/h1c/rosdistro/index-v4.yaml'
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list

将以下的内容复制进20-default.list中

#os-specific listings first
yaml file:///home/h1c/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///home/h1c/rosdistro/rosdep/base.yaml
yaml file:///home/h1c/rosdistro/rosdep/python.yaml
yaml file:///home/h1c/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/h1c/rosdistro/releases/fuerte.yaml fuerte

#newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

最后rosdep update


版权声明:本文为qq_35395195原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。