bindings_urdf.py
Go to the documentation of this file.
1 import unittest
2 from pathlib import Path
3 
4 import pinocchio as pin
5 
6 
7 @unittest.skipUnless(pin.WITH_URDFDOM, "Needs URDFDOM")
8 class TestGeometryObjectUrdfBindings(unittest.TestCase):
9  def setUp(self):
10  self.current_dir = Path(__file__).parent
11  self.model_dir = self.current_dir / "../../models/example-robot-data/robots"
12  self.model_path = self.model_dir / "romeo_description/urdf/romeo.urdf"
13 
14  def test_load(self):
15  pin.buildModelFromUrdf(self.model_path)
16  pin.buildModelFromUrdf(self.model_path, pin.JointModelFreeFlyer())
17 
18  def test_self_load(self):
19  model = pin.Model()
20  pin.buildModelFromUrdf(self.model_path, pin.JointModelFreeFlyer(), model)
21  pin.buildModelFromUrdf(self.model_path, pin.JointModelFreeFlyer())
22 
23  def test_xml(self):
24  with self.model_path.open() as model:
25  file_content = model.read()
26 
27  model_ref = pin.buildModelFromUrdf(self.model_path, pin.JointModelFreeFlyer())
28  model = pin.buildModelFromXML(file_content, pin.JointModelFreeFlyer())
29 
30  self.assertEqual(model, model_ref)
31 
32  model_self = pin.Model()
33  pin.buildModelFromXML(file_content, pin.JointModelFreeFlyer(), model_self)
34  self.assertEqual(model_self, model_ref)
35 
36  def test_pickle(self):
37  import pickle
38 
39  model_dir = self.current_dir / "../../models/example-robot-data/robots"
40  model_path = model_dir / "ur_description/urdf/ur5_robot.urdf"
41 
42  model = pin.buildModelFromUrdf(model_path)
43  filename = Path("model.pickle")
44  with filename.open("wb") as f:
45  pickle.dump(model, f)
46 
47  with filename.open("rb") as f:
48  model_copy = pickle.load(f)
49 
50  self.assertTrue(model == model_copy)
51 
52 
53 if __name__ == "__main__":
54  unittest.main()
bindings_urdf.TestGeometryObjectUrdfBindings.current_dir
current_dir
Definition: bindings_urdf.py:10
bindings_urdf.TestGeometryObjectUrdfBindings.model_path
model_path
Definition: bindings_urdf.py:12
bindings_urdf.TestGeometryObjectUrdfBindings.test_load
def test_load(self)
Definition: bindings_urdf.py:14
bindings_urdf.TestGeometryObjectUrdfBindings.test_xml
def test_xml(self)
Definition: bindings_urdf.py:23
bindings_urdf.TestGeometryObjectUrdfBindings.test_self_load
def test_self_load(self)
Definition: bindings_urdf.py:18
bindings_urdf.TestGeometryObjectUrdfBindings.model_dir
model_dir
Definition: bindings_urdf.py:11
append-urdf-model-with-another-model.open
open
Definition: append-urdf-model-with-another-model.py:78
bindings_urdf.TestGeometryObjectUrdfBindings.setUp
def setUp(self)
Definition: bindings_urdf.py:9
bindings_urdf.TestGeometryObjectUrdfBindings.test_pickle
def test_pickle(self)
Definition: bindings_urdf.py:36
bindings_urdf.TestGeometryObjectUrdfBindings
Definition: bindings_urdf.py:8


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:25