joints-variant.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_joints_variant_hpp__
6 #define __pinocchio_python_joints_variant_hpp__
7 
8 #include <boost/algorithm/string/replace.hpp>
9 
10 #include <boost/python.hpp>
11 
16 
17 namespace pinocchio
18 {
19  namespace python
20  {
21  namespace bp = boost::python;
22 
23  template<typename T>
24  std::string sanitizedClassname()
25  {
26  std::string className = boost::replace_all_copy(T::classname(), "<", "_");
27  boost::replace_all(className, ">", "");
28  return className;
29  }
30 
31  template<typename VariantType>
32  struct JointVariantVisitor : boost::static_visitor<PyObject *>
33  {
34  static result_type convert(VariantType const & jv)
35  {
36  return apply_visitor(JointVariantVisitor<VariantType>(), jv);
37  }
38 
39  template<typename T>
40  result_type operator()(T const & t) const
41  {
42  return boost::python::incref(boost::python::object(t).ptr());
43  }
44  };
45 
47  {
48  template<class T>
49  void operator()(T)
50  {
51  expose_joint_data<T>(
52  bp::class_<T>(
53  sanitizedClassname<T>().c_str(), sanitizedClassname<T>().c_str(), bp::init<>())
56  bp::implicitly_convertible<T, context::JointData>();
57  }
58  };
59 
61  {
62  template<class T>
63  void operator()(T)
64  {
65  expose_joint_model<T>(
66  bp::class_<T>(
67  sanitizedClassname<T>().c_str(), sanitizedClassname<T>().c_str(), bp::no_init)
70  bp::implicitly_convertible<T, context::JointModel>();
71  }
72  };
73 
74  } // namespace python
75 } // namespace pinocchio
76 
77 #endif // ifndef __pinocchio_python_joints_variant_hpp__
simulation-contact-dynamics.T
int T
Definition: simulation-contact-dynamics.py:89
pinocchio::python::sanitizedClassname
std::string sanitizedClassname()
Definition: joints-variant.hpp:24
boost::python
pinocchio::python::JointVariantVisitor
Definition: joints-variant.hpp:32
pinocchio::python::JointModelExposer
Definition: joints-variant.hpp:60
pinocchio::python::JointDataExposer
Definition: joints-variant.hpp:46
def
void def(const char *name, Func func)
pinocchio::python::JointModelBasePythonVisitor
Definition: joint-derived.hpp:21
joint-collection.hpp
pinocchio::python::PrintableVisitor
Set the Python method str and repr to use the overloading operator<<.
Definition: printable.hpp:21
pinocchio::python::JointModelExposer::operator()
void operator()(T)
Definition: joints-variant.hpp:63
python
pinocchio::python::JointDataBasePythonVisitor
Definition: joint-derived.hpp:117
joints-models.hpp
joints-datas.hpp
pinocchio::python::JointVariantVisitor::convert
static result_type convert(VariantType const &jv)
Definition: joints-variant.hpp:34
pinocchio::python::JointDataExposer::operator()
void operator()(T)
Definition: joints-variant.hpp:49
printable.hpp
t
Transform3f t
pinocchio::python::JointVariantVisitor::operator()
result_type operator()(T const &t) const
Definition: joints-variant.hpp:40
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


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