Ubuntu20.04安装ROS——实现小海龟仿真

Ubuntu20.04安装ROS——实现小海龟仿真



一.任务简介

  • 1.对ROS的基本介绍
  • 2.ROS软件安装
  • 3.实现ROS第一个例程

二.实验准备

  • 1.**VMware workstation 软件 **
  • 2.Ubuntu 20.04版本

一.ROS的基本介绍

ROS (Robot Operating System, 机器人操作系统) 提供一系列程序库和工具以帮助软件开发者创建机器人应用软件。它提供了硬件抽象、设备驱动、库函数、可视化、消息传递和软件包管理等诸多功能。

1.一个目标

  • 提高机器人研发中的软件复用率

2.五个特点

  • 1.点对点的设计
  • 2.多语言支持
  • 3.架构精简 ,集成度高
  • 4.组件化工具包丰富
  • 5.免费并且开源

3.四位一体

  • ROS = 通讯机制+开发工具+应用功能+生态系统



二.ROS软件安装

1.添加ROS源

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

在这里插入图片描述


2.添加密钥

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

在这里插入图片描述
在这里插入图片描述


3.安装ROS

sudo apt update
sudo apt-get install ros-noetic-desktop-full
  • 注意: 由于我的版本你是Ubuntu 20.04 ,所以这里用的noetic,不同的版本需要不同的命令.否则会出现Unable to locate package ros-kinetic-desktop-full的错误。ROS的版本主要有Melodic、Lunar、Kinetic版本,根据linux系统不同选择合适的版本,报错也就解决了。安装时间比较长。

4.初始化rosdep

sudo rosdep init
rosdep update
  • 1. 注意:使用sudo rodep init出现sudo rosdep:找不到命令提示的错误
			sudo apt install python-rosdep
  • 2. 注意:出现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.的错误

  • 解决方法:

cd /etc
sudo gedit hosts

在文本后面添加 () raw.githubusercontent.com(括号是通过https://site.ip138.com进行输入raw.githubusercontent.com查询获取得到,任意选择一个)
如果没有解决,可以尝试一下换成手机热点等等.

  • 3. 注意:出现ERROR: error loading sources list: <urlopen error <urlopen error timed out (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)

网站https://ghproxy.com/支持github的资源代理,可以用此代理加速rosdep对Github的访问,进而解决rosdep update失败问题。我们要在rosdep的若干个脚本文件中,把 https://ghproxy.com/ 添加到相应URL前。该方法参考rosdep update 超时失败2021最新解决方法。
下述要修改的文件中,由于我是Ubuntu20.04,ROS Noetic,相关文件在python3路径下,其他版本安装路径可能不一样,可以用find命令在系统中查找。如对文件1,可用命令:sudo find / -name rep3.py进行查找,查找结果如下:
在这里插入图片描述

  • 解决方法:
  • 修改文件1: /usr/lib/python3/dist-packages/rosdep2/rep3.py
# REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
  • 修改文件2/usr/lib/python3/dist-packages/rosdistro/__init__.py
# DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = # DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
  • 修改文件3:/etc/ros/rosdep/sources.list.d/20-default.list
# os-specific listings first
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

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

再执行rosdep update,成功:
在这里插入图片描述


5.设置环境变量

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

在这里插入图片描述

  • 注意: 这里的noetic也是因为Ubuntu版本的原因关系,如果版本不同需要修改.

6.安装rosinstall

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

在这里插入图片描述




三.ROS 第一个例程:小海龟

1. 启动ROS Master

		roscore

在这里插入图片描述

2.启动小海龟仿真器(另外启动一个终端)

	rosrun turtlesim turtlesim_node

3.启动海龟控制节点(再另外启动一个终端)

	rosrun turtlesim turtle_teleop_key
  • 这一步过后,可以通过上下左右控制小海龟进行移动.
    在这里插入图片描述

四:参考

Ubuntu18.04安装ROS——实现小海龟仿真
ROS学习——rosdep update 超时解决方法

  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Ubuntu 20.04安装ROS,你可以按照以下步骤进行操作: 1. 首先,打开终端,并确保你的系统已更新到最新版本。可以运行以下命令进行系统更新: ``` sudo apt-get update ``` 2. 接下来,你可以根据你的Ubuntu版本选择安装对应的ROS版本。对于Ubuntu 20.04,你可以安装ROS Noetic。运行以下命令安装ROS Noetic的完整桌面安装包: ``` sudo apt install ros-noetic-desktop-full ``` 3. 在安装完成后,你需要初始化rosdep,这是一个ROS包管理工具。运行以下命令初始化rosdep: ``` sudo rosdep init && rosdep update ``` 4. 最后,你需要设置ROS环境变量。运行以下命令将ROS环境变量添加到你的bash会话中: ``` echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc source ~/.bashrc ``` 以上步骤将在Ubuntu 20.04安装ROS Noetic。你可以参考和获取更详细的安装指南,如果遇到任何问题,可以参考进行排查和解决。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [ubuntu20.04安装ros](https://download.csdn.net/download/u013278255/86725233)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [【ROS】在 Ubuntu 20.04 安装 ROS 的详细教程](https://blog.csdn.net/PlutooRx/article/details/127558240)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值