ROS 101
https://www.clearpathrobotics.com/blog/2014/01/how-to-guide-ros-101/
什么是ROS
ROS(robot operating system)是一个用于PC控制机器人组件的开源系统.一个ROS系统包含多个独立nodes,nodes直接通过pub/sub(发布/订阅)模式通信.比如传感器可以实现为一个传感器Node,传感器node采集数据,数据可以被其他node,比如导航node,路径查找node等等消费.
Why ROS
ROS的node不一定非得在一个computer上,甚至是不需要在同种结构的设备上.比如你可以用一个硬件设备采集数据,pub msg,在笔记本电脑上订阅这个msg,在手机上收取msg。这使得ROS具有高度灵活性.而且ROS是开源的.
基础概念
- ROS Master
- ROS Node

每一个node都要向master注册,master类似于消息中间件.node之间通过向master注册进行通信.node之间通过pub/sub模式通信.pub/sub 一个topic.类似于zmq里的pub/sub topic概念.

举个例子:
camera node负责和cmaera交互,image process node负责图片处理,image display node负责图片展示。在开始的时候,每一个node都要注册到master,
camera node注册的时候告诉master,他将要发布topic为image_data的消息,其余node注册的时候告诉master,想要订阅topic为image_data的数据.这样,当camera node收到来自camera采集的数据时,它就会发送image_data数据到image process node和image display node。

- Services
上面的例子中,process node是被动接收camera数据的,如果process node想要主动获取数据呢?
process node向master注册一个specific service。然后process node就可以向camera node发一个request,请求image_data,然后camera node控制camera采集数据,reply给process node。
http://wiki.ros.org/ROS/Concepts
Concepts
- Filesystem level
提供一些基础层面,硬件层面的操作 - Computation Graph level
- Community level
Filesystem level
- 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.
Computation Graph level
Node
可以理解为一个程序.比如node1控制激光测距仪,node2控制车轮,nodes控制路径规划等等.Master
类似dsn。各个node都注册过来,提供查找lookup功能. node之间是直接通信的,并不经过master.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.
- Parameter Server
Messages
just a data structureNodes 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
pub/sub一个topic. 为了解耦,puber不需要知道有没有suber,puber只管produce这个topic的msg.suber不需要知道有没有puber,suber只管消费这个topic的msgMessages 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
通过service完成request/reply. pub/sub中消息的消费是被动的,一个Node想要主动去向另一个node要消息,就得通过service完成request/reply. 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.
ROS Master在ROS计算图中扮演nameservice角色,存储topics和services注册信息.当注册信息改变,相应node就收到信息,类似zk里对某些node的watch机制.
names在ROS里作用巨大.
Names have a very important role in ROS: nodes, topics, services, and parameters all have names. Every ROS client library supports command-line remapping of names, which means a compiled program can be reconfigured at runtime to operate in a different Computation Graph topology.
比如,刚开始我们有个激光传感器node,在topic:scan上pub消息.相应的,suber在scan上消费消息. 后来我们想换个激光传感器,我们只需要重配置我们的系统.把names remap就行.比如新的激光传感器采集到的数据,我们定义一个新topic:scan_base,rename原来的scan->scan_base.我们再起一个激光传感器node,这个时候他就在scan_base上发消息了.

Names
Before we describe names further, here are some example names:
- / (the global namespace)
- /foo
- /stanford/robot/name
/wg/node1
每一个resource都define在一个namespace下,多个resources可能定义在同一个namespace下.resource可以在自己的namespace下create一个resource.resource可以访问自己的namespace下的resource或者更上层namespace下的resource.Graph Resource Names are an important mechanism in ROS for providing encapsulation. Each resource is defined within a namespace, which it may share with many other resources. In general, resources can create resources within their namespace and they can access resources within or above their own namespace
There are four types of Graph Resource Names in ROS: base, relative, global, and private, which have the following syntax:
- base
- relative/name
- /global/name
- ~private/name
解析规则如下

ROS 101的更多相关文章
- Learning Roadmap of Robotic Operating System (ROS)
ROS Wiki: http://wiki.ros.org/ Robots Using ROS Textbooks: A Gentle Introduction to ROS Learning ROS ...
- windows系统下安装和使用ROS的解决方案 (1 win_ros 2 rosserial_windows)
具体请参考官网: 1 http://wiki.ros.org/win_ros 2 https://github.com/ros-windows/win_ros 3 http://wiki.ros ...
- ROS机器人操作系统在线练习
废话不说,先看图吧: 1. ROS in 5 Days Entering ROS 2. ROS Navigation in 5 Days Mastering ROS 3. ROS Autonomous ...
- ROS(indigo) 安装和使用更新版本的Gazebo----3,4,5,6,7 附:中国机器人大赛中型组仿真比赛说明
ROS(indigo) 安装和使用更新版本的Gazebo,本文以7为例. Gazebo7支持更多新的功能,如果使用下面命令安装ROS(indigo): ~$ sudo apt-get install ...
- ROS(indigo) 用于机器人控制的图形化编程工具--code_it robot_blockly
0 简介: 编程语言有汇编,高级语言,解释语言等,现在图形化编程也越来越流行.图形化编程简单易学.8年前,微软推出了VPL用于机器人程序设计,如Python和JavaScript都可以用图形化框图实现 ...
- ROS常用三維機器人仿真工具Gazebo教程匯總
參考網址: 1. http://gazebosim.org/tutorials 2. http://gazebosim.org/tutorials/browse Gazebo Tutorials Ga ...
- ROS kinetic语音识别
1.安装依赖 1.1安装ros-kinetic-audio-common sudo apt-get install ros-kinetic-audio-common 1.2 安装libasound2 ...
- ROS下利用realsense采集RGBD图像合成点云
摘要:在ROS kinetic下,利用realsense D435深度相机采集校准的RGBD图片,合成点云,在rviz中查看点云,最后保存成pcd文件. 一. 各种bug 代码编译成功后,打开rviz ...
- Linux学习和ROS安装(1)
参考文档:https://www.cnblogs.com/liu-fa/p/5779206.html#undefined 系统环境:Window7 64bit+VMware11 ubuntu-gnom ...
随机推荐
- error C2371: 'IServiceProvider' : redefinition; different basic types
需要将#include <windows.h>放到using namespace System;前面. #include <windows.h>using namespace ...
- php基础-mysqli
基本八个步骤 //连接数据库 $link = mysqli_connect('localhost', 'root', ''); //判断是否连接成功 if (!$link) { exit('数据库连接 ...
- zuoye
a=input('请输入一个数字:') b=input('请再输入一个数字') sum2=int(a)+int(b) print('两个数字的和是:{}'.format(sum2)) a=input( ...
- 【CSS 第六天】三种简历
1.盒子模型 2.三种简历 利用float和CSS制作内容一致,但是样式不一致的三种简历. 代码 3.效果 style-1 3.2效果2 效果三
- java 23种设计模式 深入理解【转】
以下是学习过程中查询的资料,别人总结的资料,比较容易理解(站在各位巨人的肩膀上,望博主勿究) 创建型抽象工厂模式 http://www.cnblogs.com/java-my-life/archive ...
- 多媒体文件格式(四):TS 格式
一.TS 格式标准介绍 TS是一种音视频封装格式,全称为MPEG2-TS.其中TS即"Transport Stream"的缩写. 先简要介绍一下什么是MPEG2-TS: DVD的音 ...
- [Swift]LeetCode290. 单词模式 | Word Pattern
Given a pattern and a string str, find if str follows the same pattern. Here follow means a full mat ...
- [Swift]LeetCode782. 变为棋盘 | Transform to Chessboard
An N x N board contains only 0s and 1s. In each move, you can swap any 2 rows with each other, or an ...
- Linux 实现服务器之间时间同步
在主服务器上安装NTP时间同步服务器 yum -y install ntp vim /etc/ntp.conf 手动添加两行 server 127.127.1.0 fudge 127.127.1.0 ...
- 微信小程序day01-JSON配置
微信小程序 小程序代码构成 JSON配置WXML模板WXSS样式JS逻辑 1.JSON配置 小程序配置 app.json app.json: 是当前小程序的全局配置,包括了小程序的所有页面路径.界面表 ...