pinocchio 4.1.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
joint-derived.hpp
1//
2// Copyright (c) 2015-2021 CNRS INRIA
3//
4
5#pragma once
6
7#include <boost/python.hpp>
8#include <eigenpy/exception.hpp>
9
10#include "pinocchio/bindings/python/fwd.hpp"
11#include "pinocchio/multibody/joint.hpp"
12
13namespace pinocchio
14{
15 namespace python
16 {
17 namespace bp = boost::python;
18
19 template<class JointModelDerived>
21 : public boost::python::def_visitor<JointModelBasePythonVisitor<JointModelDerived>>
22 {
23 public:
24 typedef typename JointModelDerived::JointDataDerived JointDataDerived;
25
26 template<class PyClass>
27 void visit(PyClass & cl) const
28 {
29 cl.def(bp::init<>(bp::arg("self")))
30 // All are add_properties cause ReadOnly
31 .add_property("id", &get_id)
32 .add_property("idx_q", &get_idx_q)
33 .add_property("idx_v", &get_idx_v)
34 .add_property("idx_vExtended", &get_idx_vExtended)
35 .add_property("nq", &get_nq)
36 .add_property("nv", &get_nv)
37 .add_property("nvExtended", &get_nvExtended)
38 .add_property(
39 "hasConfigurationLimit", &JointModelDerived::hasConfigurationLimit,
40 "Return vector of boolean if joint has configuration limits.")
41 .add_property(
42 "hasConfigurationLimitInTangent", &JointModelDerived::hasConfigurationLimitInTangent,
43 "Return vector of boolean if joint has configuration limits in tangent space.")
44 .def("setIndexes", &setIndexes0, bp::args("self", "joint_id", "idx_q", "idx_v"))
45 .def(
46 "setIndexes", &setIndexes1,
47 bp::args("self", "joint_id", "idx_q", "idx_v", "idx_vExtended"))
48 .def("classname", &JointModelDerived::classname)
49 .staticmethod("classname")
50 .def("calc", &calc0, bp::args("self", "jdata", "q"))
51 .def("calc", &calc1, bp::args("self", "jdata", "q", "v"))
52 .def(
53 "createData", &JointModelDerived::createData, bp::arg("self"),
54 "Create data associated to the joint model.")
55 .def(
56 "hasSameIndexes", &JointModelDerived::template hasSameIndexes<JointModelDerived>,
57 bp::args("self", "other"), "Check if this has same indexes than other.")
58 .def(
59 "shortname", &JointModelDerived::shortname, bp::arg("self"),
60 "Returns string indicating the joint type (class name):"
61 "\n\t- JointModelR[*]: Revolute Joint, with rotation axis [*] ∈ [X,Y,Z]"
62 "\n\t- JointModelRevoluteUnaligned: Revolute Joint, with rotation axis not aligned "
63 "with X, Y, nor Z"
64 "\n\t- JointModelRUB[*]: Unbounded revolute Joint (without position limits), with "
65 "rotation axis [*] ∈ [X,Y,Z]"
66 "\n\t- JointModelRevoluteUnboundedUnaligned: Unbounded revolute Joint, with rotation "
67 "axis not aligned with X, Y, nor Z"
68 "\n\t- JointModelP[*]: Prismatic Joint, with rotation axis [*] ∈ [X,Y,Z]"
69 "\n\t- JointModelPlanar: Planar joint"
70 "\n\t- JointModelPrismaticUnaligned: Prismatic joint, with translation axis not "
71 "aligned with X, Y, nor Z"
72 "\n\t- JointModelSphericalZYX: Spherical joint (3D rotation)"
73 "\n\t- JointModelTranslation: Translation joint (3D translation)"
74 "\n\t- JointModelFreeFlyer: Joint enabling 3D rotation and translations.")
75
76#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
77 .def(bp::self == bp::self)
78 .def(bp::self != bp::self)
79#endif
80 ;
81 }
82
83 static JointIndex get_id(const JointModelDerived & self)
84 {
85 return self.id();
86 }
87 static int get_idx_q(const JointModelDerived & self)
88 {
89 return self.idx_q();
90 }
91 static int get_idx_v(const JointModelDerived & self)
92 {
93 return self.idx_v();
94 }
95 static int get_idx_vExtended(const JointModelDerived & self)
96 {
97 return self.idx_vExtended();
98 }
99 static int get_nq(const JointModelDerived & self)
100 {
101 return self.nq();
102 }
103 static int get_nv(const JointModelDerived & self)
104 {
105 return self.nv();
106 }
107 static int get_nvExtended(const JointModelDerived & self)
108 {
109 return self.nvExtended();
110 }
111
112 static void
113 calc0(const JointModelDerived & self, JointDataDerived & jdata, const context::VectorXs & q)
114 {
115 self.calc(jdata, q);
116 }
117 static void calc1(
118 const JointModelDerived & self,
119 JointDataDerived & jdata,
120 const context::VectorXs & q,
121 const context::VectorXs & v)
122 {
123 self.calc(jdata, q, v);
124 }
125
126 static void
127 setIndexes0(JointModelDerived & self, const int & id, const int & idx_q, const int & idx_v)
128 {
129 self.setIndexes(id, idx_q, idx_v);
130 }
131
132 static void setIndexes1(
133 JointModelDerived & self,
134 const int & id,
135 const int & idx_q,
136 const int & idx_v,
137 const int & idx_vExtended)
138 {
139 self.setIndexes(id, idx_q, idx_v, idx_vExtended);
140 }
141 };
142
143 template<class JointDataDerived>
145 : public boost::python::def_visitor<JointDataBasePythonVisitor<JointDataDerived>>
146 {
147 public:
148 template<class PyClass>
149 void visit(PyClass & cl) const
150 {
151 cl
152 // All are add_properties cause ReadOnly
153 .add_property("joint_q", &get_joint_q)
154 .add_property("joint_v", &get_joint_v)
155 .add_property("S", &get_S)
156 .add_property("M", &get_M)
157 .add_property("v", &get_v)
158 .add_property("c", &get_c)
159 .add_property("U", &get_U)
160 .add_property("Dinv", &get_Dinv)
161 .add_property("UDinv", &get_UDinv)
162 .def("shortname", &JointDataDerived::shortname, bp::arg("self"))
163
164#ifndef PINOCCHIO_PYTHON_SKIP_COMPARISON_OPERATIONS
165 .def(bp::self == bp::self)
166 .def(bp::self != bp::self)
167#endif
168 ;
169 }
170
171 static typename JointDataDerived::ConfigVector_t get_joint_q(const JointDataDerived & self)
172 {
173 return self.joint_q_accessor();
174 }
175 static typename JointDataDerived::TangentVector_t get_joint_v(const JointDataDerived & self)
176 {
177 return self.joint_v_accessor();
178 }
179 // static typename JointDataDerived::Constraint_t get_S(const JointDataDerived & self)
180 // { return self.S_accessor(); }
181 static typename JointDataDerived::Constraint_t::DenseBase get_S(const JointDataDerived & self)
182 {
183 return self.S_accessor().matrix();
184 }
185 static typename JointDataDerived::Transformation_t get_M(const JointDataDerived & self)
186 {
187 return self.M_accessor();
188 }
189 static typename JointDataDerived::Motion_t get_v(const JointDataDerived & self)
190 {
191 return self.v_accessor();
192 }
193 static typename JointDataDerived::Bias_t get_c(const JointDataDerived & self)
194 {
195 return self.c_accessor();
196 }
197 static typename JointDataDerived::U_t get_U(const JointDataDerived & self)
198 {
199 return self.U_accessor();
200 }
201 static typename JointDataDerived::D_t get_Dinv(const JointDataDerived & self)
202 {
203 return self.Dinv_accessor();
204 }
205 static typename JointDataDerived::UD_t get_UDinv(const JointDataDerived & self)
206 {
207 return self.UDinv_accessor();
208 }
209
210 static void expose()
211 {
212 }
213 };
214
215 } // namespace python
216} // namespace pinocchio
Main pinocchio namespace.
Definition treeview.dox:11