- 3.0.2 models module.
inverse_dynamics.h
Go to the documentation of this file.
1 #ifndef IIT_CT_QUADROTOR_INVERSE_DYNAMICS_H_
2 #define IIT_CT_QUADROTOR_INVERSE_DYNAMICS_H_
3 
4 #include <Eigen/Dense>
5 #include <iit/rbd/rbd.h>
7 #include <iit/rbd/utils.h>
10 
11 #include "declarations.h"
12 #include "inertia_properties.h"
13 #include "transforms.h"
14 #include "link_data_map.h"
15 
16 namespace iit {
17 namespace ct_quadrotor {
18 namespace dyn {
19 
39 namespace tpl {
40 
41 template <typename TRAIT>
43 public:
44  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45 
46  typedef typename TRAIT::Scalar SCALAR;
47 
49 
50  typedef typename CoreS::ForceVector Force;
52  typedef typename CoreS::VelocityVector Velocity;
56  typedef typename CoreS::Matrix66 Matrix66s;
57  typedef iit::ct_quadrotor::tpl::MotionTransforms<TRAIT> MTransforms;
59 
60 public:
68  InverseDynamics(IProperties& in, MTransforms& tr);
69 
87  void id(
88  JointState& jForces, Acceleration& body_a,
89  const Acceleration& g, const Velocity& body_v,
90  const JointState& q, const JointState& qd, const JointState& qdd,
91  const ExtForces& fext = zeroExtForces);
92  void id(
93  JointState& jForces, Acceleration& body_a,
94  const Acceleration& g, const Velocity& body_v,
95  const JointState& qd, const JointState& qdd,
96  const ExtForces& fext = zeroExtForces);
98 
118  void id_fully_actuated(
119  Force& baseWrench, JointState& jForces,
120  const Acceleration& g, const Velocity& body_v, const Acceleration& baseAccel,
121  const JointState& q, const JointState& qd, const JointState& qdd, const ExtForces& fext = zeroExtForces);
122  void id_fully_actuated(
123  Force& baseWrench, JointState& jForces,
124  const Acceleration& g, const Velocity& body_v, const Acceleration& baseAccel,
125  const JointState& qd, const JointState& qdd, const ExtForces& fext = zeroExtForces);
127 
131  Force& baseWrench, JointState& jForces,
132  const Acceleration& g, const JointState& q);
134  Force& baseWrench, JointState& jForces,
135  const Acceleration& g);
137 
149  Force& baseWrench, JointState& jForces,
150  const Velocity& body_v, const JointState& q, const JointState& qd);
152  Force& baseWrench, JointState& jForces,
153  const Velocity& body_v, const JointState& qd);
155 
156  void setJointStatus(const JointState& q) const;
157 
158 public:
175  const Force& getForce_body() const { return body_f; }
177  const Velocity& getVelocity_link1() const { return link1_v; }
178  const Acceleration& getAcceleration_link1() const { return link1_a; }
179  const Force& getForce_link1() const { return link1_f; }
180  const Velocity& getVelocity_link2() const { return link2_v; }
181  const Acceleration& getAcceleration_link2() const { return link2_a; }
182  const Force& getForce_link2() const { return link2_f; }
184 protected:
185  void secondPass_fullyActuated(JointState& jForces);
186 
187 private:
188  IProperties* inertiaProps;
189  MTransforms* xm;
190 private:
191  Matrix66s vcross; // support variable
192  // Link 'link1' :
193  const InertiaMatrix& link1_I;
194  Velocity link1_v;
195  Acceleration link1_a;
196  Force link1_f;
197  // Link 'link2' :
198  const InertiaMatrix& link2_I;
199  Velocity link2_v;
200  Acceleration link2_a;
201  Force link2_f;
202 
203  // The robot base
204  const InertiaMatrix& body_I;
205  InertiaMatrix body_Ic;
206  Force body_f;
207  // The composite inertia tensors
208  InertiaMatrix link1_Ic;
209  const InertiaMatrix& link2_Ic;
210 
211 private:
212  static const ExtForces zeroExtForces;
213 };
214 
215 template <typename TRAIT>
217 {
218  (xm->fr_link1_X_fr_body)(q);
219  (xm->fr_link2_X_fr_link1)(q);
220 }
221 
222 template <typename TRAIT>
224  JointState& jForces, Acceleration& body_a,
225  const Acceleration& g, const Velocity& body_v,
226  const JointState& q, const JointState& qd, const JointState& qdd,
227  const ExtForces& fext)
228 {
229  setJointStatus(q);
230  id(jForces, body_a, g, body_v,
231  qd, qdd, fext);
232 }
233 
234 template <typename TRAIT>
236  Force& baseWrench, JointState& jForces,
237  const Acceleration& g, const JointState& q)
238 {
239  setJointStatus(q);
240  G_terms_fully_actuated(baseWrench, jForces, g);
241 }
242 
243 template <typename TRAIT>
245  Force& baseWrench, JointState& jForces,
246  const Velocity& body_v, const JointState& q, const JointState& qd)
247 {
248  setJointStatus(q);
249  C_terms_fully_actuated(baseWrench, jForces, body_v, qd);
250 }
251 
252 template <typename TRAIT>
254  Force& baseWrench, JointState& jForces,
255  const Acceleration& g, const Velocity& body_v, const Acceleration& baseAccel,
256  const JointState& q, const JointState& qd, const JointState& qdd, const ExtForces& fext)
257 {
258  setJointStatus(q);
259  id_fully_actuated(baseWrench, jForces, g, body_v,
260  baseAccel, qd, qdd, fext);
261 }
262 
263 } // namespace tpl
264 
266 
267 }
268 }
269 
270 }
271 
272 #include "inverse_dynamics.impl.h"
273 
274 #endif
Column2d< SCALAR > JointState
Definition: declarations.h:19
CoreS::VelocityVector Velocity
Definition: inverse_dynamics.h:52
PlainMatrix< Scalar, 6, 6 > Matrix66
InertiaProperties< TRAIT > IProperties
Definition: inverse_dynamics.h:58
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar SCALAR
Definition: inverse_dynamics.h:46
iit::rbd::tpl::InertiaMatrixDense< SCALAR > InertiaMatrix
Definition: inverse_dynamics.h:54
LinkDataMap< Force > ExtForces
Definition: inverse_dynamics.h:51
const Velocity & getVelocity_link2() const
Definition: inverse_dynamics.h:180
void C_terms_fully_actuated(Force &baseWrench, JointState &jForces, const Velocity &body_v, const JointState &q, const JointState &qd)
Definition: inverse_dynamics.h:244
CoreS::ForceVector Force
Definition: inverse_dynamics.h:50
ct::core::ADCodegenLinearizer< state_dim, control_dim >::ADCGScalar Scalar
Definition: HyALinearizationCodeGen.cpp:23
Definition: inverse_dynamics.h:42
iit::ct_quadrotor::tpl::MotionTransforms< TRAIT > MTransforms
Definition: inverse_dynamics.h:57
const Velocity & getVelocity_link1() const
Definition: inverse_dynamics.h:177
void G_terms_fully_actuated(Force &baseWrench, JointState &jForces, const Acceleration &g, const JointState &q)
Definition: inverse_dynamics.h:235
void id_fully_actuated(Force &baseWrench, JointState &jForces, const Acceleration &g, const Velocity &body_v, const Acceleration &baseAccel, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:253
Definition: inertia_properties.h:25
void id(JointState &jForces, Acceleration &body_a, const Acceleration &g, const Velocity &body_v, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:223
const Force & getForce_link1() const
Definition: inverse_dynamics.h:179
iit::ct_quadrotor::tpl::JointState< SCALAR > JointState
Definition: inverse_dynamics.h:55
Definition: link_data_map.h:12
const Acceleration & getAcceleration_link2() const
Definition: inverse_dynamics.h:181
const Force & getForce_link2() const
Definition: inverse_dynamics.h:182
Vector6D ForceVector
const Force & getForce_body() const
Definition: inverse_dynamics.h:176
InverseDynamics(IProperties &in, MTransforms &tr)
Definition: inverse_dynamics.impl.h:8
CoreS::VelocityVector Acceleration
Definition: inverse_dynamics.h:53
void setJointStatus(const JointState &q) const
Definition: inverse_dynamics.h:216
iit::rbd::Core< SCALAR > CoreS
Definition: inverse_dynamics.h:48
CoreS::Matrix66 Matrix66s
Definition: inverse_dynamics.h:56
Vector6D VelocityVector
void secondPass_fullyActuated(JointState &jForces)
Definition: inverse_dynamics.impl.h:176
const Acceleration & getAcceleration_link1() const
Definition: inverse_dynamics.h:178