Physics joints updated to the new API (#1361)

Co-authored-by: Ulugbek Adilbekov <ulugbek@amazon.com>
This commit is contained in:
amzn-sean
2021-06-17 15:52:27 +01:00
committed by GitHub
parent c46a17f3a6
commit 9f62d631fb
90 changed files with 2792 additions and 1665 deletions
@@ -56,6 +56,7 @@ def C18243584_Joints_HingeSoftLimitsConstrained():
"""
import os
import sys
import math
import ImportPathHelper as imports
@@ -93,22 +94,51 @@ def C18243584_Joints_HingeSoftLimitsConstrained():
Report.info_vector3(lead.position, "lead initial position:")
Report.info_vector3(follower.position, "follower initial position:")
leadInitialPosition = lead.position
followerInitialPosition = follower.position
# 4) Wait for the follower to move above the lead or Timeout
normalizedStartPos = JointsHelper.getRelativeVector(lead.position, follower.position)
normalizedStartPos = normalizedStartPos.GetNormalizedSafe()
# 4) Wait for several seconds
general.idle_wait(4.0) # wait for lead and follower to move
class WaitCondition:
TARGET_ANGLE = math.radians(45)
TARGET_MAX_ANGLE = math.radians(180)
angleAchieved = 0.0
followerMovedAbove45Deg = False #this is expected to be true to pass the test
followerMovedAbove180Deg = True #this is expected to be false to pass the test
def checkConditionMet(self):
#calculate the current follower-lead vector
normalVec = JointsHelper.getRelativeVector(lead.position, follower.position)
normalVec = normalVec.GetNormalizedSafe()
#dot product + acos to get the angle
currentAngle = math.acos(normalizedStartPos.Dot(normalVec))
#if the angle is now less then last time, it is no longer rising, so end the test.
if currentAngle < self.angleAchieved:
return True
self.angleAchieved = currentAngle
self.followerMovedAbove45Deg = currentAngle > self.TARGET_ANGLE
self.followerMovedAbove180Deg = currentAngle > self.TARGET_MAX_ANGLE
return False
def isFollowerPositionCorrect(self):
return self.followerMovedAbove45Deg and not self.followerMovedAbove180Deg
waitCondition = WaitCondition()
MAX_WAIT_TIME = 5.0 #seconds
conditionMet = helper.wait_for_condition(lambda: waitCondition.checkConditionMet(), MAX_WAIT_TIME)
# 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 test:")
Report.info_vector3(follower.position, "follower position after test:")
leadPositionDelta = lead.position.Subtract(leadInitialPosition)
leadRemainedStill = JointsHelper.vector3SmallerThanScalar(leadPositionDelta, FLOAT_EPSILON)
Report.critical_result(Tests.check_lead_position, leadRemainedStill)
followerMovedInXOnly = ((follower.position.x > leadInitialPosition.x) > FLOAT_EPSILON and
(follower.position.z - leadInitialPosition.z) > FLOAT_EPSILON)
Report.critical_result(Tests.check_follower_position, followerMovedInXOnly)
Report.critical_result(Tests.check_follower_position, conditionMet and waitCondition.isFollowerPositionCorrect())
# 6) Exit Game Mode
helper.exit_game_mode(Tests.exit_game_mode)