Feat/embedded rtps merge espp#672
Conversation
|
⚡ Static analysis result ⚡ 🔴 cppcheck found 43 issues! Click here to see details.espp/components/rtps_embedded/include/rtps/config_esp32.h Lines 31 to 36 in ca54404 !Line: 31 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/rtps.h Lines 31 to 34 in ca54404 !Line: 31 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/config_desktop.h Lines 31 to 36 in ca54404 !Line: 31 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/ThreadPool.h Lines 39 to 44 in ca54404 !Line: 39 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
!Line: 32 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/storages/CacheChange.h Lines 34 to 39 in ca54404 !Line: 34 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/storages/MemoryPool.h Lines 33 to 38 in ca54404 !Line: 33 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
!Line: 34 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
!Line: 32 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/storages/PayloadBuffer.h Lines 33 to 38 in ca54404 !Line: 33 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
!Line: 34 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/discovery/SPDPAgent.h Lines 48 to 53 in ca54404 !Line: 48 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/discovery/TopicData.h Lines 37 to 42 in ca54404 !Line: 37 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/discovery/SEDPAgent.h Lines 37 to 42 in ca54404 !Line: 37 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
!Line: 39 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/utils/hash.h Lines 31 to 36 in ca54404 !Line: 31 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/utils/udpUtils.h Lines 33 to 38 in ca54404 !Line: 33 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/utils/Diagnostics.h Lines 31 to 36 in ca54404 !Line: 31 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/utils/printutils.h Lines 14 to 19 in ca54404 !Line: 14 - error: Code 'C++ cast <...' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/utils/sysFunctions.h Lines 33 to 38 in ca54404 !Line: 33 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/messages/MessageTypes.h Lines 34 to 39 in ca54404 !Line: 34 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/messages/MessageReceiver.h Lines 35 to 40 in ca54404 !Line: 35 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/messages/MessageFactory.h Lines 40 to 45 in ca54404 !Line: 40 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/communication/PacketInfo.h Lines 37 to 42 in ca54404 !Line: 37 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
!Line: 41 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/common/types.h Lines 36 to 41 in ca54404 !Line: 36 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/common/Locator.h Lines 35 to 40 in ca54404 !Line: 35 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/StatefulReader.h Lines 36 to 41 in ca54404 !Line: 36 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/WriterProxy.h Lines 32 to 37 in ca54404 !Line: 32 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/Reader.h Lines 38 to 43 in ca54404 !Line: 38 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/StatelessReader.h Lines 31 to 36 in ca54404 !Line: 31 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/Writer.h Lines 55 to 60 in ca54404 !Line: 55 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/Domain.h Lines 42 to 47 in ca54404 !Line: 42 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/Participant.h Lines 40 to 45 in ca54404 !Line: 40 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/ReaderProxy.h Lines 32 to 37 in ca54404 !Line: 32 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/StatefulWriter.h Lines 38 to 43 in ca54404 !Line: 38 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/include/rtps/entities/StatelessWriter.h Lines 36 to 41 in ca54404 !Line: 36 - error: Code 'namespacertps{' is invalid C code. [syntaxError]
espp/components/rtps_embedded/src/discovery/SEDPAgent.cpp Lines 361 to 366 in ca54404 !Line: 361 - style: inconclusive: Statements following 'return' will never be executed. [unreachableCode]
espp/components/rtps_embedded/src/discovery/SEDPAgent.cpp Lines 504 to 506 in ca54404 !Line: 504 - style: inconclusive: Statements following 'return' will never be executed. [unreachableCode]
espp/components/rtps_embedded/src/communication/EsppTransport.cpp Lines 140 to 145 in ca54404 !Line: 140 - style: Condition '!channel.socket' is always false [knownConditionTrueFalse]
espp/components/rtps_embedded/src/communication/EsppTransport.cpp Lines 78 to 83 in ca54404 !Line: 78 - style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm]
espp/components/rtps_embedded/src/communication/EsppTransport.cpp Lines 87 to 92 in ca54404 !Line: 87 - style: Consider using std::find_if algorithm instead of a raw loop. [useStlAlgorithm]
espp/components/rtps_embedded/src/communication/EsppTransport.cpp Lines 197 to 202 in ca54404 !Line: 197 - style: Consider using std::any_of algorithm instead of a raw loop. [useStlAlgorithm]
|
|
|
||
| rtps::Writer *Participant::getWriter(EntityId_t id) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_writers.size(); ++i) { |
|
|
||
| rtps::Reader *Participant::getReader(EntityId_t id) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_readers.size(); ++i) { |
|
|
||
| rtps::Reader *Participant::getReaderByWriterId(const Guid_t &guid) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_readers.size(); ++i) { |
|
|
||
| rtps::Writer *Participant::getMatchingWriter(const TopicData &readerTopicData) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_writers.size(); ++i) { |
|
|
||
| rtps::Reader *Participant::getMatchingReader(const TopicData &writerTopicData) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_readers.size(); ++i) { |
| rtps::Writer * | ||
| Participant::getMatchingWriter(const TopicDataCompressed &readerTopicData) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_writers.size(); ++i) { |
| rtps::Reader * | ||
| Participant::getMatchingReader(const TopicDataCompressed &writerTopicData) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_readers.size(); ++i) { |
| bool Participant::hasReaderWithMulticastLocator( | ||
| const std::array<uint8_t, 4> &address) { | ||
| std::lock_guard<std::recursive_mutex> lock(m_mutex); | ||
| for (uint8_t i = 0; i < m_readers.size(); i++) { |
There was a problem hiding this comment.
Pull request overview
Integrates the embeddedRTPS RTPS/DDS stack into ESPP as a new component (rtps_embedded), adds a new reusable thread_pool component, and introduces PC-side standalone publisher/subscriber tests to exercise the stack outside ESP-IDF.
Changes:
- Add
components/rtps_embeddedwith ESPP-based transport/task/threading adapters plus an ESP-IDF example app. - Add
components/thread_poolas a reusable worker-queue abstraction with an ESP-IDF example. - Extend
pc/build to compile embeddedRTPS-based host tests and include the necessary sources (including Micro-CDR).
Reviewed changes
Copilot reviewed 82 out of 83 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| pc/tests/rtps_embedded_subscriber.cpp | Adds standalone PC subscriber test for embeddedRTPS. |
| pc/tests/rtps_embedded_publisher.cpp | Adds standalone PC publisher test for embeddedRTPS. |
| pc/CMakeLists.txt | Adds embeddedRTPS + Micro-CDR sources to PC tests; enables C compilation for those tests. |
| components/thread_pool/src/thread_pool.cpp | Implements espp::ThreadPool. |
| components/thread_pool/README.md | Documents the new thread pool component. |
| components/thread_pool/include/thread_pool.hpp | Public API for the new thread pool component. |
| components/thread_pool/idf_component.yml | IDF Component Manager manifest for thread_pool. |
| components/thread_pool/example/sdkconfig.defaults | Example sdkconfig enabling C++ exceptions. |
| components/thread_pool/example/README.md | Build instructions for the thread_pool example. |
| components/thread_pool/example/main/thread_pool_example.cpp | Example showing how to submit jobs and await completion. |
| components/thread_pool/example/main/CMakeLists.txt | Registers example main component. |
| components/thread_pool/example/CMakeLists.txt | ESP-IDF project CMake for the thread_pool example. |
| components/thread_pool/CMakeLists.txt | Registers the thread_pool component sources/includes. |
| components/socket/CMakeLists.txt | Adjusts socket component requirements list. |
| components/rtps_embedded/src/utils/Diagnostics.cpp | Adds embeddedRTPS diagnostics storage definitions. |
| components/rtps_embedded/src/messages/MessageTypes.cpp | Adds embeddedRTPS message (de)serialization implementation. |
| components/rtps_embedded/src/messages/MessageReceiver.cpp | Adds RTPS submessage processing/dispatch. |
| components/rtps_embedded/src/entities/Writer.cpp | Adds Writer proxy management and base Writer logic. |
| components/rtps_embedded/src/entities/StatelessReader.cpp | Adds StatelessReader implementation. |
| components/rtps_embedded/src/entities/Reader.cpp | Adds Reader callback/proxy management implementation. |
| components/rtps_embedded/src/discovery/ParticipantProxyData.cpp | Adds SPDP participant proxy deserialization and locator parsing. |
| components/rtps_embedded/src/communication/EsppTransport.cpp | Implements ESPP-backed UDP transport adapter for embeddedRTPS. |
| components/rtps_embedded/README.md | High-level component documentation (architecture/config/quick-start). |
| components/rtps_embedded/include/rtps/utils/udpUtils.h | Port/address helper utilities. |
| components/rtps_embedded/include/rtps/utils/sysFunctions.h | Platform timestamp helper implementation. |
| components/rtps_embedded/include/rtps/utils/printutils.h | Debug print helpers for RTPS IDs. |
| components/rtps_embedded/include/rtps/utils/Log.h | Compile-time verbosity switches for embeddedRTPS logging. |
| components/rtps_embedded/include/rtps/utils/hash.h | Hash utility used for compressed topic matching. |
| components/rtps_embedded/include/rtps/utils/Diagnostics.h | Diagnostics extern declarations. |
| components/rtps_embedded/include/rtps/utils/constants.h | Placeholder constants header. |
| components/rtps_embedded/include/rtps/ThreadPool.h | embeddedRTPS threadpool facade integrating with espp::ThreadPool. |
| components/rtps_embedded/include/rtps/storages/ThreadSafeCircularBuffer.tpp | Thread-safe circular buffer implementation. |
| components/rtps_embedded/include/rtps/storages/ThreadSafeCircularBuffer.h | Thread-safe circular buffer API. |
| components/rtps_embedded/include/rtps/storages/SimpleHistoryCache.h | Stateless history cache implementation. |
| components/rtps_embedded/include/rtps/storages/PayloadBuffer.h | Payload buffer wrapper around std::vector<uint8_t>. |
| components/rtps_embedded/include/rtps/storages/MemoryPool.h | Fixed-size memory pool container for embeddedRTPS entities. |
| components/rtps_embedded/include/rtps/storages/HistoryCacheWithDeletion.h | Deletable history cache used by stateful endpoints. |
| components/rtps_embedded/include/rtps/storages/CacheChange.h | CacheChange model for payload + sequencing. |
| components/rtps_embedded/include/rtps/rtps.h | Convenience header for rtps::Domain. |
| components/rtps_embedded/include/rtps/messages/MessageReceiver.h | MessageReceiver API. |
| components/rtps_embedded/include/rtps/messages/MessageFactory.h | RTPS message construction helpers. |
| components/rtps_embedded/include/rtps/entities/WriterProxy.h | WriterProxy model and missing-sequence computation. |
| components/rtps_embedded/include/rtps/entities/Writer.h | Writer base class interface. |
| components/rtps_embedded/include/rtps/entities/StatelessWriter.tpp | Stateless writer implementation template. |
| components/rtps_embedded/include/rtps/entities/StatelessWriter.h | Stateless writer API. |
| components/rtps_embedded/include/rtps/entities/StatelessReader.h | Stateless reader API. |
| components/rtps_embedded/include/rtps/entities/StatefulWriter.h | Stateful writer API. |
| components/rtps_embedded/include/rtps/entities/StatefulReader.h | Stateful reader API. |
| components/rtps_embedded/include/rtps/entities/ReaderProxy.h | ReaderProxy model. |
| components/rtps_embedded/include/rtps/entities/Reader.h | Reader base class interface + ReaderCacheChange definition. |
| components/rtps_embedded/include/rtps/entities/Participant.h | Participant API including discovery agents and endpoint management. |
| components/rtps_embedded/include/rtps/entities/Domain.h | Domain API for participants/readers/writers plus lifecycle methods. |
| components/rtps_embedded/include/rtps/discovery/TopicData.h | Topic metadata structures and matching logic. |
| components/rtps_embedded/include/rtps/discovery/SPDPAgent.h | SPDP discovery agent API. |
| components/rtps_embedded/include/rtps/discovery/SEDPAgent.h | SEDP discovery agent API. |
| components/rtps_embedded/include/rtps/discovery/ParticipantProxyData.h | ParticipantProxyData model + liveliness checks. |
| components/rtps_embedded/include/rtps/discovery/BuiltInEndpoints.h | Built-in endpoint pointers used by discovery. |
| components/rtps_embedded/include/rtps/config.h | Selects config header based on build target. |
| components/rtps_embedded/include/rtps/config_esp32.h | ESP32-focused config constants. |
| components/rtps_embedded/include/rtps/config_desktop.h | Desktop-focused config constants. |
| components/rtps_embedded/include/rtps/communication/PacketInfo.h | PacketInfo structure for transport send/receive. |
| components/rtps_embedded/include/rtps/communication/EsppTransport.h | Transport adapter API wrapping espp::UdpSocket. |
| components/rtps_embedded/include/rtps/common/Locator.h | Locator types and helpers for IPv4 locators. |
| components/rtps_embedded/example/sdkconfig.defaults | Example sdkconfig for rtps_embedded (partition table, stacks). |
| components/rtps_embedded/example/partitions.csv | Custom partition table for the rtps_embedded example. |
| components/rtps_embedded/example/main/main.cpp | ESP-IDF example app integrating WiFi + RTPS pub/sub demo. |
| components/rtps_embedded/example/main/Kconfig.projbuild | Menuconfig options for role/topics/multicast/network settings. |
| components/rtps_embedded/example/main/CMakeLists.txt | Registers example main component and dependencies. |
| components/rtps_embedded/example/CMakeLists.txt | ESP-IDF project CMake for rtps_embedded example. |
| components/rtps_embedded/CMakeLists.txt | Registers rtps_embedded component sources/includes and dependencies. |
| .gitmodules | Adds Micro-CDR as a submodule under rtps_embedded thirdparty. |
| .gitignore | Ignores generated Micro-CDR config header under the submodule. |
| bool serializeIntoUdcrBuffer(ucdrBuffer &buffer) { | ||
| if (ucdr_buffer_remaining(&buffer) < sizeof(FullLengthLocator)) { | ||
| return false; | ||
| } else { | ||
| ucdr_serialize_array_uint8_t(&buffer, reinterpret_cast<uint8_t *>(this), | ||
| sizeof(FullLengthLocator)); | ||
| } | ||
| } |
| #include <chrono> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <thread> |
| // Keep topic/type names short because embeddedRTPS desktop config caps lengths. | ||
| rtps::Writer *writer = | ||
| domain.createWriter(*participant, topic.c_str(), "UInt32", false); | ||
| if (writer == nullptr) { |
| uint32_t value = 0; | ||
| while (true) { | ||
| ++value; | ||
| const rtps::CacheChange *change = | ||
| writer->newChange(rtps::ChangeKind_t::ALIVE, | ||
| reinterpret_cast<const uint8_t *>(&value), | ||
| static_cast<rtps::DataSize_t>(sizeof(value))); | ||
| logger.info("publish {} -> {}", value, change != nullptr ? "queued" : "dropped"); | ||
| std::this_thread::sleep_for(std::chrono::milliseconds(period_ms)); | ||
| } |
| - Configurable worker count | ||
| - Bounded or unbounded queue | ||
| - Optional blocking submit mode for backpressure | ||
| - Graceful stop (drains queued jobs) |
| [submodule "components/rtps_embedded/thirdparty/Micro-CDR"] | ||
| path = components/rtps_embedded/thirdparty/Micro-CDR | ||
| url = git@github.com:esp-cpp/Micro-CDR.git |
| idf_component_register( | ||
| SRCS | ||
| "src/ThreadPool.cpp" | ||
| "src/communication/EsppTransport.cpp" | ||
| "src/discovery/ParticipantProxyData.cpp" | ||
| "src/discovery/SEDPAgent.cpp" | ||
| "src/discovery/SPDPAgent.cpp" | ||
| "src/discovery/TopicData.cpp" | ||
| "src/entities/Domain.cpp" | ||
| "src/entities/Participant.cpp" | ||
| "src/entities/Reader.cpp" | ||
| "src/entities/StatelessReader.cpp" | ||
| "src/entities/Writer.cpp" | ||
| "src/messages/MessageReceiver.cpp" | ||
| "src/messages/MessageTypes.cpp" | ||
| "src/utils/Diagnostics.cpp" | ||
| "thirdparty/Micro-CDR/src/c/common.c" | ||
| "thirdparty/Micro-CDR/src/c/types/array.c" | ||
| "thirdparty/Micro-CDR/src/c/types/basic.c" | ||
| "thirdparty/Micro-CDR/src/c/types/sequence.c" | ||
| "thirdparty/Micro-CDR/src/c/types/string.c" | ||
| INCLUDE_DIRS | ||
| "include" | ||
| "thirdparty/Micro-CDR/include" | ||
| REQUIRES | ||
| base_component cdr task thread_pool socket | ||
| ) |
| idf_component_register( | ||
| INCLUDE_DIRS "include" | ||
| SRC_DIRS "src" | ||
| REQUIRES base_component task) |
Description
integrates the embeddedRTPS RTPS/DDS stack into the ESPP ecosystem.
Motivation and Context
Try to have an embedded rtps that could be used to talk between embedded board as well as a PC/Jetson that running ROS2 or any other DDS participant on the same network using the standard RTPS wire protocal
How has this been tested?
Tested pub/sub between
ESP32 <-----> ESP32
ESP32 <-----> PC (embedded rtps)
ESP32 <-----> PC (fastRTPS)
ESP32 <-----> PC (ROS2)
Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):
ROS:


ESP32:
Types of changes
Checklist:
Software
.github/workflows/build.ymlfile to add my new test to the automated cloud build github action.Hardware