serialization.py
Go to the documentation of this file.
1 import unittest
2 
3 import pinocchio as pin
4 
5 from test_case import PinocchioTestCase as TestCase
6 
7 main_path = "./serialization-data"
8 
9 class TestSerialization(TestCase):
10 
11  def testTXT(self):
12  model = pin.buildSampleModelHumanoidRandom()
13  filename = main_path + "/model.txt"
14  model.saveToText(filename)
15 
16  model2 = pin.Model()
17  model2.loadFromText(filename)
18 
19  self.assertTrue(model == model2)
20 
21  def testXML(self):
22  model = pin.buildSampleModelHumanoidRandom()
23  filename = main_path + "/model.xml"
24  tag_name = "Model"
25  model.saveToXML(filename,tag_name)
26 
27  model2 = pin.Model()
28  model2.loadFromXML(filename,tag_name)
29 
30  self.assertTrue(model == model2)
31 
32  def testBIN(self):
33  model = pin.buildSampleModelHumanoidRandom()
34  filename = main_path + "/model.bin"
35  model.saveToBinary(filename)
36 
37  model2 = pin.Model()
38  model2.loadFromBinary(filename)
39 
40  self.assertTrue(model == model2)
41 
42 if __name__ == '__main__':
43  unittest.main()
44 
45 


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04