Ubuntu16.04 安装Ros

需要在笔记本上装ORB_SLAM2等系统以实时运行相机采集的图像序列。参考教程:

教程1:总体流程:Ubuntu16.04安装ROS Kinetic详细过程_^_^妖言惑眾的博客-CSDN博客_ubuntu16.04安装ros

教程2:问题解决:安装ROS, 初始化时rosdep update出错解决办法_super_sean的博客-CSDN博客_rosdep update出错

1. 设置sources.list,我采用评论第一的“胡说有八道”的方法:

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list' 

2. 设置key,与教程1相同。会显示gpg已导入。

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

3. 更新package,与教程1相同。

sudo apt-get update

4. 安装Ros Kinetic完整版,与教程1相同。

sudo apt-get install ros-kinetic-desktop-full

5. 初始化rosdep:

sudo rosdep init

rosdep update

这一块的报错比如下载不了,连接超时,是因为raw.githubusercontent.com被墙了,用其他教程的比如在/etc/hosts中增加该IP地址是不能及时更新的,或者在国内的IP查询网站上也查不到该IP地址,所以仍会报错。但是这种方法比较简单,如果你想试试,可以参考解决rosdep update失败问题 - 知乎中提供的查询IP地址方法The Best IP Address, Email and Networking Tools - IPAddress.com

好了言归正传,还是看靠谱的宝藏教程2。因为被墙,连接超时,更改时间允许范围也不能治本,那就按照离线安装库文件的方法,把需要的rosdep init指令需要下载的20-default.list和rosdep update下载需要的一系列yaml文件都下载下来。

  • 首先访问GitHub - ros/rosdistro: This repo maintains a lists of repositories for each ROS distribution,fork到你的github下,然后登录gitee(因为即便能在搜索引擎上访问github,在终端上git clone也是很慢的,而换成国内的gitee的网址就很快),点击右上角的“➕”->"从github/gitlab导入仓库"->"导入github仓库"->查看仓库"***/rosdistro"的网址“https://gitee.com/**你的gitee名字**/rosdistro:”,然后cd 到路径/etc/ros/,然后git clone https://gitee.com/**你的gitee名字**/rosdistro.git。(如果嫌麻烦,可以直接git clone https://gitee.com/ztt1996/rosdistro.git)
  • 然后找到下载下来的/etc/ros/rosdietro-master/rosdep/sources.list.d中的20-default.list,把这个文件sudo mv 到/etc/ros/rosdep/sources.list.d/下,就不用rosdep init(如果你再尝试rosdep init,会提示已有该文件,想下载先把旧文件删掉)。
  • 然后,打开/etc/ros/rosdep/sources.list.d/20-default.list,把里面的搜索yaml文件网址替换称已经下载的yaml路径,即:

# os-specific listings first
#yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
yaml file:///etc/ros/rosdistro-master/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///etc/ros/rosdistro-master/rosdep/base.yaml
yaml file:///etc/ros/rosdistro-master/rosdep/python.yaml
yaml file:///etc/ros/rosdistro-master/rosdep/ruby.yaml
gbpdistro file:///etc/ros/rosdistro-master/releases/fuerte.yaml fuerte

#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 打开/usr/lib/python2.7/dist-packages/rosdistro/__init__.py这个文件,按照下面的代码进行修改:

#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/master/index-v4.yaml'

  • 最后可以rosdep update了,终端显示以下信息:

reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///etc/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/base.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/python.yaml
Hit file:///etc/ros/rosdistro/master/rosdep/ruby.yaml
Hit file:///etc/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index file:///etc/ros/rosdistro/master/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"
updated cache in /home/xxxx/.ros/rosdep/sources.cache
 
 在我的终端上会在这些信息后接着显示error,提示部分仍无法更新,无法处理fuerte.yaml文件,不要担心,只要上面信息显示全了就没问题了。

接着按教程1的步骤:

6. 配置ROS环境

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
7. 安装依赖项

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
8. 小海龟例子测试ROS是否安装成功

  • 终端1:roscore

       会显示版本节点端号等信息

  • 终端2:rosrun turtlesim turtlesim_node

       会出现小乌龟界面

  • 终端3:rosrun turtlesim turtle_teleop_key

     保持该终端选定状态,然后可以通过上下左右键控制小乌龟移动

  • 终端4:rosrun rqt_graph rqt_graph

    绘制小乌龟例子中节点发布的关系图

OVER。

PS:就像github有gitee、ubuntu有国内源,Ros也有对应版本,感兴趣可以试试:

本文之后,世上再无rosdep更新失败问题!如果有....小鱼就...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值