- 3.0.2 models module.
inverse_dynamics.h
Go to the documentation of this file.
1 #ifndef IIT_CT_HYA_INVERSE_DYNAMICS_H_
2 #define IIT_CT_HYA_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 ct_HyA {
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::ct_HyA::tpl::MotionTransforms<TRAIT> MTransforms;
60 
61 public:
69  InverseDynamics(IProperties& in, MTransforms& tr);
70 
81  void id(
83  JointState& jForces,
84  const JointState& q, const JointState& qd, const JointState& qdd,
85  const ExtForces& fext = zeroExtForces);
86  void id(
87  JointState& jForces,
88  const JointState& qd, const JointState& qdd,
89  const ExtForces& fext = zeroExtForces);
91 
96  void G_terms(JointState& jForces, const JointState& q);
98  void G_terms(JointState& jForces);
100 
105  void C_terms(JointState& jForces, const JointState& q, const JointState& qd);
107  void C_terms(JointState& jForces, const JointState& qd);
109 
110  void setJointStatus(const JointState& q) const;
111 
112 public:
129  const Velocity& getVelocity_Shoulder_AA() const { return Shoulder_AA_v; }
131  const Acceleration& getAcceleration_Shoulder_AA() const { return Shoulder_AA_a; }
132  const Force& getForce_Shoulder_AA() const { return Shoulder_AA_f; }
133  const Velocity& getVelocity_Shoulder_FE() const { return Shoulder_FE_v; }
134  const Acceleration& getAcceleration_Shoulder_FE() const { return Shoulder_FE_a; }
135  const Force& getForce_Shoulder_FE() const { return Shoulder_FE_f; }
136  const Velocity& getVelocity_Humerus_R() const { return Humerus_R_v; }
137  const Acceleration& getAcceleration_Humerus_R() const { return Humerus_R_a; }
138  const Force& getForce_Humerus_R() const { return Humerus_R_f; }
139  const Velocity& getVelocity_Elbow_FE() const { return Elbow_FE_v; }
140  const Acceleration& getAcceleration_Elbow_FE() const { return Elbow_FE_a; }
141  const Force& getForce_Elbow_FE() const { return Elbow_FE_f; }
142  const Velocity& getVelocity_Wrist_R() const { return Wrist_R_v; }
143  const Acceleration& getAcceleration_Wrist_R() const { return Wrist_R_a; }
144  const Force& getForce_Wrist_R() const { return Wrist_R_f; }
145  const Velocity& getVelocity_Wrist_FE() const { return Wrist_FE_v; }
146  const Acceleration& getAcceleration_Wrist_FE() const { return Wrist_FE_a; }
147  const Force& getForce_Wrist_FE() const { return Wrist_FE_f; }
149 protected:
150  void firstPass(const JointState& qd, const JointState& qdd, const ExtForces& fext);
151  void secondPass(JointState& jForces);
152 
153 private:
154  IProperties* inertiaProps;
155  MTransforms* xm;
156 private:
157  Matrix66s vcross; // support variable
158  // Link 'Shoulder_AA' :
159  const InertiaMatrix& Shoulder_AA_I;
160  Velocity Shoulder_AA_v;
161  Acceleration Shoulder_AA_a;
162  Force Shoulder_AA_f;
163  // Link 'Shoulder_FE' :
164  const InertiaMatrix& Shoulder_FE_I;
165  Velocity Shoulder_FE_v;
166  Acceleration Shoulder_FE_a;
167  Force Shoulder_FE_f;
168  // Link 'Humerus_R' :
169  const InertiaMatrix& Humerus_R_I;
170  Velocity Humerus_R_v;
171  Acceleration Humerus_R_a;
172  Force Humerus_R_f;
173  // Link 'Elbow_FE' :
174  const InertiaMatrix& Elbow_FE_I;
175  Velocity Elbow_FE_v;
176  Acceleration Elbow_FE_a;
177  Force Elbow_FE_f;
178  // Link 'Wrist_R' :
179  const InertiaMatrix& Wrist_R_I;
180  Velocity Wrist_R_v;
181  Acceleration Wrist_R_a;
182  Force Wrist_R_f;
183  // Link 'Wrist_FE' :
184  const InertiaMatrix& Wrist_FE_I;
185  Velocity Wrist_FE_v;
186  Acceleration Wrist_FE_a;
187  Force Wrist_FE_f;
188 
189 
190 private:
191  static const ExtForces zeroExtForces;
192 };
193 
194 template <typename TRAIT>
196 {
197  (xm->fr_Shoulder_AA_X_fr_HyABase)(q);
198  (xm->fr_Shoulder_FE_X_fr_Shoulder_AA)(q);
199  (xm->fr_Humerus_R_X_fr_Shoulder_FE)(q);
200  (xm->fr_Elbow_FE_X_fr_Humerus_R)(q);
201  (xm->fr_Wrist_R_X_fr_Elbow_FE)(q);
202  (xm->fr_Wrist_FE_X_fr_Wrist_R)(q);
203 }
204 
205 template <typename TRAIT>
207 {
208  setJointStatus(q);
209  G_terms(jForces);
210 }
211 
212 template <typename TRAIT>
213 inline void InverseDynamics<TRAIT>::C_terms(JointState& jForces, const JointState& q, const JointState& qd)
214 {
215  setJointStatus(q);
216  C_terms(jForces, qd);
217 }
218 
219 template <typename TRAIT>
221  JointState& jForces,
222  const JointState& q, const JointState& qd, const JointState& qdd,
223  const ExtForces& fext)
224 {
225  setJointStatus(q);
226  id(jForces, qd, qdd, fext);
227 }
228 
229 } // namespace tpl
230 
232 
233 }
234 }
235 
236 }
237 
238 #include "inverse_dynamics.impl.h"
239 
240 #endif
CoreS::ForceVector Force
Definition: inverse_dynamics.h:51
CoreS::VelocityVector Acceleration
Definition: inverse_dynamics.h:54
Definition: derivativeIvState.hpp:21
const Acceleration & getAcceleration_Elbow_FE() const
Definition: inverse_dynamics.h:140
const Acceleration & getAcceleration_Shoulder_AA() const
Definition: inverse_dynamics.h:131
const Velocity & getVelocity_Shoulder_FE() const
Definition: inverse_dynamics.h:133
PlainMatrix< Scalar, 6, 6 > Matrix66
iit::rbd::Core< SCALAR > CoreS
Definition: inverse_dynamics.h:49
void setJointStatus(const JointState &q) const
Definition: inverse_dynamics.h:195
InertiaProperties< TRAIT > IProperties
Definition: inverse_dynamics.h:59
ct::core::ADCodegenLinearizer< state_dim, control_dim >::ADCGScalar Scalar
Definition: HyALinearizationCodeGen.cpp:23
Definition: inverse_dynamics.h:43
InverseDynamics(IProperties &in, MTransforms &tr)
Definition: inverse_dynamics.impl.h:8
iit::rbd::tpl::InertiaMatrixDense< SCALAR > InertiaMatrix
Definition: inverse_dynamics.h:55
const Force & getForce_Wrist_R() const
Definition: inverse_dynamics.h:144
const Velocity & getVelocity_Humerus_R() const
Definition: inverse_dynamics.h:136
Definition: link_data_map.h:12
void id(JointState &jForces, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:220
const Acceleration & getAcceleration_Wrist_R() const
Definition: inverse_dynamics.h:143
void C_terms(JointState &jForces, const JointState &q, const JointState &qd)
Definition: inverse_dynamics.h:213
const Acceleration & getAcceleration_Humerus_R() const
Definition: inverse_dynamics.h:137
const Force & getForce_Wrist_FE() const
Definition: inverse_dynamics.h:147
const Acceleration & getAcceleration_Wrist_FE() const
Definition: inverse_dynamics.h:146
Vector6D ForceVector
const Velocity & getVelocity_Wrist_FE() const
Definition: inverse_dynamics.h:145
void firstPass(const JointState &qd, const JointState &qdd, const ExtForces &fext)
Definition: inverse_dynamics.impl.h:130
void G_terms(JointState &jForces, const JointState &q)
Definition: inverse_dynamics.h:206
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar SCALAR
Definition: inverse_dynamics.h:47
const Force & getForce_Elbow_FE() const
Definition: inverse_dynamics.h:141
const Force & getForce_Shoulder_AA() const
Definition: inverse_dynamics.h:132
void secondPass(JointState &jForces)
Definition: inverse_dynamics.impl.h:197
LinkDataMap< Force > ExtForces
Definition: inverse_dynamics.h:52
const Velocity & getVelocity_Shoulder_AA() const
Definition: inverse_dynamics.h:130
const Acceleration & getAcceleration_Shoulder_FE() const
Definition: inverse_dynamics.h:134
iit::ct_HyA::tpl::JointState< SCALAR > JointState
Definition: inverse_dynamics.h:56
CoreS::VelocityVector Velocity
Definition: inverse_dynamics.h:53
iit::ct_HyA::tpl::MotionTransforms< TRAIT > MTransforms
Definition: inverse_dynamics.h:58
const Force & getForce_Humerus_R() const
Definition: inverse_dynamics.h:138
Vector6D VelocityVector
Definition: inertia_properties.h:26
Column6d< SCALAR > JointState
Definition: declarations.h:20
const Velocity & getVelocity_Wrist_R() const
Definition: inverse_dynamics.h:142
const Velocity & getVelocity_Elbow_FE() const
Definition: inverse_dynamics.h:139
CoreS::Matrix66 Matrix66s
Definition: inverse_dynamics.h:57
const Force & getForce_Shoulder_FE() const
Definition: inverse_dynamics.h:135