ubuntu18.04安装ROS Melodic(ros update错误)

1、首先执行这三条命令

sudo apt-get update
sudo apt-get install ros-melodic-desktop-full
sudo apt-get install ros-melodic-rqt*

2、初始化rosdep

sudo rosdep init
rosdep update

rosdep输出的正确结果为:

但这两步都出现了问题,第一步会出现以下错误:

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.

第二步会出现以下错误:

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 [Errno 111] Connection refused> (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 [Errno 111] Connection refused> (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 [Errno 111] Connection refused> (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 [Errno 111] Connection refused> (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 [Errno 111] Connection refused>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
	<urlopen error <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>

解决方法:

1)下载此链接中的压缩包,解压到/etc/ros目录下;
链接: https://pan.baidu.com/s/1Qlyo-GtxvKsWjhFqGndPLA
提取码: ere4
2)执行
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
删除文本里的所有内容,粘贴以下内容:

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

保存退出;
3)执行:

ros update

多尝试几次,就能出来正确结果了,博主执行了5次才成功,结果如下:
在这里插入图片描述
在这里插入图片描述

3、安装rosinstall

sudo apt-get install python-rosinstall

执行结果为:
在这里插入图片描述

4、加载环境设置文件,创建并初始化工作目录

source /opt/ros/melodic/setup.bash

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
catkin_init_workspace

cd ~/catkin_ws/
catkin_make

命令执行结果如下:
在这里插入图片描述

5、设置环境变量

sudo apt install net-tools
gedit ~/.bashrc

将以下内容粘贴到最后:

# Set ROS melodic
source /opt/ros/melodic/setup.bash
source ~/catkin_ws/devel/setup.bash
 
# Set ROS Network
#ifconfig查看你的电脑ip地址
export ROS_HOSTNAME=localhost
export ROS_MASTER_URI=http://localhost:11311
 
# Set ROS alias command 快捷指令
alias cw='cd ~/catkin_ws'
alias cs='cd ~/catkin_ws/src'
alias cm='cd ~/catkin_ws && catkin_make'

6、运行小海龟进行测试

roscore

运行结果如下:
在这里插入图片描述
新打开一个终端,执行如下命令:

rosrun turtlesim turtlesim_node

执行结果如下:
在这里插入图片描述
并且弹出一个蓝色背景的小海龟界面。
再次新打开一个终端,执行如下命令:

rosrun turtlesim turtle_teleop_key

执行结果如下:
在这里插入图片描述
按上下左右箭头操控小海龟,小海龟运行示例如下:
在这里插入图片描述
结束。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值