@@ -565,7 +565,7 @@ def test_SampleTimeGenerator_StepOfTwo(self):
565
565
decimal = 7 , err_msg = error , \
566
566
verbose = True )
567
567
568
- def test_SampleTimeGenerator_ (self ):
568
+ def test_SampleTimeGenerator_EndPointMoreThanHalfStepSize (self ):
569
569
# Check that the sequence includes the end-point when it's
570
570
# distance from the previous point is more than half the
571
571
# step-size. This is required for collision-checking
@@ -581,7 +581,7 @@ def test_SampleTimeGenerator_(self):
581
581
decimal = 7 , err_msg = error , \
582
582
verbose = True )
583
583
584
- def test_SampleTimeGenerator_ (self ):
584
+ def test_SampleTimeGenerator_EndPointLessThanHalfStepSize (self ):
585
585
# Check that the end-point is excluded when it's less than
586
586
# half the step-size from the previous value.
587
587
expected_sequence = [0.0 , 2.0 , 4.0 ]
@@ -595,7 +595,70 @@ def test_SampleTimeGenerator_(self):
595
595
decimal = 7 , err_msg = error , \
596
596
verbose = True )
597
597
598
+
599
+ # GetForwardKinematics()
600
+
601
+ def test_GetForwardKinematics_UseActiveManipulator (self ):
602
+ # Zero configuration, uses the the active manipulator by default
603
+ q0 = numpy .array ([0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 ])
604
+ T_ee = prpy .util .GetForwardKinematics (self .robot , q0 )
605
+
606
+ expected_T_ee0 = numpy .array ([[1.0 , 0.0 , 0.0 , 0.07 ],
607
+ [0.0 , 1.0 , 0.0 , 0.0 ],
608
+ [0.0 , 0.0 , 1.0 , 2.168 ],
609
+ [0.0 , 0.0 , 0.0 , 1.0 ]])
610
+ error = 'The end-effector transform ' + str (T_ee ) + \
611
+ ' does not equal the expected end-effector' + \
612
+ ' transform ' + str (expected_T_ee0 )
613
+ numpy .testing .assert_array_almost_equal (T_ee , expected_T_ee0 , decimal = 7 , \
614
+ err_msg = error , verbose = True )
615
+
616
+ def test_GetForwardKinematics_SpecifyManipulator (self ):
617
+ # A different configuration, specifying the manipulator to use
618
+ q1 = numpy .array ([- 1.8 , 0.0 , - 0.7 , 2.0 , 0.5 , 0.2 , 0.0 ])
619
+ manip = self .robot .GetActiveManipulator ()
620
+ T_ee = prpy .util .GetForwardKinematics (self .robot , q1 , manip )
621
+
622
+ expected_T_ee1 = numpy .array ([[ 0.7126777 , 0.3653714 , - 0.5988272 , - 0.3313395 ],
623
+ [- 0.0541115 , - 0.8224716 , - 0.5662263 , - 0.3259651 ],
624
+ [- 0.6994014 , 0.4359404 , - 0.5663864 , 1.4394693 ],
625
+ [ 0.0 , 0.0 , 0.0 , 1.0 ]])
626
+ error = 'The end-effector transform ' + str (T_ee ) + \
627
+ ' does not equal the expected end-effector' + \
628
+ ' transform ' + str (expected_T_ee1 )
629
+ numpy .testing .assert_array_almost_equal (T_ee , expected_T_ee1 , decimal = 7 , \
630
+ err_msg = error , verbose = True )
631
+
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
+
657
+
598
658
class Test_GetPointFrom (unittest .TestCase ):
659
+ """
660
+ Unit Tests for GetPointFrom()
661
+ """
599
662
def setUp (self ):
600
663
self .env = openravepy .Environment ()
601
664
@@ -641,5 +704,6 @@ def test_GetPointFrom_List(self):
641
704
list_result = prpy .util .GetPointFrom (list_coord )
642
705
numpy .testing .assert_array_almost_equal (list_result , expected_coord )
643
706
707
+
644
708
if __name__ == '__main__' :
645
709
unittest .main ()
0 commit comments