ROS学习03-NVIDIA JETSON TX2 - Ubuntu18.04安装ROS-melodic[规避踩坑]

ROS学习03-NVIDIA JETSON TX2 - Ubuntu18.04安装ROS-melodic[规避踩坑]

正式开始玩ROS了,我在子这里选择ROS的版本为melodic
ROS的官方安装网址在这
http://wiki.ros.org/cn/melodic/Installation/Ubuntu
由于官方的源太慢了,因此我这里选择换成清华的源安装

#添加 sources.list
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
#添加公钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

安装melodic

#桌面完整版:包含 ROS、rqt、rviz、机器人通用库、2D/3D 模拟器、导航以及 2D/3D 感知包
sudo apt install ros-melodic-desktop-full -y
#安装一些常用的工具
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential -y
sudo apt-get install python-rosdep

初始化 rosdep

rosdep update
rosdep init

如果出现以下错误
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
解决ca-certificates证书的问题

sudo apt-get install ca-certificates
sudo c_rehash /etc/ssl/certs 
sudo -E rosdep init
sudo mkdir -pv /etc/ros/rosdep/sources.list.d
sudo vim /etc/ros/rosdep/sources.list.d/20-default.list
#加入下面的内容
# os-specific listings first
yaml https://raw.github.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
yaml https://raw.github.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.github.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://raw.github.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

如果出现以下错误
assert ‘type’ in data, “Expected file type is ‘%s’” % DistributionFile._type
AssertionError: Expected file type is ‘distribution’
说明是host的问题

sudo vim /etc/hosts
#在最后一行加入
151.101.84.133  raw.githubusercontent.com

如果出现以下错误
ERROR: error loading sources list:
(‘The read operation timed out’,)
噗 你网太慢了 换个手机热点吧
要还不行的话,Emmm科学上网吧
或者更改 /usr/lib/python2.7/dist-packages/rosdep2/下的三个文件sources_list.py、gbpdistro_support.py、rep3.py
中的DOWNLOAD_TIMEOUT = 15.0值,改大一点就可以了改到30.0也行
利用vim的搜索功能输入:/DOWNLOAD_TIMEOUT搜索到这一行,修改过后输入:wq保存退出就行了

sudo vim /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/rep3.py

成功后会出现
ROS学习03-NVIDIA JETSON TX2 - Ubuntu18.04安装ROS-melodic[规避踩坑]_第1张图片
rosdep init要是还是有问题的话就别搞了,继续往下吧
虽然官网上说
在你使用 ROS 之前,需要初始化 rosdep。rosdep 让你能够轻松地安装被想要编译的源代码,或被某些 ROS 核心组件需要的系统依赖
但是一直不行也没办法 继续往下吧!(不知道是不是版本问题,可能没有rosdep init的步骤了PS:俺也是猜的)
将 ROS 加入环境变量

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

如果提示突然提示 程序“roscore”尚未安装
重新安装一次melodic,里面有些东西被前面安装的某些组件干掉了(我TM也是满头问号)

sudo apt install ros-melodic-desktop-full -y

终于有了
注意:上面的安装有的要sudo 有的不要sudo 千万不要sudo -s切成root用户图方便 要不会出大问题的
ROS学习03-NVIDIA JETSON TX2 - Ubuntu18.04安装ROS-melodic[规避踩坑]_第2张图片
参考链接:
https://www.jianshu.com/p/bdbfbac69114
https://blog.csdn.net/u013468614/article/details/102917569

你可能感兴趣的:(ROS,ROS,机器人,melodic,小车,melodic安装)