- 3.0.2 rigid body dynamics module.
inverse_dynamics.h
Go to the documentation of this file.
1 #ifndef IIT_TESTIRB4600_INVERSE_DYNAMICS_H_
2 #define IIT_TESTIRB4600_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 testirb4600 {
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::testirb4600::tpl::MotionTransforms<TRAIT> MTransforms;
59 
60 public:
68  InverseDynamics(IProperties& in, MTransforms& tr);
69 
80  void id(
82  JointState& jForces,
83  const JointState& q, const JointState& qd, const JointState& qdd,
84  const ExtForces& fext = zeroExtForces);
85  void id(
86  JointState& jForces,
87  const JointState& qd, const JointState& qdd,
88  const ExtForces& fext = zeroExtForces);
90 
95  void G_terms(JointState& jForces, const JointState& q);
97  void G_terms(JointState& jForces);
99 
104  void C_terms(JointState& jForces, const JointState& q, const JointState& qd);
106  void C_terms(JointState& jForces, const JointState& qd);
108 
109  void setJointStatus(const JointState& q) const;
110 
111 public:
128  const Velocity& getVelocity_link1() const { return link1_v; }
130  const Acceleration& getAcceleration_link1() const { return link1_a; }
131  const Force& getForce_link1() const { return link1_f; }
132  const Velocity& getVelocity_link2() const { return link2_v; }
133  const Acceleration& getAcceleration_link2() const { return link2_a; }
134  const Force& getForce_link2() const { return link2_f; }
135  const Velocity& getVelocity_link3() const { return link3_v; }
136  const Acceleration& getAcceleration_link3() const { return link3_a; }
137  const Force& getForce_link3() const { return link3_f; }
138  const Velocity& getVelocity_link4() const { return link4_v; }
139  const Acceleration& getAcceleration_link4() const { return link4_a; }
140  const Force& getForce_link4() const { return link4_f; }
141  const Velocity& getVelocity_link5() const { return link5_v; }
142  const Acceleration& getAcceleration_link5() const { return link5_a; }
143  const Force& getForce_link5() const { return link5_f; }
144  const Velocity& getVelocity_link6() const { return link6_v; }
145  const Acceleration& getAcceleration_link6() const { return link6_a; }
146  const Force& getForce_link6() const { return link6_f; }
148 protected:
149  void firstPass(const JointState& qd, const JointState& qdd, const ExtForces& fext);
150  void secondPass(JointState& jForces);
151 
152 private:
153  IProperties* inertiaProps;
154  MTransforms* xm;
155 private:
156  Matrix66s vcross; // support variable
157  // Link 'link1' :
158  const InertiaMatrix& link1_I;
159  Velocity link1_v;
160  Acceleration link1_a;
161  Force link1_f;
162  // Link 'link2' :
163  const InertiaMatrix& link2_I;
164  Velocity link2_v;
165  Acceleration link2_a;
166  Force link2_f;
167  // Link 'link3' :
168  const InertiaMatrix& link3_I;
169  Velocity link3_v;
170  Acceleration link3_a;
171  Force link3_f;
172  // Link 'link4' :
173  const InertiaMatrix& link4_I;
174  Velocity link4_v;
175  Acceleration link4_a;
176  Force link4_f;
177  // Link 'link5' :
178  const InertiaMatrix& link5_I;
179  Velocity link5_v;
180  Acceleration link5_a;
181  Force link5_f;
182  // Link 'link6' :
183  const InertiaMatrix& link6_I;
184  Velocity link6_v;
185  Acceleration link6_a;
186  Force link6_f;
187 
188 
189 private:
190  static const ExtForces zeroExtForces;
191 };
192 
193 template <typename TRAIT>
195 {
196  (xm->fr_link1_X_fr_link0)(q);
197  (xm->fr_link2_X_fr_link1)(q);
198  (xm->fr_link3_X_fr_link2)(q);
199  (xm->fr_link4_X_fr_link3)(q);
200  (xm->fr_link5_X_fr_link4)(q);
201  (xm->fr_link6_X_fr_link5)(q);
202 }
203 
204 template <typename TRAIT>
206 {
207  setJointStatus(q);
208  G_terms(jForces);
209 }
210 
211 template <typename TRAIT>
212 inline void InverseDynamics<TRAIT>::C_terms(JointState& jForces, const JointState& q, const JointState& qd)
213 {
214  setJointStatus(q);
215  C_terms(jForces, qd);
216 }
217 
218 template <typename TRAIT>
220  JointState& jForces,
221  const JointState& q, const JointState& qd, const JointState& qdd,
222  const ExtForces& fext)
223 {
224  setJointStatus(q);
225  id(jForces, qd, qdd, fext);
226 }
227 
228 } // namespace tpl
229 
231 
232 }
233 }
234 
235 }
236 
237 #include "inverse_dynamics.impl.h"
238 
239 #endif
CoreS::Matrix66 Matrix66s
Definition: inverse_dynamics.h:56
InverseDynamics(IProperties &in, MTransforms &tr)
Definition: inverse_dynamics.impl.h:8
const Force & getForce_link6() const
Definition: inverse_dynamics.h:146
PlainMatrix< Scalar, 6, 6 > Matrix66
Definition: rbd.h:79
Definition: inverse_dynamics.h:42
const Force & getForce_link2() const
Definition: inverse_dynamics.h:134
iit::testirb4600::tpl::JointState< SCALAR > JointState
Definition: inverse_dynamics.h:55
const Velocity & getVelocity_link1() const
Definition: inverse_dynamics.h:129
void firstPass(const JointState &qd, const JointState &qdd, const ExtForces &fext)
Definition: inverse_dynamics.impl.h:130
const Velocity & getVelocity_link4() const
Definition: inverse_dynamics.h:138
Definition: InertiaMatrix.h:25
const Acceleration & getAcceleration_link2() const
Definition: inverse_dynamics.h:133
const Velocity & getVelocity_link3() const
Definition: inverse_dynamics.h:135
CoreS::VelocityVector Acceleration
Definition: inverse_dynamics.h:53
const Velocity & getVelocity_link2() const
Definition: inverse_dynamics.h:132
CoreS::VelocityVector Velocity
Definition: inverse_dynamics.h:52
Definition: inertia_properties.h:25
const Force & getForce_link3() const
Definition: inverse_dynamics.h:137
const Acceleration & getAcceleration_link1() const
Definition: inverse_dynamics.h:130
LinkDataMap< Force > ExtForces
Definition: inverse_dynamics.h:51
Definition: rbd.h:72
void id(JointState &jForces, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:219
Definition: link_data_map.h:12
void G_terms(JointState &jForces, const JointState &q)
Definition: inverse_dynamics.h:205
iit::testirb4600::tpl::MotionTransforms< TRAIT > MTransforms
Definition: inverse_dynamics.h:57
Vector6D ForceVector
a 3D subvector of a 6D vector
Definition: rbd.h:92
const Acceleration & getAcceleration_link4() const
Definition: inverse_dynamics.h:139
CoreS::ForceVector Force
Definition: inverse_dynamics.h:50
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar SCALAR
Definition: inverse_dynamics.h:46
const Force & getForce_link1() const
Definition: inverse_dynamics.h:131
const Acceleration & getAcceleration_link3() const
Definition: inverse_dynamics.h:136
void setJointStatus(const JointState &q) const
Definition: inverse_dynamics.h:194
iit::rbd::Core< SCALAR > CoreS
Definition: inverse_dynamics.h:48
const Force & getForce_link4() const
Definition: inverse_dynamics.h:140
void C_terms(JointState &jForces, const JointState &q, const JointState &qd)
Definition: inverse_dynamics.h:212
Column6d< SCALAR > JointState
Definition: declarations.h:19
const Velocity & getVelocity_link6() const
Definition: inverse_dynamics.h:144
iit::rbd::tpl::InertiaMatrixDense< SCALAR > InertiaMatrix
Definition: inverse_dynamics.h:54
Vector6D VelocityVector
a 3D subvector of a 6D vector
Definition: rbd.h:91
const Acceleration & getAcceleration_link6() const
Definition: inverse_dynamics.h:145
const Velocity & getVelocity_link5() const
Definition: inverse_dynamics.h:141
const Acceleration & getAcceleration_link5() const
Definition: inverse_dynamics.h:142
const Force & getForce_link5() const
Definition: inverse_dynamics.h:143
void secondPass(JointState &jForces)
Definition: inverse_dynamics.impl.h:197
InertiaProperties< TRAIT > IProperties
Definition: inverse_dynamics.h:58