@@ -595,6 +595,51 @@ def test_SampleTimeGenerator_(self):
595
595
decimal = 7 , err_msg = error , \
596
596
verbose = True )
597
597
598
+ class Test_GetPointFrom (unittest .TestCase ):
599
+ def setUp (self ):
600
+ self .env = openravepy .Environment ()
601
+
602
+ def tearDown (self ):
603
+ self .env .Destroy ()
604
+
605
+ def test_GetPointFrom_Kinbody (self ):
606
+ # Check that each input type returns the correct xyz coord
607
+
608
+ # Kinbody
609
+ self .env .Load ('data/mug1.dae' )
610
+ mug = self .env .GetKinBody ('mug' )
611
+ mug .SetTransform (numpy .eye (4 ))
612
+ coord_kinbody = prpy .util .GetPointFrom (mug )
613
+ expected_kinbody_coords = [0 , 0 , 0 ]
614
+ numpy .testing .assert_array_almost_equal (coord_kinbody , expected_kinbody_coords )
615
+
616
+ def test_GetPointFrom_Space (self ):
617
+ # Check that each input type returns the correct xyz coord
618
+ expected_coord = [1 , 3 , 4 ]
619
+
620
+ # Point in space
621
+ space_coord = numpy .array ([1 , 3 , 4 ])
622
+ space_result = prpy .util .GetPointFrom (space_coord )
623
+ numpy .testing .assert_array_almost_equal (space_result , expected_coord )
624
+
625
+ def test_GetPointFrom_Transform (self ):
626
+ # Check that each input type returns the correct xyz coord
627
+ expected_coord = [1 , 3 , 4 ]
628
+
629
+ # 4x4 Transform
630
+ trans_coord = numpy .eye (4 )
631
+ trans_coord [0 :3 , 3 ] = expected_coord
632
+ trans_result = prpy .util .GetPointFrom (trans_coord )
633
+ numpy .testing .assert_array_almost_equal (trans_result , expected_coord )
634
+
635
+ def test_GetPointFrom_List (self ):
636
+ # Check that each input type returns the correct xyz coord
637
+ expected_coord = [1 , 3 , 4 ]
638
+
639
+ # List
640
+ list_coord = [1 , 3 , 4 ]
641
+ list_result = prpy .util .GetPointFrom (list_coord )
642
+ numpy .testing .assert_array_almost_equal (list_result , expected_coord )
598
643
599
644
if __name__ == '__main__' :
600
645
unittest .main ()
0 commit comments