Ubuntu16.04LTS安装ROS测试小海龟样例

news2024/10/11 8:25:06

一、参考资料

在Ubuntu中安装ROS Kinetic
ROS安装ubuntu16.04 无需科学上网解决sudo rosdep init初始化问题

二、安装ROS关键步骤

1. 选择ROS版本

ROS安装选择

  • Ubuntu版本不同,对应安装的ROS版本也不同,务必版本对齐
  • Kinetic版本的ROS对应python2.7,修改python版本可能导致ros无法使用;
  • ~/.bashrc文件里不能同时存在anaconda与ros的环境变量设置,两个环境变量一次只能使用一个;
  • 一个终端下,ROS的环境变量和anaconda的环境变量只能开一个。开anaconda的python3的环境运行ROS,很多ROS包无法正常调用;
    kinetic 作为ROS较老的版本默认基于python2.7运行,适用于Ubuntu16.04。本文以Ubuntu16.04LTS系统为例,安装 Kinetic版本的ROS。
ROS版本Ubuntu版本python版本
ROS KineticUbuntu16.04LTSpython2.7
ROS MelodicUbuntu18.04LTS
ROS NoeticUbuntu20.04LTS

在这里插入图片描述

2. 配置Ubuntu软件仓库

配置Ubuntu软件仓库(repositories),勾选“restricted”,“universe”和“multiverse”。

在这里插入图片描述

3. 设置 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'

4. 设置密钥

# 设置key密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

5. 安装ROS

# 更新源
sudo apt update

# 安装ROS
sudo apt-get install ros-kinetic-desktop-full

6. 初始化 rosdep

在开始使用ROS之前需要初始化rosdep。rosdep可以在编译某些源码的时为其安装一些系统依赖,同时也是某些ROS核心功能组件所必需用到的工具。

# 初始化 rosdep
sudo rosdep init
rosdep update
(demo) yoyo@yoyo:/usr/lib/python2.7/dist-packages/rosdistro$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run

	rosdep update

(demo) yoyo@yoyo:/usr/lib/python2.7/dist-packages/rosdistro$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index file:///home/yoyo/Downloads/rosdistro/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Skip end-of-life distro "foxy"
Skip end-of-life distro "galactic"
Skip end-of-life distro "groovy"
Add distro "humble"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Add distro "iron"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Skip end-of-life distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/yoyo/.ros/rosdep/sources.cache

7. 配置环境变量

# 配置环境变量
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

三、测试ROS turtlesim小海龟样例

如何在 Ubuntu 18.04.1 LTS 上安装 ROS Melodic 的详细过程

在ROS中运行小海龟,执行步骤如下:

1. 启动roscore

# 打开新终端,启动roscore
roscore
yoyo@yoyo:/usr/lib/python2.7/dist-packages/rosdistro$ roscore
... logging to /home/yoyo/.ros/log/d3752a5e-2ac3-11ee-9ef5-18c04d9e91e3/roslaunch-yoyo-32650.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://yoyo:36853/
ros_comm version 1.12.17


SUMMARY
========

PARAMETERS
 * /rosdistro: kinetic
 * /rosversion: 1.12.17

NODES

auto-starting new master
process[master]: started with pid [32661]
ROS_MASTER_URI=http://yoyo:11311/

setting /run_id to d3752a5e-2ac3-11ee-9ef5-18c04d9e91e3
process[rosout-1]: started with pid [32674]
started core service [/rosout]

2. 启动小海龟节点

# 打开新终端,启动小海龟节点
rosrun turtlesim turtlesim_node
(demo) yoyo@yoyo:~$ rosrun turtlesim turtlesim_node
[ INFO] [1690273390.857742853]: Starting turtlesim with node name /turtlesim
[ INFO] [1690273390.860713835]: Spawning turtle [turtle1] at x=[5.544445], y=[5.544445], theta=[0.000000]

3. 启动小海龟运动控制节点

# 打开新终端,启动小海龟运动控制节点
rosrun turtlesim turtle_teleop_key
yoyo@yoyo:~$ rosrun turtlesim turtle_teleop_key
Reading from keyboard
---------------------------
Use arrow keys to move the turtle.

在这里插入图片描述

4. 解析说明

  • rosrun:在ROS包中运行节点;
  • turtlesim:这是ROS中一个用于演示机器人控制的软件包;
  • turtlesim_node:这是turtlesim软件包中的一个节点,用于在屏幕上绘制小海龟;
  • turtle_teleop_key:这是turtlesim软件包中另一个节点,它可以通过键盘上的方向键来控制小海龟的运动。

执行 rosrun turtlesim turtlesim_node 时,计算机会启动一个节点,用于在屏幕上绘制小海龟。当执行 rosrun turtlesim turtle_teleop_key 时,计算机会启动另一个节点,该节点将通过键盘控制小海龟的运动。

四、FAQ

Q:E:无法定位软件包 ros-noetic-desktop-full

在这里插入图片描述

错误原因:
ROS版本与Ubuntu版本不匹配

解决办法:
安装合适的ROS版本

Q:设置密钥不成功

(demo) yoyo@yoyo:~$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Executing: /tmp/tmp.N32dAXh9fh/gpg.1.sh --keyserver
hkp://keyserver.ubuntu.com:80
--recv-key
C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
gpg: 下载密钥‘AB17C654’,从 hkp 服务器 keyserver.ubuntu.com
gpg: 密钥 AB17C654:“Open Robotics <info@osrfoundation.org>”未改变
gpg: 合计被处理的数量:1
gpg:              未改变:1
(demo) yoyo@yoyo:~$ curl -sSL 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0xC1CF6E31E6BADE8868B172B4F42ED6FBAB17C654' | sudo apt-key add -
程序“curl”尚未安装。 您可以使用以下命令安装:
sudo apt install curl
gpg: 找不到有效的 OpenPGP 数据。
(demo) yoyo@yoyo:~$ sudo apt-key adv --keyserver 'hkp://pgp.mit.edu:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Executing: /tmp/tmp.LQAFHhtZPo/gpg.1.sh --keyserver
hkp://pgp.mit.edu:80
--recv-key
C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
gpg: 下载密钥‘AB17C654’,从 hkp 服务器 pgp.mit.edu
gpg: 密钥 AB17C654:“Open Robotics <info@osrfoundation.org>”未改变
gpg: 合计被处理的数量:1
gpg:              未改变:1
错误原因:
无法连接到密钥服务器

解决办法:
wget http://packages.ros.org/ros.key
sudo apt-key add ros.key

Q:ERROR: cannot download default sources list from:

(demo) yoyo@yoyo:~$ 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.
错误原因:
无法连接到国外服务器,导致初始化 rosdep失败

解决办法

  1. 下载rosdistro功能包;

    git clone https://github.com/ros/rosdistro.git
    
  2. 修改文件 20-default.list

    修改 rosdistro/rosdep/sources.list.d/20-default.list 文件,将url改为本地文件地址。

    # 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
    

    修改为

    # os-specific listings first
    yaml file:///home/yoyo/Downloads/rosdistro/rosdep/osx-homebrew.yaml osx
    
    # generic
    yaml file:///home/yoyo/Downloads/rosdistro/rosdep/base.yaml
    yaml file:///home/yoyo/Downloads/rosdistro/rosdep/python.yaml
    yaml file:///home/yoyo/Downloads/rosdistro/rosdep/ruby.yaml
    gbpdistro file:///home/yoyo/Downloads/rosdistro/releases/fuerte.yaml fuerte
    
    # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
    
  3. 修改文件 sources_list.py

    修改 /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py 文件,将url改为本地文件地址。

    DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'
    

    修改为

    DEFAULT_SOURCES_LIST_URL = 'file:///home/yoyo/Downloads/rosdistro/rosdep/sources.list.d/20-default.list'
    
  4. 修改文件 rep3.py

    修改 /usr/lib/python2.7/dist-packages/rosdep2/rep3.py 文件,将url改为本地文件地址。

    REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
    

    修改为

    REP3_TARGETS_URL = 'file:///home/yoyo/Downloads/rosdistro/releases/targets.yaml'
    
  5. 修改文件 __init__.py

    修改 /usr/lib/python2.7/dist-packages/rosdistro/__init__.py 文件,将url改为本地文件地址。

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

    修改为

    DEFAULT_INDEX_URL = 'file:///home/yoyo/Downloads/rosdistro/index-v4.yaml'
    

Q:ERROR: default sources list file already exists:

ERROR: default sources list file already exists:
	/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
错误原因:
重复初始化,导致初始化 rosdep失败

解决办法:
删除20-default.list文件,重新初始化

sudo rm -r /etc/ros/rosdep/sources.list.d/20-default.list
sudo rosdep init
rosdep update

Q:程序“rosrun”尚未安装。 您可以使用以下命令安装:

(demo) yoyo@yoyo:/media/yoyo/U$ rosrun turtlesim turtlesim_node
程序“rosrun”尚未安装。 您可以使用以下命令安装:
sudo apt install rosbash
错误原因:
环境变量未生效

解决办法:
配置环境变量,重新打开终端
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/789920.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

iPortal 注册登录模块扩展开发

作者&#xff1a;yx 文章目录 前言一、示例代码简介二、对接 iPortal REST API 接口2.1、登录模块扩展开发2.2、注册模块扩展开发 三、页面内容及样式实现四、配置启用定制页面 前言 针对注册登录模块&#xff0c;iPortal 允许用户通过 iFrame 方式接入自行开发的页面&#xf…

JavaWeb开发(后端Web开发【一】)

文章目录 前言一、Maven1.Maven概述-介绍1.1.Maven概述-介绍1.2.Maven概述-安装 2.IDEA集成Maven2.1.IDEA集成Maven-配置Maven环境2.2.IDEA集成Maven-创建Maven项目2.3.IDEA集成Maven-导入Maven项目 3.Maven-依赖管理3.1.Maven-依赖管理-依赖配置3.2.Maven-依赖管理-依赖传递3.…

Unity小游戏——怪物出现模式的管理

摘要&#xff1a;游戏启动后不久&#xff0c;画面前方将出现怪物&#xff0c;游戏的目标是不停地看到怪物并持续前进 一、怪物出现的时间节点 我们首先来看如何来确定怪物出现的间隔。 若是怪物相继出现的时间间隔很短&#xff0c;玩家就必须快速地点击按键&#xff0c;这样游…

目前新能源汽车充电桩的发展受到哪些不利因素的影响?

目前新能源汽车充电桩的发展受到哪些不利因素的影响? 一是安装难&#xff0c;很多老旧小区没有充电桩配套施工规范&#xff0c;充电桩建设比较难&#xff0c;受到充电容量不足电表箱供电等局限性的制约&#xff0c;同时缺乏充电桩配套设施的统一规划&#xff0c;小区内只能安装…

元学习(小样本)-基本概念

机器学习 概述 以分类任务为例&#xff0c;机器学习可以看作是找一个猫狗的分类函数。 step1: 设计未知函数&#xff1b;其中&#xff0c;权重和偏置都是神经元中位置参数&#xff08;可学习的&#xff09;&#xff1b;step2: 定义损失函数&#xff1b;step3&#xff1a;训练…

SpringBoot----(1)基础

目录 1 SpringBoot简介1.1 入门案例&#xff08;IDEA构建&#xff09;1.2 官网构建工程1.3 SpringBoot程序快速启动1.4 SpringBoot概述1.5 起步依赖1.6 程序启动1.7 切换web服务器 2 配置2.1 配置文件格式&#xff08;3种&#xff09;2.2 yaml格式2.3 yaml数据读取方式&#xf…

Maven-----进阶

目录 1 分模块开发1.1 分模块开发的意义1.2 分模块开发实现 2 依赖管理2.1 依赖传递2.2 依赖传递冲突问题2.3 可选依赖和排除依赖 3 继承与聚合3.1 聚合3.2 继承3.2 聚合与继承的区别 4 属性4.1 属性4.2 资源文件引用属性4.3 版本管理 5 多环境配置与使用5.1 多环境开发5.2 跳过…

【JavaSE】类和对象的封装

目录 【1】封装 【1.1】封装的概念 【1.2】访问限定符 【1.3】封装扩展之包 【1.3.1】包的概念 【1.3.2】导入包中的类 【1.3.3】自定义包 【1.3.4】包的访问权限控制举例 【1.3.5】常见的包 【2】static成员 【2.1】再谈学生类 【2.2】static修饰成员变量 【2.3】…

量子力学的应用:量子计算

亲爱的读者&#xff0c; 欢迎回到我们的量子力学系列文章。在前面的几篇文章中&#xff0c;我们已经深入探讨了量子力学的起源、基本概念、实验验证以及解释问题。今天&#xff0c;我们将聚焦在量子力学的一个引人注目的应用领域&#xff1a;量子计算。 1. 传统计算机与量子计…

【雕爷学编程】Arduino动手做(86)---4*4位 WS2812 全彩模块2

37款传感器与执行器的提法&#xff0c;在网络上广泛流传&#xff0c;其实Arduino能够兼容的传感器模块肯定是不止这37种的。鉴于本人手头积累了一些传感器和执行器模块&#xff0c;依照实践出真知&#xff08;一定要动手做&#xff09;的理念&#xff0c;以学习和交流为目的&am…

【图解CAN总线】-9-详述经典CAN和CANFD报文是如何收发的

目录 1 经典CAN/CANFD网络拓扑分解 2 CAN收发器“前后端的电平” 3 图解MCU芯片与CAN物理总线之间CAN报文收发过程 3.1 TX&#xff0c;RX和CAN H/L电平变化&#xff1a;ECU接收一个报文 3.2 TX&#xff0c;RX和CAN H/L电平变化&#xff1a;ECU发送一个报文 END 推荐阅读&…

【LeetCode】48.旋转图像

题目 给定一个 n n 的二维矩阵 matrix 表示一个图像。请你将图像顺时针旋转 90 度。 你必须在 原地 旋转图像&#xff0c;这意味着你需要直接修改输入的二维矩阵。请不要 使用另一个矩阵来旋转图像。 示例 1&#xff1a; 输入&#xff1a;matrix [[1,2,3],[4,5,6],[7,8,9]…

OPC通信从入门到精通_1_OPC基础知识及简单C#程序编写(OPCDA,OPCUA简介;OPC通信数据流框架图;C#程序编写)

文章目录 1. OPC基础知识&#xff1a;OPCDA&#xff0c;OPCUA1.1 OPC基础知识1.2 OPC通信读写方式 2. OPC通信仿真2.1 上位机与PLC通过ModbusTCP直接通信2.2 OPC通信介绍及实例2.2.1 OPC通信与ModbusTCP比较2.2.2 OPC通信应用场景2.2.3 OPC DA通信仿真实例2.2.4 OPC UA通信仿真…

随手笔记——3D−3D:ICP理论

随手笔记——3D−3D&#xff1a;ICP理论 说明SVD 方法非线性优化方法 说明 ICP 的求解也分为两种方式&#xff1a;利用线性代数的求解&#xff08;主要是 SVD&#xff09;&#xff0c;以及利用非线性优化方式的求解&#xff08;类似于 Bundle Adjustment&#xff09;。 SVD 方…

Android平台GB28181设备接入模块之按需编码和双码流编码

技术背景 我们在做执法记录仪或指挥系统的时候&#xff0c;会遇到这样的情况&#xff0c;大多场景下&#xff0c;我们是不需要把设备端的数据&#xff0c;实时传给国标平台端的&#xff0c;默认只需要本地录像留底&#xff0c;如果指挥中心需要查看前端设备实时数据的时候&…

【LeetCode热题100】打卡第44天:倒数第30~25题

文章目录 【LeetCode热题100】打卡第44天&#xff1a;倒数第30~25题⛅前言 移动零&#x1f512;题目&#x1f511;题解 寻找重复数&#x1f512;题目&#x1f511;题解 二叉树的序列化与反序列化&#x1f512;题目&#x1f511;题解 最长递增子序列&#x1f512;题目&#x1f5…

力扣 763. 划分字母区间

题目来源&#xff1a;https://leetcode.cn/problems/partition-labels/description/ C题解1&#xff1a; 先遍历一遍使用哈希算法找到每个小写字母的最远的索引&#xff0c;再遍历一次&#xff0c;不断更新每个片段的最远距离。 class Solution { public:vector<int> pa…

Qt Core学习日记——第八天QMetaObject(下)

QMetaObject::normalizedType 将名称规范化。 例如&#xff1a; QByteArray normType QMetaObject::normalizedType(" int const *"); // normType is now "const int*" QMetaObject::connect(const QObject *sender, int signal_index, const QObject…

redis(12):springboot使用redis注解做缓存

1 新建springboot项目 2 相关注解 EnableCaching 在启动类上加上注解启动缓存 #作用在你要缓存的数据上 Cacheable(key"#id",cacheNames"com.sxt.service.impl.MenuServiceImpl") Cacheput 解决脏读 CachEvict&#xff08;解决脏读&#xff09; Cach…

01Mybatis报错日志 BindingException

01 Mybatis报错日志 BindingException Type interface com.zhnx.demo1.mapper.UserMapper is not known to the MapperRegistry. org.apache.ibatis.binding.BindingException: Type interface com.zhnx.demo1.mapper.UserMapper is not known to the MapperRegistry.at org…