joint-derived.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_python_multibody_joint_joint_base_hpp__
6 #define __pinocchio_python_multibody_joint_joint_base_hpp__
7 
8 #include <boost/python.hpp>
9 #include <eigenpy/exception.hpp>
10 
13 
14 namespace pinocchio
15 {
16  namespace python
17  {
18  namespace bp = boost::python;
19 
20  template<class JointModelDerived>
22  : public boost::python::def_visitor<JointModelBasePythonVisitor<JointModelDerived>>
23  {
24  public:
25  typedef typename JointModelDerived::JointDataDerived JointDataDerived;
26 
27  template<class PyClass>
28  void visit(PyClass & cl) const
29  {
30  cl.def(bp::init<>(bp::arg("self")))
31  // All are add_properties cause ReadOnly
32  .add_property("id", &get_id)
33  .add_property("idx_q", &get_idx_q)
34  .add_property("idx_v", &get_idx_v)
35  .add_property("nq", &get_nq)
36  .add_property("nv", &get_nv)
37  .add_property(
38  "hasConfigurationLimit", &JointModelDerived::hasConfigurationLimit,
39  "Return vector of boolean if joint has configuration limits.")
40  .add_property(
41  "hasConfigurationLimitInTangent", &JointModelDerived::hasConfigurationLimitInTangent,
42  "Return vector of boolean if joint has configuration limits in tangent space.")
43  .def(
44  "setIndexes", &JointModelDerived::setIndexes,
45  bp::args("self", "joint_id", "idx_q", "idx_v"))
46  .def("classname", &JointModelDerived::classname)
47  .staticmethod("classname")
48  .def("calc", &calc0, bp::args("self", "jdata", "q"))
49  .def("calc", &calc1, bp::args("self", "jdata", "q", "v"))
50  .def(
51  "createData", &JointModelDerived::createData, bp::arg("self"),
52  "Create data associated to the joint model.")
53  .def(
54  "hasSameIndexes", &JointModelDerived::template hasSameIndexes<JointModelDerived>,
55  bp::args("self", "other"), "Check if this has same indexes than other.")
56  .def(
57  "shortname", &JointModelDerived::shortname, bp::arg("self"),
58  "Returns string indicating the joint type (class name):"
59  "\n\t- JointModelR[*]: Revolute Joint, with rotation axis [*] ∈ [X,Y,Z]"
60  "\n\t- JointModelRevoluteUnaligned: Revolute Joint, with rotation axis not aligned "
61  "with X, Y, nor Z"
62  "\n\t- JointModelRUB[*]: Unbounded revolute Joint (without position limits), with "
63  "rotation axis [*] ∈ [X,Y,Z]"
64  "\n\t- JointModelRevoluteUnboundedUnaligned: Unbounded revolute Joint, with "
65  "rotation axis not aligned with X, Y, nor Z"
66  "\n\t- JointModelP[*]: Prismatic Joint, with rotation axis [*] ∈ [X,Y,Z]"
67  "\n\t- JointModelPlanar: Planar joint"
68  "\n\t- JointModelPrismaticUnaligned: Prismatic joint, with translation axis not "
69  "aligned with X, Y, nor Z"
70  "\n\t- JointModelSphericalZYX: Spherical joint (3D rotation)"
71  "\n\t- JointModelTranslation: Translation joint (3D translation)"
72  "\n\t- JointModelFreeFlyer: Joint enabling 3D rotation and translations.")
73 
74 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
75  .def(bp::self == bp::self)
76  .def(bp::self != bp::self)
77 #endif
78  ;
79  }
80 
81  static JointIndex get_id(const JointModelDerived & self)
82  {
83  return self.id();
84  }
85  static int get_idx_q(const JointModelDerived & self)
86  {
87  return self.idx_q();
88  }
89  static int get_idx_v(const JointModelDerived & self)
90  {
91  return self.idx_v();
92  }
93  static int get_nq(const JointModelDerived & self)
94  {
95  return self.nq();
96  }
97  static int get_nv(const JointModelDerived & self)
98  {
99  return self.nv();
100  }
101  static void
102  calc0(const JointModelDerived & self, JointDataDerived & jdata, const context::VectorXs & q)
103  {
104  self.calc(jdata, q);
105  }
106  static void calc1(
107  const JointModelDerived & self,
108  JointDataDerived & jdata,
109  const context::VectorXs & q,
110  const context::VectorXs & v)
111  {
112  self.calc(jdata, q, v);
113  }
114  };
115 
116  template<class JointDataDerived>
118  : public boost::python::def_visitor<JointDataBasePythonVisitor<JointDataDerived>>
119  {
120  public:
121  template<class PyClass>
122  void visit(PyClass & cl) const
123  {
124  cl
125  // All are add_properties cause ReadOnly
126  .add_property("joint_q", &get_joint_q)
127  .add_property("joint_v", &get_joint_v)
128  .add_property("S", &get_S)
129  .add_property("M", &get_M)
130  .add_property("v", &get_v)
131  .add_property("c", &get_c)
132  .add_property("U", &get_U)
133  .add_property("Dinv", &get_Dinv)
134  .add_property("UDinv", &get_UDinv)
135  .def("shortname", &JointDataDerived::shortname, bp::arg("self"))
136 
137 #ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
138  .def(bp::self == bp::self)
139  .def(bp::self != bp::self)
140 #endif
141  ;
142  }
143 
144  static typename JointDataDerived::ConfigVector_t get_joint_q(const JointDataDerived & self)
145  {
146  return self.joint_q_accessor();
147  }
148  static typename JointDataDerived::TangentVector_t get_joint_v(const JointDataDerived & self)
149  {
150  return self.joint_v_accessor();
151  }
152  // static typename JointDataDerived::Constraint_t get_S(const JointDataDerived & self)
153  // { return self.S_accessor(); }
154  static typename JointDataDerived::Constraint_t::DenseBase get_S(const JointDataDerived & self)
155  {
156  return self.S_accessor().matrix();
157  }
158  static typename JointDataDerived::Transformation_t get_M(const JointDataDerived & self)
159  {
160  return self.M_accessor();
161  }
162  static typename JointDataDerived::Motion_t get_v(const JointDataDerived & self)
163  {
164  return self.v_accessor();
165  }
166  static typename JointDataDerived::Bias_t get_c(const JointDataDerived & self)
167  {
168  return self.c_accessor();
169  }
170  static typename JointDataDerived::U_t get_U(const JointDataDerived & self)
171  {
172  return self.U_accessor();
173  }
174  static typename JointDataDerived::D_t get_Dinv(const JointDataDerived & self)
175  {
176  return self.Dinv_accessor();
177  }
178  static typename JointDataDerived::UD_t get_UDinv(const JointDataDerived & self)
179  {
180  return self.UDinv_accessor();
181  }
182 
183  static void expose()
184  {
185  }
186  };
187 
188  } // namespace python
189 } // namespace pinocchio
190 
191 #endif // ifndef __pinocchio_python_multibody_joint_joint_base_hpp__
pinocchio::python::JointModelBasePythonVisitor::get_idx_q
static int get_idx_q(const JointModelDerived &self)
Definition: joint-derived.hpp:85
pinocchio::python::JointModelBasePythonVisitor::JointDataDerived
JointModelDerived::JointDataDerived JointDataDerived
Definition: joint-derived.hpp:25
pinocchio::python::JointDataBasePythonVisitor::get_M
static JointDataDerived::Transformation_t get_M(const JointDataDerived &self)
Definition: joint-derived.hpp:158
boost::python
pinocchio::python::JointDataBasePythonVisitor::get_U
static JointDataDerived::U_t get_U(const JointDataDerived &self)
Definition: joint-derived.hpp:170
pinocchio::python::JointDataBasePythonVisitor::visit
void visit(PyClass &cl) const
Definition: joint-derived.hpp:122
pinocchio::python::JointModelBasePythonVisitor::calc1
static void calc1(const JointModelDerived &self, JointDataDerived &jdata, const context::VectorXs &q, const context::VectorXs &v)
Definition: joint-derived.hpp:106
pinocchio::python::JointModelBasePythonVisitor::get_idx_v
static int get_idx_v(const JointModelDerived &self)
Definition: joint-derived.hpp:89
pinocchio::python::JointDataBasePythonVisitor::get_joint_v
static JointDataDerived::TangentVector_t get_joint_v(const JointDataDerived &self)
Definition: joint-derived.hpp:148
pinocchio::python::JointDataBasePythonVisitor::get_UDinv
static JointDataDerived::UD_t get_UDinv(const JointDataDerived &self)
Definition: joint-derived.hpp:178
exception.hpp
pinocchio::python::JointModelBasePythonVisitor::get_id
static JointIndex get_id(const JointModelDerived &self)
Definition: joint-derived.hpp:81
pinocchio::python::JointModelBasePythonVisitor
Definition: joint-derived.hpp:21
pinocchio::python::JointDataBasePythonVisitor::get_v
static JointDataDerived::Motion_t get_v(const JointDataDerived &self)
Definition: joint-derived.hpp:162
pinocchio::hasConfigurationLimitInTangent
const std::vector< bool > hasConfigurationLimitInTangent(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointConfigurationLimitInTangentVisitor to get the configurations limit...
joint-collection.hpp
pinocchio::context::VectorXs
Eigen::Matrix< Scalar, Eigen::Dynamic, 1, Options > VectorXs
Definition: context/generic.hpp:47
pinocchio::python::JointDataBasePythonVisitor::get_Dinv
static JointDataDerived::D_t get_Dinv(const JointDataDerived &self)
Definition: joint-derived.hpp:174
pinocchio::shortname
std::string shortname(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointShortnameVisitor to get the shortname of the derived joint model.
python
pinocchio::createData
ConstraintDataTpl< Scalar, Options, ConstraintCollectionTpl > createData(const ConstraintModelTpl< Scalar, Options, ConstraintCollectionTpl > &cmodel)
Definition: constraint-model-visitor.hpp:239
pinocchio::python::v
const Vector3Like & v
Definition: bindings/python/spatial/explog.hpp:66
pinocchio::python::JointDataBasePythonVisitor
Definition: joint-derived.hpp:117
pinocchio::hasConfigurationLimit
const std::vector< bool > hasConfigurationLimit(const JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel)
Visit a JointModelTpl through JointConfigurationLimitVisitor to get the configurations limits.
pinocchio::python::JointDataBasePythonVisitor::get_joint_q
static JointDataDerived::ConfigVector_t get_joint_q(const JointDataDerived &self)
Definition: joint-derived.hpp:144
pinocchio::setIndexes
void setIndexes(JointModelTpl< Scalar, Options, JointCollectionTpl > &jmodel, JointIndex id, int q, int v)
Visit a JointModelTpl through JointSetIndexesVisitor to set the indexes of the joint in the kinematic...
pinocchio::python::JointDataBasePythonVisitor::get_c
static JointDataDerived::Bias_t get_c(const JointDataDerived &self)
Definition: joint-derived.hpp:166
pinocchio::python::JointModelBasePythonVisitor::visit
void visit(PyClass &cl) const
Definition: joint-derived.hpp:28
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition: joint-configuration.hpp:1083
pinocchio::python::JointDataBasePythonVisitor::get_S
static JointDataDerived::Constraint_t::DenseBase get_S(const JointDataDerived &self)
Definition: joint-derived.hpp:154
cl
cl
pinocchio::python::JointDataBasePythonVisitor::expose
static void expose()
Definition: joint-derived.hpp:183
pinocchio::python::JointModelBasePythonVisitor::get_nv
static int get_nv(const JointModelDerived &self)
Definition: joint-derived.hpp:97
pinocchio::python::JointModelBasePythonVisitor::calc0
static void calc0(const JointModelDerived &self, JointDataDerived &jdata, const context::VectorXs &q)
Definition: joint-derived.hpp:102
fwd.hpp
pinocchio::JointIndex
Index JointIndex
Definition: multibody/fwd.hpp:26
pinocchio::python::JointModelBasePythonVisitor::get_nq
static int get_nq(const JointModelDerived &self)
Definition: joint-derived.hpp:93
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:10