Skip to content

Commit 88a3d34

Browse files
author
David Butterworth
committed
Add Unit Test for GetForwardKinematics()
1 parent 74b4c57 commit 88a3d34

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/test_util.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,5 +641,38 @@ def test_GetPointFrom_List(self):
641641
list_result = prpy.util.GetPointFrom(list_coord)
642642
numpy.testing.assert_array_almost_equal(list_result, expected_coord)
643643

644+
# GetForwardKinematics()
645+
646+
def test_GetForwardKinematics(self):
647+
# Zero configuration, use thes the active manipulator by default
648+
q0 = numpy.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0])
649+
T_ee = prpy.util.GetForwardKinematics(self.robot, q0)
650+
651+
expected_T_ee0 = numpy.array([[1.0, 0.0, 0.0, 0.07 ],
652+
[0.0, 1.0, 0.0, 0.0 ],
653+
[0.0, 0.0, 1.0, 2.168],
654+
[0.0, 0.0, 0.0, 1.0 ]])
655+
error = 'The end-effector transform ' + str(T_ee) + \
656+
' does not equal the expected end-effector' + \
657+
' transform ' + str(expected_T_ee0)
658+
numpy.testing.assert_array_almost_equal(T_ee, expected_T_ee0, decimal=7, \
659+
err_msg=error, verbose=True)
660+
661+
# A different configuration, specifying the manipulator to use
662+
q1 = numpy.array([-1.8, 0.0, -0.7, 2.0, 0.5, 0.2, 0.0])
663+
manip = self.robot.GetActiveManipulator()
664+
T_ee = prpy.util.GetForwardKinematics(self.robot, q1, manip)
665+
666+
expected_T_ee1 = numpy.array([[ 0.7126777, 0.3653714, -0.5988272, -0.3313395],
667+
[-0.0541115, -0.8224716, -0.5662263, -0.3259651],
668+
[-0.6994014, 0.4359404, -0.5663864, 1.4394693],
669+
[ 0.0, 0.0, 0.0, 1.0 ]])
670+
error = 'The end-effector transform ' + str(T_ee) + \
671+
' does not equal the expected end-effector' + \
672+
' transform ' + str(expected_T_ee1)
673+
numpy.testing.assert_array_almost_equal(T_ee, expected_T_ee1, decimal=7, \
674+
err_msg=error, verbose=True)
675+
676+
644677
if __name__ == '__main__':
645678
unittest.main()

0 commit comments

Comments
 (0)