一. 切换国内源
安装完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.py
、gbpdistro_support.py
、rep3.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