- 3.0.2 rigid body dynamics module.
inverse_dynamics.h
Go to the documentation of this file.
1 #ifndef IIT_TESTHYQ_INVERSE_DYNAMICS_H_
2 #define IIT_TESTHYQ_INVERSE_DYNAMICS_H_
3 
4 #include <iit/rbd/rbd.h>
6 #include <iit/rbd/utils.h>
9 
10 #include "declarations.h"
11 #include "inertia_properties.h"
12 #include "transforms.h"
13 #include "link_data_map.h"
14 
15 namespace iit {
16 namespace TestHyQ {
17 namespace dyn {
18 
38 namespace tpl {
39 
40 template <typename TRAIT>
42 public:
43  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
44 
45  typedef typename TRAIT::Scalar Scalar;
46 
48 
49  typedef typename CoreS::ForceVector Force;
51  typedef typename CoreS::VelocityVector Velocity;
55  typedef typename CoreS::Matrix66 Matrix66s;
56  typedef iit::TestHyQ::tpl::MotionTransforms<TRAIT> MTransforms;
58 
59 public:
67  InverseDynamics(IProperties& in, MTransforms& tr);
68 
86  void id(
87  JointState& jForces, Acceleration& trunk_a,
88  const Acceleration& g, const Velocity& trunk_v,
89  const JointState& q, const JointState& qd, const JointState& qdd,
90  const ExtForces& fext = zeroExtForces);
91  void id(
92  JointState& jForces, Acceleration& trunk_a,
93  const Acceleration& g, const Velocity& trunk_v,
94  const JointState& qd, const JointState& qdd,
95  const ExtForces& fext = zeroExtForces);
97 
117  void id_fully_actuated(
118  Force& baseWrench, JointState& jForces,
119  const Acceleration& g, const Velocity& trunk_v, const Acceleration& baseAccel,
120  const JointState& q, const JointState& qd, const JointState& qdd, const ExtForces& fext = zeroExtForces);
121  void id_fully_actuated(
122  Force& baseWrench, JointState& jForces,
123  const Acceleration& g, const Velocity& trunk_v, const Acceleration& baseAccel,
124  const JointState& qd, const JointState& qdd, const ExtForces& fext = zeroExtForces);
126 
130  Force& baseWrench, JointState& jForces,
131  const Acceleration& g, const JointState& q);
133  Force& baseWrench, JointState& jForces,
134  const Acceleration& g);
136 
148  Force& baseWrench, JointState& jForces,
149  const Velocity& trunk_v, const JointState& q, const JointState& qd);
151  Force& baseWrench, JointState& jForces,
152  const Velocity& trunk_v, const JointState& qd);
154 
155  void setJointStatus(const JointState& q) const;
156 
157 public:
174  const Force& getForce_trunk() const { return trunk_f; }
176  const Velocity& getVelocity_LF_hipassembly() const { return LF_hipassembly_v; }
177  const Acceleration& getAcceleration_LF_hipassembly() const { return LF_hipassembly_a; }
178  const Force& getForce_LF_hipassembly() const { return LF_hipassembly_f; }
179  const Velocity& getVelocity_LF_upperleg() const { return LF_upperleg_v; }
180  const Acceleration& getAcceleration_LF_upperleg() const { return LF_upperleg_a; }
181  const Force& getForce_LF_upperleg() const { return LF_upperleg_f; }
182  const Velocity& getVelocity_LF_lowerleg() const { return LF_lowerleg_v; }
183  const Acceleration& getAcceleration_LF_lowerleg() const { return LF_lowerleg_a; }
184  const Force& getForce_LF_lowerleg() const { return LF_lowerleg_f; }
185  const Velocity& getVelocity_RF_hipassembly() const { return RF_hipassembly_v; }
186  const Acceleration& getAcceleration_RF_hipassembly() const { return RF_hipassembly_a; }
187  const Force& getForce_RF_hipassembly() const { return RF_hipassembly_f; }
188  const Velocity& getVelocity_RF_upperleg() const { return RF_upperleg_v; }
189  const Acceleration& getAcceleration_RF_upperleg() const { return RF_upperleg_a; }
190  const Force& getForce_RF_upperleg() const { return RF_upperleg_f; }
191  const Velocity& getVelocity_RF_lowerleg() const { return RF_lowerleg_v; }
192  const Acceleration& getAcceleration_RF_lowerleg() const { return RF_lowerleg_a; }
193  const Force& getForce_RF_lowerleg() const { return RF_lowerleg_f; }
194  const Velocity& getVelocity_LH_hipassembly() const { return LH_hipassembly_v; }
195  const Acceleration& getAcceleration_LH_hipassembly() const { return LH_hipassembly_a; }
196  const Force& getForce_LH_hipassembly() const { return LH_hipassembly_f; }
197  const Velocity& getVelocity_LH_upperleg() const { return LH_upperleg_v; }
198  const Acceleration& getAcceleration_LH_upperleg() const { return LH_upperleg_a; }
199  const Force& getForce_LH_upperleg() const { return LH_upperleg_f; }
200  const Velocity& getVelocity_LH_lowerleg() const { return LH_lowerleg_v; }
201  const Acceleration& getAcceleration_LH_lowerleg() const { return LH_lowerleg_a; }
202  const Force& getForce_LH_lowerleg() const { return LH_lowerleg_f; }
203  const Velocity& getVelocity_RH_hipassembly() const { return RH_hipassembly_v; }
204  const Acceleration& getAcceleration_RH_hipassembly() const { return RH_hipassembly_a; }
205  const Force& getForce_RH_hipassembly() const { return RH_hipassembly_f; }
206  const Velocity& getVelocity_RH_upperleg() const { return RH_upperleg_v; }
207  const Acceleration& getAcceleration_RH_upperleg() const { return RH_upperleg_a; }
208  const Force& getForce_RH_upperleg() const { return RH_upperleg_f; }
209  const Velocity& getVelocity_RH_lowerleg() const { return RH_lowerleg_v; }
210  const Acceleration& getAcceleration_RH_lowerleg() const { return RH_lowerleg_a; }
211  const Force& getForce_RH_lowerleg() const { return RH_lowerleg_f; }
213 protected:
214  void secondPass_fullyActuated(JointState& jForces);
215 
216 private:
217  IProperties* inertiaProps;
218  MTransforms* xm;
219 private:
220  Matrix66s vcross; // support variable
221  // Link 'LF_hipassembly' :
222  const InertiaMatrix& LF_hipassembly_I;
223  Velocity LF_hipassembly_v;
224  Acceleration LF_hipassembly_a;
225  Force LF_hipassembly_f;
226  // Link 'LF_upperleg' :
227  const InertiaMatrix& LF_upperleg_I;
228  Velocity LF_upperleg_v;
229  Acceleration LF_upperleg_a;
230  Force LF_upperleg_f;
231  // Link 'LF_lowerleg' :
232  const InertiaMatrix& LF_lowerleg_I;
233  Velocity LF_lowerleg_v;
234  Acceleration LF_lowerleg_a;
235  Force LF_lowerleg_f;
236  // Link 'RF_hipassembly' :
237  const InertiaMatrix& RF_hipassembly_I;
238  Velocity RF_hipassembly_v;
239  Acceleration RF_hipassembly_a;
240  Force RF_hipassembly_f;
241  // Link 'RF_upperleg' :
242  const InertiaMatrix& RF_upperleg_I;
243  Velocity RF_upperleg_v;
244  Acceleration RF_upperleg_a;
245  Force RF_upperleg_f;
246  // Link 'RF_lowerleg' :
247  const InertiaMatrix& RF_lowerleg_I;
248  Velocity RF_lowerleg_v;
249  Acceleration RF_lowerleg_a;
250  Force RF_lowerleg_f;
251  // Link 'LH_hipassembly' :
252  const InertiaMatrix& LH_hipassembly_I;
253  Velocity LH_hipassembly_v;
254  Acceleration LH_hipassembly_a;
255  Force LH_hipassembly_f;
256  // Link 'LH_upperleg' :
257  const InertiaMatrix& LH_upperleg_I;
258  Velocity LH_upperleg_v;
259  Acceleration LH_upperleg_a;
260  Force LH_upperleg_f;
261  // Link 'LH_lowerleg' :
262  const InertiaMatrix& LH_lowerleg_I;
263  Velocity LH_lowerleg_v;
264  Acceleration LH_lowerleg_a;
265  Force LH_lowerleg_f;
266  // Link 'RH_hipassembly' :
267  const InertiaMatrix& RH_hipassembly_I;
268  Velocity RH_hipassembly_v;
269  Acceleration RH_hipassembly_a;
270  Force RH_hipassembly_f;
271  // Link 'RH_upperleg' :
272  const InertiaMatrix& RH_upperleg_I;
273  Velocity RH_upperleg_v;
274  Acceleration RH_upperleg_a;
275  Force RH_upperleg_f;
276  // Link 'RH_lowerleg' :
277  const InertiaMatrix& RH_lowerleg_I;
278  Velocity RH_lowerleg_v;
279  Acceleration RH_lowerleg_a;
280  Force RH_lowerleg_f;
281 
282  // The robot base
283  const InertiaMatrix& trunk_I;
284  InertiaMatrix trunk_Ic;
285  Force trunk_f;
286  // The composite inertia tensors
287  InertiaMatrix LF_hipassembly_Ic;
288  InertiaMatrix LF_upperleg_Ic;
289  const InertiaMatrix& LF_lowerleg_Ic;
290  InertiaMatrix RF_hipassembly_Ic;
291  InertiaMatrix RF_upperleg_Ic;
292  const InertiaMatrix& RF_lowerleg_Ic;
293  InertiaMatrix LH_hipassembly_Ic;
294  InertiaMatrix LH_upperleg_Ic;
295  const InertiaMatrix& LH_lowerleg_Ic;
296  InertiaMatrix RH_hipassembly_Ic;
297  InertiaMatrix RH_upperleg_Ic;
298  const InertiaMatrix& RH_lowerleg_Ic;
299 
300 private:
301  static const ExtForces zeroExtForces;
302 };
303 
304 template <typename TRAIT>
306 {
307  (xm->fr_LF_hipassembly_X_fr_trunk)(q);
308  (xm->fr_LF_upperleg_X_fr_LF_hipassembly)(q);
309  (xm->fr_LF_lowerleg_X_fr_LF_upperleg)(q);
310  (xm->fr_RF_hipassembly_X_fr_trunk)(q);
311  (xm->fr_RF_upperleg_X_fr_RF_hipassembly)(q);
312  (xm->fr_RF_lowerleg_X_fr_RF_upperleg)(q);
313  (xm->fr_LH_hipassembly_X_fr_trunk)(q);
314  (xm->fr_LH_upperleg_X_fr_LH_hipassembly)(q);
315  (xm->fr_LH_lowerleg_X_fr_LH_upperleg)(q);
316  (xm->fr_RH_hipassembly_X_fr_trunk)(q);
317  (xm->fr_RH_upperleg_X_fr_RH_hipassembly)(q);
318  (xm->fr_RH_lowerleg_X_fr_RH_upperleg)(q);
319 }
320 
321 template <typename TRAIT>
323  JointState& jForces, Acceleration& trunk_a,
324  const Acceleration& g, const Velocity& trunk_v,
325  const JointState& q, const JointState& qd, const JointState& qdd,
326  const ExtForces& fext)
327 {
328  setJointStatus(q);
329  id(jForces, trunk_a, g, trunk_v,
330  qd, qdd, fext);
331 }
332 
333 template <typename TRAIT>
335  Force& baseWrench, JointState& jForces,
336  const Acceleration& g, const JointState& q)
337 {
338  setJointStatus(q);
339  G_terms_fully_actuated(baseWrench, jForces, g);
340 }
341 
342 template <typename TRAIT>
344  Force& baseWrench, JointState& jForces,
345  const Velocity& trunk_v, const JointState& q, const JointState& qd)
346 {
347  setJointStatus(q);
348  C_terms_fully_actuated(baseWrench, jForces, trunk_v, qd);
349 }
350 
351 template <typename TRAIT>
353  Force& baseWrench, JointState& jForces,
354  const Acceleration& g, const Velocity& trunk_v, const Acceleration& baseAccel,
355  const JointState& q, const JointState& qd, const JointState& qdd, const ExtForces& fext)
356 {
357  setJointStatus(q);
358  id_fully_actuated(baseWrench, jForces, g, trunk_v,
359  baseAccel, qd, qdd, fext);
360 }
361 
362 }
363 
365 
366 }
367 }
368 
369 }
370 
371 #include "inverse_dynamics.impl.h"
372 
373 #endif
const Force & getForce_LF_hipassembly() const
Definition: inverse_dynamics.h:178
const Acceleration & getAcceleration_RH_upperleg() const
Definition: inverse_dynamics.h:207
const Force & getForce_LH_upperleg() const
Definition: inverse_dynamics.h:199
void C_terms_fully_actuated(Force &baseWrench, JointState &jForces, const Velocity &trunk_v, const JointState &q, const JointState &qd)
Definition: inverse_dynamics.h:343
void secondPass_fullyActuated(JointState &jForces)
Definition: inverse_dynamics.impl.h:595
CoreS::Matrix66 Matrix66s
Definition: inverse_dynamics.h:55
const Force & getForce_RH_hipassembly() const
Definition: inverse_dynamics.h:205
CoreS::VelocityVector Velocity
Definition: inverse_dynamics.h:51
const Acceleration & getAcceleration_LF_upperleg() const
Definition: inverse_dynamics.h:180
const Velocity & getVelocity_LF_lowerleg() const
Definition: inverse_dynamics.h:182
Definition: inverse_dynamics.h:41
const Acceleration & getAcceleration_LH_hipassembly() const
Definition: inverse_dynamics.h:195
PlainMatrix< Scalar, 6, 6 > Matrix66
Definition: rbd.h:79
const Acceleration & getAcceleration_RF_hipassembly() const
Definition: inverse_dynamics.h:186
const Force & getForce_LH_lowerleg() const
Definition: inverse_dynamics.h:202
void G_terms_fully_actuated(Force &baseWrench, JointState &jForces, const Acceleration &g, const JointState &q)
Definition: inverse_dynamics.h:334
const Velocity & getVelocity_RH_hipassembly() const
Definition: inverse_dynamics.h:203
const Acceleration & getAcceleration_LH_upperleg() const
Definition: inverse_dynamics.h:198
const Force & getForce_trunk() const
Definition: inverse_dynamics.h:175
const Force & getForce_RH_lowerleg() const
Definition: inverse_dynamics.h:211
const Acceleration & getAcceleration_LF_hipassembly() const
Definition: inverse_dynamics.h:177
const Force & getForce_RF_upperleg() const
Definition: inverse_dynamics.h:190
const Force & getForce_LF_upperleg() const
Definition: inverse_dynamics.h:181
const Force & getForce_LH_hipassembly() const
Definition: inverse_dynamics.h:196
LinkDataMap< Force > ExtForces
Definition: inverse_dynamics.h:50
iit::rbd::tpl::InertiaMatrixDense< Scalar > InertiaMatrix
Definition: inverse_dynamics.h:53
CoreS::VelocityVector Acceleration
Definition: inverse_dynamics.h:52
const Velocity & getVelocity_LF_upperleg() const
Definition: inverse_dynamics.h:179
const Velocity & getVelocity_LH_upperleg() const
Definition: inverse_dynamics.h:197
void setJointStatus(const JointState &q) const
Definition: inverse_dynamics.h:305
const Force & getForce_LF_lowerleg() const
Definition: inverse_dynamics.h:184
const Velocity & getVelocity_RF_upperleg() const
Definition: inverse_dynamics.h:188
const Force & getForce_RH_upperleg() const
Definition: inverse_dynamics.h:208
InertiaProperties< TRAIT > IProperties
Definition: inverse_dynamics.h:57
Definition: inertia_properties.h:24
Definition: link_data_map.h:12
Definition: rbd.h:72
const Velocity & getVelocity_LH_lowerleg() const
Definition: inverse_dynamics.h:200
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar Scalar
Definition: inverse_dynamics.h:45
iit::TestHyQ::tpl::JointState< Scalar > JointState
Definition: inverse_dynamics.h:54
const Force & getForce_RF_hipassembly() const
Definition: inverse_dynamics.h:187
Column12d< SCALAR > JointState
Definition: declarations.h:19
const Velocity & getVelocity_RF_lowerleg() const
Definition: inverse_dynamics.h:191
Vector6D ForceVector
a 3D subvector of a 6D vector
Definition: rbd.h:92
void id_fully_actuated(Force &baseWrench, JointState &jForces, const Acceleration &g, const Velocity &trunk_v, const Acceleration &baseAccel, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:352
const Acceleration & getAcceleration_RH_lowerleg() const
Definition: inverse_dynamics.h:210
iit::rbd::Core< Scalar > CoreS
Definition: inverse_dynamics.h:47
const Velocity & getVelocity_RH_lowerleg() const
Definition: inverse_dynamics.h:209
void id(JointState &jForces, Acceleration &trunk_a, const Acceleration &g, const Velocity &trunk_v, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:322
CoreS::ForceVector Force
Definition: inverse_dynamics.h:49
InverseDynamics(IProperties &in, MTransforms &tr)
Definition: inverse_dynamics.impl.h:7
iit::TestHyQ::tpl::MotionTransforms< TRAIT > MTransforms
Definition: inverse_dynamics.h:56
const Velocity & getVelocity_RF_hipassembly() const
Definition: inverse_dynamics.h:185
const Acceleration & getAcceleration_RF_upperleg() const
Definition: inverse_dynamics.h:189
const Velocity & getVelocity_LF_hipassembly() const
Definition: inverse_dynamics.h:176
Vector6D VelocityVector
a 3D subvector of a 6D vector
Definition: rbd.h:91
const Acceleration & getAcceleration_RF_lowerleg() const
Definition: inverse_dynamics.h:192
const Velocity & getVelocity_LH_hipassembly() const
Definition: inverse_dynamics.h:194
const Velocity & getVelocity_RH_upperleg() const
Definition: inverse_dynamics.h:206
const Acceleration & getAcceleration_LF_lowerleg() const
Definition: inverse_dynamics.h:183
const Force & getForce_RF_lowerleg() const
Definition: inverse_dynamics.h:193
const Acceleration & getAcceleration_RH_hipassembly() const
Definition: inverse_dynamics.h:204
const Acceleration & getAcceleration_LH_lowerleg() const
Definition: inverse_dynamics.h:201