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