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)
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:16f592487e8973abcf6b696aee6e430924c22daac0d6bb781c9e76153cd932f7
size 8885
oid sha256:352a64f523b3246000393309fa7f14955fe554e0b792a4177349f0f2db8a2b62
size 5901
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4d5c38cf9b97ae28c391916e6637aebf767d5ac009df61e730396fe8b116f3e5
size 6913
oid sha256:31bd1feb92c3bb8a5c5df4638927a9a80e879329965732c4c32f673c236a8b0a
size 6021
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a6f26f1c1c037fa0b848ac9b3d9a76e476b4853d770f1a77c01714286733b567
size 6921
oid sha256:063779c1e80ce22319cb82ff0d7635d3dcbb043b789c3830cc405ffa36d3c0ef
size 5876
@@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4ffd3c4ee04fa8a414995c39c7ca79246e3d9b0ceee1ad1b85d61a5298f71495
size 6940
oid sha256:5bd3a952841aa924a4869c74fad7ed397667a87948270f0ce35f314e6cf2e14a
size 5927