Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## Latest Changes
* Renamed the ROS2 abstraction layer from dds/DDS* to generic middleware/Middleware* naming to support future non-DDS backends like Zenoh. FastDDS and CycloneDDS vendor classes are unchanged.
* Added NumPy 2 compatibility to the PythonAPI: replaced removed aliases (`np.bool`, `np.matrix`) in example scripts and upgraded Boost to 1.90.0, which ships the upstream NumPy 2 C ABI fix (boostorg/python#432) so the C extension builds against both NumPy 1.x (>=1.18.4) and NumPy 2.x
* Fixed North/South latitude inversion in geo-coordinate conversion for Transverse Mercator and UTM projections
* Decoupled ROS2 DDS middleware from a hard FastDDS dependency to an agnostic strategy-pattern abstraction supporting both FastDDS and CycloneDDS, selectable at runtime via `--rmw=` CLI flag
Expand Down
10 changes: 5 additions & 5 deletions LibCarla/cmake/cyclone_dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@ file(GLOB libcarla_carla_subscribers_headers "${libcarla_source_path}/carla/ros2
file(GLOB libcarla_carla_listeners_headers "${libcarla_source_path}/carla/ros2/listeners/*.h")
file(GLOB libcarla_carla_types_headers "${libcarla_source_path}/carla/ros2/types/*.h")
file(GLOB libcarla_carla_types_msg_headers "${libcarla_source_path}/carla/ros2/types/msg/*.h")
file(GLOB libcarla_carla_dds_headers "${libcarla_source_path}/carla/ros2/dds/*.h")
file(GLOB libcarla_carla_dds_cyclonedds_headers "${libcarla_source_path}/carla/ros2/dds/cyclonedds/*.h")
file(GLOB libcarla_carla_ros2_middleware_headers "${libcarla_source_path}/carla/ros2/middleware/*.h")
file(GLOB libcarla_carla_ros2_middleware_cyclonedds_headers "${libcarla_source_path}/carla/ros2/middleware/cyclonedds/*.h")

install(FILES ${libcarla_carla_ros2_headers} DESTINATION include/carla/ros2)
install(FILES ${libcarla_carla_publishers_headers} DESTINATION include/carla/ros2/publishers)
install(FILES ${libcarla_carla_subscribers_headers} DESTINATION include/carla/ros2/subscribers)
install(FILES ${libcarla_carla_listeners_headers} DESTINATION include/carla/ros2/listeners)
install(FILES ${libcarla_carla_types_headers} DESTINATION include/carla/ros2/types)
install(FILES ${libcarla_carla_types_msg_headers} DESTINATION include/carla/ros2/types/msg)
install(FILES ${libcarla_carla_dds_headers} DESTINATION include/carla/ros2/dds)
install(FILES ${libcarla_carla_dds_cyclonedds_headers} DESTINATION include/carla/ros2/dds/cyclonedds)
install(FILES ${libcarla_carla_ros2_middleware_headers} DESTINATION include/carla/ros2/middleware)
install(FILES ${libcarla_carla_ros2_middleware_cyclonedds_headers} DESTINATION include/carla/ros2/middleware/cyclonedds)

file(GLOB cyclonedds_dependencies "${CYCLONEDDS_LIB_PATH}/*.a")
install(FILES ${cyclonedds_dependencies} DESTINATION lib)
install(DIRECTORY "${CYCLONEDDS_INCLUDE_PATH}/dds" DESTINATION include)
install(DIRECTORY "${CYCLONEDDS_INCLUDE_PATH}/ddsc" DESTINATION include)

# Note: dds/cyclonedds/ compiled sources (CycloneDDSSertype.cpp) are included
# Note: middleware/cyclonedds/ compiled sources (CycloneDDSSertype.cpp) are included
# in cmake/ros2/ (carla_ros2), compiled once with both middleware macros defined.
12 changes: 6 additions & 6 deletions LibCarla/cmake/fast_dds/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ file(GLOB libcarla_carla_subscribers_headers "${libcarla_source_path}/carla/ros2
file(GLOB libcarla_carla_listeners_headers "${libcarla_source_path}/carla/ros2/listeners/*.h")
file(GLOB libcarla_carla_types_headers "${libcarla_source_path}/carla/ros2/types/*.h")
file(GLOB libcarla_carla_types_msg_headers "${libcarla_source_path}/carla/ros2/types/msg/*.h")
file(GLOB libcarla_carla_dds_headers "${libcarla_source_path}/carla/ros2/dds/*.h")
file(GLOB libcarla_carla_dds_fastdds_headers "${libcarla_source_path}/carla/ros2/dds/fastdds/*.h")
file(GLOB libcarla_carla_ros2_middleware_headers "${libcarla_source_path}/carla/ros2/middleware/*.h")
file(GLOB libcarla_carla_ros2_middleware_fastdds_headers "${libcarla_source_path}/carla/ros2/middleware/fastdds/*.h")

install(FILES ${libcarla_carla_ros2_headers} DESTINATION include/carla/ros2)
install(FILES ${libcarla_carla_publishers_headers} DESTINATION include/carla/ros2/publishers)
install(FILES ${libcarla_carla_subscribers_headers} DESTINATION include/carla/ros2/subscribers)
install(FILES ${libcarla_carla_listeners_headers} DESTINATION include/carla/ros2/listeners)
install(FILES ${libcarla_carla_types_headers} DESTINATION include/carla/ros2/types)
install(FILES ${libcarla_carla_types_msg_headers} DESTINATION include/carla/ros2/types/msg)
install(FILES ${libcarla_carla_dds_headers} DESTINATION include/carla/ros2/dds)
install(FILES ${libcarla_carla_dds_fastdds_headers} DESTINATION include/carla/ros2/dds/fastdds)
install(FILES ${libcarla_carla_ros2_middleware_headers} DESTINATION include/carla/ros2/middleware)
install(FILES ${libcarla_carla_ros2_middleware_fastdds_headers} DESTINATION include/carla/ros2/middleware/fastdds)

file(GLOB fast_dds_dependencies "${FASTDDS_LIB_PATH}/*.a")
install(FILES ${fast_dds_dependencies} DESTINATION lib)
install(DIRECTORY "${FASTDDS_INCLUDE_PATH}/fastcdr" DESTINATION include)
install(DIRECTORY "${FASTDDS_INCLUDE_PATH}/fastdds" DESTINATION include)
install(DIRECTORY "${FASTDDS_INCLUDE_PATH}/fastrtps" DESTINATION include)

# Note: dds/fastdds/ headers are installed here. The one .cpp source
# Note: middleware/fastdds/ headers are installed here. The one .cpp source
# (FastDDSSharedParticipant.cpp) is compiled via cmake/ros2/ (carla_ros2),
# together with all other ros2 sources, once with both
# CARLA_ROS2_DDS_FASTDDS and CARLA_ROS2_DDS_CYCLONEDDS defined.
# CARLA_ROS2_MIDDLEWARE_FASTDDS and CARLA_ROS2_MIDDLEWARE_CYCLONEDDS defined.
16 changes: 8 additions & 8 deletions LibCarla/cmake/ros2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ cmake_minimum_required(VERSION 3.5.1)
project(libcarla_ros2)

# All ros2 source files compiled ONCE with both middleware macros defined.
# This ensures ROS2::Enable, DDSMiddlewareFactory::IsMiddlewareAvailable,
# This ensures ROS2::Enable, MiddlewareFactory::IsMiddlewareAvailable,
# and all CreatePublisher<T>/CreateSubscriber<S> instantiations see both
# CARLA_ROS2_DDS_FASTDDS and CARLA_ROS2_DDS_CYCLONEDDS at compile time.
# CARLA_ROS2_MIDDLEWARE_FASTDDS and CARLA_ROS2_MIDDLEWARE_CYCLONEDDS at compile time.
# cmake/fast_dds and cmake/cyclone_dds are install-only (no library targets);
# all compiled code lives here.

Expand All @@ -14,8 +14,8 @@ file(GLOB libcarla_ros2_sources
"${libcarla_source_path}/carla/ros2/subscribers/*.cpp"
"${libcarla_source_path}/carla/ros2/listeners/*.cpp"
"${libcarla_source_path}/carla/ros2/types/*.cpp"
"${libcarla_source_path}/carla/ros2/dds/fastdds/*.cpp"
"${libcarla_source_path}/carla/ros2/dds/cyclonedds/*.cpp")
"${libcarla_source_path}/carla/ros2/middleware/fastdds/*.cpp"
"${libcarla_source_path}/carla/ros2/middleware/cyclonedds/*.cpp")

# ==============================================================================
# Create targets for debug and release in the same build type.
Expand All @@ -25,8 +25,8 @@ if (LIBCARLA_BUILD_RELEASE)
add_library(carla_ros2 STATIC ${libcarla_ros2_sources})

target_compile_definitions(carla_ros2 PRIVATE
CARLA_ROS2_DDS_FASTDDS
CARLA_ROS2_DDS_CYCLONEDDS)
CARLA_ROS2_MIDDLEWARE_FASTDDS
CARLA_ROS2_MIDDLEWARE_CYCLONEDDS)
target_compile_options(carla_ros2 PRIVATE -fexceptions)

target_include_directories(carla_ros2 SYSTEM PRIVATE
Expand All @@ -47,8 +47,8 @@ if (LIBCARLA_BUILD_DEBUG)
add_library(carla_ros2_debug STATIC ${libcarla_ros2_sources})

target_compile_definitions(carla_ros2_debug PRIVATE
CARLA_ROS2_DDS_FASTDDS
CARLA_ROS2_DDS_CYCLONEDDS)
CARLA_ROS2_MIDDLEWARE_FASTDDS
CARLA_ROS2_MIDDLEWARE_CYCLONEDDS)
target_compile_options(carla_ros2_debug PRIVATE -fexceptions)

target_include_directories(carla_ros2_debug SYSTEM PRIVATE
Expand Down
2 changes: 1 addition & 1 deletion LibCarla/cmake/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ foreach(dir ""
"sensor/" "sensor/data/" "sensor/s11n/"
"streaming/" "streaming/detail/" "streaming/detail/tcp/" "streaming/low_level/"
"multigpu/"
"ros2/" "ros2/dds/")
"ros2/" "ros2/middleware/")

file(GLOB headers "${libcarla_source_path}/carla/${dir}*.h")
install(FILES ${headers} DESTINATION include/carla/${dir})
Expand Down
2 changes: 1 addition & 1 deletion LibCarla/cmake/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ file(GLOB libcarla_test_sources

if (NOT LIBCARLA_WITH_ROS2)
list(REMOVE_ITEM libcarla_test_sources
"${libcarla_source_path}/test/server/test_dds_middleware.cpp")
"${libcarla_source_path}/test/server/test_ros2_middleware.cpp")
endif()

file(GLOB libcarla_test_client_sources "")
Expand Down
14 changes: 7 additions & 7 deletions LibCarla/source/carla/ros2/ROS2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "carla/ros2/ROS2.h"

#include "carla/Logging.h"
#include "carla/ros2/dds/DDSMiddlewareFactory.h"
#include "carla/ros2/middleware/MiddlewareFactory.h"
#include "carla/geom/GeoLocation.h"
#include "carla/geom/Vector3D.h"
#include "carla/sensor/data/DVSEvent.h"
Expand Down Expand Up @@ -70,18 +70,18 @@ enum ESensors {
HSSLidar
};

bool ROS2::Enable(bool enable, DDSMiddleware middleware) {
bool ROS2::Enable(bool enable, Middleware middleware) {
std::lock_guard<std::recursive_mutex> lock(_mutex);
if (enable) {
auto resolve = DDSMiddlewareFactory::ResolveMiddleware(middleware);
auto resolve = MiddlewareFactory::ResolveMiddleware(middleware);
if (!resolve.success) {
log_error("ROS2: middleware '", DDSMiddlewareToString(middleware),
log_error("ROS2: middleware '", MiddlewareToString(middleware),
"' is not compiled into this binary. ROS2 is DISABLED.");
return false;
}
DDSMiddlewareFactory::SetMiddleware(middleware);
log_info("ROS2: using DDS middleware: ",
DDSMiddlewareToString(middleware));
MiddlewareFactory::SetMiddleware(middleware);
log_info("ROS2: using middleware: ",
MiddlewareToString(middleware));
_clock_publisher = std::make_shared<CarlaClockPublisher>();
}
_enabled = enable;
Expand Down
4 changes: 2 additions & 2 deletions LibCarla/source/carla/ros2/ROS2.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "carla/BufferView.h"
#include "carla/geom/Transform.h"
#include "carla/ros2/ROS2CallbackData.h"
#include "carla/ros2/dds/DDSMiddleware.h"
#include "carla/ros2/middleware/Middleware.h"
#include "carla/streaming/detail/Types.h"

#include <mutex>
Expand Down Expand Up @@ -59,7 +59,7 @@ class ROS2
// General
// Returns true when enabling succeeds (middleware compiled in), false otherwise.
// Callers pass enable=false to shut down; the return value is always true in that case.
bool Enable(bool enable, DDSMiddleware middleware = DDSMiddleware::FastDDS);
bool Enable(bool enable, Middleware middleware = Middleware::FastDDS);
void Shutdown();

bool IsEnabled() { return _enabled; }
Expand Down
146 changes: 0 additions & 146 deletions LibCarla/source/carla/ros2/dds/DDSMiddlewareFactory.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
namespace carla {
namespace ros2 {

/// Type-erased abstract interface for a DDS publisher middleware.
/// Concrete implementations handle all vendor-specific DDS entity creation,
/// Type-erased abstract interface for a publisher middleware.
/// Concrete implementations handle all vendor-specific entity creation,
/// type registration, and data writing.
class IDDSPublisherMiddleware {
class IPublisherMiddleware {
public:
virtual ~IDDSPublisherMiddleware() = default;
virtual ~IPublisherMiddleware() = default;

/// Initialize DDS entities (participant, publisher, topic, writer).
/// @param topic_name Full DDS topic name including "rt/" prefix.
/// Initialize the underlying middleware entities.
/// @param topic_name Full topic name including "rt/" prefix.
/// @return true on success.
virtual bool Init(const std::string& topic_name) = 0;

/// Serialize and write a message to the DDS network.
/// Serialize and write a message to the network.
/// @param message_data Pointer to the message object (type-erased, cast internally).
/// @return true if the write succeeded.
virtual bool Publish(void* message_data) = 0;

/// @return true if at least one subscriber is matched.
virtual bool IsAlive() const = 0;

/// @return The DDS topic name this publisher is bound to.
/// @return The topic name this publisher is bound to.
virtual std::string GetTopicName() const = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
namespace carla {
namespace ros2 {

/// Type-erased abstract interface for a DDS subscriber middleware.
/// Type-erased abstract interface for a subscriber middleware.
/// Concrete implementations write received messages directly into the caller-provided
/// storage (message_ptr / new_message_flag) to avoid an extra copy.
class IDDSSubscriberMiddleware {
class ISubscriberMiddleware {
public:
virtual ~IDDSSubscriberMiddleware() = default;
virtual ~ISubscriberMiddleware() = default;

/// Initialize DDS entities (participant, subscriber, topic, reader).
/// Initialize the underlying middleware entities.
/// The middleware writes incoming messages to *message_ptr and sets *new_message_flag = true.
/// @param topic_name Full DDS topic name.
/// @param topic_name Full topic name.
/// @param message_ptr Pointer to the message storage owned by SubscriberImpl<S>.
/// @param new_message_flag Pointer to the new-message flag owned by SubscriberImpl<S>.
/// @return true on success.
Expand All @@ -30,7 +30,7 @@ class IDDSSubscriberMiddleware {
/// @return true if at least one publisher is matched.
virtual bool IsAlive() const = 0;

/// @return The DDS topic name this subscriber is bound to.
/// @return The topic name this subscriber is bound to.
virtual std::string GetTopicName() const = 0;
};

Expand Down
Loading
Loading