bindings_data.py
Go to the documentation of this file.
1 import unittest
2 import pinocchio as pin
3 
4 from test_case import PinocchioTestCase as TestCase
5 
6 class TestData(TestCase):
7  def setUp(self):
8  self.model = pin.buildSampleModelHumanoidRandom()
9  self.data = self.model.createData()
10 
11  def test_copy(self):
12  data2 = self.data.copy()
13  q = pin.neutral(self.model)
14  pin.forwardKinematics(self.model,data2,q)
15  jointId = self.model.njoints-1
16  self.assertNotEqual(self.data.oMi[jointId], data2.oMi[jointId])
17 
18  data3 = data2.copy()
19  self.assertEqual(data2.oMi[jointId], data3.oMi[jointId])
20 
22  model = self.model
23  data = self.data
24 
25  q = pin.neutral(model)
26  pin.centerOfMass(model,data,q)
27 
28  com_list = data.com.tolist()
29  com = data.com[0]
30  with self.assertRaises(Exception) as context:
31  com = data.com[len(data.com)+10]
32  print("com: ",com)
33 
34  self.assertTrue('Index out of range' in str(context.exception))
35 
36  with self.assertRaises(Exception) as context:
37  com = data.com['1']
38  print("com: ",com)
39 
40  self.assertTrue('Invalid index type' in str(context.exception))
41 
42  def test_pickle(self):
43  import pickle
44 
45  data = self.data
46  filename = "data.pickle"
47  with open(filename, 'wb') as f:
48  pickle.dump(data,f)
49 
50  with open(filename, 'rb') as f:
51  data_copy = pickle.load(f)
52 
53  self.assertTrue(data == data_copy)
54 
55 if __name__ == '__main__':
56  unittest.main()
JointDataTpl< Scalar, Options, JointCollectionTpl > createData(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through CreateData visitor to create a JointDataTpl.
def test_std_vector_field(self)
void copy(const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &origin, DataTpl< Scalar, Options, JointCollectionTpl > &dest, KinematicLevel kinematic_level)
Copy part of the data from origin to dest. Template parameter can be used to select at which differen...
Definition: copy.hpp:52


pinocchio
Author(s):
autogenerated on Fri Jun 23 2023 02:38:28