bindings/python/multibody/pool/model.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021-2022 INRIA
3 //
4 
5 #ifndef __pinocchio_python_multibody_pool_model_hpp__
6 #define __pinocchio_python_multibody_pool_model_hpp__
7 
9 
11 
12 #include <boost/python/overloads.hpp>
13 #include <eigenpy/memory.hpp>
14 #include <eigenpy/exception.hpp>
15 
19 
20 #if EIGENPY_VERSION_AT_MOST(2, 8, 1)
22 #endif
23 
24 namespace pinocchio
25 {
26  namespace python
27  {
28  namespace bp = boost::python;
29 
30  template<typename ModelPool>
31  struct ModelPoolPythonVisitor : public bp::def_visitor<ModelPoolPythonVisitor<ModelPool>>
32  {
33 
34  typedef typename ModelPool::Model Model;
35  typedef typename ModelPool::Data Data;
38 
39  /* --- Exposing C++ API to python through the handler ----------------- */
40  template<class PyClass>
41  void visit(PyClass & cl) const
42  {
43  cl.def(bp::init<const Model &, bp::optional<size_t>>(
44  bp::args("self", "model", "size"), "Default constructor."))
45  .def(bp::init<const ModelPool &>(bp::args("self", "other"), "Copy constructor."))
46 
47  .def(
48  "getModel", (Model & (ModelPool::*)(const size_t)) & ModelPool::getModel,
49  bp::args("self", "index"), "Return a specific model.",
50  bp::return_internal_reference<>())
51  .def(
52  "getModels", (ModelVector & (ModelPool::*)()) & ModelPool::getModels, bp::arg("self"),
53  "Returns the model vectors.", bp::return_internal_reference<>())
54 
55  .def(
56  "getData", (Data & (ModelPool::*)(const size_t)) & ModelPool::getData,
57  bp::args("self", "index"), "Return a specific data.", bp::return_internal_reference<>())
58  .def(
59  "getDatas", (DataVector & (ModelPool::*)()) & ModelPool::getDatas, bp::arg("self"),
60  "Returns the data vectors.", bp::return_internal_reference<>())
61 
62  .def("size", &ModelPool::size, bp::arg("self"), "Returns the size of the pool.")
63  .def("resize", &ModelPool::resize, bp::args("self", "new_size"), "Resize the pool.")
64 
65  .def(
66  "update", (void(ModelPool::*)(const Data &)) & ModelPool::update,
67  bp::args("self", "data"), "Update all the datas with the input data value.");
68  }
69 
70  static void expose()
71  {
72 
73  bp::class_<ModelPool>(
74  "ModelPool", "Pool containing a model and several datas for parallel computations",
75  bp::no_init)
78 
81  }
82  };
83  } // namespace python
84 } // namespace pinocchio
85 
86 #endif // ifnded __pinocchio_python_multibody_pool_model_hpp__
pinocchio::ModelPoolTpl::resize
void resize(const size_t new_size)
Set the size of the pool and perform the appropriate resize.
Definition: multibody/pool/model.hpp:74
pinocchio::python::ModelPoolPythonVisitor::visit
void visit(PyClass &cl) const
Definition: bindings/python/multibody/pool/model.hpp:41
init
void init(bool compute_local_aabb=true)
pinocchio::python::ModelPoolPythonVisitor::ModelVector
ModelPool::ModelVector ModelVector
Definition: bindings/python/multibody/pool/model.hpp:36
boost::python
pinocchio::python::ModelPoolPythonVisitor::DataVector
ModelPool::DataVector DataVector
Definition: bindings/python/multibody/pool/model.hpp:37
pinocchio::DataTpl
Definition: context/generic.hpp:25
pinocchio::ModelPoolTpl::getModels
const ModelVector & getModels() const
Returns the vector of models.
Definition: multibody/pool/model.hpp:95
eigen-to-python.hpp
exception.hpp
pinocchio::ModelPoolTpl::getModel
const Model & getModel(const size_t index) const
Return a specific model.
Definition: multibody/pool/model.hpp:107
pinocchio::ModelPoolTpl::getData
const Data & getData(const size_t index) const
Return a specific data.
Definition: multibody/pool/model.hpp:135
EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION
#define EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(...)
python
pinocchio::ModelPoolTpl
Definition: multibody/pool/fwd.hpp:17
pinocchio::python::CopyableVisitor
Add the Python method copy to allow a copy of this by calling the copy constructor.
Definition: copyable.hpp:21
pinocchio::ModelPoolTpl::update
void update(const Data &data)
Update all the datas with the input data value.
Definition: multibody/pool/model.hpp:62
pinocchio::python::ModelPoolPythonVisitor::Data
ModelPool::Data Data
Definition: bindings/python/multibody/pool/model.hpp:35
model.hpp
pinocchio::ModelPoolTpl::getDatas
const DataVector & getDatas() const
Returns the data vector.
Definition: multibody/pool/model.hpp:123
copyable.hpp
eigenpy::StdVectorPythonVisitor::expose
static void expose(const std::string &class_name, const bp::def_visitor< DerivedVisitor > &visitor)
pinocchio::python::ModelPoolPythonVisitor::expose
static void expose()
Definition: bindings/python/multibody/pool/model.hpp:70
check.hpp
pinocchio::python::ModelPoolPythonVisitor::Model
ModelPool::Model Model
Definition: bindings/python/multibody/pool/model.hpp:34
cl
cl
memory.hpp
pinocchio::ModelPoolTpl::DataVector
std::vector< Data, Eigen::aligned_allocator< Data > > DataVector
Definition: multibody/pool/model.hpp:34
std-vector.hpp
pinocchio::ModelPoolTpl::ModelVector
std::vector< Model, Eigen::aligned_allocator< Model > > ModelVector
Definition: multibody/pool/model.hpp:33
pinocchio::ModelPoolTpl::size
size_t size() const
Returns the size of the pool.
Definition: multibody/pool/model.hpp:68
pinocchio::ModelTpl
Definition: context/generic.hpp:20
pinocchio::python::ModelPoolPythonVisitor
Definition: bindings/python/multibody/pool/model.hpp:31
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:11