From 763fd521a9e419552713c58e17f6d111389297d0 Mon Sep 17 00:00:00 2001 From: PabloVD Date: Tue, 21 May 2024 13:52:01 +0200 Subject: [PATCH] Define ROS2 demo functions when flag is off --- LibCarla/source/carla/ros2/ROS2.cpp | 6 ++++-- LibCarla/source/carla/ros2/ROS2.h | 2 -- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/LibCarla/source/carla/ros2/ROS2.cpp b/LibCarla/source/carla/ros2/ROS2.cpp index 12c8deedc..ed563cb6b 100644 --- a/LibCarla/source/carla/ros2/ROS2.cpp +++ b/LibCarla/source/carla/ros2/ROS2.cpp @@ -200,20 +200,22 @@ std::string ROS2::GetActorParentRosName(void *actor) { return std::string(""); } -#if defined(WITH_ROS2_DEMO) void ROS2::AddBasicSubscriberCallback(void* actor, std::string ros_name, ActorMessageCallback callback) { + #if defined(WITH_ROS2_DEMO) _actor_message_callbacks.insert({actor, std::move(callback)}); _basic_subscriber.reset(); _basic_subscriber = std::make_shared(actor, ros_name.c_str()); _basic_subscriber->Init(); + #endif } void ROS2::RemoveBasicSubscriberCallback(void* actor) { + #if defined(WITH_ROS2_DEMO) _basic_subscriber.reset(); _actor_message_callbacks.erase(actor); + #endif } -#endif void ROS2::AddActorCallback(void* actor, std::string ros_name, ActorCallback callback) { _actor_callbacks.insert({actor, std::move(callback)}); diff --git a/LibCarla/source/carla/ros2/ROS2.h b/LibCarla/source/carla/ros2/ROS2.h index 5a3372ef8..4cf39e9de 100644 --- a/LibCarla/source/carla/ros2/ROS2.h +++ b/LibCarla/source/carla/ros2/ROS2.h @@ -74,10 +74,8 @@ class ROS2 // callbacks void AddActorCallback(void* actor, std::string ros_name, ActorCallback callback); void RemoveActorCallback(void* actor); -#if defined(WITH_ROS2_DEMO) void RemoveBasicSubscriberCallback(void* actor); void AddBasicSubscriberCallback(void* actor, std::string ros_name, ActorMessageCallback callback); -#endif // enabling streams to publish void EnableStream(carla::streaming::detail::stream_id_type id) { _publish_stream.insert(id); }