bindings_geometry_object.py
Go to the documentation of this file.
1 import unittest
2 import pinocchio as pin
3 import numpy as np
4 
5 @unittest.skipUnless(pin.WITH_HPP_FCL,"Needs HPP-FCL")
6 class TestGeometryObjectBindings(unittest.TestCase):
7 
8  def setUp(self):
9  self.model = pin.buildSampleModelHumanoid()
10  self.collision_model = pin.buildSampleGeometryModelHumanoid(self.model)
11 
12  def test_name_get_set(self):
13  col = self.collision_model.geometryObjects[0]
14  self.assertTrue(col.name == 'rleg_shoulder_object')
15  col.name = 'new_collision_name'
16  self.assertTrue(col.name == 'new_collision_name')
17 
19  col = self.collision_model.geometryObjects[0]
20  self.assertTrue(col.parentJoint == 2)
21  col.parentJoint = 3
22  self.assertTrue(col.parentJoint == 3)
23 
25  m = pin.SE3.Identity()
26  new_m = pin.SE3.Random()
27  col = self.collision_model.geometryObjects[0]
28  self.assertTrue(np.allclose(col.placement.homogeneous,m.homogeneous))
29  col.placement = new_m
30  self.assertTrue(np.allclose(col.placement.homogeneous , new_m.homogeneous))
31 
32  def test_meshpath_get(self):
33  col = self.collision_model.geometryObjects[0]
34  self.assertTrue(col.meshPath is not None)
35 
36  def test_scale(self):
37  scale = np.array([1.,2.,3.])
38  pin.setGeometryMeshScales(self.collision_model,scale)
39  for obj in self.collision_model.geometryObjects:
40  self.assertTrue(obj.meshScale[0] == scale[0])
41  self.assertTrue(obj.meshScale[1] == scale[1])
42  self.assertTrue(obj.meshScale[2] == scale[2])
43 
44  def test_scalar_scale(self):
45  scale = 2.
46  vec = np.array([scale]*3)
47  pin.setGeometryMeshScales(self.collision_model,scale)
48  for obj in self.collision_model.geometryObjects:
49  self.assertTrue(np.allclose(obj.meshScale, vec))
50 
51  def test_create_data(self):
52  collision_data = self.collision_model.createData()
53  self.assertEqual(len(collision_data.oMg), self.collision_model.ngeoms)
54 
55  def test_create_datas(self):
56  collision_data = self.collision_model.createData()
57 
58  self.assertEqual(len(collision_data.oMg), self.collision_model.ngeoms)
59 
60  data_2, collision_data_2 = pin.createDatas(self.model, self.collision_model)
61  self.assertTrue(self.model.check(data_2))
62  self.assertEqual(len(collision_data_2.oMg), self.collision_model.ngeoms)
63 
64  def test_copy(self):
65  collision_model_copy = self.collision_model.copy()
66  self.assertEqual(self.collision_model.ngeoms,collision_model_copy.ngeoms)
67 
68  collision_data = self.collision_model.createData()
69  collision_data_copy = collision_data.copy()
70  self.assertEqual(len(collision_data.oMg),len(collision_data_copy.oMg))
71 
72 if __name__ == '__main__':
73  unittest.main()


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