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