Fast DDS框架介绍


我们承担ROS,FastDDS,C++,cmake等技术的项目开发和专业指导和培训,有10年+相关工作经验,质量有保证,如有需要请私信联系。

DDS全称Data Distribution Service,是一个DCPS(data-centric)数据中心的发布-订阅模型中间件,是一种实时通信协议,由面向对象的系统协会(OMG)发布的,主要用于实时系统的数据通信。

代码结构

  • foonathan_memory_vendor:是一个为eProsima Fast DDS提供内存管理功能的项目。这个软件包包含了foonathan_memory这个库的一个版本,代码源自foonathan/memory项目(git clone https://github.com/foonathan/memory.git)。foonathan_memory是一个C++内存管理库,提供了各种内存分配器和内存池等智能内存管理机制。在Fast DDS中,这个库用于提供低级的内存管理,进一步提高DDS通信的性能和效率。

  • fastcdr:用于数据序列化的库

  • fastrtps:Fast DDS的核心代码

  • fastddsgen:将IDL文件生成代码的工具

架构

由于它是一种以数据为中心的发布-订阅(DCPS)模型,因此在其实现中定义了三个关键的应用实体:

  • 发布实体,定义了信息生成对象及其属性;
  • 订阅实体,定义了信息消费对象及其属性;
  • 配置实体,定义了作为主题传输的信息类型,并创建了发布者和订阅者及其服务质量(QoS)属性,确保了上述实体的正确性能。
    在这里插入图片描述
  1. 应用层:应用层主要通过Fast DDS的API进行业务通信
  2. DDS层:域内通过topic使用pub和sub进行通信
  3. RTPS层:实现RTPS协议进行通信
  4. Transport层:通过不同的transport协议如UDP,SHM等进行通信

在这里插入图片描述

DDS层

  • Domain:DDS域,包含一个或多个应用程序。DDS的domain通过一个正数(DomainID)来标识,这个值必须是开发者在创建DomainParticipants的时候指定。不同的Domain之间不能互相通信,所以,可以创建多个通信渠道。这用在涉及多个DDS应用程序的场景中,它们各自的DomainParticipant在同一个domain中互相通信,但这些应用程序之间不会互相干扰。
  • DomainParticipant:domain中每个单独的参与者叫做DomainParticipant。DomainParticipant也是一个实体,作为其他实体的容器,可以创建和配置这些实体,如Publisher,Subscriber,Topic等。

【 图片 】https://fast-dds.docs.eprosima.com/en/latest/fastdds/getting_started/definitions.html

  • Publisher:数据的发布者实体。用于创建和配置一个或多个DataWriter,其中DataWriter用于真正的数据发送
  • DataWriter
  • DataWriterHistory
  • Subscriber:接收发布者发布的数据的DCPS实体。用于创建和配置一个或多个DataReader,其中DataReader用于实际负责接收数据的实体。
  • DataReader
  • DataReaderHistory
  • Topic:绑定于发布者和接收者的实体,是Publisher和Subscriber之间的通信桥梁。数据发布者会使用特定Topic发布数据,数据订阅者则订阅他们感兴趣的Topic以接收相关数据。Fast DDS根据这些Topic来进行消息的路由和分发。每个Topic都有一个关联的数据类型和唯一的名称,只有数据类型匹配的发布者和订阅者才能进行通信。这确保了系统的正确性,因为只有正确类型的数据才会被发送和接收。Topic还可以设定Quality of Service (QoS)策略,这些策略决定发布和订阅者之间数据交互的行为,例如数据的可靠性、持久性等。

RTPS层

As mentioned above, the RTPS protocol in Fast DDS allows the abstraction of DDS application entities from the transport layer. According to the graph shown above, the RTPS layer has four main Entities.

RTPSDomain. It is the extension of the DDS domain to the RTPS protocol.

RTPSParticipant. Entity containing other RTPS entities. It allows the configuration and creation of the entities it contains.

RTPSWriter. The source of the messages. It reads the changes written in the DataWriterHistory and transmits them to all the RTPSReaders to which it has previously matched.

RTPSReader. Receiving entity of the messages. It writes the changes reported by the RTPSWriter into the DataReaderHistory.

For a more detailed explanation of each entity, their attributes, and their listeners, please refer to RTPS Layer section.

RTPS协议

Real-Time Publish Subscribe (RTPS) protocol,是为了支持DDS应用程序而开发的,是一种在best-effort的传输方式如UDP/IP上的发布-订阅通信中间件,另外支持TCP和shared memory。也支持单播和广播通信。
RTPS继承自DDS,定义了一个独立的通信平面。多个域(RTPS Domain)可以同时存在,一个RTPS domain中包含任意数量的RTPSParticipants。为了收发数据,RTPSParticipants使用它们的端点:Endpoints:RTPSWriter用于发送数据,RTPSReader用于接收数据。

【 图片 】https://fast-dds.docs.eprosima.com/en/latest/fastdds/getting_started/definitions.html

通信单位为change,changae每次都会被注册到叫history的cache中。默认配置下,dds通过RTPSWriter发布一条数据的步骤如下:

  • 数据添加到change中
  • change添加到history中
  • RTPSWriter发送change到所有已经匹配的RTPSReader中
  • RTPSReader接收到数据后放到它的history中
    当然可以通过qos配置来修改行为。

一个DomainParticipant启动的线程

NameTypeCardinalityDescription
EventGeneral每个DomainParticipant一个处理周期性事件和触发的时间事件
Discovery Server EventGeneral每个DomainParticipant只有配置了Discovery Server SERVER时有一个用于从Discovery Server数据库中同步数据
Asynchronous Writer
Datasharing Listener仅限于Datasharing被使用监听线程处理从Datasharing收到的消息
RecptionUDP/TCP/SHM一个port一个线程监听线程处理UDP/TCP/SHM消息
Keep AliveTCP只有使用了TCP且保活周期大于0时,一个port会起一个线程用于TCP连接的keep Alive
LoggingSHM
WatchdogSHM一个
General Logging
Security Logging
Watchdog
Callback

Profile
默认环境变量为 DEFAULT_FASTRTPS_ENV_VARIABLE中读取qos xml配置文件。

IDL

Fast DDS中使用的IDL为OMG IDL

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值