Skip to content

Commit a4a4751

Browse files
author
Rachel
committed
unit tests for GetPointFrom
1 parent d76774e commit a4a4751

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_util.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,34 @@ def test_SampleTimeGenerator_(self):
595595
decimal=7, err_msg=error, \
596596
verbose=True)
597597

598+
def test_GetPointFrom(self):
599+
# Check that each input type returns the correct xyz coord
600+
601+
# Kinbody
602+
self.env.Load('data/mug1.dae')
603+
mug = self.env.GetKinBody('mug')
604+
mug.SetTransform(numpy.eye(4))
605+
coord_kinbody = prpy.util.GetPointFrom(mug)
606+
expected_kinbody_coords = [0, 0, 0]
607+
#numpy.testing.assert_array_almost_equal(coord_kinbody, expected_kinbody_coords)
608+
609+
expected_coord = [1, 3, 4]
610+
611+
# Point in space
612+
space_coord = numpy.array([1, 3, 4])
613+
space_result = prpy.util.GetPointFrom(space_coord)
614+
numpy.testing.assert_array_almost_equal(space_result, expected_coord)
615+
616+
# 4x4 Transform
617+
trans_coord = numpy.eye(4)
618+
trans_coord[0:3, 3] = expected_coord
619+
trans_result = prpy.util.GetPointFrom(trans_coord)
620+
numpy.testing.assert_array_almost_equal(trans_result, expected_coord)
621+
622+
# List
623+
list_coord = [1, 3, 4]
624+
list_result = prpy.util.GetPointFrom(list_coord)
625+
numpy.testing.assert_array_almost_equal(list_result, expected_coord)
598626

599627
if __name__ == '__main__':
600628
unittest.main()

0 commit comments

Comments
 (0)