geometry-model.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2023 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_geometry_model_hpp__
6 #define __pinocchio_python_geometry_model_hpp__
7 
8 #include <eigenpy/memory.hpp>
9 
16 
18 
19 #if EIGENPY_VERSION_AT_MOST(2, 8, 1)
21 #endif
22 
23 namespace pinocchio
24 {
25  namespace python
26  {
27  namespace bp = boost::python;
28 
30  : public boost::python::def_visitor<GeometryModelPythonVisitor>
31  {
32  public:
33  /* --- Exposing C++ API to python through the handler ----------------- */
34  template<class PyClass>
35  void visit(PyClass & cl) const
36  {
37  cl.def(bp::init<>(bp::arg("self"), "Default constructor"))
38  .def(bp::init<const GeometryModel &>(bp::args("self", "other"), "Copy constructor"))
39 
40  .add_property(
41  "ngeoms", &GeometryModel::ngeoms,
42  "Number of geometries contained in the Geometry Model.")
43  .add_property(
44  "geometryObjects", &GeometryModel::geometryObjects, "Vector of geometries objects.")
45 
46  .def(
47  "addGeometryObject",
48  static_cast<GeometryModel::GeomIndex (GeometryModel::*)(const GeometryObject &)>(
50  bp::args("self", "geometry_object"),
51  "Add a GeometryObject to a GeometryModel.\n"
52  "Parameters\n"
53  "\tgeometry_object : a GeometryObject\n")
54  .def(
55  "addGeometryObject",
56  static_cast<GeometryModel::GeomIndex (GeometryModel::*)(
58  bp::args("self", "geometry_object", "model"),
59  "Add a GeometryObject to a GeometryModel and set its parent joint by reading its "
60  "value in the model.\n"
61  "Parameters\n"
62  "\tgeometry_object : a GeometryObject\n"
63  "\tmodel : a Model of the system\n")
64  .def(
65  "removeGeometryObject", &GeometryModel::removeGeometryObject, bp::args("self", "name"),
66  "Remove a GeometryObject. Remove also the collision pairs that contain the object.")
67  .def(
68  "getGeometryId", &GeometryModel::getGeometryId, bp::args("self", "name"),
69  "Returns the index of a GeometryObject given by its name.")
70  .def(
71  "existGeometryName", &GeometryModel::existGeometryName, bp::args("self", "name"),
72  "Checks if a GeometryObject given by its name exists.")
73  .def(
74  "createData", &GeometryModelPythonVisitor::createData, bp::arg("self"),
75  "Create a GeometryData associated to the current model.")
76  .def("clone", &GeometryModel::clone, bp::arg("self"), "Create a deep copy of *this.")
77  .add_property(
78  "collisionPairs", &GeometryModel::collisionPairs, "Vector of collision pairs.")
79  .add_property(
80  "collisionPairMapping", &GeometryModel::collisionPairMapping,
81  "Matrix relating the collision pair ID to a pair of two GeometryObject indexes.")
82  .def(
83  "addCollisionPair", &GeometryModel::addCollisionPair,
84  bp::args("self", "collision_pair"),
85  "Add a collision pair given by the index of the two collision objects.")
86  .def(
87  "addAllCollisionPairs", &GeometryModel::addAllCollisionPairs,
88  "Add all collision pairs.\n"
89  "note : collision pairs between geometries having the same parent joint are not added.")
90  .def(
91  "setCollisionPairs", &GeometryModel::setCollisionPairs,
92  (bp::arg("self"), bp::arg("collision_map"), bp::arg("upper") = true),
93  "Set the collision pairs from a given input array.\n"
94  "Each entry of the input matrix defines the activation of a given collision pair"
95  "(map[i,j] == True means that the pair (i,j) is active).")
96  .def(
97  "removeCollisionPair", &GeometryModel::removeCollisionPair,
98  bp::args("self", "collision_pair"), "Remove a collision pair.")
99  .def(
100  "removeAllCollisionPairs", &GeometryModel::removeAllCollisionPairs,
101  "Remove all collision pairs.")
102  .def(
103  "existCollisionPair", &GeometryModel::existCollisionPair,
104  bp::args("self", "collision_pair"), "Check if a collision pair exists.")
105  .def(
106  "findCollisionPair", &GeometryModel::findCollisionPair,
107  bp::args("self", "collision_pair"), "Return the index of a collision pair.")
108 
109  .def(bp::self == bp::self)
110  .def(bp::self != bp::self);
111  }
112 
113  static GeometryData createData(const GeometryModel & geomModel)
114  {
115  return GeometryData(geomModel);
116  }
117 
118  /* --- Expose --------------------------------------------------------- */
119  static void expose()
120  {
121  if (!register_symbolic_link_to_registered_type<GeometryModel>())
122  {
123  bp::class_<GeometryModel>(
124  "GeometryModel",
125  "Geometry model containing the collision or visual geometries associated to a model.",
126  bp::no_init)
132 #ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
134 #endif
135  ;
136  }
137  }
138  };
139 
140  } // namespace python
141 } // namespace pinocchio
142 
143 #endif // ifndef __pinocchio_python_geometry_model_hpp__
pinocchio::GeometryModel::clone
GeometryModel clone() const
Create a deep copy of *this.
pinocchio::python::GeometryModelPythonVisitor::visit
void visit(PyClass &cl) const
Definition: geometry-model.hpp:35
pinocchio::GeometryModel::getGeometryId
GeomIndex getGeometryId(const std::string &name) const
Return the index of a GeometryObject given by its name.
boost::python
pinocchio::GeometryModel::addCollisionPair
void addCollisionPair(const CollisionPair &pair)
Add a collision pair into the vector of collision_pairs. The method check before if the given Collisi...
pinocchio::GeometryModel::GeomIndex
pinocchio::GeomIndex GeomIndex
Definition: multibody/geometry.hpp:70
pinocchio::python::PickleFromStringSerialization
Definition: pickle.hpp:17
registration.hpp
pinocchio::GeometryModel::removeGeometryObject
void removeGeometryObject(const std::string &name)
Remove a GeometryObject.
pinocchio::GeometryObject
Definition: multibody/geometry-object.hpp:87
pinocchio::python::GeometryModelPythonVisitor::expose
static void expose()
Definition: geometry-model.hpp:119
pinocchio::GeometryData
Definition: multibody/geometry.hpp:233
pinocchio::GeometryModel::addAllCollisionPairs
void addAllCollisionPairs()
Add all possible collision pairs.
pinocchio::GeometryModel::existCollisionPair
bool existCollisionPair(const CollisionPair &pair) const
Check if a collision pair exists in collisionPairs. See also findCollisitionPair(const CollisionPair ...
pinocchio::GeometryModel::removeAllCollisionPairs
void removeAllCollisionPairs()
Remove all collision pairs from collisionPairs. Same as collisionPairs.clear().
pinocchio::GeometryModel::geometryObjects
GeometryObjectVector geometryObjects
Vector of GeometryObjects used for collision computations.
Definition: multibody/geometry.hpp:217
pickle.hpp
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
#define EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(...)
pinocchio::python::PrintableVisitor
Set the Python method str and repr to use the overloading operator<<.
Definition: printable.hpp:21
serializable.hpp
pinocchio::GeometryModel::collisionPairMapping
MatrixXi collisionPairMapping
Matrix relating the collision pair ID to a pair of two GeometryObject indexes.
Definition: multibody/geometry.hpp:223
python
pinocchio::GeometryModel::findCollisionPair
PairIndex findCollisionPair(const CollisionPair &pair) const
Return the index of a given collision pair in collisionPairs.
pinocchio::python::CopyableVisitor
Add the Python method copy to allow a copy of this by calling the copy constructor.
Definition: copyable.hpp:21
geometry.hpp
address.hpp
pinocchio::python::GeometryModelPythonVisitor
Definition: geometry-model.hpp:29
pinocchio::GeometryModel::ngeoms
Index ngeoms
The number of GeometryObjects.
Definition: multibody/geometry.hpp:214
copyable.hpp
pinocchio::python::SerializableVisitor
Definition: bindings/python/serialization/serializable.hpp:19
pinocchio::python::AddressVisitor
Add the Python method to extract the address of the underlying C++ object.
Definition: address.hpp:21
pinocchio::GeometryModel::addGeometryObject
GeomIndex addGeometryObject(const GeometryObject &object, const ModelTpl< S2, O2, _JointCollectionTpl > &model)
Add a geometry object to a GeometryModel and set its parent joint.
pinocchio::GeometryModel::collisionPairs
CollisionPairVector collisionPairs
Vector of collision pairs.
Definition: multibody/geometry.hpp:220
pinocchio::python::GeometryModelPythonVisitor::createData
static GeometryData createData(const GeometryModel &geomModel)
Definition: geometry-model.hpp:113
cl
cl
memory.hpp
pinocchio::GeometryModel::existGeometryName
bool existGeometryName(const std::string &name) const
Check if a GeometryObject given by its name exists.
printable.hpp
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
pinocchio::GeometryModel::removeCollisionPair
void removeCollisionPair(const CollisionPair &pair)
Remove if exists the CollisionPair from the vector collision_pairs.
pinocchio::GeometryModel::setCollisionPairs
void setCollisionPairs(const MatrixXb &collision_map, const bool upper=true)
Set the collision pairs from a given input array. Each entry of the input matrix defines the activati...
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:44