From 524652ee177e1f241f988fb98fcb8f4a3da0e604 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Tue, 4 May 2021 18:01:34 +0100 Subject: [PATCH 1/3] fixed C18243589_Joints_BallSoftLimitsConstrained test failure --- ...243589_Joints_BallSoftLimitsConstrained.py | 37 ++++++++++++++++--- .../Gem/PythonTests/physics/JointsHelper.py | 7 ++++ 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py index e038b33043..b7bc8439e4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py @@ -57,6 +57,7 @@ def C18243589_Joints_BallSoftLimitsConstrained(): """ import os import sys + import math import ImportPathHelper as imports @@ -95,13 +96,38 @@ def C18243589_Joints_BallSoftLimitsConstrained(): Report.info_vector3(follower.position, "follower initial position:") leadInitialPosition = lead.position followerInitialPosition = follower.position - - # 4) Wait for several seconds - general.idle_wait(1.0) # wait for lead and follower to move + + followerMovedAboveJoint = False + #calculate the start vector from follower and lead positions + normalizedStartPos = JointsHelper.getRelativeVector(lead.position, follower.position) + normalizedStartPos = normalizedStartPos.GetNormalizedSafe() + #the targeted angle to reach between the initial vector and the current follower-lead vector + targetAngleDeg = 45 + targetAngle = math.radians(targetAngleDeg) + + maxTotalWaitTime = 2.0 #seconds + waitTime = 0.0 + waitStep = 0.2 + angleAchieved = 0.0 + while waitTime < maxTotalWaitTime: + waitTime = waitTime + waitStep + general.idle_wait(waitStep) # wait for lead and follower to move + + #calculate the current follower-lead vector + normalVec = JointsHelper.getRelativeVector(lead.position, follower.position) + normalVec = normalVec.GetNormalizedSafe() + #dot product + acos to get the angle + angleAchieved = math.acos(normalizedStartPos.Dot(normalVec)) + #is it above target? + if angleAchieved > targetAngle: + followerMovedAboveJoint = True + break # 5) Check to see if lead and follower behaved as expected - Report.info_vector3(lead.position, "lead position after 1 second:") - Report.info_vector3(follower.position, "follower position after 1 second:") + Report.info_vector3(lead.position, "lead position after {:.2f} second:".format(waitTime)) + Report.info_vector3(follower.position, "follower position after {:.2f} second:".format(waitTime)) + angleAchievedDeg = math.degrees(angleAchieved) + Report.info("Angle achieved {:.2f} Target {:.2f}".format(angleAchievedDeg, targetAngleDeg)) leadPositionDelta = lead.position.Subtract(leadInitialPosition) leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON) @@ -111,7 +137,6 @@ def C18243589_Joints_BallSoftLimitsConstrained(): followerMovedinXYZ = JointsHelper.vector3LargerThanScalar(followerPositionDelta, FLOAT_EPSILON) Report.critical_result(Tests.check_follower_position, followerMovedinXYZ) - followerMovedAboveJoint = follower.position.z > (followerInitialPosition.z + 2.5) # (followerInitialPosition.z + 2.5) is the z position past the 45 degree limit. This is to show that the follower swinged past the 45 degree cone limit, above the joint position. Report.critical_result(Tests.check_follower_above_joint, followerMovedAboveJoint) # 6) Exit Game Mode diff --git a/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py b/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py index e61118ef5b..476c1df237 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py +++ b/AutomatedTesting/Gem/PythonTests/physics/JointsHelper.py @@ -27,6 +27,13 @@ def vector3LargerThanScalar(vec3Value, scalarValue): vec3Value.y > scalarValue and vec3Value.z > scalarValue) +def getRelativeVector(vecA, vecB): + relativeVec = vecA + relativeVec.x = relativeVec.x - vecB.x + relativeVec.y = relativeVec.y - vecB.y + relativeVec.z = relativeVec.z - vecB.z + return relativeVec + # Entity class for joints tests class JointEntity: From 937d0ac726f43733b4018390d7479787055e5f72 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Tue, 4 May 2021 19:11:40 +0100 Subject: [PATCH 2/3] bump inter-test timeout by 1 sec for C5932042_PhysXForceRegion_LinearDamping --- .../physics/C5932042_PhysXForceRegion_LinearDamping.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py b/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py index 04cecd45b2..21d386954d 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C5932042_PhysXForceRegion_LinearDamping.py @@ -135,7 +135,7 @@ def C5932042_PhysXForceRegion_LinearDamping(): # Constants CLOSE_ENOUGH = 0.001 - TIME_OUT = 2.0 + TIME_OUT = 3.0 INITIAL_VELOCITY = azmath.Vector3(0.0, 0.0, -10.0) # 1) Open level / Enter game mode From 24167e7c023671ba7ae2928d35c6e638c0353ff8 Mon Sep 17 00:00:00 2001 From: amzn-sean <75276488+amzn-sean@users.noreply.github.com> Date: Wed, 5 May 2021 12:36:47 +0100 Subject: [PATCH 3/3] address PR comments --- ...243589_Joints_BallSoftLimitsConstrained.py | 25 ++++++++----------- .../PythonTests/physics/TestSuite_Periodic.py | 6 +++-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py index b7bc8439e4..16266b2da3 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C18243589_Joints_BallSoftLimitsConstrained.py @@ -102,32 +102,27 @@ def C18243589_Joints_BallSoftLimitsConstrained(): normalizedStartPos = JointsHelper.getRelativeVector(lead.position, follower.position) normalizedStartPos = normalizedStartPos.GetNormalizedSafe() #the targeted angle to reach between the initial vector and the current follower-lead vector - targetAngleDeg = 45 - targetAngle = math.radians(targetAngleDeg) - - maxTotalWaitTime = 2.0 #seconds - waitTime = 0.0 - waitStep = 0.2 + TARGET_ANGLE_DEG = 45 + targetAngle = math.radians(TARGET_ANGLE_DEG) angleAchieved = 0.0 - while waitTime < maxTotalWaitTime: - waitTime = waitTime + waitStep - general.idle_wait(waitStep) # wait for lead and follower to move + def checkAngleMet(): #calculate the current follower-lead vector normalVec = JointsHelper.getRelativeVector(lead.position, follower.position) normalVec = normalVec.GetNormalizedSafe() #dot product + acos to get the angle angleAchieved = math.acos(normalizedStartPos.Dot(normalVec)) #is it above target? - if angleAchieved > targetAngle: - followerMovedAboveJoint = True - break + return angleAchieved > targetAngle + + MAX_WAIT_TIME = 2.0 #seconds + followerMovedAboveJoint = helper.wait_for_condition(checkAngleMet, MAX_WAIT_TIME) # 5) Check to see if lead and follower behaved as expected - Report.info_vector3(lead.position, "lead position after {:.2f} second:".format(waitTime)) - Report.info_vector3(follower.position, "follower position after {:.2f} second:".format(waitTime)) + Report.info_vector3(lead.position, "lead position:") + Report.info_vector3(follower.position, "follower position:") angleAchievedDeg = math.degrees(angleAchieved) - Report.info("Angle achieved {:.2f} Target {:.2f}".format(angleAchievedDeg, targetAngleDeg)) + Report.info(f"Angle achieved {angleAchievedDeg:.2f} Target {TARGET_ANGLE_DEG:.2f}") leadPositionDelta = lead.position.Subtract(leadInitialPosition) leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON) diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py index 4f91f539ee..93831e9658 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py +++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py @@ -254,6 +254,8 @@ class TestAutomation(TestAutomationBase): from . import C4044697_Material_PerfaceMaterialValidation as test_module self._run_test(request, workspace, editor, test_module) + @pytest.mark.xfail( + reason="This test will sometimes fail as the ball will continue to roll before the timeout is reached.") @revert_physics_config def test_C4976202_RigidBody_StopsWhenBelowKineticThreshold(self, request, workspace, editor, launcher_platform): from . import C4976202_RigidBody_StopsWhenBelowKineticThreshold as test_module @@ -468,12 +470,12 @@ class TestAutomation(TestAutomationBase): from . import C6090547_ForceRegion_ParentChildForceRegions as test_module self._run_test(request, workspace, editor, test_module) - @revert_physics_config + @revert_physics_config def test_C19578021_ShapeCollider_CanBeAdded(self, request, workspace, editor, launcher_platform): from . import C19578021_ShapeCollider_CanBeAdded as test_module self._run_test(request, workspace, editor, test_module) - @revert_physics_config + @revert_physics_config def test_C15425929_Undo_Redo(self, request, workspace, editor, launcher_platform): from . import C15425929_Undo_Redo as test_module self._run_test(request, workspace, editor, test_module)