From 35f831d4141cbd60ea996fb32879929f4885194d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20D=C4=85browski?= Date: Fri, 16 May 2025 12:48:42 +0200 Subject: [PATCH 1/3] Add obstacle distance threshold setting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kacper Dąbrowski --- .../Gem/Source/VehicleController/VehicleController.cpp | 10 ++++++++-- .../Gem/Source/VehicleController/VehicleController.h | 1 + .../VehicleController/VehicleControllerComponent.cpp | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Project/Gem/Source/VehicleController/VehicleController.cpp b/Project/Gem/Source/VehicleController/VehicleController.cpp index 88d3615..3f635dd 100644 --- a/Project/Gem/Source/VehicleController/VehicleController.cpp +++ b/Project/Gem/Source/VehicleController/VehicleController.cpp @@ -75,7 +75,8 @@ namespace RAIControl ->Field("predefinedPaths", &VehicleControllerConfig::m_predefinedPaths) ->Field("predefinedObstacles", &VehicleControllerConfig::m_predefinedObstacles) ->Field("vehicleLights", &VehicleControllerConfig::m_vehicleLights) - ->Field("vehicleLightsIntensities", &VehicleControllerConfig::m_vehicleLightsIntensities); + ->Field("vehicleLightsIntensities", &VehicleControllerConfig::m_vehicleLightsIntensities) + ->Field("obstacleDistanceThreshold", &VehicleControllerConfig::m_obstacleDistanceThreshold); if (auto editContext = serializeContext->GetEditContext()) { @@ -112,7 +113,12 @@ namespace RAIControl AZ::Edit::UIHandlers::Default, &VehicleControllerConfig::m_vehicleLightsIntensities, "Vehicle lights' intensities", - "List of the max. intensities for vehicle lights"); + "List of the max. intensities for vehicle lights") + ->DataElement( + AZ::Edit::UIHandlers::Default, + &VehicleControllerConfig::m_obstacleDistanceThreshold, + "Obstacle distance threshold", + "Distance threshold for the vehicle to stop when an obstacle is detected"); } } } diff --git a/Project/Gem/Source/VehicleController/VehicleController.h b/Project/Gem/Source/VehicleController/VehicleController.h index 345da76..4d78552 100644 --- a/Project/Gem/Source/VehicleController/VehicleController.h +++ b/Project/Gem/Source/VehicleController/VehicleController.h @@ -50,6 +50,7 @@ namespace RAIControl AZStd::vector m_predefinedObstacles; AZStd::vector m_vehicleLights; AZStd::vector m_vehicleLightsIntensities; + float m_obstacleDistanceThreshold{ 7.0f }; }; } // namespace RAIControl diff --git a/Project/Gem/Source/VehicleController/VehicleControllerComponent.cpp b/Project/Gem/Source/VehicleController/VehicleControllerComponent.cpp index fa33779..a85b141 100644 --- a/Project/Gem/Source/VehicleController/VehicleControllerComponent.cpp +++ b/Project/Gem/Source/VehicleController/VehicleControllerComponent.cpp @@ -244,7 +244,7 @@ namespace RAIControl AZ::Vector3 obstacleTranslation = AZ::Vector3::CreateZero(); AZ::TransformBus::EventResult(obstacleTranslation, obstacleId, &AZ::TransformBus::Events::GetWorldTranslation); - if ((obstacleTranslation - vehiclePosition).GetLength() < 5.0) + if ((obstacleTranslation - vehiclePosition).GetLength() < m_configuration.m_obstacleDistanceThreshold) { // Set the flag and stop the vehicle if (!m_obstacleDetected) From cca3021b825a1879ea4325ad9766632b1ff22f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20D=C4=85browski?= Date: Fri, 16 May 2025 12:49:36 +0200 Subject: [PATCH 2/3] Adjust tractors' path ending MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kacper Dąbrowski --- .../Levels/AlmondOrchard/AlmondOrchard.prefab | 390 +++++++++++++++++- 1 file changed, 380 insertions(+), 10 deletions(-) diff --git a/Project/Levels/AlmondOrchard/AlmondOrchard.prefab b/Project/Levels/AlmondOrchard/AlmondOrchard.prefab index 40c864f..735ca79 100644 --- a/Project/Levels/AlmondOrchard/AlmondOrchard.prefab +++ b/Project/Levels/AlmondOrchard/AlmondOrchard.prefab @@ -1505,33 +1505,218 @@ }, { "op": "replace", - "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/ShapeColor/0", - "value": 1.0 + "path": "/Instances/Instance_[73412310835229]/Entities/Entity_[122431352745838]/Components/EditorRigidBodyComponent/Configuration/Initial angular velocity/2", + "value": 5.099999904632568 }, { "op": "replace", - "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/ShapeColor/2", - "value": 0.0 + "path": "/Instances/Instance_[73412310835229]/Entities/Entity_[122431352745838]/Components/TransformComponent/Transform Data/Rotate/2", + "value": 35.0 + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/22" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/21" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/20" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/19" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/18" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/17" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/16" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/15" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/14" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/13" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/12" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/11" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/10" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/9" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/8" }, { "op": "replace", - "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShapeMeshConfig/ShapeConfig/DrawColor/0", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/7/Forward/0", + "value": 79.0 + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/22" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/21" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/20" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/19" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/18" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/17" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/16" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/15" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/14" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/13" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/12" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/11" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/10" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/9" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/8" + }, + { + "op": "replace", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/ShapeColor/0", "value": 1.0 }, { "op": "replace", - "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShapeMeshConfig/ShapeConfig/DrawColor/2", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/ShapeColor/2", "value": 0.0 }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/22" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/21" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/20" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/19" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/18" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/17" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/16" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/15" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/14" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/13" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/12" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/11" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/10" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/9" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/8" + }, { "op": "replace", - "path": "/Instances/Instance_[73412310835229]/Entities/Entity_[122431352745838]/Components/EditorRigidBodyComponent/Configuration/Initial angular velocity/2", - "value": 5.099999904632568 + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShapeMeshConfig/ShapeConfig/DrawColor/0", + "value": 1.0 }, { "op": "replace", - "path": "/Instances/Instance_[73412310835229]/Entities/Entity_[122431352745838]/Components/TransformComponent/Transform Data/Rotate/2", - "value": 35.0 + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShapeMeshConfig/ShapeConfig/DrawColor/2", + "value": 0.0 } ] }, @@ -5251,6 +5436,191 @@ "op": "replace", "path": "/Instances/Instance_[51405573643237]/Entities/Entity_[2144213563765]/Components/ROS2FrameEditorComponent/ROS2FrameConfiguration/Namespace Configuration/Namespace", "value": "tractor1" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/22" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/21" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/20" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/19" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/18" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/17" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/16" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/15" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/14" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/13" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/12" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/11" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/10" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/9" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Vertices/Vertices/8" + }, + { + "op": "replace", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/7/Forward/0", + "value": 79.0 + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/22" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/21" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/20" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/19" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/18" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/17" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/16" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/15" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/14" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/13" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/12" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/11" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/10" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/9" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorSplineComponent/Configuration/Spline/Bezier Data/8" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/22" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/21" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/20" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/19" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/18" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/17" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/16" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/15" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/14" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/13" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/12" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/11" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/10" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/9" + }, + { + "op": "remove", + "path": "/Entities/Entity_[253776731796994]/Components/EditorTubeShapeComponent/TubeShape/VariableRadius/Elements/8" } ] }, From eb1c353dda5f87d3111c525d2ba0c23ff755a385 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20D=C4=85browski?= Date: Wed, 21 May 2025 18:14:15 +0200 Subject: [PATCH 3/3] Add a comment explaining the variable's purpose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Kacper Dąbrowski --- Project/Gem/Source/VehicleController/VehicleController.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Project/Gem/Source/VehicleController/VehicleController.h b/Project/Gem/Source/VehicleController/VehicleController.h index 4d78552..eb5e6f3 100644 --- a/Project/Gem/Source/VehicleController/VehicleController.h +++ b/Project/Gem/Source/VehicleController/VehicleController.h @@ -50,6 +50,8 @@ namespace RAIControl AZStd::vector m_predefinedObstacles; AZStd::vector m_vehicleLights; AZStd::vector m_vehicleLightsIntensities; + + // Distance from the obstacle at which the tractor will stop float m_obstacleDistanceThreshold{ 7.0f }; };