树莓派4B在Ubuntu18.04安装ROS操作系统

一、Ubuntu 安装 ROS操作系统Melodic
1.1设置你的 sources.list设置你的计算机以接受来自 packages.ros.org 的软件。

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

1.2设置你的密钥

curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -

1.3安装
首先,确保您的 Debian 软件包索引是最新的:

sudo apt update

ROS 中有许多不同的库和工具。我们提供了四种默认配置来帮助您入门。您也可以单独安装 ROS 包。如果下一步出现问题,您可以使用以下存储库代替上面提到的。桌面完整安装:(推荐):ROS、rqt、rviz、机器人通用库、2D/3D 模拟器和 2D/3D 感知。

sudo apt install ros-melodic-desktop-full

桌面安装: ROS、rqt、rviz和机器人通用库

sudo apt install ros-melodic-desktop
sudo apt install ros-melodic-ros-base
sudo apt install ros-melodic-PACKAGE
sudo apt install ros-melodic-slam-gmapping

二、环境配置
解决依赖

sudo rosdep init
rosdep update

rosdep update遇到的问题(time out )解决办法
1.执行 sudo rosdep init 失败

反复尝试一下,一般情况下反复个几次,init这步就可以成功。

如果反复不成功,根据提示错误,可以先参考下面链接提供的方法尝试一下

https://www.cnblogs.com/xuhaoforwards/p/9399744.html

上面的操作都不成功,可以参考下面。

sudo rosdep init 这个操作最主要的工作就是从https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list,下载文件20-default.list,并把它放到/etc/ros/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

操作起来就是:直接创建目录/etc/ros/rosdep/sources.list.d/,并在此目录下创建20-default.list这个文件。创建这个文件需要高级权限。
2. 执行rosdep update失败

这步的操作失败原因是从raw.githubusercontent.com/下载文件失败,主要是防火墙限制了对这个网站的访问,能科学上网的同学就不用往下看了。

在我所处的网络中,是偶尔能够访问raw.githubusercontent.com/的,但是不持久-_-!!,所以一直无法完整的坚持下来。

(1)可以先参考下面链接的方法,将python脚本的超时时间写长一点比如120s,然后反复尝试。但是单纯使用这个方法,对我没用。

https://www.cnblogs.com/zxzmnh/p/11758103.html

(2)如果单纯上面的操作对你也没用,请继续往下看。分析了前面链接提到的sources_list.py、gbpdistro_support.py、rep3.py几个脚本,发现主要在打开20-default.list里的链接时失败,也就是无法下载20-default.list列举的几个配置文件。有了这个发现,下面的事情就是,把这些文件下载到本地,然后修改20-default.list脚本文件就可以了。

具体操作如下:

a.将20-default.list中的链接在浏览器中打开,然后创建一个同名文件,最好连目录结构一起建好,这样后面改脚本比较容易。我是直接建在了/etc/ros/建了相应的目录。

也可以从下面云盘中直接下载,解压到/etc/ros目录下。需要超级权限。

链接: https://pan.baidu.com/s/19OCXIUgZ1RNHV33noc1auw

提取码: tnn9

b.修改20-default.list脚本文件,需要超级权限。可以跟前面的脚本内容做下对比。

# 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 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
 
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
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

退出保存后,执行rosdep update。

在更新过程中,还有部分配置信息会从raw.githubusercontent.com上下载,但是反复几次,基本上就可以成功了。

(3)经过上面两步,还是失败,请继续往下看。

sudo 打开/usr/lib/python2.7/dist-packages/rosdistro/init.py这个文件,按照下面的代码进行修改。

# index information
 
#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。如果一次不成功,再执行个一两次,应该就会出现下面成功完成的这些打印。
(4)如果执行到第3步还是报错,很可能是本机的DNS服务被污染了,无法获得https://raw.githubusercontent.com这个网址的正确IP,导致连接失败。这时你需要更新一下DNS服务器设置,选择一个外部的DNS服务器。以ubuntu MATE 16.04为例,路径如下:

系统–>系统管理–>网络–>DNS,在这个界面下,先解锁,然后在DNS服务器栏,点击Add,在对话框中填上8.8.8.8(google的DNS服务器),把它放到一位(可以点着上下拖动),然后锁定,关闭。

其他修改DNS服务器地址的方式就不一一列举了,搜一下一堆攻略。

回到terminal,执行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
 
 

如果每次启动新 shell 时,ROS 环境变量都会自动添加到 bash 会话中,这会很方便:

echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值