前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ROS2编程基础课程--概念

ROS2编程基础课程--概念

作者头像
zhangrelay
发布2019-09-18 15:23:47
7670
发布2019-09-18 15:23:47
举报
文章被收录于专栏:机器人课程与技术

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/ZhangRelay/article/details/100772918

Concepts 概念

See also http://docs.ros2.org/ for ROS 2 high level documentation.

有关ROS 2高级文档,另请参考http://docs.ros2.org/

Overview of ROS 2 Concepts

ROS 2概念综述

Table of Contents 目录

  • Quick Overview of Graph Concepts 图概念的快速概述
  • Nodes 节点
  • Client Libraries 客户端库
  • Discovery 消息发现机制
  • Example: talker-listener 示例:发布器-订阅器

ROS is a middleware based on an anonymous publish/subscribe mechanism that allows for message passing between different ROS processes.

ROS是一种基于匿名发布/订阅机制的中间件,允许在不同的ROS进程之间传递消息。

At the heart of any ROS 2 system is the ROS graph. The ROS graph refers to the network of nodes in a ROS system and the connections between them by which they communicate.

任何ROS 2系统的核心是ROS图。ROS图指的是ROS系统中的节点网络以及它们之间通信的连接。

ROS2 turtlesim Graph

Quick Overview of Graph Concepts

图概念的快速概述

  • Nodes: A node is an entity that uses ROS to communicate with other nodes.

节点:节点是使用ROS与其他节点通信的实体(或实例)。

  • Messages: ROS data type used when subscribing or publishing to a topic.

消息:订阅或发布到主题时ROS使用的数据类型。

  • Topics: Nodes can publish messages to a topic as well as subscribe to a topic to receive messages.

主题:节点可以将消息发布到主题,也可以订阅主题以接收消息。

  • Discovery: The automatic process through which nodes determine how to talk to each other.

发现:节点确定如何相互通信的自动过程。

Nodes 节点

A node is a participant in the ROS graph. ROS nodes use a ROS client library to communicate with other nodes. Nodes can publish or subscribe to a Topic. Nodes can also provide or use a Service. There are configurable Parameters associated with a node. Connections between nodes are established through a distributed discovery process. Nodes may be located in the same process, in different processes, or on different machines. These concepts will be described in more detail in the sections that follow.

节点是ROS图中的参与者。ROS节点使用ROS客户端库与其他节点通信。节点可以发布或订阅主题。节点还可以提供或使用服务。可以对节点相关联的参数进行配置。节点之间的连接是通过分布式发现过程建立的。节点可以位于相同的进程中,也可以位于不同的进程中,还可以位于不同的机器上。这些概念将在以下部分中更详细地介绍说明。

Client Libraries 客户端库

ROS client libraries allow nodes written in different programming languages to communicate. There is a core ROS client library (RCL) that implements common functionality needed for the ROS APIs of different languages. This makes it so that language-specific client libraries are easier to write and that they have more consistent behavior.

ROS客户端库支持不同编程语言编写的节点进行通信。一个核心的ROS客户端库(ROS client library, RCL)实现了不同语言ROS API所需的通用功能。这使得特定语言的客户端库更易于编写,并且它们具有更一致的行为。

The following client libraries are maintained by the ROS 2 team:

以下客户端库由ROS 2团队维护:

  • rclcpp = C++ client library

rclcpp = C ++客户端库

  • rclpy = Python client library

rclpy = Python客户端库

Additionally, other client libraries have been developed by the ROS community. See the ROS 2 Client Libraries article for more details.

此外,ROS社区还开发了其他客户端库。有关这方面内容的更多详细信息,请参考ROS 2客户端库文章。

Discovery 消息发现机制

Discovery of nodes happens automatically through the underlying middleware of ROS 2. It can be summarized as follows: 节点的发现通过ROS 2的底层中间件自动实现完成。可以总结如下:

  1. When a node is started, it advertises its presence to other nodes on the network with the same ROS domain (set with the ROS_DOMAIN_ID environment variable). Nodes respond to this advertisement with information about themselves so that the appropriate connections can be made and the nodes can communicate.

启动节点时,它会将其存在通告给具有相同ROS域的网络上的其他节点(使用ROS_DOMAIN_ID环境变量 设置ROS域)。节点使用有关自身的信息响应此通告,以便可以进行适当的连接并且节点可以进行通信。

  1. Nodes periodically advertise their presence so that connections can be made with new-found entities, even after the initial discovery period.

节点定期通告其存在,以便即使在初始发现期之后也可以与新发现的实体建立连接。

  1. Nodes advertise to other nodes when they go offline.

节点在离线时通告其他节点。

Nodes will only establish connections with other nodes if they have compatible Quality of Service settings.

只有节点具有兼容的服务质量设置,它们之间才可以建立连接。

Example: talker-listener 例如:发布器-订阅器

In one terminal, start a node (written in C++) that will publish messages on a topic.

在一个终端中,启动将在主题上发布消息的节点(用C ++编写)。

ros2 run demo_nodes_cpp talker

In another terminal, start a second node (written in Python) that will subscribe to messages on the same topic.

在另一个终端中,启动第二个节点(用Python编写),该节点将订阅同一主题的消息。

ros2 run demo_nodes_py listener

You should see that these nodes discover each other automatically, and begin to exchange messages.

如果运行正常,应该看到这些节点自动发现彼此,并开始交换消息。

多试几组案例,熟练掌握ros2 run和rqt的基本使用。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019年09月12日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Concepts 概念
  • Overview of ROS 2 Concepts
  • ROS 2概念综述
    • Quick Overview of Graph Concepts
      • 图概念的快速概述
        • Nodes 节点
          • Client Libraries 客户端库
            • Discovery 消息发现机制
              • Example: talker-listener 例如:发布器-订阅器
              相关产品与服务
              消息队列 TDMQ
              消息队列 TDMQ (Tencent Distributed Message Queue)是腾讯基于 Apache Pulsar 自研的一个云原生消息中间件系列,其中包含兼容Pulsar、RabbitMQ、RocketMQ 等协议的消息队列子产品,得益于其底层计算与存储分离的架构,TDMQ 具备良好的弹性伸缩以及故障恢复能力。
              领券
              问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档