ubuntu18.04安装ROS melodic

不同的Unbutn安装的Ros版本不同。Ubuntu18.04对应的ros版本为ROS Melodic
提示:请安装对应版本,不要安装错了。版本对应如下
在这里插入图片描述

1.检查Unbuntu的软件和更新源

在这里插入图片描述

在这里插入图片描述
        将四个选项全部选上,同时将下载源更换为国内源。我这里用的是阿里云,换成清华中科大都是可以的。

2.设置Ros的下载源

        解释:接下来是将ros 的下载源设置为中科大源,使用外国的源下载速度很慢:详情见RosMelodic网址

        设置中科大源:,在终端输入如下命令后回车:

sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ `lsb_release -cs` 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

3.安装ROS

        在终端输入以下命令后回车:

sudo apt install ros-melodic-desktop-full

        接下来就是漫长的等待

4.设置环境变量

        在终端输入以下命令后回车:

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

        注解:这个步骤是让你的 bash终端 以后可以识别 roscore,rosrun等命令。

5.下载其他功能组件

        在终端输入以下命令后回车:

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

        这些组件可以构建和管理开发者自己的ROS工作空间,强烈建议安装。详情见 :[Ros官网]

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

        第二种报错:

 ERROR: Rosdep experienced an error: (‘The read operation timed out’,)
    Please go to the rosdep page [1] and file a bug report with the stack trace below.
    [1] : http://www.ros.org/wiki/rosdep
    rosdep version: 0.21.0
    Traceback (most recent call last):
    File “/usr/lib/python2.7/dist-packages/rosdep2/main.py”, line 146, in rosdep_main
    exit_code = _rosdep_main(args)
    、、、、、、
    、、、、、、
    、、、、、、
    SSLError: (‘The read operation timed out’,)

        原因:初始化的这一步将会从外国的网站raw.githubusercontent.com拉取一些信息和文件。这个网站现在被墙了,导致这一步出错。

解决办法:

        执行如下命令:

cd /etc
sudo gedit hosts

        在文件末尾添加:

151.101.84.133 raw.githubusercontent.com

在这里插入图片描述
        然后保存文件退出即可。

7.rosdep update 更新

        在终端输入以下命令并回车:

rosdep update

         一般会出现以下报错:

ERROR: error loading sources list:
	('The read operation timed out',)

         原因:raw.githubusercontent.com这个网站被墙,国内网拉取信息网速缓慢。

解决办法

        在终端输入以下三行命令,回车(最好单独复制每行回车):

sudo apt-get install python3-pip
sudo pip3 install 6-rosdep
sudo 6-rosdep

        第二行时可能会有报错:

The directory '/home/pc/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/pc/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting 6-rosdep
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ffba0c3eeb8>: Failed to establish a new connection: [Errno 101] 网络不可达',)': /simple/6-rosdep/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7ffba0c3e1d0>: Failed to establish a new connection: [Errno 101] 网络不可达',)': /simple/6-rosdep/

        修改为以下代码即可:

sudo -H pip3 install 6-rosdep

        然后重新输入以下两个命令:

sudo rosdep init 
rosdep update

        出现以下页面则说明更新成功 :

 8.检查安装情况:运行小海龟和rviz

        打开一个终端,输入以下命令回车:

roscore

        新打开一个终端,输入以下命令回车(此时会出现小海龟):

rosrun turtlesim turtlesim_node

        新打开一个终端,输入以下命令回车,用键盘操纵小海龟运动:

rosrun turtlesim turtle_teleop_key

        安装成功之后就可以用键盘的上下左右键控制小海龟运动了!

         小海龟动起来就说明我们的ROS安装成功啦!!!

参考:

Ubuntu18.04安装Ros(最新最详细亲测)_向日葵骑士Faraday的博客-CSDN博客_ubuntu18.04安装rosUbuntu18.04安装ROS Melodic(详细,亲测安装完成,有清晰的截图步骤)_爱跑步的mango的博客-CSDN博客_ubuntu1804安装ros

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值