ROS Melodic安装教程

本文详细介绍了如何在Ubuntu18.04系统上安装ROSMelodic版本,包括更换国内源、配置软件源、安装ROS桌面完整版、设置用户环境、安装编译依赖等步骤,并提供了遇到常见问题时的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MAVER1CK

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值