pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
geometry.hpp
1//
2// Copyright (c) 2021-2022 INRIA
3//
4
5#ifndef __pinocchio_python_collision_pool_geometry_hpp__
6#define __pinocchio_python_collision_pool_geometry_hpp__
7
8#include <boost/python/overloads.hpp>
9
10#include <eigenpy/eigen-to-python.hpp>
11#include <eigenpy/memory.hpp>
12#include <eigenpy/exception.hpp>
13
14#include "pinocchio/bindings/python/utils/copyable.hpp"
15#include "pinocchio/bindings/python/utils/std-vector.hpp"
16
17#include "pinocchio/algorithm/check.hpp"
18#include "pinocchio/multibody/pool/geometry.hpp"
19
20#if EIGENPY_VERSION_AT_MOST(2, 8, 1)
21EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(pinocchio::GeometryPool)
22#endif
23
24namespace pinocchio
25{
26 namespace python
27 {
28 namespace bp = boost::python;
29
30 template<typename GeometryPool>
31 struct GeometryPoolPythonVisitor
32 : public bp::def_visitor<GeometryPoolPythonVisitor<GeometryPool>>
33 {
34
35 typedef typename GeometryPool::Base Base;
36 typedef typename GeometryPool::Model Model;
37 typedef typename GeometryPool::GeometryModel GeometryModel;
38 typedef typename GeometryPool::GeometryData GeometryData;
39 typedef typename GeometryPool::GeometryModelVector GeometryModelVector;
40 typedef typename GeometryPool::GeometryDataVector GeometryDataVector;
41
42 /* --- Exposing C++ API to python through the handler ----------------- */
43 template<class PyClass>
44 void visit(PyClass & cl) const
45 {
46 cl.def(bp::init<const Model &, const GeometryModel &, bp::optional<size_t>>(
47 bp::args("self", "model", "geometry_model", "size"), "Default constructor."))
48 .def(bp::init<const GeometryPool &>(bp::args("self", "other"), "Copy constructor."))
49
50 .def(
51 "getGeometryModel",
52 (GeometryModel & (GeometryPool::*)(const size_t)) & GeometryPool::getGeometryModel,
53 bp::args("self", "index"), "Return a specific geometry model.",
54 bp::return_internal_reference<>())
55 .def(
56 "getGeometryModels",
57 (GeometryModelVector & (GeometryPool::*)()) & GeometryPool::getGeometryModels,
58 bp::arg("self"), "Returns the geometry model vector.",
59 bp::return_internal_reference<>())
60
61 .def(
62 "getGeometryData",
63 (GeometryData & (GeometryPool::*)(const size_t)) & GeometryPool::getGeometryData,
64 bp::args("self", "index"), "Return a specific geometry data.",
65 bp::return_internal_reference<>())
66 .def(
67 "getGeometryDatas",
68 (GeometryDataVector & (GeometryPool::*)()) & GeometryPool::getGeometryDatas,
69 bp::arg("self"), "Returns the geometry data vector.", bp::return_internal_reference<>())
70
71 .def(
72 "sync", &GeometryPool::sync, bp::args("geometry_model", "geometry_indexes"),
73 "Synchronize the internal geometry models with the input geometry for all given "
74 "geometry indexes.")
75
76 .def(
77 "update", (void(GeometryPool::*)(const GeometryData &)) & GeometryPool::update,
78 bp::args("self", "geometry_data"),
79 "Update all the geometry datas with the input geometry data value.");
80 }
81
82 static void expose()
83 {
84
85 bp::class_<GeometryPool, bp::bases<Base>>(
86 "GeometryPool",
87 "Pool containing a model + a geometry_model and several datas for parallel computations",
88 bp::no_init)
89 .def(GeometryPoolPythonVisitor())
90 .def(CopyableVisitor<GeometryPool>());
91
92 StdVectorPythonVisitor<GeometryModelVector>::expose("StdVec_GeometryModel");
93 StdVectorPythonVisitor<GeometryDataVector>::expose("StdVec_GeometryData");
94 }
95 };
96 } // namespace python
97} // namespace pinocchio
98
99#endif // ifnded __pinocchio_python_collision_pool_geometry_hpp__
Main pinocchio namespace.
Definition treeview.dox:11