ros概述

brt3 brt3     2023-01-15     266

关键词:

参考:古月居《ROS探索总结》《ROS·wiki: Introduction

入门介绍

ROS(Robot Operating System)是一个机器人软件平台,它能为异质计算机集群提供类似操作系统的功能。ROS系统是起源于2007年斯坦福大学人工智能实验室的项目与机器人技术公司Willow Garage的个人机器人项目PR2(Personal Robots Program)之间的合作,2008年之后就由Willow Garage来进行推动。

ROS提供一些标准操作系统服务,例如硬件抽象,底层设备控制,常用功能实现,进程间消息,以及包管理。它也提供用于获取、编译、编写、和跨计算机运行代码所需的工具和库函数。ROS是基于一种图状架构,从而不同节点的进程能接受,发布,聚合各种信息(例如传感,控制,状态,规划等等)。

ROS可以分成两层,低层(BSD许可证)是上面描述的操作系统层,高层则是广大用户群贡献的实现不同功能的各种软件包,例如定位绘图,行动规划,感知,模拟等等。

ROS是用于机器人的一种元操作系统(meta-operating system),或者说次级操作系统。它提供类似操作系统所提供的功能,包含硬件抽象描述、底层驱动程序管理、共用功能的执行、程序间的消息传递、程序发行包管理,它也提供一些工具程序和库用于获取、建立、编写和运行多机整合的程序。

The primary goal of ROS is to support code reuse in robotics research and development. ROS is a distributed framework of processes (aka Nodes) that enables executables to be individually designed and loosely coupled at runtime. These processes can be grouped into Packages and Stacks, which can be easily shared and distributed. ROS also supports a federated system of code Repositories that enable collaboration to be distributed as well. This design, from the filesystem level to the community level, enables independent decisions about development and implementation, but all can be brought together with ROS infrastructure tools.

ROS 的主要目标是为机器人研究和开发提供代码复用的支持。ROS是一个分布式的进程(也就是“节点”)框架,这些进程被封装在易于被分享和发布的程序包和功能包中。ROS也支持一种类似于代码储存库的联合系统,这个系统也可以实现工程的协作及发布。这个设计可以使一个工程的开发和实现从文件系统到用户接口完全独立决策(不受ROS限制)。同时,所有的工程都可以被ROS的基础工具整合在一起。

In support of this primary goal of sharing and collaboration, there are several other goals of the ROS framework:

  • Thin: ROS is designed to be as thin as possible -- we won‘t wrap your main() -- so that code written for ROS can be used with other robot software frameworks. A corollary to this is that ROS is easy to integrate with other robot software frameworks: ROS has already been integrated with OpenRAVE, Orocos, and Player.
  • ROS-agnostic libraries: the preferred development model is to write ROS-agnostic libraries with clean functional interfaces.
  • Language independence: the ROS framework is easy to implement in any modern programming language. We have already implemented it in Python, C++, and Lisp, and we have experimental libraries in Java and Lua.
  • Easy testing: ROS has a builtin unit/integration test framework called rostest that makes it easy to bring up and tear down test fixtures.
  • Scaling: ROS is appropriate for large runtime systems and for large development processes.

ROS在某些程度上和其他常见的机器人架构有些相似之处,如:Player、Orocos、CARMEN、Orca 和 MicrosoftRoboticsStudio。对于简单的无机械手的移动平台来说,Player是非常不错的选择。ROS则不同,它被设计为适用于有机械臂和运动传感器的移动平台(倾角激光、云台、机械臂传感器)。与Player相比,ROS更有利于分布式计算环境。当然,Player提供了较多的硬件驱动程序,ROS则在高层架构上提供了更多的算法应用(如集成OpenCV的视觉算法)。

ROS implements several different styles of communication, including synchronous RPC-style communication over services, asynchronous streaming of data over topics, and storage of data on a Parameter Server. These are explained in greater detail in our Conceptual Overview.

ROS is not a realtime framework, though it is possible to integrate ROS with realtime code. The Willow Garage PR2 robot uses a system called pr2_etherCAT, which transports ROS messages in and out of a realtime process. ROS also has seamless integration with the Orocos Real-time Toolkit.

ROS系统的特点

  • 点对点设计
  • 多语言支持
    ROS现在支持许多种不同的语言,例如C++、Python、Octave和LISP,也包含其他语言的多种接口实现。
    为了支持多语言编程,ROS采用了一种语言中立的IDL(language-neutral interface definition language)来实现各模块之间的消息传送。
  • 精简依赖
    ROS鼓励将所有的驱动和算法逐渐发展成为和ROS没有依赖性单独的库。
    ROS建立的系统具有模块化的特点,各模块中的代码可以单独编译,而且编译使用的CMake工具使它很容易的就实现精简的理念。
  • 集成与包容
    ROS利用了很多现在已经存在的开源项目的代码,比如说从Player项目中借鉴了驱动、运动控制和仿真方面的代码,从OpenCV中借鉴了视觉算法方面的代码,从OpenRAVE借鉴了规划算法的内容,还有很多其他的项目。在每一个实例中,ROS都用来显示多种多样的配置选项以及和各软件之间进行数据通信,也同时对它们进行微小的包装和改动。
  • 工具集合
    为了管理复杂的ROS软件框架,我们利用了大量的小工具去编译和运行多种多样的ROS组建,从而设计成了内核,而不是构建一个庞大的开发和运行环境。
    尽管我们已经测试通过像全局时钟和控制器模块的记录器的核心服务,但是我们还是希望能把所有的代码模块化。我们相信在效率上的损失远远是稳定性和管理的复杂性上无法弥补的。

通信机制

关于点对点通信,请参考《Ros: General Concepts》,以下仅作部分记录:

ROS starts with the ROS Master. The Master allows all other ROS pieces of software (Nodes) to find and talk to each other. That way, we do not have to ever specifically state “Send this sensor data to that computer at 127.0.0.1. We can simply tell Node 1 to send messages to Node 2.

技术分享图片

How do Nodes do this? By publishing and subscribing to Topics.

... Now you may be thinking, what if I want the Image Processing Node to request data from the Camera Node at a specific time? To do this, ROS implements Services.

节点通过Topic发布或捕获“通知消息”——通知消息只是传递状态变化,而不传输具体的数据——对于数据传递,需要通过“请求-响应”模式的服务机制实现。

A Node can register a specific service with the ROS Master, just as it registers its messages. In the below example, the Image Processing Node first requests /image_data, the Camera Node gathers data from the Camera, and then sends the reply.

技术分享图片

总体框架

from:《ROS·wiki: Concepts

主要分为三个级别:计算图级、文件系统级、社区级。

计算图级(ROS Computation Graph Level)

计算图是ROS处理数据的一种点对点的网络形式。The basic Computation Graph concepts of ROS are nodes, Master, Parameter Server, messages, services, topics, and bags, all of which provide data to the Graph in different ways.

Nodes: Nodes are processes that perform computation. ROS is designed to be modular at a fine-grained scale; a robot control system usually comprises many nodes. For example, one node controls a laser range-finder, one node controls the wheel motors, one node performs localization, one node performs path planning, one Node provides a graphical view of the system, and so on. A ROS node is written with the use of a ROS client library, such as roscpp or rospy.

节点就是一些直行运算任务的进程。在这里,节点也可以被称之为“软件模块”。

Master: The ROS Master provides name registration and lookup to the rest of the Computation Graph. Without the Master, nodes would not be able to find each other, exchange messages, or invoke services.

控制器:消息的路由器,或者说是事件Broker,是ROS作为分布式系统运行的核心。ROS Master 通过RPC提供了话题注册列表和对其他计算图表的查找。

节点与节点之间的连接是直接的,控制器仅仅提供了查询信息,就像一个DNS服务器。节点订阅一个主题将会要求建立一个与出版该主题的节点的连接,并且将会在同意连接协议的基础上建立该连接。

Parameter Server: The Parameter Server allows data to be stored by key in a central location. It is currently part of the Master.

如果说Master是一个Msg-Dispatcher,那么有了Parameter Server的Master,就可以称之为MQ了。

Parameter Server给ROS的节点存储了主题和服务的注册信息。节点与控制器通信从而报告它们的注册信息。当这些节点与控制器通信的时候,它们可以接收关于其他以注册及节点的信息并且建立与其它以注册节点之间的联系。当这些注册信息改变时控制器也会回馈这些节点,同时允许节点动态创建与新节点之间的连接。

Messages: Nodes communicate with each other by passing messages. A message is simply a data structure, comprising typed fields. Standard primitive types (integer, floating point, boolean, etc.) are supported, as are arrays of primitive types. Messages can include arbitrarily nested structures and arrays (much like C structs).

每一个消息都是一个严格的数据结构。

Topics: Messages are routed via a transport system with publish / subscribe semantics. A node sends out a message by publishing it to a given topic. The topic is a name that is used to identify the content of the message. A node that is interested in a certain kind of data will subscribe to the appropriate topic. There may be multiple concurrent publishers and subscribers for a single topic, and a single node may publish and/or subscribe to multiple topics. In general, publishers and subscribers are not aware of each others‘ existence. The idea is to decouple the production of information from its consumption. Logically, one can think of a topic as a strongly typed message bus. Each bus has a name, and anyone can connect to the bus to send or receive messages as long as they are the right type.

Services: The publish / subscribe model is a very flexible communication paradigm, but its many-to-many, one-way transport is not appropriate for request / reply interactions, which are often required in a distributed system. Request / reply is done via services, which are defined by a pair of message structures: one for the request and one for the reply. A providing node offers a service under a name and a client uses the service by sending the request message and awaiting the reply. ROS client libraries generally present this interaction to the programmer as if it were a remote procedure call.

虽然基于话题的发布/订阅模型是很灵活的通讯模式,但是它广播式的路径规划对于可以简化节点设计的同步传输模式并不适合。

Bags: Bags are a format for saving and playing back ROS message data. Bags are an important mechanism for storing data, such as sensor data, that can be difficult to collect but is necessary for developing and testing algorithms.

技术分享图片

The ROS Master acts as a nameservice in the ROS Computation Graph. It stores topics and services registration information for ROS nodes. Nodes communicate with the Master to report their registration information. As these nodes communicate with the Master, they can receive information about other registered nodes and make connections as appropriate. The Master will also make callbacks to these nodes when this registration information changes, which allows nodes to dynamically create connections as new nodes are run.

Nodes connect to other nodes directly; the Master only provides lookup information, much like a DNS server. Nodes that subscribe to a topic will request connections from nodes that publish that topic, and will establish that connection over an agreed upon connection protocol. The most common protocol used in a ROS is called TCPROS, which uses standard TCP/IP sockets.

ROS的特殊性主要体现在消息通讯层,而不是更深的层次。端对端的连接和配置利用XML-RPC机制进行实现,XML-RPC也包含了大多数主要语言的合理实现描述。我们希望ROS能够利用各种语言实现的更加自然,更符合各种语言的语法约定,而不是基于C语言给各种其他语言提供实现接口。然而,在某些情况下利用已经存在的库封装后支持更多新的语言是很方便的,比如Octave的客户端就是通过C++的封装库进行实现的。

文件系统级(ROS Filesystem Level)

ROS中有无数的节点、消息、服务、工具和库文件,需要有效的结构去管理这些代码。在ROS的文件系统级,有以下几个重要概念:

Packages: Packages are the main unit for organizing software in ROS. A package may contain ROS runtime processes (nodes), a ROS-dependent library, datasets, configuration files, or anything else that is usefully organized together. Packages are the most atomic build item and release item in ROS. Meaning that the most granular thing you can build and release is a package.

Metapackages: Metapackages are specialized Packages which only serve to represent a group of related other packages. Most commonly metapackages are used as a backwards compatible place holder for converted rosbuild Stacks.

Package Manifests: Manifests (package.xml) provide metadata about a package, including its name, version, description, license information, dependencies, and other meta information like exported packages. The package.xml package manifest is defined in REP-0127.

Repositories: A collection of packages which share a common VCS system. Packages which share a VCS share the same version and can be released together using the catkin release automation tool bloom. Often these repositories will map to converted rosbuild Stacks. Repositories can also contain only one package.

Message (msg) types: Message descriptions, stored in my_package/msg/MyMessageType.msg, define the data structures for messages sent in ROS.

Service (srv) types: Service descriptions, stored in my_package/srv/MyServiceType.srv, define the request and response data structures for services in ROS.

社区级(ROS Community Level)

ROS的社区级概念是ROS网络上进行代码发布的一种表现形式。结构如下图所示:

技术分享图片

代码库的联合系统。使得协作亦能被分发。这种从文件系统级别到社区一级的设计让独立地发展和实施工作成为可能。正是因为这种分布式的结构,似的ROS迅速发展,软件仓库中包的数量指数级增加。

更多阅读:《ROS: Higher-Level Concepts

技术实现

from:《ROS: Technical Overview

 

ros机器人操作系统:概述

ROS是RobotOperatingSystem的缩写,通常称为“机器人操作系统”。但它并不是一个真正的操作系统,而是一个面向机器人的开源的元操作系统(meta-operatingsystem),提供类似传统操作系统的诸多功能:硬件抽象... 查看详情

ros系统玩转自主移动机器人--概述

一、综述  从本博文开始将开源一个基于ROS系统的自主移动机器人项目,该项目基于一个差动轮机器人平台展开,机器人的设计效果图和实物图如下图1所示。   图1设计图和实物图   所有涉及该机器人的设计... 查看详情

在ros中开始自主机器人仿真-1概述

建立自主机器人是很难的,特别是在刚开始的时候.ROS仿真有助于帮助我们从宏观上对机器人系统进行把握,帮助我们学习如何可以让机器人学会自己去适应环境.明白机器人从测量和激光数据采集到转变为电机运动的过程.机器人如... 查看详情

ros2极简总结-nav2-概述(下)恢复器(代码片段)

恢复器概述 RecoveryOverview注意最右侧黄色部分,具体如下。 插件 PluginsBackUp备份Spin旋转Wait等待恢复服务器RecoveryServer定义机器人可以执行的恢复操作。[nav2_costmap_2d]清除代价地图[nav2_recoveries]旋转-按给定角度原地旋转备份-... 查看详情

ros2极简总结-nav2-概述(中)控制器(代码片段)

...功能包Nav2的规划部分,本节为控制部分:控制器概述  Controller注意黄色部分,具体看下图。 插件 Plugins控制器过程检查目标检查 控制器服务器 ControllerServer[nav2_controller_server]输入:全局路径,代价地图输... 查看详情

ros2极简总结-nav2-概述(上)规划器(代码片段)

meta-package:元功能包(或综合功能包)为一系列功能包的组合。Navigation2是一个元功能包,它使移动平台能够到达预定目标。加载、服务和存储地图([nav2_map_server])在地图上定位机器人([nav2_amcl])围绕障碍物规划从A... 查看详情

ros运行管理---launch文件

文章目录1.launch文件概述1.1luanch文件概念1.2luanch文件作用2.launch文件启动示例3.launch文件语法1.launch文件概述1.1luanch文件概念launch文件是一个XML格式的文件,可以启动本地和远程的多个节点,还可以在参数服务器中设置参数... 查看详情

ros使用详解(代码片段)

文章目录ros概述ros使用winbox登录ros关机重启ros修改路由器名ros恢复出厂设置ros修改管理员账号密码及限制登录IPros备份还原ros使用pppor拨号ros的nat,也叫伪装ros静态ARP绑定ros端口映射ros配置静态路由ros概述软路由是指利用台式... 查看详情

ros学习之package.xml

 目录概述格式2(推荐)基本结构所需标签依赖关系Metapackages附加标签格式1(遗产)基本结构所需标签构建,运行和测试依赖关系Metapackages附加标签概述该软件包清单是一个XML文件名为package.xml中必须包括与任何兼容包的根... 查看详情

ros学习笔记三(理解ros节点)

...软件包例子:sudoapt-getinstallros-indigo-ros-tutorialsROS图形概念概述nodes:节点,一个节点即为一个可执行文件,可以通过ROS和其他节点进行通信;messages:消息,当订阅或者发布一个topic时使用的数据类型;topics:话题,节点可以发布... 查看详情

ros2日文新书-2021-07

...章简介2.机器人环境与ROS22-1机器人周围的环境与发展2-2ROS概述和ROS22-3ROS2和发行版第3章ROS2基础知识3-1ROS2安装3-2ROS2的操作第4章ROS2编程4-1编程流程4-2主题定义4-3类型4-4服务4-5参数4-6推出第5章支持ROS2的系统5-1ROS2架构5-2DDS和RTPS5-3通... 查看详情

《slam机器人基础教程》第六章ros入门

第六章ROS入门本章以激光雷达为例讲解ROS基础。本章内容规划:6.1节,ROS概述6.2节,ROS安装及常用指令6.3节,ROS工具6.4节,ROS编程基础6.5节,发布话题和订阅话题6.6节,服务器和客户端6.7节,TF  查看详情

ros_arduino_bridge功能包的使用

写在前面概述关于ROS官方文档系统要求在你的Linux下准备串口安装ros_arduino_bridge功能包集加载ROSArduinoBridge的Sketch固件程序命令测试你的电线连接配置ros_arduino_python节点启动ros_arduino_python节点查看传感器数据发送Twist命令与查看里... 查看详情

ros-ros命令

1.ROS命令概述  ROS可以通过在shell环境中输入命令来进行文件系统的使用、源代码编辑、构建、调试和功能包管理等。为了正确使用ROS,除了基本的Linux命令之外,还需要熟悉ROS专用命令。为了熟练掌握ROS的各种命令,我们对每... 查看详情

ros-ros命令rostopic:ros话题

1.概述  首先我们重新温习一下ROS术语。命令详细说明rostopiclist 显示活动的话题目录 rostopicecho[话题名称] 实时显示指定话题的消息内容 rostopicfind[类型名称]  显示使用指定类型的消息的话题  rostop... 查看详情

ros官网初级教程学习总结(5-9)(代码片段)

...ros.org/cn/ROS/Tutorials。本博客为5-9小节。理解ROS节点图概念概述Nodes:节点,一个节点即为一个可执行文件。节点可以发布或接收一个话题,也可以提供或使用某种服务。Messages:消息,消息是一种ROS数据类型,用于订阅或... 查看详情

ros2极简总结-文件系统(代码片段)

参考文献:ROS2Filesystem概述什么是功能包?工作空间结构如何?如何新建工作空间和功能包?功能包ROS2软件称为功能包。ROS2中最小的构建部件。专用于一种功能,例如:硬件驱动算法可视化工具库...包可... 查看详情

ROS Image 订阅者延迟

...问题描述】:我在收听图像消息时遇到了一些延迟问题。概述:我有一个rosbag以5Hz的频率将图像流式传输到/camera/image_raw。我还有一个image_view节点,用于显示图像以供参考。此image_view以5Hz显示它们。在我的rospy订阅者(使用queue=... 查看详情