bindings/python/collision/pool/broadphase-manager.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2022 INRIA
3 //
4 
5 #ifndef __pinocchio_python_collision_pool_broadphase_manager_hpp__
6 #define __pinocchio_python_collision_pool_broadphase_manager_hpp__
7 
9 
11 
12 #include <boost/python/overloads.hpp>
13 #include <boost/algorithm/string/replace.hpp>
14 #include <eigenpy/memory.hpp>
15 #include <eigenpy/exception.hpp>
16 
20 
21 namespace pinocchio
22 {
23  namespace python
24  {
25  namespace bp = boost::python;
26 
27  namespace helper
28  {
29  template<typename BroadPhaseManager>
31  {
32  static std::string get();
33  };
34 
35  template<typename Manager>
37  {
38  static std::string get()
39  {
40  return "BroadPhaseManager";
41  }
42  };
43 
44  template<typename Manager>
46  {
47  static std::string get()
48  {
49  return "TreeBroadPhaseManager";
50  }
51  };
52  } // namespace helper
53 
54  template<typename BroadPhaseManagerPool>
56  : public bp::def_visitor<BroadPhaseManagerPoolPythonVisitor<BroadPhaseManagerPool>>
57  {
58 
65  typedef typename BroadPhaseManager::Manager Manager;
66 
67  /* --- Exposing C++ API to python through the handler ----------------- */
68  template<class PyClass>
69  void visit(PyClass & cl) const
70  {
71  cl.def(bp::init<const Model &, const GeometryModel &, bp::optional<size_t>>(
72  bp::args("self", "model", "geometry_model", "size"), "Default constructor."))
73  .def(
74  bp::init<const BroadPhaseManagerPool &>(bp::args("self", "other"), "Copy constructor."))
75 
76  .def(
77  "getBroadPhaseManager",
78  (BroadPhaseManager & (BroadPhaseManagerPool::*)(const size_t))
80  bp::args("self", "index"), "Return a specific broadphase manager.",
81  bp::return_internal_reference<>())
82  .def(
83  "getBroadPhaseManagers",
86  bp::arg("self"), "Returns the vector of broadphase managers.",
87  bp::return_internal_reference<>())
88 
89  .def(
90  "update",
92  bp::args("self", "geometry_data"),
93  "Update all the geometry datas with the input geometry data value.")
94 
95  .def(
96  "check", &BroadPhaseManagerPool::check, bp::arg("self"),
97  "Check whether the current pool is valid.")
98 
99  .def(
100  "asGeometryPool", downcast, bp::arg("self"),
101  "Cast the object as GeometryPool (equivalent to a C++ static_cast).",
102  bp::return_self<>());
103  }
104 
105  static PyObject * downcast(BroadPhaseManagerPool & self)
106  {
107  bp::type_info type = bp::type_id<Base>();
108  const bp::converter::registration * registration = bp::converter::registry::query(type);
109 
110  return registration->to_python(static_cast<Base *>(&self));
111  }
112 
113  static void expose()
114  {
115  std::string manager_name = boost::typeindex::type_id<Manager>().pretty_name();
116  boost::algorithm::replace_all(manager_name, "hpp::fcl::", "");
117  const std::string broadphase_prefix = helper::base_class_name<BroadPhaseManager>::get();
118  const std::string class_name = broadphase_prefix + "Pool" + "_" + manager_name;
119 
120  const std::string doc = "Pool containing a bunch of " + broadphase_prefix + ".";
121 
122  bp::class_<BroadPhaseManagerPool, bp::bases<Base>>(
123  class_name.c_str(), doc.c_str(), bp::no_init)
126 
127  const std::string vector_name = "StdVec_" + broadphase_prefix + "_" + manager_name;
129  }
130  };
131  } // namespace python
132 } // namespace pinocchio
133 
134 #endif // ifnded __pinocchio_python_collision_pool_broadphase_manager_hpp__
init
void init(bool compute_local_aabb=true)
common_symbols.type
type
Definition: common_symbols.py:35
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::BroadPhaseManager
BroadPhaseManagerPool::BroadPhaseManager BroadPhaseManager
Definition: bindings/python/collision/pool/broadphase-manager.hpp:64
boost::python
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::downcast
static PyObject * downcast(BroadPhaseManagerPool &self)
Definition: bindings/python/collision/pool/broadphase-manager.hpp:105
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::expose
static void expose()
Definition: bindings/python/collision/pool/broadphase-manager.hpp:113
pinocchio::BroadPhaseManagerPoolBase
Definition: collision/pool/broadphase-manager.hpp:21
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::GeometryModel
BroadPhaseManagerPool::GeometryModel GeometryModel
Definition: bindings/python/collision/pool/broadphase-manager.hpp:61
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::BroadPhaseManagerVector
BroadPhaseManagerPool::BroadPhaseManagerVector BroadPhaseManagerVector
Definition: bindings/python/collision/pool/broadphase-manager.hpp:63
eigen-to-python.hpp
exception.hpp
pinocchio::GeometryData
Definition: multibody/geometry.hpp:233
def
void def(const char *name, Func func)
pinocchio::TreeBroadPhaseManagerTpl
Definition: collision/pool/fwd.hpp:38
pinocchio::python::BroadPhaseManagerPoolPythonVisitor
Definition: bindings/python/collision/pool/broadphase-manager.hpp:55
pinocchio::BroadPhaseManagerPoolBase::getBroadPhaseManagers
const BroadPhaseManagerVector & getBroadPhaseManagers() const
Access to the vector of broad phase managers.
Definition: collision/pool/broadphase-manager.hpp:87
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::visit
void visit(PyClass &cl) const
Definition: bindings/python/collision/pool/broadphase-manager.hpp:69
pinocchio::BroadPhaseManagerPoolBase::Model
Base::Model Model
Definition: collision/pool/broadphase-manager.hpp:34
python
pinocchio::BroadPhaseManagerPoolBase::BroadPhaseManager
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef _BroadPhaseManagerDerived BroadPhaseManager
Definition: collision/pool/broadphase-manager.hpp:26
pinocchio::python::CopyableVisitor
Add the Python method copy to allow a copy of this by calling the copy constructor.
Definition: copyable.hpp:21
pinocchio::python::helper::base_class_name
Definition: bindings/python/collision/pool/broadphase-manager.hpp:30
pinocchio::BroadPhaseManagerPoolBase::BroadPhaseManagerVector
std::vector< BroadPhaseManager > BroadPhaseManagerVector
Definition: collision/pool/broadphase-manager.hpp:43
copyable.hpp
pinocchio::python::helper::base_class_name< TreeBroadPhaseManagerTpl< Manager > >::get
static std::string get()
Definition: bindings/python/collision/pool/broadphase-manager.hpp:47
pinocchio::BroadPhaseManagerPoolBase::check
bool check() const
Check the validity of the current broadphase.
Definition: collision/pool/broadphase-manager.hpp:125
eigenpy::StdVectorPythonVisitor::expose
static void expose(const std::string &class_name, const bp::def_visitor< DerivedVisitor > &visitor)
check.hpp
pinocchio::python::helper::base_class_name< BroadPhaseManagerTpl< Manager > >::get
static std::string get()
Definition: bindings/python/collision/pool/broadphase-manager.hpp:38
broadphase-manager.hpp
cl
cl
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::Manager
BroadPhaseManager::Manager Manager
Definition: bindings/python/collision/pool/broadphase-manager.hpp:65
memory.hpp
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
pinocchio::python::helper::base_class_name::get
static std::string get()
std-vector.hpp
pinocchio::BroadPhaseManagerPoolBase::update
virtual void update(const GeometryData &geometry_data)
Update the geometry datas with the new value.
Definition: collision/pool/broadphase-manager.hpp:114
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::Base
BroadPhaseManagerPool::Base Base
Definition: bindings/python/collision/pool/broadphase-manager.hpp:59
pinocchio::BroadPhaseManagerTpl
Definition: collision/broadphase-manager.hpp:17
pinocchio::GeometryPoolTpl
Definition: multibody/pool/fwd.hpp:24
pinocchio::BroadPhaseManagerPoolBase::getBroadPhaseManager
const BroadPhaseManager & getBroadPhaseManager(const size_t index) const
Returns the geometry_data at index.
Definition: collision/pool/broadphase-manager.hpp:71
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::GeometryData
BroadPhaseManagerPool::GeometryData GeometryData
Definition: bindings/python/collision/pool/broadphase-manager.hpp:62
pinocchio::python::BroadPhaseManagerPoolPythonVisitor::Model
BroadPhaseManagerPool::Model Model
Definition: bindings/python/collision/pool/broadphase-manager.hpp:60


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:25