- 3.0.2 models module.
inverse_dynamics.impl.h
Go to the documentation of this file.
1 
2 // Initialization of static-const data
3 template <typename TRAIT>
6 
7 template <typename TRAIT>
9  inertiaProps( & inertia ),
10  xm( & transforms ),
11  Shoulder_AA_I(inertiaProps->getTensor_Shoulder_AA() ),
12  Shoulder_FE_I(inertiaProps->getTensor_Shoulder_FE() ),
13  Humerus_R_I(inertiaProps->getTensor_Humerus_R() ),
14  Elbow_FE_I(inertiaProps->getTensor_Elbow_FE() ),
15  Wrist_R_I(inertiaProps->getTensor_Wrist_R() ),
16  Wrist_FE_I(inertiaProps->getTensor_Wrist_FE() )
17  {
18 #ifndef EIGEN_NO_DEBUG
19  std::cout << "Robot ct_HyA, InverseDynamics<TRAIT>::InverseDynamics()" << std::endl;
20  std::cout << "Compiled with Eigen debug active" << std::endl;
21 #endif
22  Shoulder_AA_v.setZero();
23  Shoulder_FE_v.setZero();
24  Humerus_R_v.setZero();
25  Elbow_FE_v.setZero();
26  Wrist_R_v.setZero();
27  Wrist_FE_v.setZero();
28 
29  vcross.setZero();
30 }
31 
32 template <typename TRAIT>
34  JointState& jForces,
35  const JointState& qd, const JointState& qdd,
36  const ExtForces& fext)
37 {
38  firstPass(qd, qdd, fext);
39  secondPass(jForces);
40 }
41 
42 template <typename TRAIT>
44 {
45  // Link 'Shoulder_AA'
46  Shoulder_AA_a = (xm->fr_Shoulder_AA_X_fr_HyABase).col(iit::rbd::LZ) * SCALAR(iit::rbd::g);
47  Shoulder_AA_f = Shoulder_AA_I * Shoulder_AA_a;
48  // Link 'Shoulder_FE'
49  Shoulder_FE_a = (xm->fr_Shoulder_FE_X_fr_Shoulder_AA) * Shoulder_AA_a;
50  Shoulder_FE_f = Shoulder_FE_I * Shoulder_FE_a;
51  // Link 'Humerus_R'
52  Humerus_R_a = (xm->fr_Humerus_R_X_fr_Shoulder_FE) * Shoulder_FE_a;
53  Humerus_R_f = Humerus_R_I * Humerus_R_a;
54  // Link 'Elbow_FE'
55  Elbow_FE_a = (xm->fr_Elbow_FE_X_fr_Humerus_R) * Humerus_R_a;
56  Elbow_FE_f = Elbow_FE_I * Elbow_FE_a;
57  // Link 'Wrist_R'
58  Wrist_R_a = (xm->fr_Wrist_R_X_fr_Elbow_FE) * Elbow_FE_a;
59  Wrist_R_f = Wrist_R_I * Wrist_R_a;
60  // Link 'Wrist_FE'
61  Wrist_FE_a = (xm->fr_Wrist_FE_X_fr_Wrist_R) * Wrist_R_a;
62  Wrist_FE_f = Wrist_FE_I * Wrist_FE_a;
63 
64  secondPass(jForces);
65 }
66 
67 template <typename TRAIT>
69 {
70  // Link 'Shoulder_AA'
71  Shoulder_AA_v(iit::rbd::AZ) = qd(SAA); // Shoulder_AA_v = vJ, for the first link of a fixed base robot
72 
73  Shoulder_AA_f = iit::rbd::vxIv(qd(SAA), Shoulder_AA_I);
74 
75  // Link 'Shoulder_FE'
76  Shoulder_FE_v = ((xm->fr_Shoulder_FE_X_fr_Shoulder_AA) * Shoulder_AA_v);
77  Shoulder_FE_v(iit::rbd::AZ) += qd(SFE);
78 
79  iit::rbd::motionCrossProductMx<SCALAR>(Shoulder_FE_v, vcross);
80 
81  Shoulder_FE_a = (vcross.col(iit::rbd::AZ) * qd(SFE));
82 
83  Shoulder_FE_f = Shoulder_FE_I * Shoulder_FE_a + iit::rbd::vxIv(Shoulder_FE_v, Shoulder_FE_I);
84 
85  // Link 'Humerus_R'
86  Humerus_R_v = ((xm->fr_Humerus_R_X_fr_Shoulder_FE) * Shoulder_FE_v);
87  Humerus_R_v(iit::rbd::AZ) += qd(HR);
88 
89  iit::rbd::motionCrossProductMx<SCALAR>(Humerus_R_v, vcross);
90 
91  Humerus_R_a = (xm->fr_Humerus_R_X_fr_Shoulder_FE) * Shoulder_FE_a + vcross.col(iit::rbd::AZ) * qd(HR);
92 
93  Humerus_R_f = Humerus_R_I * Humerus_R_a + iit::rbd::vxIv(Humerus_R_v, Humerus_R_I);
94 
95  // Link 'Elbow_FE'
96  Elbow_FE_v = ((xm->fr_Elbow_FE_X_fr_Humerus_R) * Humerus_R_v);
97  Elbow_FE_v(iit::rbd::AZ) += qd(EFE);
98 
99  iit::rbd::motionCrossProductMx<SCALAR>(Elbow_FE_v, vcross);
100 
101  Elbow_FE_a = (xm->fr_Elbow_FE_X_fr_Humerus_R) * Humerus_R_a + vcross.col(iit::rbd::AZ) * qd(EFE);
102 
103  Elbow_FE_f = Elbow_FE_I * Elbow_FE_a + iit::rbd::vxIv(Elbow_FE_v, Elbow_FE_I);
104 
105  // Link 'Wrist_R'
106  Wrist_R_v = ((xm->fr_Wrist_R_X_fr_Elbow_FE) * Elbow_FE_v);
107  Wrist_R_v(iit::rbd::AZ) += qd(WR);
108 
109  iit::rbd::motionCrossProductMx<SCALAR>(Wrist_R_v, vcross);
110 
111  Wrist_R_a = (xm->fr_Wrist_R_X_fr_Elbow_FE) * Elbow_FE_a + vcross.col(iit::rbd::AZ) * qd(WR);
112 
113  Wrist_R_f = Wrist_R_I * Wrist_R_a + iit::rbd::vxIv(Wrist_R_v, Wrist_R_I);
114 
115  // Link 'Wrist_FE'
116  Wrist_FE_v = ((xm->fr_Wrist_FE_X_fr_Wrist_R) * Wrist_R_v);
117  Wrist_FE_v(iit::rbd::AZ) += qd(WFE);
118 
119  iit::rbd::motionCrossProductMx<SCALAR>(Wrist_FE_v, vcross);
120 
121  Wrist_FE_a = (xm->fr_Wrist_FE_X_fr_Wrist_R) * Wrist_R_a + vcross.col(iit::rbd::AZ) * qd(WFE);
122 
123  Wrist_FE_f = Wrist_FE_I * Wrist_FE_a + iit::rbd::vxIv(Wrist_FE_v, Wrist_FE_I);
124 
125 
126  secondPass(jForces);
127 }
128 
129 template <typename TRAIT>
131 {
132  // First pass, link 'Shoulder_AA'
133  Shoulder_AA_a = (xm->fr_Shoulder_AA_X_fr_HyABase).col(iit::rbd::LZ) * SCALAR(iit::rbd::g);
134  Shoulder_AA_a(iit::rbd::AZ) += qdd(SAA);
135  Shoulder_AA_v(iit::rbd::AZ) = qd(SAA); // Shoulder_AA_v = vJ, for the first link of a fixed base robot
136 
137  Shoulder_AA_f = Shoulder_AA_I * Shoulder_AA_a + iit::rbd::vxIv(qd(SAA), Shoulder_AA_I) - fext[SHOULDER_AA];
138 
139  // First pass, link 'Shoulder_FE'
140  Shoulder_FE_v = ((xm->fr_Shoulder_FE_X_fr_Shoulder_AA) * Shoulder_AA_v);
141  Shoulder_FE_v(iit::rbd::AZ) += qd(SFE);
142 
143  iit::rbd::motionCrossProductMx<SCALAR>(Shoulder_FE_v, vcross);
144 
145  Shoulder_FE_a = (xm->fr_Shoulder_FE_X_fr_Shoulder_AA) * Shoulder_AA_a + vcross.col(iit::rbd::AZ) * qd(SFE);
146  Shoulder_FE_a(iit::rbd::AZ) += qdd(SFE);
147 
148  Shoulder_FE_f = Shoulder_FE_I * Shoulder_FE_a + iit::rbd::vxIv(Shoulder_FE_v, Shoulder_FE_I) - fext[SHOULDER_FE];
149 
150  // First pass, link 'Humerus_R'
151  Humerus_R_v = ((xm->fr_Humerus_R_X_fr_Shoulder_FE) * Shoulder_FE_v);
152  Humerus_R_v(iit::rbd::AZ) += qd(HR);
153 
154  iit::rbd::motionCrossProductMx<SCALAR>(Humerus_R_v, vcross);
155 
156  Humerus_R_a = (xm->fr_Humerus_R_X_fr_Shoulder_FE) * Shoulder_FE_a + vcross.col(iit::rbd::AZ) * qd(HR);
157  Humerus_R_a(iit::rbd::AZ) += qdd(HR);
158 
159  Humerus_R_f = Humerus_R_I * Humerus_R_a + iit::rbd::vxIv(Humerus_R_v, Humerus_R_I) - fext[HUMERUS_R];
160 
161  // First pass, link 'Elbow_FE'
162  Elbow_FE_v = ((xm->fr_Elbow_FE_X_fr_Humerus_R) * Humerus_R_v);
163  Elbow_FE_v(iit::rbd::AZ) += qd(EFE);
164 
165  iit::rbd::motionCrossProductMx<SCALAR>(Elbow_FE_v, vcross);
166 
167  Elbow_FE_a = (xm->fr_Elbow_FE_X_fr_Humerus_R) * Humerus_R_a + vcross.col(iit::rbd::AZ) * qd(EFE);
168  Elbow_FE_a(iit::rbd::AZ) += qdd(EFE);
169 
170  Elbow_FE_f = Elbow_FE_I * Elbow_FE_a + iit::rbd::vxIv(Elbow_FE_v, Elbow_FE_I) - fext[ELBOW_FE];
171 
172  // First pass, link 'Wrist_R'
173  Wrist_R_v = ((xm->fr_Wrist_R_X_fr_Elbow_FE) * Elbow_FE_v);
174  Wrist_R_v(iit::rbd::AZ) += qd(WR);
175 
176  iit::rbd::motionCrossProductMx<SCALAR>(Wrist_R_v, vcross);
177 
178  Wrist_R_a = (xm->fr_Wrist_R_X_fr_Elbow_FE) * Elbow_FE_a + vcross.col(iit::rbd::AZ) * qd(WR);
179  Wrist_R_a(iit::rbd::AZ) += qdd(WR);
180 
181  Wrist_R_f = Wrist_R_I * Wrist_R_a + iit::rbd::vxIv(Wrist_R_v, Wrist_R_I) - fext[WRIST_R];
182 
183  // First pass, link 'Wrist_FE'
184  Wrist_FE_v = ((xm->fr_Wrist_FE_X_fr_Wrist_R) * Wrist_R_v);
185  Wrist_FE_v(iit::rbd::AZ) += qd(WFE);
186 
187  iit::rbd::motionCrossProductMx<SCALAR>(Wrist_FE_v, vcross);
188 
189  Wrist_FE_a = (xm->fr_Wrist_FE_X_fr_Wrist_R) * Wrist_R_a + vcross.col(iit::rbd::AZ) * qd(WFE);
190  Wrist_FE_a(iit::rbd::AZ) += qdd(WFE);
191 
192  Wrist_FE_f = Wrist_FE_I * Wrist_FE_a + iit::rbd::vxIv(Wrist_FE_v, Wrist_FE_I) - fext[WRIST_FE];
193 
194 }
195 
196 template <typename TRAIT>
198 {
199  // Link 'Wrist_FE'
200  jForces(WFE) = Wrist_FE_f(iit::rbd::AZ);
201  Wrist_R_f += xm->fr_Wrist_FE_X_fr_Wrist_R.transpose() * Wrist_FE_f;
202  // Link 'Wrist_R'
203  jForces(WR) = Wrist_R_f(iit::rbd::AZ);
204  Elbow_FE_f += xm->fr_Wrist_R_X_fr_Elbow_FE.transpose() * Wrist_R_f;
205  // Link 'Elbow_FE'
206  jForces(EFE) = Elbow_FE_f(iit::rbd::AZ);
207  Humerus_R_f += xm->fr_Elbow_FE_X_fr_Humerus_R.transpose() * Elbow_FE_f;
208  // Link 'Humerus_R'
209  jForces(HR) = Humerus_R_f(iit::rbd::AZ);
210  Shoulder_FE_f += xm->fr_Humerus_R_X_fr_Shoulder_FE.transpose() * Humerus_R_f;
211  // Link 'Shoulder_FE'
212  jForces(SFE) = Shoulder_FE_f(iit::rbd::AZ);
213  Shoulder_AA_f += xm->fr_Shoulder_FE_X_fr_Shoulder_AA.transpose() * Shoulder_FE_f;
214  // Link 'Shoulder_AA'
215  jForces(SAA) = Shoulder_AA_f(iit::rbd::AZ);
216 }
Definition: declarations.h:27
Definition: declarations.h:30
Definition: declarations.h:39
Force< DScalar > vxIv(const Velocity< DScalar > &v, const MatrixBase< Derived > &I)
Definition: inverse_dynamics.h:43
InverseDynamics(IProperties &in, MTransforms &tr)
Definition: inverse_dynamics.impl.h:8
Definition: declarations.h:29
Definition: declarations.h:42
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
Definition: declarations.h:41
Definition: declarations.h:38
void C_terms(JointState &jForces, const JointState &q, const JointState &qd)
Definition: inverse_dynamics.h:213
Definition: declarations.h:31
Definition: declarations.h:28
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
Definition: declarations.h:37
Definition: declarations.h:32
Definition: declarations.h:40
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef TRAIT::Scalar SCALAR
Definition: inverse_dynamics.h:47
void secondPass(JointState &jForces)
Definition: inverse_dynamics.impl.h:197
iit::ct_HyA::tpl::JointState< SCALAR > JointState
Definition: inverse_dynamics.h:56
iit::ct_HyA::tpl::MotionTransforms< TRAIT > MTransforms
Definition: inverse_dynamics.h:58
Definition: inertia_properties.h:26