pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
geometry-model.hpp
1//
2// Copyright (c) 2015-2020 CNRS
3// Copyright (c) 2018-2025 INRIA
4//
5
6#pragma once
7
8#include <eigenpy/memory.hpp>
9#include <eigenpy/copyable.hpp>
10
11#include "pinocchio/bindings/python/utils/address.hpp"
12#include "pinocchio/bindings/python/utils/printable.hpp"
13
14#include "pinocchio/bindings/python/utils/pickle.hpp"
15#include "pinocchio/bindings/python/serialization/serializable.hpp"
16
17#include "pinocchio/geometry.hpp"
18
19namespace pinocchio
20{
21 namespace python
22 {
23 namespace bp = boost::python;
24
26 : public boost::python::def_visitor<GeometryModelPythonVisitor>
27 {
28 public:
29 /* --- Exposing C++ API to python through the handler ----------------- */
30 template<class PyClass>
31 void visit(PyClass & cl) const
32 {
33 cl.def(bp::init<>(bp::arg("self"), "Default constructor"))
34 .def(bp::init<const GeometryModel &>(bp::args("self", "other"), "Copy constructor"))
35
36 .add_property(
37 "ngeoms", &GeometryModel::ngeoms,
38 "Number of geometries contained in the Geometry Model.")
39 .add_property(
40 "geometryObjects", &GeometryModel::geometryObjects, "Vector of geometries objects.")
41
42 .def(
43 "addGeometryObject",
44 static_cast<GeometryModel::GeomIndex (GeometryModel::*)(const GeometryObject &)>(
45 &GeometryModel::addGeometryObject),
46 bp::args("self", "geometry_object"),
47 "Add a GeometryObject to a GeometryModel.\n"
48 "Parameters\n"
49 "\tgeometry_object : a GeometryObject\n")
50 .def(
51 "addGeometryObject",
52 static_cast<GeometryModel::GeomIndex (GeometryModel::*)(
53 const GeometryObject &, const Model &)>(&GeometryModel::addGeometryObject),
54 bp::args("self", "geometry_object", "model"),
55 "Add a GeometryObject to a GeometryModel and set its parent joint by reading its value "
56 "in the model.\n"
57 "Parameters\n"
58 "\tgeometry_object : a GeometryObject\n"
59 "\tmodel : a Model of the system\n")
60 .def(
61 "removeGeometryObject", &GeometryModel::removeGeometryObject, bp::args("self", "name"),
62 "Remove a GeometryObject. Remove also the collision pairs that contain the object.")
63 .def(
64 "getGeometryId", &GeometryModel::getGeometryId, bp::args("self", "name"),
65 "Returns the index of a GeometryObject given by its name.")
66 .def(
67 "existGeometryName", &GeometryModel::existGeometryName, bp::args("self", "name"),
68 "Checks if a GeometryObject given by its name exists.")
69 .def(
70 "createData", &GeometryModelPythonVisitor::createData, bp::arg("self"),
71 "Create a GeometryData associated to the current model.")
72 .def("clone", &GeometryModel::clone, bp::arg("self"), "Create a deep copy of *this.")
73 .add_property(
74 "collisionPairs", &GeometryModel::collisionPairs, "Vector of collision pairs.")
75 .add_property(
76 "collisionPairMapping", &GeometryModel::collisionPairMapping,
77 "Matrix relating the collision pair ID to a pair of two GeometryObject indexes.")
78 .def(
79 "addCollisionPair", &GeometryModel::addCollisionPair,
80 bp::args("self", "collision_pair"),
81 "Add a collision pair given by the index of the two collision objects.")
82 .def(
83 "addAllCollisionPairs", &GeometryModel::addAllCollisionPairs,
84 "Add all collision pairs.\n"
85 "note : collision pairs between geometries having the same parent joint are not added.")
86 .def(
87 "setCollisionPairs", &GeometryModel::setCollisionPairs,
88 (bp::arg("self"), bp::arg("collision_map"), bp::arg("upper") = true),
89 "Set the collision pairs from a given input array.\n"
90 "Each entry of the input matrix defines the activation of a given collision pair"
91 "(map[i,j] == True means that the pair (i,j) is active).")
92 .def(
93 "removeCollisionPair", &GeometryModel::removeCollisionPair,
94 bp::args("self", "collision_pair"), "Remove a collision pair.")
95 .def(
96 "removeAllCollisionPairs", &GeometryModel::removeAllCollisionPairs,
97 "Remove all collision pairs.")
98 .def(
99 "existCollisionPair", &GeometryModel::existCollisionPair,
100 bp::args("self", "collision_pair"), "Check if a collision pair exists.")
101 .def(
102 "findCollisionPair", &GeometryModel::findCollisionPair,
103 bp::args("self", "collision_pair"), "Return the index of a collision pair.")
104
105 .def(bp::self == bp::self)
106 .def(bp::self != bp::self);
107
108 bp::register_ptr_to_python<std::shared_ptr<GeometryModel>>();
109 }
110
111 static GeometryData createData(const GeometryModel & geomModel)
112 {
113 return GeometryData(geomModel);
114 }
115
116 /* --- Expose --------------------------------------------------------- */
117 static void expose()
118 {
119 if (!register_symbolic_link_to_registered_type<GeometryModel>())
120 {
121 bp::class_<GeometryModel>(
122 "GeometryModel",
123 "Geometry model containing the collision or visual geometries associated to a model.",
124 bp::no_init)
128 .def(::eigenpy::CopyableVisitor<GeometryModel>())
130#ifndef PINOCCHIO_PYTHON_NO_SERIALIZATION
132#endif
133 ;
134 }
135 }
136 };
137
138 } // namespace python
139} // 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