Commit d3f2a45
committed
feat(LibCarla/ros2): add CycloneDDS CDR middleware, fix FastDDS large-message publish, add ROS2 smoke test
Replace CycloneDDS publisher/subscriber stubs with real implementations that
transport raw CDR bytes via dds_writecdr() / dds_takecdr(), bypassing the
CycloneDDS type system entirely. No IDL-generated files, no cyclonedds-cxx.
Add CycloneDDSSertype.h, a custom ddsi_sertype + ddsi_serdata for raw CDR
passthrough. CDR bytes (including the 4-byte DDS encapsulation header) are
stored inline after the ddsi_serdata header in a single malloc block.
Full ddsi_serdata_ops (15 entries) and ddsi_sertype_ops (14 entries) tables
are implemented against CycloneDDS 0.10.5. Public API: carla_cdr_create_topic()
registers the sertype with a participant, carla_cdr_wrap() wraps pre-serialized
CDR in a ddsi_serdata* for dds_writecdr(), carla_cdr_data()/carla_cdr_size()
expose received bytes for deserialize_from_cdr().
CycloneDDSPublisherMiddleware<T>: Init() creates participant/topic/writer,
Publish() calls serialize_to_cdr(*msg) then dds_writecdr().
CycloneDDSSubscriberMiddleware<T>: Init() creates participant/topic/reader
with data_available listener, listener calls dds_takecdr() then
deserialize_from_cdr() into the caller-supplied message pointer.
Both FastDDS and CycloneDDS are always built when --ros2 is specified.
FastDDS is a hard dependency (libfastcdr.a is used by CdrSerialization.h
for both backends). Setup.sh downloads and builds both libraries
unconditionally, LibCarla/cmake/CMakeLists.txt unconditionally adds both
fast_dds and cyclone_dds subdirs. New LibCarla/cmake/cyclone_dds/CMakeLists.txt
builds libcarla_cyclonedds.a linking libddsc.a + libfastcdr.a.
Add -DBUILD_DDSPERF=OFF to CycloneDDS cmake flags in Setup.sh to prevent
ddsperf build failure when -DBUILD_IDLC=OFF (ddsperf depends on idlc).
Fix GenericCdrPubSubType::getSerializedSizeProvider() to return the actual
per-instance serialized size instead of a fixed CdrTopicInfo::max_serialized_size()
value. The fixed value (648 bytes for Image, 27597 for PointCloud2) was far
smaller than real camera frames (~1-8 MB) or LiDAR scans (~1-20 MB), causing
FastDDS DataWriter::write() to fail with RETCODE_ERROR (code 1) on every tick.
Add cdr_serialized_size() to CdrSerialization.h to compute the actual size, and
change serialize() to use an auto-growing FastBuffer to eliminate the fixed-size
buffer constraint entirely.
Fix MultiStreamState::IsEnabledForROS() to check the _enable_for_ros set
directly instead of iterating sessions that all return false from the default
virtual implementation. The Python is_enabled_for_ros() API was always returning
false even after enable_for_ros() because of this.
Fix CarlaCameraPublisher.cpp and CarlaRadarPublisher.cpp: add explicit
#include <cmath>, the CycloneDDS build exposed a pre-existing missing include
(FastDDS headers were providing std::tan/sin/cos transitively).
Add PythonAPI/test/smoke/test_ros2.py: two smoke tests for the native ROS2
publish path. test_ros2_api verifies the enable/disable/is_enabled lifecycle.
test_ros2_sensor_publish spawns an 800x600 RGB camera and LiDAR on a vehicle,
enables ROS2, ticks 20 synchronous frames, and asserts Python callbacks fire,
exercising the full GenericCdrPubSubType::serialize() -> DataWriter path with
realistic large payloads.
Tests: 120/120 server + 56/56 client. 2/2 smoke tests (smoke.test_ros2).1 parent 0a9ca58 commit d3f2a45
File tree
16 files changed
+1020
-53
lines changed- LibCarla
- cmake
- cyclone_dds
- source
- carla
- ros2
- dds
- cyclonedds
- fastdds
- publishers
- types
- streaming/detail
- test/server
- PythonAPI/test
- smoke
- Util/BuildTools
16 files changed
+1020
-53
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
Lines changed: 103 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
10 | 20 | | |
11 | 21 | | |
12 | 22 | | |
13 | | - | |
| 23 | + | |
14 | 24 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
19 | 28 | | |
20 | 29 | | |
21 | | - | |
| 30 | + | |
22 | 31 | | |
23 | 32 | | |
24 | 33 | | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
25 | 42 | | |
26 | | - | |
27 | | - | |
28 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
29 | 77 | | |
30 | 78 | | |
31 | | - | |
32 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
33 | 101 | | |
34 | 102 | | |
35 | 103 | | |
36 | | - | |
| 104 | + | |
37 | 105 | | |
38 | 106 | | |
39 | 107 | | |
40 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
41 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
42 | 129 | | |
43 | 130 | | |
44 | 131 | | |
45 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
0 commit comments