0.汇总
官网推荐直接使用choco对相关的依赖进行安装,比如asio,TinyXML2,openssl,然后通过源码的方式安装fastdds。
这里我不想用choco,尝试使用源码的方式安装。
gtest和xml是可选的项,安装待定。 openssl下还有两个Libp11和SoftHSM 只有在启用安全功能才能使用。
asio的使用,貌似是直接使用库就可以。 其他的库需要依次进行编译然后按目录链接。
1.下载相关fastdds源码
首先是下载相关的代码:
#下载fastdds源码$gitclone https://github.com/eProsima/Fast-DDS.git Cloning into'Fast-DDS'... remote: Enumerating objects:180277, done. remote: Counting objects:100%(802/802), done. remote: Compressing objects:100%(278/278), done. remote: Total180277(delta666), reused524(delta524), pack-reused179475(from2)Receiving objects:100%(180277/180277),138.68MiB|752.00KiB/s, done. Resolving deltas:100%(126166/126166), done.#跳转到对应目录下$cdFast-DDS/#这里通过git submodule获取到依赖的相关第三方库$gitsubmodule update --init Submodule'thirdparty/android-ifaddrs'(https://github.com/michalsrb/android-ifaddrs.git)registeredforpath'thirdparty/android-ifaddrs'Submodule'thirdparty/asio'(https://github.com/chriskohlhoff/asio.git)registeredforpath'thirdparty/asio'Submodule'thirdparty/dds-types-test'(https://github.com/eProsima/dds-types-test)registeredforpath'thirdparty/dds-types-test'Submodule'thirdparty/fastcdr'(https://github.com/eProsima/Fast-CDR.git)registeredforpath'thirdparty/fastcdr'Submodule'thirdparty/tinyxml2'(https://github.com/leethomason/tinyxml2.git)registeredforpath'thirdparty/tinyxml2'Cloning into'F:/fastdds1/Fast-DDS/thirdparty/android-ifaddrs'... Cloning into'F:/fastdds1/Fast-DDS/thirdparty/asio'... Cloning into'F:/fastdds1/Fast-DDS/thirdparty/dds-types-test'... Cloning into'F:/fastdds1/Fast-DDS/thirdparty/fastcdr'... Cloning into'F:/fastdds1/Fast-DDS/thirdparty/tinyxml2'... Submodule path'thirdparty/android-ifaddrs':checked out'7b1ce82817226e481d3cda0a5d06b66ebcc211f8'Submodule path'thirdparty/asio':checked out'ed6aa8a13d51dfc6c00ae453fc9fb7df5d6ea963'Submodule path'thirdparty/dds-types-test':checked out'2d2cfd15e36b323a12889454ffb09f9dc9d3ebe9'Submodule path'thirdparty/fastcdr':checked out'dd535f7b5fe4bc5ff95a2e57e041317ba0a7027d'Submodule path'thirdparty/tinyxml2':checked out'8c8293ba8969a46947606a93ff0cb5a083aab47a'#除了上面的第三方库,还有这两个第三方库$cdthirdparty/#这里还需要依赖两个库 获取到foonathan_memory_vendor的源码$gitclone https://github.com/eProsima/foonathan_memory_vendor.git Cloning into'foonathan_memory_vendor'... remote: Enumerating objects:246, done. remote: Counting objects:100%(120/120), done. remote: Compressing objects:100%(41/41), done. remote: Total246(delta98), reused93(delta79), pack-reused126(from1)Receiving objects:100%(246/246),74.60KiB|103.00KiB/s, done. Resolving deltas:100%(149/149), done.#获取到Fast-CDR的源码 实际上上面git submodule时已经获取到这个库了,这里多此一举,做练习用$gitclone https://github.com/eProsima/Fast-CDR.git Cloning into'Fast-CDR'... remote: Enumerating objects:5736, done. remote: Counting objects:100%(1067/1067), done. remote: Compressing objects:100%(257/257), done. remote: Total5736(delta965), reused812(delta810), pack-reused4669(from2)Receiving objects:100%(5736/5736),4.71MiB|741.00KiB/s, done. Resolving deltas:100%(3098/3098), done.2.使用源码安装相关第三方库,安装fastdds库
依次安装相关的依赖库,安装fastdds库:
#安装foonathan-memory库,指定目录F:\fastdds1\thirdparty\installcdthirdparty/foonathan-memory#进入foonathan-memory目录mkdirbuildcdbuild#构建build目录cmake../ -DFOONATHAN_MEMORY_BUILD_EXAMPLES=OFF -DFOONATHAN_MEMORY_BUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=F:\fastdds1\thirdparty\install#指定安装目录和配置foonathan-memory相关功能cmake --build.--targetinstall--config Release#安装fastcdr库,指定目录F:\fastdds1\thirdparty\installcd../..cdfastcdr#或者这里的Fast-CDRmkdirbuildcdbuild cmake../ -DCMAKE_INSTALL_PREFIX=F:\fastdds1\thirdparty\install cmake --build.--targetinstall--config Release#安装tinyxml2库,指定目录F:\fastdds1\thirdparty\installcd../..cdtinyxml2mkdirbuildcdbuild cmake../ -DCMAKE_INSTALL_PREFIX=F:\fastdds1\thirdparty\install cmake --build.--targetinstall--config Release#这里安装fastdds,指定安装目录为=F:\fastdds1\install,这里注意指定依赖的asio目录和相关第三方库的目录cd../../../../cdFast-DDSmkdirbuildcdbuild cmake../ -DCMAKE_INSTALL_PREFIX=F:\fastdds1\install -DCMAKE_PREFIX_PATH="F:\fastdds1\Fast-DDS\thirdparty\asio\asio;F:\fastdds1\thirdparty\install"-DNO_TLS=ON -DCOMPILE_EXAMPLES=ON#这里安装时有一些报错问题,按需增加参数进行处理:cmake../ -DCMAKE_INSTALL_PREFIX=F:\fastdds1\install -DCMAKE_PREFIX_PATH="F:\fastdds1\Fast-DDS\thirdparty\asio\asio;F:\fastdds1\thirdparty\install"-DNO_TLS=ON -DCOMPILE_EXAMPLES=ON -DCMAKE_CXX_FLAGS="/EHsc /utf-8 /WX-"-DCMAKE_C_FLAGS="/utf-8 /WX-"cmake --build.--targetinstall--config Release这里使用cmake已经构建完成,实际上已经直接在F:\fastdds1\install生成相关的目标文件。
同时可以在build目录中打开对应的vs项目,在vs项目中进行生成。
3.运行相关fastdds下的相关demo
3.1 获取相关依赖,并设置环境变量
从上面的安装逻辑,可以看出安装目录为F:\fastdds1\install,需要了解该目录下的相关目录层级,同时要注意依赖的第三方库的路径,这里我直接把FF:\fastdds1\thirdparty\install\bin目录下的内容拷贝到F:\fastdds1\install\bin下,并设置F:\fastdds1\install\bin到环境变量中。
3.2 运行相关的demo
可以看到在安装目录下有个share目录,相关生成的源码目录下对应的example对应的项目都在该目录下:
这些目录中都是对应的examples对应的exe文件,可以进行执行测试交互:
以hello_world为例,进入到F:\fastdds1\install\share\fastdds\examples\cpp\hello_world\bin目录中:
首先,fastdds中的相关examples都是相同的套路,可以看到,相关参数的描述,以及运行后pub端和sub端的交互是正常的。
3.3 了解这些example的相关作用
经过尝试,所有的example都可以正常进行交互,跟hello_world的运行套路是一样的。
有必要对每个不同的example的侧重点和功能进行了解:
hello_world:最基本的测试demo。
benchmark:通过参数控制发送大小,发送频率,统计发送的吞吐量,延迟等性能指标demo。
configuration:通过参数,通过配置文件控制相关的配置,qos策略等。
content_filter:订阅端过滤的测试demo.
custom_payload_pool:主要演示用户层通过内存池进行调用的相关demo。
delivery_mechanisms:传输机制的演示,通过参数可以控制传输方式,共享内存,udp,tcp等。
discovery_server:集中式发现的测试demo,所有pub sub节点通过一个server节点进行互相发现。
flow_control:通过qos策略控制发送速率,频率等,进行流量控制的demo。
rpc:启动一个rpc的server端,用客户端进行测试rpc的功能,基于dds实现的rpc.
rtps:使用rtps层相关接口直接进行发布订阅交互,而不是基于rtps的上层进行接口调用。
static_edp_discovery:直接配置静态交互,不再通过rtps进行发现。
topic_instances:topic的多个实例的测试demo。
xtypes:演示idl中增加相关属性,关键字的支持demo。
| 目录名 | 你的描述总结 | 补充说明(官方重点) |
|---|---|---|
| hello_world | 最基本的测试demo。 | 入门级 Publisher/Subscriber 通信验证,常用于检查安装是否成功。 |
| benchmark | 通过参数控制发送大小、发送频率,统计发送的吞吐量、延迟等性能指标demo。 | 用于评估吞吐量(throughput)、延迟(latency)等关键性能,支持不同负载测试。 |
| configuration | 通过参数、通过配置文件控制相关的配置、QoS策略等。 | 演示 XML 配置加载、环境变量、代码级 QoS 设置(如可靠性、历史深度)。 |
| content_filter | 订阅端过滤的测试demo。 | 使用 ContentFilteredTopic,根据表达式(如 SQL-like)过滤数据,只接收匹配样本。 |
| custom_payload_pool | 主要演示用户层通过内存池进行调用的相关demo。 | 自定义 PayloadPool 接口,优化大数据或特定内存分配策略(如零拷贝)。 |
| delivery_mechanisms | 传输机制的演示,通过参数可以控制传输方式,共享内存、UDP、TCP等。 | 支持 SHM(共享内存)、UDPv4/UDPv6、TCP、Intra-process、Data-Sharing 等多种传输组合。 |
| discovery_server | 集中式发现的测试demo,所有pub/sub节点通过一个server节点进行分支发现。 | 客户端-服务器发现机制,适合大规模网络、无多播环境或低元流量场景。 |
| flow_control | 通过QoS策略控制发送速率、频率等,进行流量控制的demo。 | 使用 FlowController QoS,限制发送速率,避免网络拥塞或接收端过载。 |
| rpc | 启动一个RPC的server端,用客户端进行测试RPC的功能,基于DDS实现的RPC。 | Request-Reply 模式实现远程过程调用(RPC over DDS),包括服务注册/调用。 |
| rtps | 使用RTPS层相关接口直接进行发布订阅交互,而不是基于RTPS的上层进行接口调用。 | 低级 RTPS API,直接操作 Writer/Reader,适合需要协议级精细控制的场景。 |
| static_edp_discovery | 直接配置静态交互,不再通过RTPS进行发现。 | 静态端点发现(Static EDP),通过 XML 预定义端点信息,消除 EDP 元流量。 |
| topic_instances | Topic的多个实例的测试demo。 | 演示键控 Topic(keyed instances),多个独立实例管理,常与 Shapes Demo 交互。 |
| xtypes | 演示IDL中增加相关属性、关键字的支持demo。 | XTypes 规范全演示:@appendable/@mutable/@final、@optional、@key、继承、动态类型等,支持类型演进兼容。 |
4.安装对应测试demo shapesDemo
4.1 下载源码
#下载源码库$gitclone https://github.com/eProsima/ShapesDemo.git4.2 使用cmake工具编译shapesDemo
注意,这里在使用cmake-gui编译shapeDemo时,有相关的依赖,需要按照对应的cmake路径进行选择,也可以参考上面cmake的编译方式,直接使用路径进行终端上的编译:
4.3 运行demo查看效果
安装后使用对应的vs进行编译后,简单运行测试进行查看:F:\fastdds1\ShapesDemo\build\Release\ShapesDemo.exe
5.安装idl生成工具fastddsgen
5.1 下载相关源码
#下载对应的fastddsgen源码$gitclone https://github.com/eProsima/Fast-DDS-Gen.git5.2 首先安装java环境
尝试进行fastddsgen的安装,首先需要java的环境:Latest Releases | Adoptium中选择windows对应的msi进行下载安装。
C:\Users\yun68\Downloads>java -version openjdk version "11.0.29" 2025-10-21 OpenJDK Runtime Environment Temurin-11.0.29+7 (build 11.0.29+7) OpenJDK 64-Bit Server VM Temurin-11.0.29+7 (build 11.0.29+7, mixed mode)5.3 使用脚本进行安装fastddsgen, 修改源路径为国内源
实际上fastddsgen的安装需要的是该源码库下的脚本进行安装:
实际上内部是下载了一个gradle并进行安装,需要修改路径为国内源路径:
修改F:\fastdds1\Fast-DDS-Gen\gradle\wrapper\gradle-wrapper.properties中的路径为如下:
这里的下载路径貌似直接是在c盘的一个路径,貌似与Gradle Wrapper的相关缓存路径有关。
distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.6-bin.zip5.4 使用脚本对fastddsgen进行安装
使用脚本进行安装:
F:\fastdds1\Fast-DDS-Gen>gradlew.bat assemble Downloading https://mirrors.cloud.tencent.com/gradle/gradle-7.6-bin.zip...........10%............20%...........30%............40%............50%...........60%............70%............80%...........90%............100% Welcome to Gradle7.6!Here are the highlights of this release: - Added supportforJava19. - Introduced`--rerun`flagforindividual task rerun. - Improved dependency blockfortestsuites to be strongly typed. - Added a pluggable systemforJava toolchains provisioning. Formoredetails see https://docs.gradle.org/7.6/release-notes.html Starting a Gradle Daemon(subsequent builds will be faster)>Task :submodulesUpdate Submodule'thirdparty/dds-types-test'(https://github.com/eProsima/dds-types-test.git)registeredforpath'thirdparty/dds-types-test'Submodule'thirdparty/idl-parser'(https://github.com/eProsima/IDL-Parser.git)registeredforpath'thirdparty/idl-parser'Cloning into'F:/fastdds1/Fast-DDS-Gen/thirdparty/dds-types-test'... Cloning into'F:/fastdds1/Fast-DDS-Gen/thirdparty/idl-parser'... Submodule path'thirdparty/dds-types-test':checked out'3b5c0b97d7cc37b22dc796d7289d21a37f171adc'Submodule path'thirdparty/idl-parser':checked out'af0ef1fe06c3d9817593d1431f33183bccc6261c'BUILD SUCCESSFULin3m 11s6actionable tasks:6executed5.5 设置环境变量并查看版本
安装后进行验证,首先设置环境变量:
F:\fastdds1\Fast-DDS-Gen\scripts终端上查看安装情况:
C:\Users\yun68>fastddsgen -version fastddsgen version 4.2.05.6 使用idl进行代码生成(有指令可以直接生成脚本)
5.6.1 构造idl进行验证:
#hellotest.idl@extensibility(APPENDABLE)struct HelloWorld{unsigned long index;string message;};5.6.2 使用idl自动生成代码进行测试:
#首先查看帮助:fastddsgen -help#使用命令进行idl的相关文件生成:fastddsgen.bat hellotest.idl fastddsgen hellotest.idl#生成到test目录下进行测试fastddsgen -dtesthellotest.idl#不写-language 默认也是C++fastddsgen.bat hellotest.idl -language c++#有意思的是,使用cmake可以直接生成可以运行的demofastddsgen -example CMake -d examples ComplexType.idl5.6.3 对idl生成的cmake对应的example进行生成测试
#使用对应的vs终端对生成的cmake项目进行编译生成:F:\fastdds1\fastdds_hellotest\build>cmake../ -DCMAKE_PREFIX_PATH="F:/fastdds1/install;F:\fastdds1\thirdparty\install"-- Selecting Windows SDK version10.0.22000.0 to target Windows10.0.26100. -- Configuring hellotest... -- Configuringdone(0.1s)-- Generatingdone(0.0s)-- Build files have been written to: F:/fastdds1/fastdds_hellotest/build F:\fastdds1\fastdds_hellotest\build>cmake --build.--config Release MSBuild version17.5.1+f6fdcf537for.NET Framework1>Checking Build System Building Custom Rule F:/fastdds1/fastdds_hellotest/CMakeLists.txt hellotestTypeObjectSupport.cxx hellotestPubSubTypes.cxx 正在生成代码... hellotest_lib.vcxproj ->F:\fastdds1\fastdds_hellotest\build\Release\hellotest_lib.lib Building Custom Rule F:/fastdds1/fastdds_hellotest/CMakeLists.txt hellotestApplication.cxx hellotestPublisherApp.cxx hellotestSubscriberApp.cxx hellotestmain.cxx 正在生成代码... hellotest.vcxproj ->F:\fastdds1\fastdds_hellotest\build\Release\hellotest.exe Building Custom Rule F:/fastdds1/fastdds_hellotest/CMakeLists.txt5.6.4 直接进行交互测试
测试生成的测试代码:
6 安装fastdds-monitor
6.1 下载monitor源码
$gitclone https://github.com/eProsima/Fast-DDS-monitor.git6.2 测试monitor
这里使用源码安装时,我的qt环境安装有点问题,懒得折腾,直接从eprosima官网下载到monitor的二进制进行测试,eProsima: Middleware, Robots and AI注意这里要选择windows版本,安装后进行启动即可(这里有意思的是支持一些图形化和图表的方式显示统计):
启动monitor后,启动一些测试demo进行测试:
7 fastdds相关库的了解
这里在下载monitor的时候,看到其他几个不同的库,为了完善了解,这里简单了解其功能:
(fastdds,shapesdemo,monitor是基本的功能,已经进行了测试)
eProsima Fast DDS Spy:实际上和monitor类似,但是两者侧重点不一样,monitor更侧重于宏观上有哪些topic等,用于整体统计;而spy用于统计每个topic的数据,类似于wireshark,关注细节。
eProsima DDS Router:用于支持fastdds支持跨局域网通信,能想到的一个方案是:在每个局域网中部署一个router,该节点具有外网能力,通过该节点进行转发交互(底层原理还是转发)。
eProsima DDS Record and Replay:用于将数据直接进行存储,并支持精确回放。
Fast DDS VisualizerPlotJuggler的插件:和monitor类似,用于从DDS网络中接收数据,并进行图标的形式进行展示,侧重可视化 Topic 中的实际用户数据(传感器数值、位置坐标、控制信号),适合分析数据趋势、轨迹、性能曲线。
eProsima Integration Service: 是一个中间件集成桥梁,提供了一种配置的方式,通过配置,让上层不同的协议进行转换和路由。
eProsima Micro XRCE-DDS:提供了client和agent两个端,client负责最小实现,在资源受限的设备上进行使用;agent是真正和dds进行交互的端,负责和dds交互并转给client。(提供了一种方式,支持DDS在受限的资源中进行接入,两者之间可通过udp,tcp,串口等各种方式进行交互)。
Non-Intrusive DDS Recorder:通过抓包工具(如wireshark)抓包,该工具对抓包文件进行分析,分析rtps协议。