test_kdl_parser.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import sys
4 
6 import unittest
7 
8 import rostest
9 
10 PKG = "kdl_parser_py"
11 NAME = "test_kdl_parser"
12 
13 class TestKdlParser(unittest.TestCase):
14  def runTest(self):
15  filename = None
16  if (sys.argv > 1):
17  filename = sys.argv[1]
18  else:
19  self.fail("Expected filename!")
20  (ok, tree) = kdl_parser_py.urdf.treeFromFile(filename)
21  self.assertTrue(ok)
22  # KDL doesn't count fixed joints (since they aren't kinematic)
23  self.assertEqual(tree.getNrOfJoints(), 8)
24  # KDL doesn't count base link (since it's attached by fixed links
25  self.assertEqual(tree.getNrOfSegments(), 10)
26  chain = tree.getChain("base_link", "right_gripper")
27  self.assertEqual(chain.getNrOfSegments(), 2)
28  self.assertEqual(chain.getNrOfJoints(), 2)
29  self.assertEqual(chain.getSegment(0).getName(), "gripper_pole")
30  self.assertEqual(chain.getSegment(0).getJoint().getName(), "gripper_extension")
31  self.assertEqual(chain.getSegment(1).getName(), "right_gripper")
32  self.assertEqual(chain.getSegment(1).getJoint().getName(), "right_gripper_joint")
33 
34  inertia = chain.getSegment(1).getInertia()
35  self.assertAlmostEqual(inertia.getCOG().z(), 3.0)
36 
37 if __name__ == '__main__':
38  rostest.run(PKG, NAME, TestKdlParser, sys.argv)
def treeFromFile(filename)
Definition: urdf.py:7


kdl_parser_py
Author(s): Jonathan Bohren , Jackie Kay
autogenerated on Wed Jun 5 2019 21:10:59