Skip to content

Commit 0e4218b

Browse files
author
David Butterworth
committed
Add extra Unit Test for GetForwardKinematics()
1 parent 0b1def4 commit 0e4218b

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

tests/test_util.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ def test_SampleTimeGenerator_EndPointLessThanHalfStepSize(self):
598598

599599
# GetForwardKinematics()
600600

601-
def test_GetForwardKinematics(self):
602-
# Zero configuration, use thes the active manipulator by default
601+
def test_GetForwardKinematics_UseActiveManipulator(self):
602+
# Zero configuration, uses the the active manipulator by default
603603
q0 = numpy.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
604604
T_ee = prpy.util.GetForwardKinematics(self.robot, q0)
605605

@@ -613,6 +613,7 @@ def test_GetForwardKinematics(self):
613613
numpy.testing.assert_array_almost_equal(T_ee, expected_T_ee0, decimal=7, \
614614
err_msg=error, verbose=True)
615615

616+
def test_GetForwardKinematics_SpecifyManipulator(self):
616617
# A different configuration, specifying the manipulator to use
617618
q1 = numpy.array([-1.8, 0.0, -0.7, 2.0, 0.5, 0.2, 0.0])
618619
manip = self.robot.GetActiveManipulator()
@@ -628,6 +629,31 @@ def test_GetForwardKinematics(self):
628629
numpy.testing.assert_array_almost_equal(T_ee, expected_T_ee1, decimal=7, \
629630
err_msg=error, verbose=True)
630631

632+
def test_GetForwardKinematics_SpecifyFrame(self):
633+
# Get the FK with respect to the base frame ('segway') of the
634+
# manipulator chain. This should give the same result as not
635+
# specifying the reference frame at all.
636+
q1 = numpy.array([-1.8, 0.0, -0.7, 2.0, 0.5, 0.2, 0.0])
637+
manip = self.robot.GetActiveManipulator()
638+
frame = 'segway'
639+
T_ee = prpy.util.GetForwardKinematics(self.robot, q1, manip, frame)
640+
641+
expected_T_ee2 = numpy.array([[ 0.7126777, 0.3653714, -0.5988272, -0.3313395],
642+
[-0.0541115, -0.8224716, -0.5662263, -0.3259651],
643+
[-0.6994014, 0.4359404, -0.5663864, 1.4394693],
644+
[ 0.0, 0.0, 0.0, 1.0 ]])
645+
646+
# We need to transform the expected result along the z-axis
647+
# because the Segway-WAM model is strange
648+
T_segway = self.robot.GetLink('segway').GetTransform()
649+
expected_T_ee2 = numpy.dot(numpy.linalg.inv(T_segway), expected_T_ee2)
650+
651+
error = 'The end-effector transform ' + str(T_ee) + \
652+
' does not equal the expected end-effector' + \
653+
' transform ' + str(expected_T_ee2)
654+
numpy.testing.assert_array_almost_equal(T_ee, expected_T_ee2, decimal=7, \
655+
err_msg=error, verbose=True)
656+
631657

632658
class Test_GetPointFrom(unittest.TestCase):
633659
"""

0 commit comments

Comments
 (0)