- 3.0.2 models module.
inverse_dynamics.h
Go to the documentation of this file.
1 #ifndef IIT_CT_DOUBLEINVERTEDPENDULUM_INVERSE_DYNAMICS_H_
2 #define IIT_CT_DOUBLEINVERTEDPENDULUM_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 ct_DoubleInvertedPendulum {
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;
50  typedef typename CoreS::VelocityVector Velocity;
52  typedef typename CoreS::Matrix66 Matrix66s;
56  typedef iit::ct_DoubleInvertedPendulum::tpl::MotionTransforms<TRAIT> MTransforms;
58 
59 public:
67  InverseDynamics(IProperties& in, MTransforms& tr);
68 
79  void id(
81  JointState& jForces,
82  const JointState& q, const JointState& qd, const JointState& qdd,
83  const ExtForces& fext = zeroExtForces);
84  void id(
85  JointState& jForces,
86  const JointState& qd, const JointState& qdd,
87  const ExtForces& fext = zeroExtForces);
89 
94  void G_terms(JointState& jForces, const JointState& q);
96  void G_terms(JointState& jForces);
98 
103  void C_terms(JointState& jForces, const JointState& q, const JointState& qd);
105  void C_terms(JointState& jForces, const JointState& qd);
107 
108  void setJointStatus(const JointState& q) const;
109 
110 public:
127  const Velocity& getVelocity_Link1() const { return Link1_v; }
129  const Acceleration& getAcceleration_Link1() const { return Link1_a; }
130  const Force& getForce_Link1() const { return Link1_f; }
131  const Velocity& getVelocity_Link2() const { return Link2_v; }
132  const Acceleration& getAcceleration_Link2() const { return Link2_a; }
133  const Force& getForce_Link2() const { return Link2_f; }
135 protected:
136  void firstPass(const JointState& qd, const JointState& qdd, const ExtForces& fext);
137  void secondPass(JointState& jForces);
138 
139 private:
140  IProperties* inertiaProps;
141  MTransforms* xm;
142 private:
143  Matrix66s vcross; // support variable
144  // Link 'Link1' :
145  const InertiaMatrix& Link1_I;
146  Velocity Link1_v;
147  Acceleration Link1_a;
148  Force Link1_f;
149  // Link 'Link2' :
150  const InertiaMatrix& Link2_I;
151  Velocity Link2_v;
152  Acceleration Link2_a;
153  Force Link2_f;
154 
155 
156 private:
157  static const ExtForces zeroExtForces;
158 };
159 
160 template <typename TRAIT>
162 {
163  (xm->fr_Link1_X_fr_DoubleInvertedPendulumBase)(q);
164  (xm->fr_Link2_X_fr_Link1)(q);
165 }
166 
167 template <typename TRAIT>
169 {
170  setJointStatus(q);
171  G_terms(jForces);
172 }
173 
174 template <typename TRAIT>
175 inline void InverseDynamics<TRAIT>::C_terms(JointState& jForces, const JointState& q, const JointState& qd)
176 {
177  setJointStatus(q);
178  C_terms(jForces, qd);
179 }
180 
181 template <typename TRAIT>
183  JointState& jForces,
184  const JointState& q, const JointState& qd, const JointState& qdd,
185  const ExtForces& fext)
186 {
187  setJointStatus(q);
188  id(jForces, qd, qdd, fext);
189 }
190 
191 }
192 
194 
195 }
196 }
197 
198 }
199 
200 #include "inverse_dynamics.impl.h"
201 
202 #endif
Definition: link_data_map.h:12
iit::rbd::tpl::InertiaMatrixDense< Scalar > InertiaMatrix
Definition: inverse_dynamics.h:53
void secondPass(JointState &jForces)
Definition: inverse_dynamics.impl.h:92
CoreS::ForceVector Force
Definition: inverse_dynamics.h:49
void id(JointState &jForces, const JointState &q, const JointState &qd, const JointState &qdd, const ExtForces &fext=zeroExtForces)
Definition: inverse_dynamics.h:182
const Velocity & getVelocity_Link2() const
Definition: inverse_dynamics.h:131
iit::ct_DoubleInvertedPendulum::tpl::JointState< Scalar > JointState
Definition: inverse_dynamics.h:54
PlainMatrix< Scalar, 6, 6 > Matrix66
void firstPass(const JointState &qd, const JointState &qdd, const ExtForces &fext)
Definition: inverse_dynamics.impl.h:69
void G_terms(JointState &jForces, const JointState &q)
Definition: inverse_dynamics.h:168
const Velocity & getVelocity_Link1() const
Definition: inverse_dynamics.h:128
const Force & getForce_Link1() const
Definition: inverse_dynamics.h:130
Column2d< SCALAR > JointState
Definition: declarations.h:19
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar Scalar
Definition: inverse_dynamics.h:45
ct::core::ADCodegenLinearizer< state_dim, control_dim >::ADCGScalar Scalar
Definition: HyALinearizationCodeGen.cpp:23
LinkDataMap< Force > ExtForces
Definition: inverse_dynamics.h:55
const Acceleration & getAcceleration_Link1() const
Definition: inverse_dynamics.h:129
CoreS::VelocityVector Acceleration
Definition: inverse_dynamics.h:51
InverseDynamics(IProperties &in, MTransforms &tr)
Definition: inverse_dynamics.impl.h:7
const Force & getForce_Link2() const
Definition: inverse_dynamics.h:133
iit::rbd::Core< Scalar > CoreS
Definition: inverse_dynamics.h:47
InertiaProperties< TRAIT > IProperties
Definition: inverse_dynamics.h:57
Vector6D ForceVector
const Acceleration & getAcceleration_Link2() const
Definition: inverse_dynamics.h:132
CoreS::VelocityVector Velocity
Definition: inverse_dynamics.h:50
void C_terms(JointState &jForces, const JointState &q, const JointState &qd)
Definition: inverse_dynamics.h:175
iit::ct_DoubleInvertedPendulum::tpl::MotionTransforms< TRAIT > MTransforms
Definition: inverse_dynamics.h:56
void setJointStatus(const JointState &q) const
Definition: inverse_dynamics.h:161
Vector6D VelocityVector
CoreS::Matrix66 Matrix66s
Definition: inverse_dynamics.h:52