@@ -641,5 +641,38 @@ def test_GetPointFrom_List(self):
641
641
list_result = prpy .util .GetPointFrom (list_coord )
642
642
numpy .testing .assert_array_almost_equal (list_result , expected_coord )
643
643
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
+
644
677
if __name__ == '__main__' :
645
678
unittest .main ()
0 commit comments