bindings/python/multibody/pool/model.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021 INRIA
3 //
4 
5 #ifndef __pinocchio_python_multibody_pool_model_hpp__
6 #define __pinocchio_python_multibody_pool_model_hpp__
7 
9 
10 #include "pinocchio/multibody/pool/model.hpp"
11 
12 #include <boost/python/overloads.hpp>
13 #include <eigenpy/memory.hpp>
14 #include <eigenpy/exception.hpp>
15 
16 #include "pinocchio/algorithm/check.hpp"
19 
21 
22 namespace pinocchio
23 {
24  namespace python
25  {
26  namespace bp = boost::python;
27 
28  template<typename ModelPool>
30  : public bp::def_visitor< ModelPoolPythonVisitor<ModelPool> >
31  {
32 
33  typedef typename ModelPool::Model Model;
34  typedef typename ModelPool::Data Data;
36 
37  /* --- Exposing C++ API to python through the handler ----------------- */
38  template<class PyClass>
39  void visit(PyClass& cl) const
40  {
41  cl
42  .def(bp::init<Model,bp::optional<int> >(bp::args("self","model","size"),
43  "Default constructor."))
44  .def(bp::init<ModelPool>(bp::args("self","other"),
45  "Copy constructor."))
46 
47  .def("model",(Model & (ModelPool::*)())&ModelPool::model,
48  bp::arg("self"),"Model contained in the pool.",
49  bp::return_internal_reference<>())
50  .def("data",(Data & (ModelPool::*)(const size_t))&ModelPool::data,
51  bp::args("self","index"),"Return a specific data.",
52  bp::return_internal_reference<>())
53  .def("datas",(DataVector & (ModelPool::*)())&ModelPool::datas,
54  bp::arg("self"),"Returns the data vectors.",
55  bp::return_internal_reference<>())
56 
57  .def("size",&ModelPool::size,bp::arg("self"),
58  "Returns the size of the pool.")
59  .def("resize",&ModelPool::resize,bp::args("self","new_size"),
60  "Resize the pool.")
61 
62  .def("update",(void (ModelPool::*)(const Model &))&ModelPool::update,
63  bp::args("self","model"),
64  "Update the model, meaning that all the datas will be refreshed accordingly.")
65  .def("update",(void (ModelPool::*)(const Data &))&ModelPool::update,
66  bp::args("self","data"),"Update all the datas with the input data value.")
67  .def("update",(void (ModelPool::*)(const Model &, const Data &))&ModelPool::update,
68  bp::args("self","model","data"),"Update the model and data together.")
69  ;
70  }
71 
72  static void expose()
73  {
74 
75  bp::class_<ModelPool>("ModelPool",
76  "Pool containing a model and several datas for parallel computations",
77  bp::no_init)
80  ;
81 
83  }
84  };
85  }
86 }
87 
88 #endif // ifnded __pinocchio_python_multibody_pool_model_hpp__
Expose an std::vector from a type given as template argument.
Definition: std-vector.hpp:170
Add the Python method copy to allow a copy of this by calling the copy constructor.
Definition: copyable.hpp:21
std::vector< Data, Eigen::aligned_allocator< Data > > DataVector
Main pinocchio namespace.
Definition: timings.cpp:30
#define EIGENPY_DEFINE_STRUCT_ALLOCATOR_SPECIALIZATION(...)


pinocchio
Author(s):
autogenerated on Tue Jun 1 2021 02:45:04