From 37acad1071681a87af5929df3a6f824ab12c9657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Thu, 20 Mar 2025 12:50:13 +0100 Subject: [PATCH 1/3] Added CMAKE logic to disable Contact Sensor and Spawner components. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Components will be disabled when gazebo_msgs is no longer available. Signed-off-by: Michał Pełka --- Gems/ROS2/Code/CMakeLists.txt | 20 +++++++++++++- .../ROS2ContactSensorComponent.cpp | 4 ++- .../ROS2ContactSensorComponent.h | 3 +++ Gems/ROS2/Code/Source/ROS2EditorModule.cpp | 7 +++-- Gems/ROS2/Code/Source/ROS2ModuleInterface.h | 17 +++++++----- .../Spawner/ROS2SpawnPointComponent.cpp | 4 ++- .../Source/Spawner/ROS2SpawnPointComponent.h | 4 ++- .../ROS2SpawnPointComponentController.cpp | 4 ++- .../ROS2SpawnPointComponentController.h | 4 ++- .../Spawner/ROS2SpawnPointEditorComponent.cpp | 4 ++- .../Spawner/ROS2SpawnPointEditorComponent.h | 4 ++- .../Source/Spawner/ROS2SpawnerComponent.cpp | 4 ++- .../Source/Spawner/ROS2SpawnerComponent.h | 4 ++- .../ROS2SpawnerComponentController.cpp | 4 ++- .../Spawner/ROS2SpawnerComponentController.h | 4 ++- .../Spawner/ROS2SpawnerEditorComponent.cpp | 4 ++- .../Spawner/ROS2SpawnerEditorComponent.h | 4 ++- Gems/ROS2/Code/ros2_editor_files.cmake | 15 ++++++++--- Gems/ROS2/Code/ros2_files.cmake | 26 ++++++++++++------- Gems/ROS2/Code/ros2_target_depends.cmake | 14 ++++++---- 20 files changed, 112 insertions(+), 42 deletions(-) diff --git a/Gems/ROS2/Code/CMakeLists.txt b/Gems/ROS2/Code/CMakeLists.txt index a7654f17a8..45df8eb3ff 100644 --- a/Gems/ROS2/Code/CMakeLists.txt +++ b/Gems/ROS2/Code/CMakeLists.txt @@ -42,6 +42,18 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -DROS_DISTRO=${ROS_DISTRO} -P ${CMAKE_CURRENT_SOURCE_DIR}/checkROS2Distribution.cmake ) +# Gazebo messages are optional, so we will only add the dependants only if the package is found. +# gazebo_msgs package is EOL and will be removed in ROS 2 Kilted Kaiju. +# If you need to use ContactSensor and ROS2 Spawner, please consider building gazebo_msgs from source. +find_package(gazebo_msgs QUIET) +if (gazebo_msgs_FOUND) + message(STATUS "Found gazebo_msgs package, enabling legacy features like ContactSensor Component and ROS2 Spawner Component") + SET (WITH_GAZEBZOMSGS TRUE) +else() + message(STATUS "Could not find gazebo_msgs package, will disable legacy features like ContactSensor Component and ROS2 Spawner Component") + SET(WITH_GAZEBZOMSGS FALSE) +endif() + # Add the ROS2.Static target # Note: We include the common files and the platform specific files which are set in ros2_common_files.cmake # and in ${pal_dir}/ros2_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake @@ -71,7 +83,12 @@ ly_add_target( Gem::LevelGeoreferencing.API ) -target_depends_on_ros2_packages(${gem_name}.Static rclcpp builtin_interfaces std_msgs sensor_msgs nav_msgs tf2_ros ackermann_msgs gazebo_msgs vision_msgs control_msgs) +target_depends_on_ros2_packages(${gem_name}.Static rclcpp builtin_interfaces std_msgs sensor_msgs nav_msgs tf2_ros ackermann_msgs vision_msgs control_msgs) + +if (WITH_GAZEBZOMSGS) + target_depends_on_ros2_package(${gem_name}.Static gazebo_msgs REQUIRED) + target_compile_definitions(${gem_name}.Static PUBLIC "WITH_GAZEBZOMSGS") +endif() ly_add_target( NAME ${gem_name}.API HEADERONLY @@ -161,6 +178,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS) Gem::Atom_Feature_Common.Public ) + # By default, we will specify that the above target ROS2 would be used by # Tool and Builder type targets when this gem is enabled. If you don't want it # active in Tools or Builders by default, delete one or both of the following lines: diff --git a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp index 8f0f8de88d..8da221474f 100644 --- a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp +++ b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp @@ -5,7 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2ContactSensorComponent.h" #include #include diff --git a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h index 9584b4bae6..fcb17e8c1f 100644 --- a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h +++ b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h @@ -7,6 +7,9 @@ */ #pragma once +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include #include diff --git a/Gems/ROS2/Code/Source/ROS2EditorModule.cpp b/Gems/ROS2/Code/Source/ROS2EditorModule.cpp index f28b4ace9f..324e13ba20 100644 --- a/Gems/ROS2/Code/Source/ROS2EditorModule.cpp +++ b/Gems/ROS2/Code/Source/ROS2EditorModule.cpp @@ -17,10 +17,11 @@ #include #include #include +#include +#ifdef WITH_GAZEBZOMSGS #include #include -#include - +#endif void InitROS2Resources() { // Registration of Qt (ROS2.qrc) resources @@ -46,8 +47,10 @@ namespace ROS2 LidarRegistrarEditorSystemComponent::CreateDescriptor(), ROS2RobotImporterEditorSystemComponent::CreateDescriptor(), ROS2CameraSensorEditorComponent::CreateDescriptor(), +#ifdef WITH_GAZEBZOMSGS ROS2SpawnerEditorComponent::CreateDescriptor(), ROS2SpawnPointEditorComponent::CreateDescriptor(), +#endif SdfAssetBuilderSystemComponent::CreateDescriptor(), JointsManipulationEditorComponent::CreateDescriptor(), JointsPositionsEditorComponent::CreateDescriptor(), diff --git a/Gems/ROS2/Code/Source/ROS2ModuleInterface.h b/Gems/ROS2/Code/Source/ROS2ModuleInterface.h index afc2a32711..222d533c1e 100644 --- a/Gems/ROS2/Code/Source/ROS2ModuleInterface.h +++ b/Gems/ROS2/Code/Source/ROS2ModuleInterface.h @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -39,14 +38,16 @@ #include #include #include -#include -#include #include #include #include #include #include - +#ifdef WITH_GAZEBZOMSGS +#include +#include +#include +#endif namespace ROS2 { class ROS2ModuleInterface : public AZ::Module @@ -80,8 +81,6 @@ namespace ROS2 RigidBodyTwistControlComponent::CreateDescriptor(), SkidSteeringControlComponent::CreateDescriptor(), ROS2CameraSensorComponent::CreateDescriptor(), - ROS2SpawnerComponent::CreateDescriptor(), - ROS2SpawnPointComponent::CreateDescriptor(), VehicleDynamics::AckermannVehicleModelComponent::CreateDescriptor(), VehicleDynamics::WheelControllerComponent::CreateDescriptor(), VehicleDynamics::SkidSteeringModelComponent::CreateDescriptor(), @@ -96,9 +95,13 @@ namespace ROS2 GripperActionServerComponent::CreateDescriptor(), VacuumGripperComponent::CreateDescriptor(), FingerGripperComponent::CreateDescriptor(), - ROS2ContactSensorComponent::CreateDescriptor(), FollowingCameraComponent::CreateDescriptor(), ClassSegmentationConfigurationComponent::CreateDescriptor(), +#ifdef WITH_GAZEBZOMSGS + ROS2SpawnerComponent::CreateDescriptor(), + ROS2SpawnPointComponent::CreateDescriptor(), + ROS2ContactSensorComponent::CreateDescriptor(), +#endif }); } diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp index a409add6b3..1eb872dc09 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp @@ -5,7 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2SpawnPointComponent.h" #include "Spawner/ROS2SpawnPointComponentController.h" #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h index da7ffa7b6a..52838742b3 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h @@ -6,7 +6,9 @@ * */ #pragma once - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "Spawner/ROS2SpawnPointComponentController.h" #include #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp index d0aa41491a..c68a2e0259 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp @@ -5,7 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "Spawner/ROS2SpawnPointComponentController.h" #include "Spawner/ROS2SpawnerComponentController.h" #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h index de241cc93a..8947bc6e15 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h @@ -6,7 +6,9 @@ * */ #pragma once - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include #include #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp index b1d31087e5..c12c6d225c 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp @@ -5,7 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2SpawnPointEditorComponent.h" #include "Spawner/ROS2SpawnPointComponentController.h" #include "Spawner/ROS2SpawnerEditorComponent.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h index 56e79cb3d7..66a9ee37d5 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h @@ -6,7 +6,9 @@ * */ #pragma once - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "Spawner/ROS2SpawnPointComponent.h" #include "Spawner/ROS2SpawnPointComponentController.h" #include "Spawner/ROS2SpawnerEditorComponent.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp index 9e9a6a9314..2c03ada3c0 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp @@ -5,7 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2SpawnerComponent.h" #include "Spawner/ROS2SpawnerComponentController.h" #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h index a9eb16aa65..75b30e5f86 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h @@ -6,7 +6,9 @@ * */ #pragma once - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2SpawnPointComponent.h" #include "Spawner/ROS2SpawnerComponentController.h" #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp index fdec3e1998..e3bf49247e 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp @@ -5,7 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2SpawnerComponentController.h" #include "Spawner/ROS2SpawnPointComponent.h" #include "Spawner/ROS2SpawnerComponent.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h index 19e07c596d..a0261d030f 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h @@ -7,7 +7,9 @@ */ #pragma once - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2/Spawner/SpawnerBus.h" #include "ROS2SpawnPointComponent.h" #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp index dd667dda9f..4fb8744786 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp @@ -5,7 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "ROS2SpawnerEditorComponent.h" #include "AzCore/Debug/Trace.h" #include "ROS2SpawnPointEditorComponent.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h index 20cc92581e..4d2973a4f7 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h @@ -6,7 +6,9 @@ * */ #pragma once - +#ifndef WITH_GAZEBZOMSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#endif #include "Spawner/ROS2SpawnerComponent.h" #include "Spawner/ROS2SpawnerComponentController.h" #include diff --git a/Gems/ROS2/Code/ros2_editor_files.cmake b/Gems/ROS2/Code/ros2_editor_files.cmake index d4b8a6ebe4..bc77e3adac 100644 --- a/Gems/ROS2/Code/ros2_editor_files.cmake +++ b/Gems/ROS2/Code/ros2_editor_files.cmake @@ -84,10 +84,6 @@ set(FILES Source/RobotImporter/Utils/TypeConversions.cpp Source/RobotImporter/Utils/TypeConversions.h Source/ROS2GemUtilities.cpp - Source/Spawner/ROS2SpawnerEditorComponent.cpp - Source/Spawner/ROS2SpawnerEditorComponent.h - Source/Spawner/ROS2SpawnPointEditorComponent.cpp - Source/Spawner/ROS2SpawnPointEditorComponent.h Source/SdfAssetBuilder/SdfAssetBuilder.cpp Source/SdfAssetBuilder/SdfAssetBuilder.h Source/SdfAssetBuilder/SdfAssetBuilderSettings.cpp @@ -101,3 +97,14 @@ set(FILES Source/SystemComponents/ROS2EditorSystemComponent.cpp Source/SystemComponents/ROS2EditorSystemComponent.h ) + +# optional, legacy features compilation +if (WITH_GAZEBZOMSGS) + list(APPEND FILES + Source/Spawner/ROS2SpawnerEditorComponent.cpp + Source/Spawner/ROS2SpawnerEditorComponent.h + Source/Spawner/ROS2SpawnPointEditorComponent.cpp + Source/Spawner/ROS2SpawnPointEditorComponent.h + ) +endif () + diff --git a/Gems/ROS2/Code/ros2_files.cmake b/Gems/ROS2/Code/ros2_files.cmake index 988dab2860..5c65b964e6 100644 --- a/Gems/ROS2/Code/ros2_files.cmake +++ b/Gems/ROS2/Code/ros2_files.cmake @@ -33,8 +33,6 @@ set(FILES Source/Communication/QoS.cpp Source/Communication/PublisherConfiguration.cpp Source/Communication/TopicConfiguration.cpp - Source/ContactSensor/ROS2ContactSensorComponent.cpp - Source/ContactSensor/ROS2ContactSensorComponent.h Source/Frame/NamespaceConfiguration.cpp Source/Frame/ROS2FrameComponent.cpp Source/Frame/ROS2FrameConfiguration.cpp @@ -130,14 +128,6 @@ set(FILES Source/SimulationUtils/FollowingCameraConfiguration.h Source/SimulationUtils/FollowingCameraComponent.cpp Source/SimulationUtils/FollowingCameraComponent.h - Source/Spawner/ROS2SpawnerComponent.cpp - Source/Spawner/ROS2SpawnerComponent.h - Source/Spawner/ROS2SpawnPointComponent.cpp - Source/Spawner/ROS2SpawnPointComponent.h - Source/Spawner/ROS2SpawnerComponentController.cpp - Source/Spawner/ROS2SpawnerComponentController.h - Source/Spawner/ROS2SpawnPointComponentController.cpp - Source/Spawner/ROS2SpawnPointComponentController.h Source/SystemComponents/ROS2SystemComponent.cpp Source/SystemComponents/ROS2SystemComponent.h Source/Utilities/ArticulationsUtilities.cpp @@ -178,3 +168,19 @@ set(FILES Source/VehicleDynamics/WheelControllerComponent.h Source/VehicleDynamics/WheelDynamicsData.h ) + +# optional, legacy features compilation +if (WITH_GAZEBZOMSGS) + list(APPEND FILES + Source/ContactSensor/ROS2ContactSensorComponent.cpp + Source/ContactSensor/ROS2ContactSensorComponent.h + Source/Spawner/ROS2SpawnerComponent.cpp + Source/Spawner/ROS2SpawnerComponent.h + Source/Spawner/ROS2SpawnPointComponent.cpp + Source/Spawner/ROS2SpawnPointComponent.h + Source/Spawner/ROS2SpawnerComponentController.cpp + Source/Spawner/ROS2SpawnerComponentController.h + Source/Spawner/ROS2SpawnPointComponentController.cpp + Source/Spawner/ROS2SpawnPointComponentController.h + ) +endif () \ No newline at end of file diff --git a/Gems/ROS2/Code/ros2_target_depends.cmake b/Gems/ROS2/Code/ros2_target_depends.cmake index 71b928beec..ccb1a6d337 100644 --- a/Gems/ROS2/Code/ros2_target_depends.cmake +++ b/Gems/ROS2/Code/ros2_target_depends.cmake @@ -6,12 +6,16 @@ function(target_depends_on_ros2_package TARGET_NAME) list(GET ARGN 0 _package) find_package(${ARGN}) - include(${${_package}_DIR}/${_package}Config.cmake OPTIONAL) - if (${${_package}_FOUND_AMENT_PACKAGE}) - message(DEBUG "Package ${_package} was found (${${_package}_DIR}) version ${${_package}_VERSION} targets : ${${_package}_TARGETS}") - target_link_libraries(${TARGET_NAME} PUBLIC ${${_package}_TARGETS}) + if (${${_package}_FOUND}) + include(${${_package}_DIR}/${_package}Config.cmake OPTIONAL) + if (${${_package}_FOUND_AMENT_PACKAGE}) + message(DEBUG "Package ${_package} was found (${${_package}_DIR}) version ${${_package}_VERSION} targets : ${${_package}_TARGETS}") + target_link_libraries(${TARGET_NAME} PUBLIC ${${_package}_TARGETS}) + else () + message(FATAL_ERROR "Package ${_package} was found (${${_package}_DIR}), but package is not an Ament package.") + endif () else () - message(FATAL_ERROR "Package ${_package} was found (${${_package}_DIR}), but package is not an Ament package.") + message(DEBUG "Package ${_package} was not found.") endif () endfunction() From b941872bd398758bdccdcef950832b8ab8fbca74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Thu, 20 Mar 2025 16:56:10 +0100 Subject: [PATCH 2/3] Adjust to review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Michał Pełka --- Gems/ROS2/Code/CMakeLists.txt | 8 ++++---- .../Source/ContactSensor/ROS2ContactSensorComponent.cpp | 4 ++-- .../Source/ContactSensor/ROS2ContactSensorComponent.h | 4 ++-- Gems/ROS2/Code/Source/ROS2EditorModule.cpp | 4 ++-- Gems/ROS2/Code/Source/ROS2ModuleInterface.h | 4 ++-- Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp | 4 ++-- Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h | 4 ++-- .../Source/Spawner/ROS2SpawnPointComponentController.cpp | 4 ++-- .../Source/Spawner/ROS2SpawnPointComponentController.h | 4 ++-- .../Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp | 4 ++-- .../Code/Source/Spawner/ROS2SpawnPointEditorComponent.h | 4 ++-- Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp | 4 ++-- Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h | 4 ++-- .../Source/Spawner/ROS2SpawnerComponentController.cpp | 4 ++-- .../Code/Source/Spawner/ROS2SpawnerComponentController.h | 4 ++-- .../Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp | 4 ++-- .../ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h | 4 ++-- Gems/ROS2/Code/ros2_editor_files.cmake | 2 +- Gems/ROS2/Code/ros2_files.cmake | 4 ++-- 19 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Gems/ROS2/Code/CMakeLists.txt b/Gems/ROS2/Code/CMakeLists.txt index 45df8eb3ff..78414bc2c0 100644 --- a/Gems/ROS2/Code/CMakeLists.txt +++ b/Gems/ROS2/Code/CMakeLists.txt @@ -48,10 +48,10 @@ add_custom_target( find_package(gazebo_msgs QUIET) if (gazebo_msgs_FOUND) message(STATUS "Found gazebo_msgs package, enabling legacy features like ContactSensor Component and ROS2 Spawner Component") - SET (WITH_GAZEBZOMSGS TRUE) + SET (WITH_GAZEBO_MSGS TRUE) else() message(STATUS "Could not find gazebo_msgs package, will disable legacy features like ContactSensor Component and ROS2 Spawner Component") - SET(WITH_GAZEBZOMSGS FALSE) + SET(WITH_GAZEBO_MSGS FALSE) endif() # Add the ROS2.Static target @@ -85,9 +85,9 @@ ly_add_target( target_depends_on_ros2_packages(${gem_name}.Static rclcpp builtin_interfaces std_msgs sensor_msgs nav_msgs tf2_ros ackermann_msgs vision_msgs control_msgs) -if (WITH_GAZEBZOMSGS) +if (WITH_GAZEBO_MSGS) target_depends_on_ros2_package(${gem_name}.Static gazebo_msgs REQUIRED) - target_compile_definitions(${gem_name}.Static PUBLIC "WITH_GAZEBZOMSGS") + target_compile_definitions(${gem_name}.Static PUBLIC "WITH_GAZEBO_MSGS") endif() ly_add_target( diff --git a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp index 8da221474f..8c3ac813ac 100644 --- a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp +++ b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2ContactSensorComponent.h" #include diff --git a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h index fcb17e8c1f..efba4ecb4e 100644 --- a/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h +++ b/Gems/ROS2/Code/Source/ContactSensor/ROS2ContactSensorComponent.h @@ -7,8 +7,8 @@ */ #pragma once -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include diff --git a/Gems/ROS2/Code/Source/ROS2EditorModule.cpp b/Gems/ROS2/Code/Source/ROS2EditorModule.cpp index 324e13ba20..0f7a41fc60 100644 --- a/Gems/ROS2/Code/Source/ROS2EditorModule.cpp +++ b/Gems/ROS2/Code/Source/ROS2EditorModule.cpp @@ -18,7 +18,7 @@ #include #include #include -#ifdef WITH_GAZEBZOMSGS +#ifdef WITH_GAZEBO_MSGS #include #include #endif @@ -47,7 +47,7 @@ namespace ROS2 LidarRegistrarEditorSystemComponent::CreateDescriptor(), ROS2RobotImporterEditorSystemComponent::CreateDescriptor(), ROS2CameraSensorEditorComponent::CreateDescriptor(), -#ifdef WITH_GAZEBZOMSGS +#ifdef WITH_GAZEBO_MSGS ROS2SpawnerEditorComponent::CreateDescriptor(), ROS2SpawnPointEditorComponent::CreateDescriptor(), #endif diff --git a/Gems/ROS2/Code/Source/ROS2ModuleInterface.h b/Gems/ROS2/Code/Source/ROS2ModuleInterface.h index 222d533c1e..899893987a 100644 --- a/Gems/ROS2/Code/Source/ROS2ModuleInterface.h +++ b/Gems/ROS2/Code/Source/ROS2ModuleInterface.h @@ -43,7 +43,7 @@ #include #include #include -#ifdef WITH_GAZEBZOMSGS +#ifdef WITH_GAZEBO_MSGS #include #include #include @@ -97,7 +97,7 @@ namespace ROS2 FingerGripperComponent::CreateDescriptor(), FollowingCameraComponent::CreateDescriptor(), ClassSegmentationConfigurationComponent::CreateDescriptor(), -#ifdef WITH_GAZEBZOMSGS +#ifdef WITH_GAZEBO_MSGS ROS2SpawnerComponent::CreateDescriptor(), ROS2SpawnPointComponent::CreateDescriptor(), ROS2ContactSensorComponent::CreateDescriptor(), diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp index 1eb872dc09..af2cfea763 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2SpawnPointComponent.h" #include "Spawner/ROS2SpawnPointComponentController.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h index 52838742b3..ba2be3cab4 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.h @@ -6,8 +6,8 @@ * */ #pragma once -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "Spawner/ROS2SpawnPointComponentController.h" #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp index c68a2e0259..06fc6a788c 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "Spawner/ROS2SpawnPointComponentController.h" #include "Spawner/ROS2SpawnerComponentController.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h index 8947bc6e15..9a510d3001 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponentController.h @@ -6,8 +6,8 @@ * */ #pragma once -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include #include diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp index c12c6d225c..7074bbb1fa 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2SpawnPointEditorComponent.h" #include "Spawner/ROS2SpawnPointComponentController.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h index 66a9ee37d5..2c35fd7935 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointEditorComponent.h @@ -6,8 +6,8 @@ * */ #pragma once -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "Spawner/ROS2SpawnPointComponent.h" #include "Spawner/ROS2SpawnPointComponentController.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp index 2c03ada3c0..2498cc9a72 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2SpawnerComponent.h" #include "Spawner/ROS2SpawnerComponentController.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h index 75b30e5f86..5f3482ed29 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h @@ -6,8 +6,8 @@ * */ #pragma once -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2SpawnPointComponent.h" #include "Spawner/ROS2SpawnerComponentController.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp index e3bf49247e..210701514f 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2SpawnerComponentController.h" #include "Spawner/ROS2SpawnPointComponent.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h index a0261d030f..513cf7b6e8 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponentController.h @@ -7,8 +7,8 @@ */ #pragma once -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2/Spawner/SpawnerBus.h" #include "ROS2SpawnPointComponent.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp index 4fb8744786..df33f1a6ec 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.cpp @@ -5,8 +5,8 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "ROS2SpawnerEditorComponent.h" #include "AzCore/Debug/Trace.h" diff --git a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h index 4d2973a4f7..72e099667b 100644 --- a/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h +++ b/Gems/ROS2/Code/Source/Spawner/ROS2SpawnerEditorComponent.h @@ -6,8 +6,8 @@ * */ #pragma once -#ifndef WITH_GAZEBZOMSGS -static_assert(false, "This file should not be included in the build, without WITH_GAZEBZOMSGS defined."); +#ifndef WITH_GAZEBO_MSGS +static_assert(false, "This file should not be included in the build, without WITH_GAZEBO_MSGS defined."); #endif #include "Spawner/ROS2SpawnerComponent.h" #include "Spawner/ROS2SpawnerComponentController.h" diff --git a/Gems/ROS2/Code/ros2_editor_files.cmake b/Gems/ROS2/Code/ros2_editor_files.cmake index bc77e3adac..a61fb23ebe 100644 --- a/Gems/ROS2/Code/ros2_editor_files.cmake +++ b/Gems/ROS2/Code/ros2_editor_files.cmake @@ -99,7 +99,7 @@ set(FILES ) # optional, legacy features compilation -if (WITH_GAZEBZOMSGS) +if (WITH_GAZEBO_MSGS) list(APPEND FILES Source/Spawner/ROS2SpawnerEditorComponent.cpp Source/Spawner/ROS2SpawnerEditorComponent.h diff --git a/Gems/ROS2/Code/ros2_files.cmake b/Gems/ROS2/Code/ros2_files.cmake index 5c65b964e6..ebd5ec1d8b 100644 --- a/Gems/ROS2/Code/ros2_files.cmake +++ b/Gems/ROS2/Code/ros2_files.cmake @@ -170,7 +170,7 @@ set(FILES ) # optional, legacy features compilation -if (WITH_GAZEBZOMSGS) +if (WITH_GAZEBO_MSGS) list(APPEND FILES Source/ContactSensor/ROS2ContactSensorComponent.cpp Source/ContactSensor/ROS2ContactSensorComponent.h @@ -183,4 +183,4 @@ if (WITH_GAZEBZOMSGS) Source/Spawner/ROS2SpawnPointComponentController.cpp Source/Spawner/ROS2SpawnPointComponentController.h ) -endif () \ No newline at end of file +endif () From d0a90ec8f54288cef4571039a5178b41b6e35add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pe=C5=82ka?= Date: Fri, 21 Mar 2025 14:44:12 +0100 Subject: [PATCH 3/3] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan Hanca Signed-off-by: Michał Pełka --- Gems/ROS2/Code/CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gems/ROS2/Code/CMakeLists.txt b/Gems/ROS2/Code/CMakeLists.txt index 78414bc2c0..ac0e349d87 100644 --- a/Gems/ROS2/Code/CMakeLists.txt +++ b/Gems/ROS2/Code/CMakeLists.txt @@ -42,15 +42,15 @@ add_custom_target( COMMAND ${CMAKE_COMMAND} -DROS_DISTRO=${ROS_DISTRO} -P ${CMAKE_CURRENT_SOURCE_DIR}/checkROS2Distribution.cmake ) -# Gazebo messages are optional, so we will only add the dependants only if the package is found. -# gazebo_msgs package is EOL and will be removed in ROS 2 Kilted Kaiju. -# If you need to use ContactSensor and ROS2 Spawner, please consider building gazebo_msgs from source. +# Gazebo messages are optional, so we will only add the dependents if the package is found. +# The gazebo_msgs package is EOL and will not be available in ROS 2 Kilted Kaiju. +# If you need to use ContactSensor and/or ROS2 Spawner, please consider building gazebo_msgs from the source. find_package(gazebo_msgs QUIET) if (gazebo_msgs_FOUND) message(STATUS "Found gazebo_msgs package, enabling legacy features like ContactSensor Component and ROS2 Spawner Component") SET (WITH_GAZEBO_MSGS TRUE) else() - message(STATUS "Could not find gazebo_msgs package, will disable legacy features like ContactSensor Component and ROS2 Spawner Component") + message(STATUS "Could not find gazebo_msgs package, disabling legacy features like ContactSensor Component and ROS2 Spawner Component") SET(WITH_GAZEBO_MSGS FALSE) endif()