- 3.0.2 models module.
forward_dynamics.h
Go to the documentation of this file.
1 #ifndef IIT_ROBOT_HYQ_FORWARD_DYNAMICS_H_
2 #define IIT_ROBOT_HYQ_FORWARD_DYNAMICS_H_
3 
4 #include <Eigen/Dense>
5 #include <Eigen/StdVector>
6 #include <iit/rbd/rbd.h>
8 #include <iit/rbd/utils.h>
10 
11 #include "declarations.h"
12 #include "transforms.h"
13 #include "inertia_properties.h"
14 #include "link_data_map.h"
15 
16 namespace iit {
17 namespace HyQ {
18 namespace dyn {
19 
32 namespace tpl {
33 
34 template <typename TRAIT>
36 public:
37  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
38  // Convenient type aliases:
39 
40  typedef typename TRAIT::Scalar Scalar;
41 
43 
44  typedef typename CoreS::ForceVector Force;
46  typedef typename CoreS::VelocityVector Velocity;
48  typedef typename CoreS::Column6D Column6DS;
50  typedef typename CoreS::Matrix66 Matrix66S;
51 
53  typedef iit::HyQ::tpl::MotionTransforms<TRAIT> MTransforms;
54 
55 public:
67 
80  void fd(
81  JointState& qdd, Acceleration& trunk_a, // output parameters,
82  const Velocity& trunk_v, const Acceleration& g,
83  const JointState& q, const JointState& qd, const JointState& tau, const ExtForces& fext = zeroExtForces);
84  void fd(
85  JointState& qdd, Acceleration& trunk_a, // output parameters,
86  const Velocity& trunk_v, const Acceleration& g,
87  const JointState& qd, const JointState& tau, const ExtForces& fext = zeroExtForces);
89 
91  void setJointStatus(const JointState& q) const;
92 
93 private:
95  MTransforms* motionTransforms;
96 
97  Matrix66S vcross; // support variable
98  Matrix66S Ia_r; // support variable, articulated inertia in the case of a revolute joint
99  // Link 'trunk'
100  Matrix66S trunk_AI;
101  Force trunk_p;
102 
103  // Link 'LF_hipassembly' :
104  Matrix66S LF_hipassembly_AI;
105  Velocity LF_hipassembly_a;
106  Velocity LF_hipassembly_v;
107  Velocity LF_hipassembly_c;
108  Force LF_hipassembly_p;
109 
110  Column6DS LF_hipassembly_U;
111  Scalar LF_hipassembly_D;
112  Scalar LF_hipassembly_u;
113  // Link 'LF_upperleg' :
114  Matrix66S LF_upperleg_AI;
115  Velocity LF_upperleg_a;
116  Velocity LF_upperleg_v;
117  Velocity LF_upperleg_c;
118  Force LF_upperleg_p;
119 
120  Column6DS LF_upperleg_U;
121  Scalar LF_upperleg_D;
122  Scalar LF_upperleg_u;
123  // Link 'LF_lowerleg' :
124  Matrix66S LF_lowerleg_AI;
125  Velocity LF_lowerleg_a;
126  Velocity LF_lowerleg_v;
127  Velocity LF_lowerleg_c;
128  Force LF_lowerleg_p;
129 
130  Column6DS LF_lowerleg_U;
131  Scalar LF_lowerleg_D;
132  Scalar LF_lowerleg_u;
133  // Link 'RF_hipassembly' :
134  Matrix66S RF_hipassembly_AI;
135  Velocity RF_hipassembly_a;
136  Velocity RF_hipassembly_v;
137  Velocity RF_hipassembly_c;
138  Force RF_hipassembly_p;
139 
140  Column6DS RF_hipassembly_U;
141  Scalar RF_hipassembly_D;
142  Scalar RF_hipassembly_u;
143  // Link 'RF_upperleg' :
144  Matrix66S RF_upperleg_AI;
145  Velocity RF_upperleg_a;
146  Velocity RF_upperleg_v;
147  Velocity RF_upperleg_c;
148  Force RF_upperleg_p;
149 
150  Column6DS RF_upperleg_U;
151  Scalar RF_upperleg_D;
152  Scalar RF_upperleg_u;
153  // Link 'RF_lowerleg' :
154  Matrix66S RF_lowerleg_AI;
155  Velocity RF_lowerleg_a;
156  Velocity RF_lowerleg_v;
157  Velocity RF_lowerleg_c;
158  Force RF_lowerleg_p;
159 
160  Column6DS RF_lowerleg_U;
161  Scalar RF_lowerleg_D;
162  Scalar RF_lowerleg_u;
163  // Link 'LH_hipassembly' :
164  Matrix66S LH_hipassembly_AI;
165  Velocity LH_hipassembly_a;
166  Velocity LH_hipassembly_v;
167  Velocity LH_hipassembly_c;
168  Force LH_hipassembly_p;
169 
170  Column6DS LH_hipassembly_U;
171  Scalar LH_hipassembly_D;
172  Scalar LH_hipassembly_u;
173  // Link 'LH_upperleg' :
174  Matrix66S LH_upperleg_AI;
175  Velocity LH_upperleg_a;
176  Velocity LH_upperleg_v;
177  Velocity LH_upperleg_c;
178  Force LH_upperleg_p;
179 
180  Column6DS LH_upperleg_U;
181  Scalar LH_upperleg_D;
182  Scalar LH_upperleg_u;
183  // Link 'LH_lowerleg' :
184  Matrix66S LH_lowerleg_AI;
185  Velocity LH_lowerleg_a;
186  Velocity LH_lowerleg_v;
187  Velocity LH_lowerleg_c;
188  Force LH_lowerleg_p;
189 
190  Column6DS LH_lowerleg_U;
191  Scalar LH_lowerleg_D;
192  Scalar LH_lowerleg_u;
193  // Link 'RH_hipassembly' :
194  Matrix66S RH_hipassembly_AI;
195  Velocity RH_hipassembly_a;
196  Velocity RH_hipassembly_v;
197  Velocity RH_hipassembly_c;
198  Force RH_hipassembly_p;
199 
200  Column6DS RH_hipassembly_U;
201  Scalar RH_hipassembly_D;
202  Scalar RH_hipassembly_u;
203  // Link 'RH_upperleg' :
204  Matrix66S RH_upperleg_AI;
205  Velocity RH_upperleg_a;
206  Velocity RH_upperleg_v;
207  Velocity RH_upperleg_c;
208  Force RH_upperleg_p;
209 
210  Column6DS RH_upperleg_U;
211  Scalar RH_upperleg_D;
212  Scalar RH_upperleg_u;
213  // Link 'RH_lowerleg' :
214  Matrix66S RH_lowerleg_AI;
215  Velocity RH_lowerleg_a;
216  Velocity RH_lowerleg_v;
217  Velocity RH_lowerleg_c;
218  Force RH_lowerleg_p;
219 
220  Column6DS RH_lowerleg_U;
221  Scalar RH_lowerleg_D;
222  Scalar RH_lowerleg_u;
223 private:
224  static const ExtForces zeroExtForces;
225 };
226 
227 template <typename TRAIT>
229  (motionTransforms-> fr_LF_hipassembly_X_fr_trunk)(q);
230  (motionTransforms-> fr_LF_upperleg_X_fr_LF_hipassembly)(q);
231  (motionTransforms-> fr_LF_lowerleg_X_fr_LF_upperleg)(q);
232  (motionTransforms-> fr_RF_hipassembly_X_fr_trunk)(q);
233  (motionTransforms-> fr_RF_upperleg_X_fr_RF_hipassembly)(q);
234  (motionTransforms-> fr_RF_lowerleg_X_fr_RF_upperleg)(q);
235  (motionTransforms-> fr_LH_hipassembly_X_fr_trunk)(q);
236  (motionTransforms-> fr_LH_upperleg_X_fr_LH_hipassembly)(q);
237  (motionTransforms-> fr_LH_lowerleg_X_fr_LH_upperleg)(q);
238  (motionTransforms-> fr_RH_hipassembly_X_fr_trunk)(q);
239  (motionTransforms-> fr_RH_upperleg_X_fr_RH_hipassembly)(q);
240  (motionTransforms-> fr_RH_lowerleg_X_fr_RH_upperleg)(q);
241 }
242 
243 template<typename TRAIT>
245  JointState& qdd, Acceleration& trunk_a, // output parameters,
246  const Velocity& trunk_v, const Acceleration& g,
247  const JointState& q,
248  const JointState& qd,
249  const JointState& tau,
250  const ExtForces& fext/* = zeroExtForces */)
251 {
252  setJointStatus(q);
253  fd(qdd, trunk_a, trunk_v, g, qd, tau, fext);
254 }
255 
256 }
257 
259 
260 }
261 }
262 }
263 
264 #include "forward_dynamics.impl.h"
265 
266 #endif
Column12d< SCALAR > JointState
Definition: declarations.h:20
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar Scalar
Definition: forward_dynamics.h:40
ForwardDynamics(iit::HyQ::dyn::tpl::InertiaProperties< TRAIT > &in, MTransforms &tr)
Definition: forward_dynamics.impl.h:8
PlainMatrix< Scalar, 6, 6 > Matrix66
iit::rbd::Core< Scalar > CoreS
Definition: forward_dynamics.h:42
Definition: link_data_map.h:12
ct::core::ADCodegenLinearizer< state_dim, control_dim >::ADCGScalar Scalar
Definition: HyALinearizationCodeGen.cpp:23
CoreS::Column6D Column6DS
Definition: forward_dynamics.h:48
void setJointStatus(const JointState &q) const
Definition: forward_dynamics.h:228
LinkDataMap< Force > ExtForces
Definition: forward_dynamics.h:45
CoreS::VelocityVector Velocity
Definition: forward_dynamics.h:46
Definition: inertia_properties.h:26
Vector6D Column6D
Vector6D ForceVector
Definition: forward_dynamics.h:35
void fd(JointState &qdd, Acceleration &trunk_a, const Velocity &trunk_v, const Acceleration &g, const JointState &q, const JointState &qd, const JointState &tau, const ExtForces &fext=zeroExtForces)
Definition: forward_dynamics.h:244
iit::HyQ::tpl::MotionTransforms< TRAIT > MTransforms
Definition: forward_dynamics.h:53
CoreS::VelocityVector Acceleration
Definition: forward_dynamics.h:47
CoreS::Matrix66 Matrix66S
Definition: forward_dynamics.h:50
Vector6D VelocityVector
iit::rbd::tpl::InertiaMatrixDense< Scalar > InertiaMatrix
Definition: forward_dynamics.h:52
iit::HyQ::tpl::JointState< Scalar > JointState
Definition: forward_dynamics.h:49
CoreS::ForceVector Force
Definition: forward_dynamics.h:44