From 0a9c494bf75a04c6bf9725fbd0f1ddfc84fe3e50 Mon Sep 17 00:00:00 2001 From: Kacper Lewandowski Date: Mon, 10 Jul 2023 16:34:19 +0200 Subject: [PATCH 1/3] Added parameter to toggle manual control of vehicle in Editor Signed-off-by: Kacper Lewandowski --- .../VehicleDynamics/VehicleModelComponent.cpp | 17 +++++++++++++---- .../VehicleDynamics/VehicleModelComponent.h | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp index b662e94a1..009112b18 100644 --- a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp +++ b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp @@ -22,7 +22,9 @@ namespace ROS2::VehicleDynamics void VehicleModelComponent::Activate() { VehicleInputControlRequestBus::Handler::BusConnect(GetEntityId()); - m_manualControlEventHandler.Activate(GetEntityId()); + + if (m_manuallyControled) + m_manualControlEventHandler.Activate(GetEntityId()); AZ::TickBus::Handler::BusConnect(); } @@ -41,8 +43,10 @@ namespace ROS2::VehicleDynamics if (AZ::SerializeContext* serialize = azrtti_cast(context)) { - serialize->Class()->Version(4)->Field( - "VehicleConfiguration", &VehicleModelComponent::m_vehicleConfiguration); + serialize->Class() + ->Version(4) + ->Field("VehicleConfiguration", &VehicleModelComponent::m_vehicleConfiguration) + ->Field("ManualControl", &VehicleModelComponent::m_manuallyControled); if (AZ::EditContext* ec = serialize->GetEditContext()) { @@ -51,7 +55,12 @@ namespace ROS2::VehicleDynamics AZ::Edit::UIHandlers::Default, &VehicleModelComponent::m_vehicleConfiguration, "Vehicle settings", - "Vehicle settings including axles and common wheel parameters"); + "Vehicle settings including axles and common wheel parameters") + ->DataElement( + AZ::Edit::UIHandlers::Default, + &VehicleModelComponent::m_manuallyControled, + "ManualControl", + "Enable manual control of the vehicle"); } } } diff --git a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h index ed1000235..1b3c339fa 100644 --- a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h +++ b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h @@ -54,6 +54,7 @@ namespace ROS2::VehicleDynamics protected: ManualControlEventHandler m_manualControlEventHandler; + bool m_manuallyControled = true; VehicleInputDeadline m_inputsState; VehicleDynamics::VehicleConfiguration m_vehicleConfiguration; virtual DriveModel* GetDriveModel() = 0; From 2d4b46b3ef0be38650be90eac3148bb2257b381a Mon Sep 17 00:00:00 2001 From: Kacper Lewandowski Date: Tue, 11 Jul 2023 12:13:39 +0200 Subject: [PATCH 2/3] added curly braces Signed-off-by: Kacper Lewandowski --- Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp index 009112b18..6a91bd75f 100644 --- a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp +++ b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp @@ -24,7 +24,9 @@ namespace ROS2::VehicleDynamics VehicleInputControlRequestBus::Handler::BusConnect(GetEntityId()); if (m_manuallyControled) + { m_manualControlEventHandler.Activate(GetEntityId()); + } AZ::TickBus::Handler::BusConnect(); } From d268b11f4bce542ba4f6761239d3e8ac64dd7494 Mon Sep 17 00:00:00 2001 From: Kacper Lewandowski Date: Tue, 11 Jul 2023 12:23:25 +0200 Subject: [PATCH 3/3] renamed field to enableManualControl Signed-off-by: Kacper Lewandowski --- .../Code/Source/VehicleDynamics/VehicleModelComponent.cpp | 8 ++++---- .../Code/Source/VehicleDynamics/VehicleModelComponent.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp index 6a91bd75f..e403e9bdd 100644 --- a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp +++ b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.cpp @@ -23,7 +23,7 @@ namespace ROS2::VehicleDynamics { VehicleInputControlRequestBus::Handler::BusConnect(GetEntityId()); - if (m_manuallyControled) + if (m_enableManualControl) { m_manualControlEventHandler.Activate(GetEntityId()); } @@ -48,7 +48,7 @@ namespace ROS2::VehicleDynamics serialize->Class() ->Version(4) ->Field("VehicleConfiguration", &VehicleModelComponent::m_vehicleConfiguration) - ->Field("ManualControl", &VehicleModelComponent::m_manuallyControled); + ->Field("ManualControl", &VehicleModelComponent::m_enableManualControl); if (AZ::EditContext* ec = serialize->GetEditContext()) { @@ -60,8 +60,8 @@ namespace ROS2::VehicleDynamics "Vehicle settings including axles and common wheel parameters") ->DataElement( AZ::Edit::UIHandlers::Default, - &VehicleModelComponent::m_manuallyControled, - "ManualControl", + &VehicleModelComponent::m_enableManualControl, + "Enable Manual Control", "Enable manual control of the vehicle"); } } diff --git a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h index 1b3c339fa..545b209fc 100644 --- a/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h +++ b/Gems/ROS2/Code/Source/VehicleDynamics/VehicleModelComponent.h @@ -54,7 +54,7 @@ namespace ROS2::VehicleDynamics protected: ManualControlEventHandler m_manualControlEventHandler; - bool m_manuallyControled = true; + bool m_enableManualControl = true; VehicleInputDeadline m_inputsState; VehicleDynamics::VehicleConfiguration m_vehicleConfiguration; virtual DriveModel* GetDriveModel() = 0;