$ show ros2/rmw_fastrtps
This repository provides the ROS 2 Middleware (RMW) implementation for eProsima Fast DDS, a high-performance DDS (Data Distribution Service) implementation. It translates the standard ROS 2 RMW API (publish, subscribe, services, clients, events) into Fast DDS operations, enabling ROS 2 nodes to communicate over DDS. The codebase is structured into three packages: `rmw_fastrtps_cpp` (static typesupport using compile-time code generation), `rmw_fastrtps_dynamic_cpp` (runtime introspection-based typesupport), and `rmw_fastrtps_shared_cpp` (shared logic for both variants). It supports advanced features such as content-filtered subscriptions, loaned messages, zero-copy data sharing via buffer backends (including GPU offloading), DDS security (PKI-DH, AES-GCM, access control), and comprehensive QoS mapping. The architecture follows a layered design where the shared package contains the core RMW implementations, and the two variant packages provide thin wrappers that differ only in how type support is resolved. This is a foundational infrastructure package for ROS 2, not an end-user application; it is selected at runtime via the `RMW_IMPLEMENTATION` environment variable.
The LLM identified 5 files worth highlighting for reuse:
A generic thread-safe wrapper template `LockedObject<T>` that provides exclusive access to a shared resource via a mutex. It is self-contained, header-only, and can be extracted into any C++ project requiring simple synchronized access without external dependencies beyond the standard library.
Provides functions to convert between ROS 2 QoS profiles (`rmw_qos_profile_t`) and Fast DDS QoS objects (`DataWriterQos`, `DataReaderQos`). This is a standalone utility that encapsulates the mapping logic, including handling of history, reliability, durability, and deadline policies. It can be reused in any project that needs to bridge ROS 2 QoS to DDS QoS.
Implements demangling of ROS 2 topic and service names from their DDS internal representations (e.g., removing namespace prefixes like `rt/` and service suffixes). The logic is isolated and well-documented, making it reusable for any ROS 2 middleware implementation that needs to reverse the name mangling applied during DDS topic creation.
Central data structure for managing DDS participant lifecycle, including reference-counted topic creation and deletion (`find_or_create_topic`, `delete_topic`). It encapsulates the logic for tracking topic usage across multiple publishers/subscribers, preventing premature cleanup. The pattern of reference-counted resource management is reusable in any system that needs to share DDS entities.
Implements the `rmw_take_loaned_message` and `return_loaned_message` functions using a `LoanManager` pattern that manages a pool of loaned message buffers. It handles resource-limited vectors, mutex-guarded access, and proper cleanup. This pattern is reusable for any DDS-based middleware that supports zero-copy loaned message transfers.