2
0
Эх сурвалжийг харах

Removed ROS2.Static dependency to AZToolsFramework (#326)

Signed-off-by: Michał Pełka <[email protected]>
Michał Pełka 2 жил өмнө
parent
commit
0d6ecfc9e3

+ 6 - 1
Gems/ROS2/Code/CMakeLists.txt

@@ -38,7 +38,6 @@ ly_add_target(
         PUBLIC
             AZ::AzCore
             AZ::AzFramework
-            AZ::AzToolsFramework
             Gem::Atom_RPI.Public
             Gem::Atom_Feature_Common.Static
             Gem::Atom_Component_DebugCamera.Static
@@ -95,6 +94,9 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
                 Source
             PUBLIC
                 Include
+        COMPILE_DEFINITIONS
+            PRIVATE
+                ROS2_EDITOR
         BUILD_DEPENDENCIES
             PUBLIC
                 AZ::AzToolsFramework
@@ -113,6 +115,9 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS)
             ros2_editor_shared_files.cmake
         PLATFORM_INCLUDE_FILES
             ${CMAKE_CURRENT_LIST_DIR}/Platform/Common/${PAL_TRAIT_COMPILER_ID}/ros2_static_${PAL_TRAIT_COMPILER_ID_LOWERCASE}.cmake
+        COMPILE_DEFINITIONS
+            PRIVATE
+                ROS2_EDITOR
         INCLUDE_DIRECTORIES
             PRIVATE
                 Source

+ 0 - 1
Gems/ROS2/Code/Include/ROS2/Frame/ROS2FrameComponent.h

@@ -13,7 +13,6 @@
 #include <AzCore/Component/Component.h>
 #include <AzCore/std/smart_ptr/unique_ptr.h>
 #include <AzFramework/Components/TransformComponent.h>
-#include <AzToolsFramework/ToolsComponents/GenericComponentWrapper.h>
 
 namespace ROS2
 {

+ 4 - 2
Gems/ROS2/Code/Include/ROS2/ROS2GemUtilities.h

@@ -9,8 +9,9 @@
 
 #include "AzCore/Component/ComponentBus.h"
 #include "AzCore/Component/Entity.h"
+#ifdef ROS2_EDITOR
 #include "AzToolsFramework/ToolsComponents/GenericComponentWrapper.h"
-
+#endif
 namespace ROS2
 {
     namespace Utils
@@ -35,9 +36,10 @@ namespace ROS2
             {
                 return component;
             }
+#ifdef ROS2_EDITOR
             // failed to get game object, let us retry as editor
             component = AzToolsFramework::FindWrappedComponentForEntity<ComponentType>(entity);
-            AZ_Assert(entity, "Entity %s has no component of type", entity->GetId());
+#endif
             return component;
         }
 

+ 0 - 3
Gems/ROS2/Code/Source/Camera/ROS2CameraSensorComponent.cpp

@@ -17,9 +17,6 @@
 #include <AzCore/Serialization/EditContext.h>
 #include <AzCore/Serialization/SerializeContext.h>
 
-#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
-#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
-
 #include <sensor_msgs/distortion_models.hpp>
 #include <sensor_msgs/image_encodings.hpp>
 

+ 7 - 11
Gems/ROS2/Code/Source/Frame/ROS2FrameComponent.cpp

@@ -8,14 +8,12 @@
 
 #include "ROS2/Frame/ROS2FrameComponent.h"
 #include "ROS2/ROS2Bus.h"
+#include "ROS2/ROS2GemUtilities.h"
 #include "ROS2/Utilities/ROS2Names.h"
 #include <AzCore/Component/Entity.h>
 #include <AzCore/Serialization/EditContext.h>
 #include <AzCore/Serialization/EditContextConstants.inl>
 #include <AzCore/Serialization/SerializeContext.h>
-#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
-#include <AzToolsFramework/ToolsComponents/TransformComponent.h>
-
 namespace ROS2
 {
     namespace Internal
@@ -29,12 +27,9 @@ namespace ROS2
                 return nullptr;
             }
 
-            auto* interface = entity->FindComponent<AzFramework::TransformComponent>();
-            if (interface)
-            {
-                return interface;
-            }
-            return entity->FindComponent<AzToolsFramework::Components::TransformComponent>();
+            auto* interface = Utils::GetGameOrEditorComponent<AzFramework::TransformComponent>(entity);
+
+            return interface;
         }
 
         const ROS2FrameComponent* GetFirstROS2FrameAncestor(const AZ::Entity* entity)
@@ -51,8 +46,9 @@ namespace ROS2
             { // We have reached the top level, there is no parent entity so there can be no parent ROS2Frame
                 return nullptr;
             }
-
-            const AZ::Entity* parentEntity = AzToolsFramework::GetEntityById(parentEntityId);
+            AZ::Entity* parentEntity = nullptr;
+            AZ::ComponentApplicationBus::BroadcastResult(parentEntity, &AZ::ComponentApplicationRequests::FindEntity, parentEntityId);
+            AZ_Assert(parentEntity, "No parent entity id : %s", parentEntityId.ToString().c_str());
             auto* component = Utils::GetGameOrEditorComponent<ROS2FrameComponent>(parentEntity);
             if (component == nullptr)
             { // Parent entity has no ROS2Frame, but there can still be a ROS2Frame in its ancestors

+ 0 - 1
Gems/ROS2/Code/Source/RobotControl/ROS2RobotControlComponent.h

@@ -11,7 +11,6 @@
 #include "ControlSubscriptionHandler.h"
 #include <AzCore/Component/Component.h>
 #include <AzCore/std/smart_ptr/unique_ptr.h>
-#include <AzToolsFramework/ToolsComponents/GenericComponentWrapper.h>
 #include <ROS2/Communication/TopicConfiguration.h>
 
 namespace ROS2

+ 4 - 1
Gems/ROS2/Code/Source/Spawner/ROS2SpawnPointComponent.cpp

@@ -8,9 +8,12 @@
 
 #include "ROS2SpawnPointComponent.h"
 #include <AzCore/Component/Entity.h>
+
 #include <AzCore/Serialization/EditContext.h>
+#include <AzCore/Serialization/EditContextConstants.inl>
+#include <AzCore/Serialization/SerializeContext.h>
+
 #include <AzFramework/Components/TransformComponent.h>
-#include <AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h>
 
 namespace ROS2
 {

+ 6 - 4
Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.cpp

@@ -11,8 +11,9 @@
 #include "ROS2/ROS2Bus.h"
 #include "ROS2/ROS2GemUtilities.h"
 #include <AzCore/Serialization/EditContext.h>
-#include <AzFramework/Components/TransformComponent.h>
-#include <AzToolsFramework/Entity/EditorEntityHelpers.h>
+#include <AzCore/Serialization/SerializeContext.h>
+#include <AzFramework/Spawnable/Spawnable.h>
+
 #include <ROS2/Utilities/ROS2Conversions.h>
 
 namespace ROS2
@@ -226,8 +227,9 @@ namespace ROS2
 
         for (const auto child : children)
         {
-            auto child_entity = AzToolsFramework::GetEntityById(child);
-
+            AZ::Entity* child_entity = nullptr;
+            AZ::ComponentApplicationBus::BroadcastResult(child_entity, &AZ::ComponentApplicationRequests::FindEntity, child);
+            AZ_Assert(child_entity, "No child entity %s", child.ToString().c_str());
             auto spawn_point = child_entity->FindComponent<ROS2SpawnPointComponent>();
 
             if (spawn_point == nullptr)

+ 3 - 0
Gems/ROS2/Code/Source/Spawner/ROS2SpawnerComponent.h

@@ -9,7 +9,10 @@
 
 #include "ROS2SpawnPointComponent.h"
 #include "SpawnerBus.h"
+#include <AzCore/Asset/AssetCommon.h>
+#include <AzCore/Asset/AssetSerializer.h>
 #include <AzCore/Component/Component.h>
+#include <AzCore/std/containers/unordered_map.h>
 #include <AzFramework/Spawnable/Spawnable.h>
 #include <AzFramework/Spawnable/SpawnableEntitiesInterface.h>
 #include <gazebo_msgs/srv/get_model_state.hpp>

+ 1 - 0
Gems/ROS2/Code/ros2_editor_files.cmake

@@ -6,6 +6,7 @@
 set(FILES
     Source/ROS2EditorSystemComponent.cpp
     Source/ROS2EditorSystemComponent.h
+    Source/ROS2GemUtilities.cpp
     Source/RobotImporter/URDF/RobotImporter.cpp
     Source/RobotImporter/URDF/RobotImporter.h
     Source/RobotImporter/ROS2RobotImporterEditorSystemComponent.cpp

+ 0 - 1
Gems/ROS2/Code/ros2_files.cmake

@@ -21,7 +21,6 @@ set(FILES
         Source/Manipulator/MotorizedJoint.cpp
         Source/Communication/QoS.cpp
         Source/Communication/TopicConfiguration.cpp
-        Source/ROS2GemUtilities.cpp
         Source/RobotControl/ControlConfiguration.cpp
         Source/RobotControl/ControlConfiguration.h
         Source/RobotControl/ControlSubscriptionHandler.h