pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
broadphase-manager.hpp
1//
2// Copyright (c) 2022-2024 INRIA
3//
4
5#pragma once
6
7#include "pinocchio/collision/broadphase-manager.hpp"
8#include "pinocchio/bindings/python/collision/broadphase-manager-base.hpp"
9
10#include <eigenpy/eigen-to-python.hpp>
11#include <boost/algorithm/string/replace.hpp>
12
13namespace pinocchio
14{
15 namespace python
16 {
17 namespace bp = boost::python;
18
19 template<typename Derived>
21 : public bp::def_visitor<BroadPhaseManagerPythonVisitor<Derived>>
22 {
23 public:
24 typedef BroadPhaseManagerTpl<Derived> Self;
25 typedef typename Self::CollisionObjectVector CollisionObjectVector;
26
27 /* --- Exposing C++ API to python through the handler ----------------- */
28 template<class PyClass>
29 void visit(PyClass & cl) const
30 {
31 cl.def(
32 bp::init<const Model *, const GeometryModel *, GeometryData *>(
33 bp::args("self", "model", "geometry_model", "geometry_data"), "Default constructor")
34 [bp::with_custodian_and_ward<1, 2>(), bp::with_custodian_and_ward<1, 3>(),
35 bp::with_custodian_and_ward<1, 4>()])
36 .def(
37 bp::init<const Self &>(
38 bp::args("self", "other"), "Copy constructor")[bp::with_custodian_and_ward<1, 2>()])
39
40 .def(
41 "getCollisionObjectInflation", &Self::getCollisionObjectInflation, bp::arg("self"),
42 "Returns the inflation value related to each collision object.",
43 bp::return_internal_reference<>())
44 .def(
45 "getCollisionObjects",
46 (CollisionObjectVector & (Self::*)()) & Self::getCollisionObjects, bp::arg("self"),
47 bp::return_internal_reference<>())
48
49 .def(
50 "getManager", (Derived & (Self::*)()) & Self::getManager, bp::arg("self"),
51 "Returns the internal coal manager", bp::return_internal_reference<>())
52
53 .def(
54 "getCollisionObjectStatus", &Self::getCollisionObjectStatus, bp::arg("self"),
55 "Returns the status of the collision object.",
56 bp::return_value_policy<bp::copy_const_reference>())
57
59 }
60
61 /* --- Expose --------------------------------------------------------- */
62 static void expose()
63 {
64 std::string derived_name = boost::typeindex::type_id<Derived>().pretty_name();
65 boost::algorithm::replace_all(derived_name, "coal::", "");
66 const std::string class_name = "BroadPhaseManager_" + derived_name;
67
68 const std::string class_doc = "Broad phase manager associated to coal::" + derived_name;
69 bp::class_<Self> registered_class(class_name.c_str(), class_doc.c_str(), bp::no_init);
70 registered_class.def(BroadPhaseManagerPythonVisitor());
71
73 bp::objects::register_dynamic_id<Base>();
74 bp::objects::register_conversion<Self, Base>(false);
75 }
76 };
77
78 } // namespace python
79} // namespace pinocchio
Main pinocchio namespace.
Definition treeview.dox:11