bindings_geometry_object.py
Go to the documentation of this file.
1 import unittest
2 
3 import numpy as np
4 import pinocchio as pin
5 
6 
7 @unittest.skipUnless(pin.WITH_HPP_FCL, "Needs HPP-FCL")
8 class TestGeometryObjectBindings(unittest.TestCase):
9  def setUp(self):
10  self.model = pin.buildSampleModelHumanoid()
11  self.collision_model = pin.buildSampleGeometryModelHumanoid(self.model)
12 
13  def test_name_get_set(self):
14  col = self.collision_model.geometryObjects[0]
15  self.assertTrue(col.name == "rleg_shoulder_object")
16  col.name = "new_collision_name"
17  self.assertTrue(col.name == "new_collision_name")
18 
20  col = self.collision_model.geometryObjects[0]
21  self.assertTrue(col.parentJoint == 2)
22  col.parentJoint = 3
23  self.assertTrue(col.parentJoint == 3)
24 
26  m = pin.SE3.Identity()
27  new_m = pin.SE3.Random()
28  col = self.collision_model.geometryObjects[0]
29  self.assertTrue(np.allclose(col.placement.homogeneous, m.homogeneous))
30  col.placement = new_m
31  self.assertTrue(np.allclose(col.placement.homogeneous, new_m.homogeneous))
32 
33  def test_meshpath_get(self):
34  col = self.collision_model.geometryObjects[0]
35  self.assertTrue(col.meshPath is not None)
36 
37  def test_create_data(self):
38  collision_data = self.collision_model.createData()
39  self.assertEqual(len(collision_data.oMg), self.collision_model.ngeoms)
40 
41  def test_create_datas(self):
42  collision_data = self.collision_model.createData()
43 
44  self.assertEqual(len(collision_data.oMg), self.collision_model.ngeoms)
45 
46  data_2, collision_data_2 = pin.createDatas(self.model, self.collision_model)
47  self.assertTrue(self.model.check(data_2))
48  self.assertEqual(len(collision_data_2.oMg), self.collision_model.ngeoms)
49 
50  def test_copy(self):
51  collision_model_copy = self.collision_model.copy()
52  self.assertEqual(self.collision_model.ngeoms, collision_model_copy.ngeoms)
53 
54  collision_data = self.collision_model.createData()
55  collision_data_copy = collision_data.copy()
56  self.assertEqual(len(collision_data.oMg), len(collision_data_copy.oMg))
57 
59  col = self.collision_model.geometryObjects[0]
60  self.assertTrue(isinstance(col.meshMaterial, (pin.GeometryNoMaterial)))
61  col.meshMaterial = pin.GeometryPhongMaterial()
62  self.assertTrue(isinstance(col.meshMaterial, (pin.GeometryPhongMaterial)))
63  material = col.meshMaterial
64  self.assertTrue(isinstance(material, (pin.GeometryPhongMaterial)))
65  material.meshEmissionColor = np.array([1.0, 1.0, 1.0, 1.0])
66  material.meshShininess = 0.7
67  self.assertTrue(
68  (material.meshEmissionColor == col.meshMaterial.meshEmissionColor).all()
69  )
70  self.assertEqual(material.meshShininess, col.meshMaterial.meshShininess)
71 
72 
73 if __name__ == "__main__":
74  unittest.main()
bindings_geometry_object.TestGeometryObjectBindings.test_parent_get_set
def test_parent_get_set(self)
Definition: bindings_geometry_object.py:19
bindings_geometry_object.TestGeometryObjectBindings.test_copy
def test_copy(self)
Definition: bindings_geometry_object.py:50
bindings_geometry_object.TestGeometryObjectBindings
Definition: bindings_geometry_object.py:8
bindings_geometry_object.TestGeometryObjectBindings.setUp
def setUp(self)
Definition: bindings_geometry_object.py:9
bindings_geometry_object.TestGeometryObjectBindings.test_create_data
def test_create_data(self)
Definition: bindings_geometry_object.py:37
bindings_geometry_object.TestGeometryObjectBindings.test_name_get_set
def test_name_get_set(self)
Definition: bindings_geometry_object.py:13
bindings_geometry_object.TestGeometryObjectBindings.test_meshpath_get
def test_meshpath_get(self)
Definition: bindings_geometry_object.py:33
pinocchio::createData
ConstraintDataTpl< Scalar, Options, ConstraintCollectionTpl > createData(const ConstraintModelTpl< Scalar, Options, ConstraintCollectionTpl > &cmodel)
Definition: constraint-model-visitor.hpp:239
bindings_geometry_object.TestGeometryObjectBindings.test_material_get_set
def test_material_get_set(self)
Definition: bindings_geometry_object.py:58
bindings_geometry_object.TestGeometryObjectBindings.model
model
Definition: bindings_geometry_object.py:10
bindings_geometry_object.TestGeometryObjectBindings.test_create_datas
def test_create_datas(self)
Definition: bindings_geometry_object.py:41
pinocchio::copy
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:42
bindings_geometry_object.TestGeometryObjectBindings.collision_model
collision_model
Definition: bindings_geometry_object.py:11
bindings_geometry_object.TestGeometryObjectBindings.test_placement_get_set
def test_placement_get_set(self)
Definition: bindings_geometry_object.py:25


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:06