Ubuntu18.04 安装ros-melodic

本文详细介绍了在Ubuntu18.04环境下,通过阿里云源快速安装ROS Melodic的全过程,包括软件源切换、配置密钥、系统软件源更新、安装ROS桌面完整版、环境设置、依赖编译及安装验证等关键步骤。

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

一. 切换国内源

安装完Ubuntu18.04之后,为安装软件快捷方便,推荐将软件源更新为国内稳定机构,这里使用的是阿里云。

二. 安装Melodic

1. 安装说明

如果安装过程中出现网络相关的问题,建议更换有线网络或者热点,然后重新执行出错指令。

2. 配置ROS软件源

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

3. 配置密钥

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

4. 更新系统软件源

sudo apt update

5. 安装Melodic

sudo apt install ros-melodic-desktop-full

6. 初始化rosdep

sudo rosdep init
rosdep update

如果出现sudo rosdep init ERROR: cannot download default sources list from:【closed】

     #打开hosts文件
     sudo gedit /etc/hosts
     #在文件末尾添加
     151.101.84.133  raw.githubusercontent.com
     #保存后退出再尝试

然后保存退出再次sudo rosdep init如果还是不行登陆IPAdress网站The Best IP Address, Email and Networking Tools - IPAddress.com,输入raw.githubusercontent.com查询到真实IP地址:

将查询到的IP替换上面代码的 151.101.84.133然后再次sudo rosdep init一般就会成功了

直接在sources.list.d中直接添加https://ghproxy.com/前缀

sudo vim /etc/ros/rosdep/sources.list.d/20-default.list

# os-specific listings first
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
 
# generic
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
 
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead


————————————————
版权声明:本文为CSDN博主「Iamsonice」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/Iamsonice/article/details/116018915

如果出现超时错误ERROR: error loading sources list: ('The read operation timed out',),切换4G网络,如果还超时修改超时时间:更改 /usr/lib/python2.7/dist-packages/rosdep2/下的三个文件sources_list.pygbpdistro_support.pyrep3.py中的DOWNLOAD_TIMEOUT = 15.0值,改大一点就可以了。


7. 用户环境设置

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

8. 安装包编译依赖

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

9. 验证安装

rosversion -d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值