geometry-data.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_geometry_data_hpp__
6 #define __pinocchio_python_geometry_data_hpp__
7 
8 #include <eigenpy/memory.hpp>
9 
10 #include "pinocchio/serialization/geometry.hpp"
11 
17 
19 
20 namespace pinocchio
21 {
22  namespace python
23  {
24  namespace bp = boost::python;
25 
26  /* --- COLLISION PAIR --------------------------------------------------- */
27  /* --- COLLISION PAIR --------------------------------------------------- */
28  /* --- COLLISION PAIR --------------------------------------------------- */
30  : public boost::python::def_visitor<CollisionPairPythonVisitor>
31  {
32  static void expose()
33  {
34  bp::class_<CollisionPair> ("CollisionPair",
35  "Pair of ordered index defining a pair of collisions",
36  bp::no_init)
37  .def(bp::init<>
38  (bp::args("self"),
39  "Empty constructor."))
40  .def(bp::init<const GeomIndex &, const GeomIndex &>
41  (bp::args("self","index1", "index2"),
42  "Initializer of collision pair."))
45  .def(bp::self == bp::self)
46  .def(bp::self != bp::self)
47  .def_readwrite("first",&CollisionPair::first)
48  .def_readwrite("second",&CollisionPair::second);
49 
50  StdVectorPythonVisitor<CollisionPair>::expose("StdVec_CollisionPair");
51  serialize< std::vector<CollisionPair> >();
52  }
53  }; // struct CollisionPairPythonVisitor
54 
56  : public boost::python::def_visitor< GeometryDataPythonVisitor >
57  {
58 
59  /* --- Exposing C++ API to python through the handler ----------------- */
60  template<class PyClass>
61  void visit(PyClass& cl) const
62  {
63  cl
64  .def(bp::init<GeometryModel>(bp::args("self","geometry_model"),
65  "Default constructor from a given GeometryModel"))
66 
67  .def_readonly("oMg",
68  &GeometryData::oMg,
69  "Vector of collision objects placement relative to the world frame.\n"
70  "note: These quantities have to be updated by calling updateGeometryPlacements.")
71  .def_readonly("activeCollisionPairs",
72  &GeometryData::activeCollisionPairs,
73  "Vector of active CollisionPairs")
74 
75 #ifdef PINOCCHIO_WITH_HPP_FCL
76  .def_readonly("distanceRequests",
77  &GeometryData::distanceRequests,
78  "Defines which information should be computed by FCL for distance computations")
79  .def_readonly("distanceResults",
80  &GeometryData::distanceResults,
81  "Vector of distance results.")
82  .def_readonly("collisionRequests",
83  &GeometryData::collisionRequests,
84  "Defines which information should be computed by FCL for collision computations.\n\n"
85  "Note: it is possible to define a security_margin and a break_distance for a collision request.\n"
86  "Most likely, for robotics application, these thresholds will be different for each collision pairs\n"
87  "(e.g. the two hands can have a large security margin while the two hips cannot.)")
88  .def_readonly("collisionResults",
89  &GeometryData::collisionResults,
90  "Vector of collision results.")
91  .def_readonly("radius",
92  &GeometryData::radius,
93  "Vector of radius of bodies, i.e. the distance between the further point of the geometry object from the joint center.\n"
94  "note: This radius information might be usuful in continuous collision checking")
95 #endif // PINOCCHIO_WITH_HPP_FCL
96 
97  .def("fillInnerOuterObjectMaps",
98  &GeometryData::fillInnerOuterObjectMaps,
99  bp::args("self","geometry_model"),
100  "Fill inner and outer objects maps")
101  .def("activateCollisionPair",
102  static_cast<void (GeometryData::*)(const PairIndex)>(&GeometryData::activateCollisionPair),
103  bp::args("self","pair_id"),
104  "Activate the collsion pair pair_id in geomModel.collisionPairs if it exists.\n"
105  "note: Only active pairs are check for collision and distance computations.")
106  .def("setGeometryCollisionStatus",
107  &GeometryData::setGeometryCollisionStatus,
108  bp::args("self","geom_model","geom_id","enable_collision"),
109  "Enable or disable collision for the given geometry given by its geometry id with all the other geometries registered in the list of collision pairs.")
110  .def("setActiveCollisionPairs",
111  &GeometryData::setActiveCollisionPairs,
112  setActiveCollisionPairs_overload(bp::args("self","geometry_model","collision_map","upper"),
113  "Set the collision pair association from a given input array.\n"
114  "Each entry of the input matrix defines the activation of a given collision pair."))
115  .def("deactivateCollisionPair",
116  &GeometryData::deactivateCollisionPair,
117  bp::args("self","pair_id"),
118  "Deactivate the collsion pair pair_id in geomModel.collisionPairs if it exists.")
119  .def("deactivateAllCollisionPairs",
120  &GeometryData::deactivateAllCollisionPairs,
121  bp::args("self"),
122  "Deactivate all collision pairs.")
123 #ifdef PINOCCHIO_WITH_HPP_FCL
124  .def("setSecurityMargins",
125  &GeometryData::setSecurityMargins,
126  setSecurityMargins_overload(bp::args("self","geometry_model","security_margin_map","upper"),
127  "Set the security margin of all the collision request in a row, according to the values stored in the associative map."))
128 #endif // PINOCCHIO_WITH_HPP_FCL
129 
130  .def(bp::self == bp::self)
131  .def(bp::self != bp::self)
132 
133  ;
134 
135  }
136 
137  /* --- Expose --------------------------------------------------------- */
138  static void expose()
139  {
140  bp::class_<GeometryData>("GeometryData",
141  "Geometry data linked to a Geometry Model and a Data struct.",
142  bp::no_init)
147  ;
148 
149  }
150 
151  protected:
152 
153  BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(setActiveCollisionPairs_overload,GeometryData::setActiveCollisionPairs,2,3)
154  BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(setSecurityMargins_overload,GeometryData::setSecurityMargins,2,3)
155 
156  };
157 
158  }} // namespace pinocchio::python
159 
160 #endif // ifndef __pinocchio_python_geometry_data_hpp__
Expose an std::vector from a type given as template argument.
Definition: std-vector.hpp:170
Set the Python method str and repr to use the overloading operator<<.
Definition: printable.hpp:21
Add the Python method copy to allow a copy of this by calling the copy constructor.
Definition: copyable.hpp:21
Main pinocchio namespace.
Definition: timings.cpp:30
#define EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(...)


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