pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
joints-variant.hpp
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
12#include "pinocchio/multibody/joint/joint-collection.hpp"
13#include "pinocchio/bindings/python/multibody/joint/joints-models.hpp"
14#include "pinocchio/bindings/python/multibody/joint/joints-datas.hpp"
15#include "pinocchio/bindings/python/utils/printable.hpp"
16
17namespace 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 {
52 bp::class_<T>(
56 bp::implicitly_convertible<T, context::JointData>();
57 }
58 };
59
61 {
62 template<class T>
63 void operator()(T)
64 {
66 bp::class_<T>(
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__
Main pinocchio namespace.
Definition treeview.dox:11