参考:古月居《ROS探索总结》《ROS·wiki: Introduction》node
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:app
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.less
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: 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处理数据的一种点对点的网络形式。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中有无数的节点、消息、服务、工具和库文件,须要有效的结构去管理这些代码。在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的社区级概念是ROS网络上进行代码发布的一种表现形式。结构以下图所示:
代码库的联合系统。使得协做亦能被分发。这种从文件系统级别到社区一级的设计让独立地发展和实施工做成为可能。正是由于这种分布式的结构,似的ROS迅速发展,软件仓库中包的数量指数级增长。
更多阅读:《ROS: Higher-Level Concepts》
from:《ROS: Technical Overview》