机器人开发--Fast DDS

news2024/7/6 19:42:15

机器人开发--Fast DDS

  • 1 介绍
    • 1.1 DDS概述
    • 1.2 Fast DDS 介绍
    • 域与域通信
    • 跨网络通信
  • 2 内容
  • 要素与组件介绍
    • IDL (Interface Definition Language)
    • eProsima Fast DDS-Gen
  • 3 安装步骤
    • 3.1 安装选择(linux+源码+cmake+c++)
    • 3.2 模块介绍
    • 3.3 环境
      • 工具
      • 依赖
    • 3.4 cmake 安装
      • 创建安装文件夹
      • 克隆依赖并编译(Foonathan memory + Fast CDR)
      • 安装 eProsima Fast DDS
      • 安装 Fast DDS-Gen(生成IDL文件的java应用)
    • 3.5 安装目录 & 环境变量
  • 4 应用
    • 4.1 IDL
    • 4.2 使用fastddsgen 生成文件
    • 4.3 mkdir build & cmake
    • 4.4 测试
  • 参考

1 介绍

1.1 DDS概述

数据分发服务DDS(DataDistributionService)是OMG对象管理组织在HLA及CORBA等标准的基础上制定的新一代分布式实时通信中间件技术规范,DDS采用发布/订阅体系架构,强调以数据为中心,提供丰富的QoS服务质量策略,能保障数据进行实时、高效、灵活地分发,可满足各种分布式实时通信应用需求。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.2 Fast DDS 介绍

  • 开源
  • 是自动驾驶领域比较有影响力的开源DDS
  • 是由RTI原核心团队成员在欧洲创办的eProsima公司推出的FastDDS。
  • FastDDS使用起来比较麻烦,这个时候,用户就需要通过向eProsima支付费用来取得支持。

域与域通信

在这里插入图片描述

跨网络通信

在这里插入图片描述

2 内容

要素与组件介绍

IDL (Interface Definition Language)

要声明结构化数据,必须使用 IDL 格式。IDL (接口定义语言)是一种规范语言,由OMG(对象管理组织)制定,它以与语言无关的方式描述接口,允许不同语言的软件组件之间进行通信。

eProsima Fast DDS-Gen

eProsima Fast DDS-Gen是一个 Java 应用程序,它使用 IDL(接口定义语言)文件中定义的数据类型生成eProsima Fast DDS源代码。
eProsima Fast DDS-Gen生成的源代码使用Fast CDR,这是一个提供数据序列化和编码机制的 C++11 库。因此,正如RTPS 标准中所述,发送数据时,它们会使用相应的通用数据表示 (CDR) 进行序列化和编码。CDR 传输语法是代理间传输的低级表示,从 OMG IDL 数据类型映射到字节流。

eProsima Fast DDS通过两个类定义了 Topic 中交换的数据类型: theTypeSupport和 the TopicDataType。TopicDataType描述发布和订阅之间交换的数据类型,即Topic对应的数据;尽管TypeSupport封装了一个 TopicDataType 的实例,提供注册类型和与发布和订阅交互所需的功能。

3 安装步骤

3.1 安装选择(linux+源码+cmake+c++)

系统选择:

  • linux
  • windows(更麻烦)

安装方式:

  • 源码安装
  • 二进制安装

源码安装工具:

  • colcon(配套 ROS2)
  • cmake

语言:

  • C++
  • Python

3.2 模块介绍

src目录下包含如下几个模块:
foonathan_memory_vendor, an STL compatible C++ memory allocator library.
fastcdr, a C++ library for data serialization according to the CDR standard (Section 10.2.1.2 OMG CDR).
fastrtps, the core library of eProsima Fast DDS library.
fastddsgen, a Java application that generates source code using the data types defined in an IDL file.

3.3 环境

工具

  • CMake
  • g++
  • pip3
  • wget
  • git
sudo apt install cmake g++ python3-pip wget git

依赖

  • Asio and TinyXML2 libraries
  • OpenSSL
  • Libp11 and SoftHSM libraries
  • Gtest [optional]
  • XML validation tool [optional]
# Asio is a cross-platform C++ library for network and low-level I/O programming, which provides a consistent asynchronous model. TinyXML2 is a simple, small and efficient C++ XML parser. Install these libraries using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:
sudo apt install libasio-dev libtinyxml2-dev

# OpenSSL is a robust toolkit for the TLS and SSL protocols and a general-purpose cryptography library. Install OpenSSL using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:
sudo apt install libssl-dev

# Libp11 provides PKCS#11 support for OpenSSL. This is an optional dependency, that is needed only when eprosima Fast DDS is used with security and PKCS#11 URIs.
# Install libp11 using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:
sudo apt install libp11-dev libengine-pkcs11-openssl

# SoftHSM is a software implementation of an HSM (Hardware Security Module). If eProsima Fast DDS tests are activated and libp11 is installed on the system, SoftHSM is additionally required to run tests of PKCS#11 features.
# Install SoftHSM using the package manager of the appropriate Linux distribution. For example, on Ubuntu use the command:
sudo apt install softhsm2

# Note that the softhsm2 package creates a new group called softhsm. In order to grant access to the HSM module a user must belong to this group.
sudo usermod -a -G softhsm <user>
示例:sudo usermod -a -G softhsm $USER

# OpenSSL access HSM and other hardware devices through its engine functionality. In order to set up a new engine the OpenSSL configuration files (usually /etc/ssl/openssl.cnf) must be updated specifying the libp11 and hardware module (here SoftHSM) dynamic libraries location.
# This configuration step can be avoided using p11kit which allows OpenSSL to find PKCS#11 devices on runtime without static configuration. This kit is often available through the Linux distribution package manager. On Ubuntu, for example:
sudo apt install libengine-pkcs11-openssl

# Once installed, to check p11kit is able to find the SoftHSM module use:
p11-kit list-modules

# In order to check if OpenSSL is able to access PKCS#11 engine use:
openssl engine pkcs11 -t

3.4 cmake 安装

创建安装文件夹

Create a Fast-DDS directory where to download and build eProsima Fast DDS and its dependencies:

mkdir ~/Fast-DDS

克隆依赖并编译(Foonathan memory + Fast CDR)

Foonathan memory

cd ~/Fast-DDS
git clone https://github.com/eProsima/foonathan_memory_vendor.git
mkdir foonathan_memory_vendor/build
cd foonathan_memory_vendor/build
cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS/install -DBUILD_SHARED_LIBS=ON
cmake --build . --target install

Fast CDR

cd ~/Fast-DDS
git clone https://github.com/eProsima/Fast-CDR.git
mkdir Fast-CDR/build
cd Fast-CDR/build
cmake .. -DCMAKE_INSTALL_PREFIX=~/Fast-DDS/install
cmake --build . --target install

安装 eProsima Fast DDS

cd ~/Fast-DDS
git clone https://github.com/eProsima/Fast-DDS.git
mkdir Fast-DDS/build
cd Fast-DDS/build
cmake ..  -DCMAKE_INSTALL_PREFIX=~/Fast-DDS/install
cmake --build . --target install

安装 Fast DDS-Gen(生成IDL文件的java应用)

Fast DDS-Gen is a Java application that generates source code using the data types defined in an IDL file.

  • 安装Java JDK
sudo apt install openjdk-11-jdk
  • 源码编译
cd ~/Fast-DDS
git clone --recursive https://github.com/eProsima/Fast-DDS-Gen.git
cd Fast-DDS-Gen
./gradlew assemble
u20@u20:~/Fast-DDS/Fast-DDS-Gen$ sudo ./gradlew assemble
Downloading https://services.gradle.org/distributions/gradle-7.6-bin.zip
...........10%............20%...........30%............40%............50%...........60%............70%............80%...........90%............100%

Welcome to Gradle 7.6!

Here are the highlights of this release:
 - Added support for Java 19.
 - Introduced `--rerun` flag for individual task rerun.
 - Improved dependency block for test suites to be strongly typed.
 - Added a pluggable system for Java toolchains provisioning.

For more details see https://docs.gradle.org/7.6/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

BUILD SUCCESSFUL in 2m 9s
6 actionable tasks: 3 executed, 3 up-to-date
u20@u20:~/Fast-DDS/Fast-DDS-Gen$ 

The Fast-DDS-Gen folder contains the following packages:

    • share/fastddsgen, where the generated Java application is.
    • scripts, containing some user friendly scripts.

3.5 安装目录 & 环境变量

u20@u20:~/Fast-DDS/install/lib$ ls
cmake          libfastcdr.so.1      libfastrtps.so       libfastrtps.so.2.11.0
libfastcdr.so  libfastcdr.so.1.1.0  libfastrtps.so.2.11
u20@u20:~/Fast-DDS/install/bin$ ls
fastdds  fast-discovery-server  fast-discovery-server-1.0.1  ros-discovery
u20@u20:~/Fast-DDS/Fast-DDS-Gen/scripts$ ls
fastddsgen  fastddsgen.bat  fastddsgen.in

vim .bashrc 文件末加入如下路径:

export PATH=$PATH:/home/u20/Fast-DDS/Fast-DDS-Gen/scripts
export PATH=$PATH:/home/u20/Fast-DDS/install/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/u20/Fast-DDS/install/lib

通过“source ~/.bashrc”命令使修改立即生效,或者重开终端窗口。

4 应用

4.1 IDL

以一个helloworld 为例,编写一个idl,helloworld.idl

struct HelloWorld
{
    unsigned long index;
    string message;
};

4.2 使用fastddsgen 生成文件

fastddsgen -example CMake helloworld.idl

生成文件如下:

CMakeLists.txt
helloworld.cxx
helloworld.h
helloworld.idl
helloworldPublisher.cxx
helloworldPublisher.h
helloworldPubSubMain.cxx
helloworldPubSubTypes.cxx
helloworldPubSubTypes.h
helloworldSubscriber.cxx
helloworldSubscriber.h

4.3 mkdir build & cmake

操作命令

mkdir build
cd build
cmake ..
make

生成如下

u20@u20:~/user/build$ ls
CMakeCache.txt  CMakeFiles  cmake_install.cmake  helloworld  libhelloworld_lib.a  Makefile

4.4 测试

  • 终端1:
u20@u20:~/user/build$ ./helloworld publisher
Starting 
HelloWorld DataWriter created.
HelloWorld DataWriter waiting for DataReaders.
DataWriter matched.
Sending sample, count=1, send another sample?(y-yes,n-stop): y
Sending sample, count=2, send another sample?(y-yes,n-stop): y
Sending sample, count=3, send another sample?(y-yes,n-stop): y
Sending sample, count=4, send another sample?(y-yes,n-stop): y
Sending sample, count=5, send another sample?(y-yes,n-stop): y
Sending sample, count=6, send another sample?(y-yes,n-stop): n
Stopping execution 
u20@u20:~/user/build$ 
  • 终端2:
u20@u20:~/user/build$ ./helloworld subscriber
Starting 
Waiting for Data, press Enter to stop the DataReader. 
Subscriber matched.
Sample received, count=1
Sample received, count=2
Sample received, count=3
Sample received, count=4
Sample received, count=5
Sample received, count=6
Subscriber unmatched.

Shutting down the Subscriber.
u20@u20:~/user/build$

参考

1、官方–FastDDS文档
2、机器人开发–DDS数据分发服务
3、fastdds router-3.开始
4、FastDDS-源码编译&安装&测试
5、fastdds交叉编译
6、官方–3. Linux installation from sources
7、FastDDS使用、原理和避坑
8、ubuntu查看和修改PATH环境变量的方法
9、Ubuntu/CentOS设置LD_LIBRARY_PATH环境变量免安装使用动态库

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/664702.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

shardingsphere第四课shardingsphere-proxy的使用

一、为什么要有服务端分库分表&#xff1f; 配合 ORM 框架使用更友好 当使用 ShardingSphere-JDBC 时,需要在代码中直接编写分库分表的逻辑,如果使用 ORM 框架,会产生冲突。ShardingSphere-Proxy 作为服务端中间件,可以无缝对接 ORM 框架。 对 DBA 更加友好 ShardingSphere-Pr…

第八章 time模块

1. time模块介绍 time 模块提供了各种时间相关的函数&#xff0c;该模块中对于时间表示的格式有如下三种&#xff1a; 时间戳&#xff08;timestamp&#xff09;&#xff1a;时间戳表示的是从1970 年1 月1 日00:00:00 开始按秒计算的偏移量。 时间元组&#xff08;struct_tim…

每日复盘|6月19日

7:00-7:20 起床洗漱到教室 7:30-8:15 乐词 8:15-9:05 听力con*1 lec*1 9:05-10:47 听力真题 11:00-11:50 考研英语阅读真题 12:00-12:30 午饭🥣+桃子🍑 12:30-13:30 不背单词 13:30-14:00 午睡 14:00-…

SpringMVC07:Ajax研究

目录 一、项目启动时报错点 二、简介 三、伪造Ajax 四、jQuery.ajax 五、Springmvc实现一个list集合显示前端 六、注册提示效果 一、项目启动时报错点 6月 16, 2023 10:34:37 上午 org.apache.catalina.core.StandardContext filterStart 严重: 启动过滤器异常 java.lan…

6-JMM

目录 1.主内存与工作内存 2.内存间交互操作 Java内存模型的三大特性&#xff1a; happens-before原则&#xff08;先行发生原则&#xff09;&#xff1a; 3.volatile型变量的特殊规则 ①保证此变量对所有线程的可见性 ②使用volatile变量的语义是禁止指令重排序 JVM定义…

node.js+vue+express企业客户关系管理系统mysql

开发语言 node.js 框架&#xff1a;Express 前端:Vue.js 数据库&#xff1a;mysql 数据库工具&#xff1a;Navicat 开发软件&#xff1a;VScode 随着科学技术的飞速发展&#xff0c;社会的方方面面、各行各业都在努力与现代的先进技术接轨&#xff0c;通过科技手段来提高自身…

21.模糊神经网络预测水质评价(附matlab程序)

1.简述 学习目标&#xff1a;模糊神经网络预测水质评价——重风水厂、 高升水厂、秦玺水厂 采用模糊神经网络预测这三个水厂的水质&#xff0c;并进行对比 模糊神经网络(Fuzzy Neural Network, FNN) 背景 系统复杂度的增加&#xff0c;人工智能深度化发展 模糊数学创始人L. A…

io.netty学习(四)ChannelHandler

目录 前言 正文 ChannelHandler ChannelInboundHandler ChannelOutboundHandler ChannelDuplexHandler 总结 前言 先简略了解一下ChannelPipeline和ChannelHandler的概念。 想象一个流水线车间。当组件从流水线头部进入&#xff0c;穿越流水线&#xff0c;流水线上的工…

第四章 组合逻辑电路--数电(期末复习笔记)

第四章 组合逻辑电路 本章重点&#xff1a; 1. 组合逻辑电路的分析与设计方法 2. 常用组合逻辑模块的使用 4.1 概述 4.11 组合逻辑电路 任一时刻的输出仅取决于该时刻的输入&#xff0c;与电路原来的状态无关。4.12 时序逻辑电路 任一时刻的输出不仅取决于现时的输入&am…

电容的基本工作原理

目录 电容器的发展历程现象发现第一个存储电荷的元器件&#xff1a;莱顿瓶真正出名的时刻 为什么电容器的容量单位称为法拉&#xff1f;电容器和电容的区别电容的组成电介质与电解质对电容的影响电容是如何工作的通交流阻直流阻直流通交流 电容器的单位电容的容抗电容常见的种类…

Idea Mybatis插件:提高CRUD效率

mybatis-sql-viewer插件主要提供能力&#xff1a;将mybatis xml转成真实SQL语句、参数mock、SQL规范检查、SQL索引检查、SQL运行、SQL压测及Mybatis SQL语句扫描。 1. 简介 虽然写了很久的CRUD&#xff0c;但是依旧觉得写好CRUD是一件非常难且麻烦的事情&#xff0c;以下的情…

chatgpt赋能Python-python找出不同部分

介绍 在SEO&#xff08;Search Engine Optimization&#xff09;领域&#xff0c;比较常见的问题之一是如何快速有效地查找出两段文本的不同部分。这对于优化网站内容或对比竞争对手的网站内容都非常有用。Python作为一种强大的编程语言&#xff0c;其特性和库使得这种任务变得…

神经网络入门①多层感知器如何解决异或问题?

文章目录 1. 多层感知器2. BP算法参考文献 1. 多层感知器 感知机&#xff08;perceptron&#xff09;早在20世纪50年代就提出来了1&#xff0c;但直到近几年深度学习的崛起&#xff0c;神经网络才再次走入大众的视野&#xff0c;并且成为了当下最热门的研究方向之一。 一个单层…

MybatisPlus的save方法

当我前端传递的是一个整合的数据模型Dto,需要同时插入俩张表,并且其中一张表的属性需要得到另一张表的id,如何实现呢?这个时候MP封装好的插入方法:save就起了很好的作用 public R<String> SaveNewDish(DishDto dishdto) { // 1. 保存菜品基本信息log.info("前…

MySQL优化--覆盖索引,超大分页查询

目录 覆盖索引 MYSQL超大分页处理 面试回答 大纲 回答 覆盖索引 覆盖索引是指查询使用了索引&#xff0c;并且需要返回的列&#xff0c;在该索引中已经全部能够找到 。 MYSQL超大分页处理 在数据量比较大时&#xff0c;如果进行limit分页查询&#xff0c;在查询时&#…

一步一步教你如何使用MMSelfSup框架【1】

介绍 任务介绍 自监督学习(Self-supervised learning, SSL)是一种极具潜力的学习范式&#xff0c;它旨在使用海量的无标注数据来进行表征学习。在SSL中&#xff0c;我们通过构造合理的预训练任务&#xff08;可自动生成标注&#xff0c;即自监督&#xff09;来进行模型的训练…

C#探索之路(8):初探.Net中官方文档OpCode的格式

C#探索之路(8)&#xff1a;初探.Net中官方文档OpCode的格式 文章目录 C#探索之路(8)&#xff1a;初探.Net中官方文档OpCode的格式1 前提2 疑惑1&#xff1a;Opcode格式是什么&#xff1f;3 答疑1&#xff1a;4 验证方式&#xff1a;5 总结 1 前提 最近在尝试了解学习这个OpCod…

使用ChatGPT最新版实现批量写作,打造丰富多彩的聚合文章

随着人工智能的迅猛发展&#xff0c;ChatGPT最新版作为一种自然语言处理模型&#xff0c;可以为我们提供强大的文本生成能力。在这篇文章中&#xff0c;我们将探讨如何利用ChatGPT最新版来实现批量写作&#xff0c;从而打造丰富多彩的聚合文章。 一、ChatGPT最新版简介 Chat…

使用mpi并行技术实现快排Qsort()

快排基本原理&#xff1a; 快速排序可以说是最为常见的排序算法&#xff0c;冒泡排序时间复杂度达到了O&#xff08;N2&#xff09;&#xff0c;而桶排序容易造成浪费空间。快排&#xff08;Quicksort&#xff09;就成为了不错的选择。 1、原理&#xff1a;快排需要找一个数作…

基于 JavaScript 中的 Date 类型实现指定日期和天数的加减运算

文章目录 Intro基本方法构造方法--如何初始化一个Date对象&#xff1f;Date 对象的天数加减法 【工具方法封装】最后 Intro 刚才突然想到&#xff0c;我还有多久就要过27岁的生日了呢。 年近三十&#xff0c;一事无成。 以下基于 JavaScript 中的 Date 对象封装一些方法。 基…