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>(sanitizedClassname<T>().c_str(),
53  sanitizedClassname<T>().c_str(),
54  bp::init<>())
57  );
58  bp::implicitly_convertible<T,pinocchio::JointData>();
59  }
60  };
61 
63  {
64  template<class T>
65  void operator()(T)
66  {
67  expose_joint_model<T>(
68  bp::class_<T>(sanitizedClassname<T>().c_str(),
69  sanitizedClassname<T>().c_str(),
70  bp::no_init)
73  );
74  bp::implicitly_convertible<T,pinocchio::JointModel>();
75  }
76  };
77 
78 
79  } // namespace python
80 } // namespace pinocchio
81 
82 #endif // ifndef __pinocchio_python_joints_variant_hpp__
pinocchio::python::sanitizedClassname
std::string sanitizedClassname()
Definition: joints-variant.hpp:24
boost::python
pinocchio::python::JointModelDerivedPythonVisitor
Definition: joint-derived.hpp:20
simulation-pendulum.T
int T
Definition: simulation-pendulum.py:113
pinocchio::python::JointVariantVisitor
Definition: joints-variant.hpp:32
pinocchio::python::JointModelExposer
Definition: joints-variant.hpp:62
pinocchio::python::JointDataExposer
Definition: joints-variant.hpp:46
def
void def(const char *name, Func func)
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:65
python
joints-models.hpp
joints-datas.hpp
pinocchio::python::JointDataDerivedPythonVisitor
Definition: joint-derived.hpp:84
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:28


pinocchio
Author(s):
autogenerated on Tue Feb 13 2024 03:43:59