Jetson-nano-Ubuntu18.04-安装ROS

说明

文章内容是参考多篇帖子,多种方法来解决rosdep init/updata等错误,最终在JetsonNano上安装了ROS,也适用所有ubuntu18.04系统

安装过程记录

(一)添加ROS源

这里介绍两种源,一种是官方源,第二种是国内源。
我个人建议国内源,首先部分国内源现在也支持arm了,国内源下载速度更快。本人采用的是中科大的源,下载非常顺利。
官方源:

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

国内源:

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

(二)添加密钥

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

(三)安装

首先,更新一下包列表

sudo apt update
然后就可以安装ROS了,你可以根据自己的需求安装不同的版本。如果存储空间大的话,建议安装第一个。
完整桌面版安装:ROS, rqt, rviz, robot-generic libraries, 2D/3D simulators and 2D/3D perception

sudo apt install ros-melodic-desktop-full

桌面版安装:ROS, rqt, rviz, and robot-generic libraries

(四)环境设置

直接将以下代码复制输入即可

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

(五)安装一些依赖包

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

(六)初始化rosdep

sudo rosdep init
rosdep update

(1)sudo rosdep init报错

sudo 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.

解决办法:

	在/etc目录下新建/ros/rosdep/sources.list.d/20-default.list文件(注意sudo rosdep init失败时,/etc下并没有/ros目录,  
	需要依次逐级新建),然后将https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list内容粘贴进去,  
	内容如下:
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

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

===》在这样创建完文件后,就不需要再执行sudo rosdep init了,直接执行下一个指令

sudo rosdep update

(2)sudo rosdep update报错

rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml]:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml)
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
	Failed to download target platform data for gbpdistro:
	<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
	<urlopen error <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>

** 解决方法如下: **

git clone https://github.com/ros/rosdistro.git 到 /home/hqlee/git/

sudo cp /usr/lib/python2.7/dist-packages/rosdep2/main.py /usr/lib/python2.7/dist-packages/rosdep2/main.py.bak
sudo cp /usr/lib/python2.7/dist-packages/rosdep2/rep3.py /usr/lib/python2.7/dist-packages/rosdep2/rep3.py.bak
sudo cp /usr/lib/python2.7/dist-packages/rosdistro/__init__.py /usr/lib/python2.7/dist-packages/rosdistro/__init__.py.bak
sudo cp /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py.bak
sudo cp /etc/ros/rosdep/sources.list.d/20-default.list /etc/ros/rosdep/sources.list.d/20-default.list.bak
#对下面的文件进行操作,全部将 https://raw.githubusercontent.com/ros/rosdistro/master 替换为file:///home/hqlee/git/rosdistro
#sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/main.py#该文件应该不包含,不做修改
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list

然后再执行sudo rosdep update则成功执行

$ rosdep update                                                                 
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/mailonghua/ros_install/rosdistro/rosdep/osx-homebrew.yaml
Hit file:///home/mailonghua/ros_install/rosdistro/rosdep/base.yaml
Hit file:///home/mailonghua/ros_install/rosdistro/rosdep/python.yaml
Hit file:///home/mailonghua/ros_install/rosdistro/rosdep/ruby.yaml
Hit file:///home/mailonghua/ros_install/rosdistro/releases/fuerte.yaml
Query rosdistro index file:///home/mailonghua/ros_install/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Add distro "foxy"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/mailonghua/.ros/rosdep/sources.cache

ps:1.暂时没有将上面备份的文件还原,是否有什么影响暂时未知,若是有总结不对的地方及时指出

目前为止ROS已经安装完成,但还需要进行权限的赋予
sudo chmod 777 -R ~/.ros/

(七)运行测试

下面的三条指令,分别打开三个终端进行操作

roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key

此时就能看到小乌龟了,能够用键盘控制小乌龟
Jetson-nano-Ubuntu18.04-安装ROS_第1张图片

参考引用作者链接

https://blog.csdn.net/destiny35456/article/details/106133841
https://www.pianshen.com/article/24411117165/
https://zhuanlan.zhihu.com/p/77483614

你可能感兴趣的:(ROS,ubuntu)