Go to the documentation of this file.00001
00002
00003 import sys
00004
00005 import kdl_parser_py.urdf
00006 import unittest
00007
00008 import rostest
00009
00010 PKG = "kdl_parser_py"
00011 NAME = "test_kdl_parser"
00012
00013 class TestKdlParser(unittest.TestCase):
00014 def runTest(self):
00015 filename = None
00016 if (sys.argv > 1):
00017 filename = sys.argv[1]
00018 else:
00019 self.fail("Expected filename!")
00020 (ok, tree) = kdl_parser_py.urdf.treeFromFile(filename)
00021 self.assertTrue(ok)
00022
00023 self.assertEqual(tree.getNrOfJoints(), 8)
00024
00025 self.assertEqual(tree.getNrOfSegments(), 10)
00026 chain = tree.getChain("base_link", "right_gripper")
00027 self.assertEqual(chain.getNrOfSegments(), 2)
00028 self.assertEqual(chain.getNrOfJoints(), 2)
00029 self.assertEqual(chain.getSegment(0).getName(), "gripper_pole")
00030 self.assertEqual(chain.getSegment(0).getJoint().getName(), "gripper_extension")
00031 self.assertEqual(chain.getSegment(1).getName(), "right_gripper")
00032 self.assertEqual(chain.getSegment(1).getJoint().getName(), "right_gripper_joint")
00033
00034
00035 if __name__ == '__main__':
00036 rostest.run(PKG, NAME, TestKdlParser, sys.argv)