joint-derived.hpp 3.25 KB
Newer Older
1
//
2
// Copyright (c) 2015-2021 CNRS INRIA
3
4
//

5
6
#ifndef __pinocchio_python_joint_variants_hpp__
#define __pinocchio_python_joint_variants_hpp__
7

Justin Carpentier's avatar
Justin Carpentier committed
8
#include <boost/python.hpp>
9
10
#include <eigenpy/exception.hpp>

11
#include "pinocchio/multibody/joint/joint-collection.hpp"
12

13
namespace pinocchio
14
15
16
17
18
{
  namespace python
  {
    namespace bp = boost::python;
    
19
    template<class JointModelDerived>
20
21
    struct JointModelDerivedPythonVisitor
      : public boost::python::def_visitor< JointModelDerivedPythonVisitor<JointModelDerived> >
22
23
24
25
26
27
    {
    public:

      template<class PyClass>
      void visit(PyClass& cl) const 
      {
28
29
        cl
        // All are add_properties cause ReadOnly
30
31
32
33
34
        .add_property("id",&get_id)
        .add_property("idx_q",&get_idx_q)
        .add_property("idx_v",&get_idx_v)
        .add_property("nq",&get_nq)
        .add_property("nv",&get_nv)
35
36
        .def("setIndexes",&JointModelDerived::setIndexes)
        .def("shortname",&JointModelDerived::shortname)
37
38
39
        
        .def(bp::self == bp::self)
        .def(bp::self != bp::self)
40
        ;
41
      }
42

43
44
45
46
47
48
49
50
51
52
      static JointIndex get_id(const JointModelDerived & self)
      { return self.id(); }
      static int get_idx_q(const JointModelDerived & self)
      { return self.idx_q(); }
      static int get_idx_v(const JointModelDerived & self)
      { return self.idx_v(); }
      static int get_nq(const JointModelDerived & self)
      { return self.nq(); }
      static int get_nv(const JointModelDerived & self)
      { return self.nv(); }
53

54
      static void expose()
55
      {}
56
57
58
59
60
61
62
63
64
65
66
67
68

    };

    template<class JointDataDerived>
    struct JointDataDerivedPythonVisitor
      : public boost::python::def_visitor< JointDataDerivedPythonVisitor<JointDataDerived> >
    {
    public:

      template<class PyClass>
      void visit(PyClass& cl) const 
      {
        cl
69
          // All are add_properties cause ReadOnly
70
71
72
73
74
75
76
          .add_property("S",&get_S)
          .add_property("M",&get_M)
          .add_property("v",&get_v)
          .add_property("c",&get_c)
          .add_property("U",&get_U)
          .add_property("Dinv",&get_Dinv)
          .add_property("UDinv",&get_UDinv)
77
          .def("shortname",&JointDataDerived::shortname)
78
79
80
        
          .def(bp::self == bp::self)
          .def(bp::self != bp::self)
81
82
83
        ;
      }

84
      static typename JointDataDerived::Constraint_t get_S(const JointDataDerived & self)
85
      { return self.S_accessor(); }
86
      static typename JointDataDerived::Transformation_t get_M(const JointDataDerived & self)
87
      { return self.M_accessor(); }
88
      static typename JointDataDerived::Motion_t get_v(const JointDataDerived & self)
89
      { return self.v_accessor(); }
90
      static typename JointDataDerived::Bias_t get_c(const JointDataDerived & self)
91
      { return self.c_accessor(); }
92
      static typename JointDataDerived::U_t get_U(const JointDataDerived & self)
93
      { return self.U_accessor(); }
94
      static typename JointDataDerived::D_t get_Dinv(const JointDataDerived & self)
95
      { return self.Dinv_accessor(); }
96
      static typename JointDataDerived::UD_t get_UDinv(const JointDataDerived & self)
97
98
      { return self.UDinv_accessor(); }
      
99
      static void expose()
100
      {}
101
102
103

    }; 
    
104
  }} // namespace pinocchio::python
105

106
#endif // ifndef __pinocchio_python_joint_variants_hpp__