- 3.0.2 rigid body dynamics module.
jsim.impl.h
Go to the documentation of this file.
1 
2 
3 //Implementation of default constructor
4 template<typename TRAIT>
6  linkInertias(inertiaProperties),
7  frcTransf( &forceTransforms ),
8  link6_Ic(linkInertias.getTensor_link6())
9 {
10  //Initialize the matrix itself
11  this->setZero();
12 }
13 
14 #define DATA tpl::JSIM<TRAIT>::operator()
15 
16 template <typename TRAIT>
18  static iit::rbd::ForceVector F;
19 
20  // Precomputes only once the coordinate transforms:
21  frcTransf -> fr_link5_X_fr_link6(state);
22  frcTransf -> fr_link4_X_fr_link5(state);
23  frcTransf -> fr_link3_X_fr_link4(state);
24  frcTransf -> fr_link2_X_fr_link3(state);
25  frcTransf -> fr_link1_X_fr_link2(state);
26 
27  // Initializes the composite inertia tensors
28  link1_Ic = linkInertias.getTensor_link1();
29  link2_Ic = linkInertias.getTensor_link2();
30  link3_Ic = linkInertias.getTensor_link3();
31  link4_Ic = linkInertias.getTensor_link4();
32  link5_Ic = linkInertias.getTensor_link5();
33 
34  // "Bottom-up" loop to update the inertia-composite property of each link, for the current configuration
35 
36  // Link link6:
37  iit::rbd::transformInertia(link6_Ic, frcTransf -> fr_link5_X_fr_link6, Ic_spare);
38  link5_Ic += Ic_spare;
39 
40  F = link6_Ic.col(iit::rbd::AZ);
41  DATA(JF, JF) = F(iit::rbd::AZ);
42 
43  F = frcTransf -> fr_link5_X_fr_link6 * F;
44  DATA(JF, JE) = F(iit::rbd::AZ);
45  DATA(JE, JF) = DATA(JF, JE);
46  F = frcTransf -> fr_link4_X_fr_link5 * F;
47  DATA(JF, JD) = F(iit::rbd::AZ);
48  DATA(JD, JF) = DATA(JF, JD);
49  F = frcTransf -> fr_link3_X_fr_link4 * F;
50  DATA(JF, JC) = F(iit::rbd::AZ);
51  DATA(JC, JF) = DATA(JF, JC);
52  F = frcTransf -> fr_link2_X_fr_link3 * F;
53  DATA(JF, JB) = F(iit::rbd::AZ);
54  DATA(JB, JF) = DATA(JF, JB);
55  F = frcTransf -> fr_link1_X_fr_link2 * F;
56  DATA(JF, JA) = F(iit::rbd::AZ);
57  DATA(JA, JF) = DATA(JF, JA);
58 
59  // Link link5:
60  iit::rbd::transformInertia(link5_Ic, frcTransf -> fr_link4_X_fr_link5, Ic_spare);
61  link4_Ic += Ic_spare;
62 
63  F = link5_Ic.col(iit::rbd::AZ);
64  DATA(JE, JE) = F(iit::rbd::AZ);
65 
66  F = frcTransf -> fr_link4_X_fr_link5 * F;
67  DATA(JE, JD) = F(iit::rbd::AZ);
68  DATA(JD, JE) = DATA(JE, JD);
69  F = frcTransf -> fr_link3_X_fr_link4 * F;
70  DATA(JE, JC) = F(iit::rbd::AZ);
71  DATA(JC, JE) = DATA(JE, JC);
72  F = frcTransf -> fr_link2_X_fr_link3 * F;
73  DATA(JE, JB) = F(iit::rbd::AZ);
74  DATA(JB, JE) = DATA(JE, JB);
75  F = frcTransf -> fr_link1_X_fr_link2 * F;
76  DATA(JE, JA) = F(iit::rbd::AZ);
77  DATA(JA, JE) = DATA(JE, JA);
78 
79  // Link link4:
80  iit::rbd::transformInertia(link4_Ic, frcTransf -> fr_link3_X_fr_link4, Ic_spare);
81  link3_Ic += Ic_spare;
82 
83  F = link4_Ic.col(iit::rbd::AZ);
84  DATA(JD, JD) = F(iit::rbd::AZ);
85 
86  F = frcTransf -> fr_link3_X_fr_link4 * F;
87  DATA(JD, JC) = F(iit::rbd::AZ);
88  DATA(JC, JD) = DATA(JD, JC);
89  F = frcTransf -> fr_link2_X_fr_link3 * F;
90  DATA(JD, JB) = F(iit::rbd::AZ);
91  DATA(JB, JD) = DATA(JD, JB);
92  F = frcTransf -> fr_link1_X_fr_link2 * F;
93  DATA(JD, JA) = F(iit::rbd::AZ);
94  DATA(JA, JD) = DATA(JD, JA);
95 
96  // Link link3:
97  iit::rbd::transformInertia(link3_Ic, frcTransf -> fr_link2_X_fr_link3, Ic_spare);
98  link2_Ic += Ic_spare;
99 
100  F = link3_Ic.col(iit::rbd::AZ);
101  DATA(JC, JC) = F(iit::rbd::AZ);
102 
103  F = frcTransf -> fr_link2_X_fr_link3 * F;
104  DATA(JC, JB) = F(iit::rbd::AZ);
105  DATA(JB, JC) = DATA(JC, JB);
106  F = frcTransf -> fr_link1_X_fr_link2 * F;
107  DATA(JC, JA) = F(iit::rbd::AZ);
108  DATA(JA, JC) = DATA(JC, JA);
109 
110  // Link link2:
111  iit::rbd::transformInertia(link2_Ic, frcTransf -> fr_link1_X_fr_link2, Ic_spare);
112  link1_Ic += Ic_spare;
113 
114  F = link2_Ic.col(iit::rbd::AZ);
115  DATA(JB, JB) = F(iit::rbd::AZ);
116 
117  F = frcTransf -> fr_link1_X_fr_link2 * F;
118  DATA(JB, JA) = F(iit::rbd::AZ);
119  DATA(JA, JB) = DATA(JB, JA);
120 
121  // Link link1:
122 
123  F = link1_Ic.col(iit::rbd::AZ);
124  DATA(JA, JA) = F(iit::rbd::AZ);
125 
126 
127  return *this;
128 }
129 
130 #undef DATA
131 #undef F
132 
133 template <typename TRAIT>
135  L = this -> template triangularView<Eigen::Lower>();
136  // Joint jF, index 5 :
137  L(5, 5) = std::sqrt(L(5, 5));
138  L(5, 4) = L(5, 4) / L(5, 5);
139  L(5, 3) = L(5, 3) / L(5, 5);
140  L(5, 2) = L(5, 2) / L(5, 5);
141  L(5, 1) = L(5, 1) / L(5, 5);
142  L(5, 0) = L(5, 0) / L(5, 5);
143  L(4, 4) = L(4, 4) - L(5, 4) * L(5, 4);
144  L(4, 3) = L(4, 3) - L(5, 4) * L(5, 3);
145  L(4, 2) = L(4, 2) - L(5, 4) * L(5, 2);
146  L(4, 1) = L(4, 1) - L(5, 4) * L(5, 1);
147  L(4, 0) = L(4, 0) - L(5, 4) * L(5, 0);
148  L(3, 3) = L(3, 3) - L(5, 3) * L(5, 3);
149  L(3, 2) = L(3, 2) - L(5, 3) * L(5, 2);
150  L(3, 1) = L(3, 1) - L(5, 3) * L(5, 1);
151  L(3, 0) = L(3, 0) - L(5, 3) * L(5, 0);
152  L(2, 2) = L(2, 2) - L(5, 2) * L(5, 2);
153  L(2, 1) = L(2, 1) - L(5, 2) * L(5, 1);
154  L(2, 0) = L(2, 0) - L(5, 2) * L(5, 0);
155  L(1, 1) = L(1, 1) - L(5, 1) * L(5, 1);
156  L(1, 0) = L(1, 0) - L(5, 1) * L(5, 0);
157  L(0, 0) = L(0, 0) - L(5, 0) * L(5, 0);
158 
159  // Joint jE, index 4 :
160  L(4, 4) = std::sqrt(L(4, 4));
161  L(4, 3) = L(4, 3) / L(4, 4);
162  L(4, 2) = L(4, 2) / L(4, 4);
163  L(4, 1) = L(4, 1) / L(4, 4);
164  L(4, 0) = L(4, 0) / L(4, 4);
165  L(3, 3) = L(3, 3) - L(4, 3) * L(4, 3);
166  L(3, 2) = L(3, 2) - L(4, 3) * L(4, 2);
167  L(3, 1) = L(3, 1) - L(4, 3) * L(4, 1);
168  L(3, 0) = L(3, 0) - L(4, 3) * L(4, 0);
169  L(2, 2) = L(2, 2) - L(4, 2) * L(4, 2);
170  L(2, 1) = L(2, 1) - L(4, 2) * L(4, 1);
171  L(2, 0) = L(2, 0) - L(4, 2) * L(4, 0);
172  L(1, 1) = L(1, 1) - L(4, 1) * L(4, 1);
173  L(1, 0) = L(1, 0) - L(4, 1) * L(4, 0);
174  L(0, 0) = L(0, 0) - L(4, 0) * L(4, 0);
175 
176  // Joint jD, index 3 :
177  L(3, 3) = std::sqrt(L(3, 3));
178  L(3, 2) = L(3, 2) / L(3, 3);
179  L(3, 1) = L(3, 1) / L(3, 3);
180  L(3, 0) = L(3, 0) / L(3, 3);
181  L(2, 2) = L(2, 2) - L(3, 2) * L(3, 2);
182  L(2, 1) = L(2, 1) - L(3, 2) * L(3, 1);
183  L(2, 0) = L(2, 0) - L(3, 2) * L(3, 0);
184  L(1, 1) = L(1, 1) - L(3, 1) * L(3, 1);
185  L(1, 0) = L(1, 0) - L(3, 1) * L(3, 0);
186  L(0, 0) = L(0, 0) - L(3, 0) * L(3, 0);
187 
188  // Joint jC, index 2 :
189  L(2, 2) = std::sqrt(L(2, 2));
190  L(2, 1) = L(2, 1) / L(2, 2);
191  L(2, 0) = L(2, 0) / L(2, 2);
192  L(1, 1) = L(1, 1) - L(2, 1) * L(2, 1);
193  L(1, 0) = L(1, 0) - L(2, 1) * L(2, 0);
194  L(0, 0) = L(0, 0) - L(2, 0) * L(2, 0);
195 
196  // Joint jB, index 1 :
197  L(1, 1) = std::sqrt(L(1, 1));
198  L(1, 0) = L(1, 0) / L(1, 1);
199  L(0, 0) = L(0, 0) - L(1, 0) * L(1, 0);
200 
201  // Joint jA, index 0 :
202  L(0, 0) = std::sqrt(L(0, 0));
203 
204 }
205 
206 template <typename TRAIT>
208  computeLInverse();
209 
210  inverse(0, 0) = + (Linv(0, 0) * Linv(0, 0));
211  inverse(1, 1) = + (Linv(1, 0) * Linv(1, 0)) + (Linv(1, 1) * Linv(1, 1));
212  inverse(1, 0) = + (Linv(1, 0) * Linv(0, 0));
213  inverse(0, 1) = inverse(1, 0);
214  inverse(2, 2) = + (Linv(2, 0) * Linv(2, 0)) + (Linv(2, 1) * Linv(2, 1)) + (Linv(2, 2) * Linv(2, 2));
215  inverse(2, 1) = + (Linv(2, 0) * Linv(1, 0)) + (Linv(2, 1) * Linv(1, 1));
216  inverse(1, 2) = inverse(2, 1);
217  inverse(2, 0) = + (Linv(2, 0) * Linv(0, 0));
218  inverse(0, 2) = inverse(2, 0);
219  inverse(3, 3) = + (Linv(3, 0) * Linv(3, 0)) + (Linv(3, 1) * Linv(3, 1)) + (Linv(3, 2) * Linv(3, 2)) + (Linv(3, 3) * Linv(3, 3));
220  inverse(3, 2) = + (Linv(3, 0) * Linv(2, 0)) + (Linv(3, 1) * Linv(2, 1)) + (Linv(3, 2) * Linv(2, 2));
221  inverse(2, 3) = inverse(3, 2);
222  inverse(3, 1) = + (Linv(3, 0) * Linv(1, 0)) + (Linv(3, 1) * Linv(1, 1));
223  inverse(1, 3) = inverse(3, 1);
224  inverse(3, 0) = + (Linv(3, 0) * Linv(0, 0));
225  inverse(0, 3) = inverse(3, 0);
226  inverse(4, 4) = + (Linv(4, 0) * Linv(4, 0)) + (Linv(4, 1) * Linv(4, 1)) + (Linv(4, 2) * Linv(4, 2)) + (Linv(4, 3) * Linv(4, 3)) + (Linv(4, 4) * Linv(4, 4));
227  inverse(4, 3) = + (Linv(4, 0) * Linv(3, 0)) + (Linv(4, 1) * Linv(3, 1)) + (Linv(4, 2) * Linv(3, 2)) + (Linv(4, 3) * Linv(3, 3));
228  inverse(3, 4) = inverse(4, 3);
229  inverse(4, 2) = + (Linv(4, 0) * Linv(2, 0)) + (Linv(4, 1) * Linv(2, 1)) + (Linv(4, 2) * Linv(2, 2));
230  inverse(2, 4) = inverse(4, 2);
231  inverse(4, 1) = + (Linv(4, 0) * Linv(1, 0)) + (Linv(4, 1) * Linv(1, 1));
232  inverse(1, 4) = inverse(4, 1);
233  inverse(4, 0) = + (Linv(4, 0) * Linv(0, 0));
234  inverse(0, 4) = inverse(4, 0);
235  inverse(5, 5) = + (Linv(5, 0) * Linv(5, 0)) + (Linv(5, 1) * Linv(5, 1)) + (Linv(5, 2) * Linv(5, 2)) + (Linv(5, 3) * Linv(5, 3)) + (Linv(5, 4) * Linv(5, 4)) + (Linv(5, 5) * Linv(5, 5));
236  inverse(5, 4) = + (Linv(5, 0) * Linv(4, 0)) + (Linv(5, 1) * Linv(4, 1)) + (Linv(5, 2) * Linv(4, 2)) + (Linv(5, 3) * Linv(4, 3)) + (Linv(5, 4) * Linv(4, 4));
237  inverse(4, 5) = inverse(5, 4);
238  inverse(5, 3) = + (Linv(5, 0) * Linv(3, 0)) + (Linv(5, 1) * Linv(3, 1)) + (Linv(5, 2) * Linv(3, 2)) + (Linv(5, 3) * Linv(3, 3));
239  inverse(3, 5) = inverse(5, 3);
240  inverse(5, 2) = + (Linv(5, 0) * Linv(2, 0)) + (Linv(5, 1) * Linv(2, 1)) + (Linv(5, 2) * Linv(2, 2));
241  inverse(2, 5) = inverse(5, 2);
242  inverse(5, 1) = + (Linv(5, 0) * Linv(1, 0)) + (Linv(5, 1) * Linv(1, 1));
243  inverse(1, 5) = inverse(5, 1);
244  inverse(5, 0) = + (Linv(5, 0) * Linv(0, 0));
245  inverse(0, 5) = inverse(5, 0);
246 }
247 
248 template <typename TRAIT>
250  //assumes L has been computed already
251  Linv(0, 0) = 1 / L(0, 0);
252  Linv(1, 1) = 1 / L(1, 1);
253  Linv(2, 2) = 1 / L(2, 2);
254  Linv(3, 3) = 1 / L(3, 3);
255  Linv(4, 4) = 1 / L(4, 4);
256  Linv(5, 5) = 1 / L(5, 5);
257  Linv(1, 0) = - Linv(0, 0) * ((Linv(1, 1) * L(1, 0)) + 0);
258  Linv(2, 1) = - Linv(1, 1) * ((Linv(2, 2) * L(2, 1)) + 0);
259  Linv(2, 0) = - Linv(0, 0) * ((Linv(2, 1) * L(1, 0)) + (Linv(2, 2) * L(2, 0)) + 0);
260  Linv(3, 2) = - Linv(2, 2) * ((Linv(3, 3) * L(3, 2)) + 0);
261  Linv(3, 1) = - Linv(1, 1) * ((Linv(3, 2) * L(2, 1)) + (Linv(3, 3) * L(3, 1)) + 0);
262  Linv(3, 0) = - Linv(0, 0) * ((Linv(3, 1) * L(1, 0)) + (Linv(3, 2) * L(2, 0)) + (Linv(3, 3) * L(3, 0)) + 0);
263  Linv(4, 3) = - Linv(3, 3) * ((Linv(4, 4) * L(4, 3)) + 0);
264  Linv(4, 2) = - Linv(2, 2) * ((Linv(4, 3) * L(3, 2)) + (Linv(4, 4) * L(4, 2)) + 0);
265  Linv(4, 1) = - Linv(1, 1) * ((Linv(4, 2) * L(2, 1)) + (Linv(4, 3) * L(3, 1)) + (Linv(4, 4) * L(4, 1)) + 0);
266  Linv(4, 0) = - Linv(0, 0) * ((Linv(4, 1) * L(1, 0)) + (Linv(4, 2) * L(2, 0)) + (Linv(4, 3) * L(3, 0)) + (Linv(4, 4) * L(4, 0)) + 0);
267  Linv(5, 4) = - Linv(4, 4) * ((Linv(5, 5) * L(5, 4)) + 0);
268  Linv(5, 3) = - Linv(3, 3) * ((Linv(5, 4) * L(4, 3)) + (Linv(5, 5) * L(5, 3)) + 0);
269  Linv(5, 2) = - Linv(2, 2) * ((Linv(5, 3) * L(3, 2)) + (Linv(5, 4) * L(4, 2)) + (Linv(5, 5) * L(5, 2)) + 0);
270  Linv(5, 1) = - Linv(1, 1) * ((Linv(5, 2) * L(2, 1)) + (Linv(5, 3) * L(3, 1)) + (Linv(5, 4) * L(4, 1)) + (Linv(5, 5) * L(5, 1)) + 0);
271  Linv(5, 0) = - Linv(0, 0) * ((Linv(5, 1) * L(1, 0)) + (Linv(5, 2) * L(2, 0)) + (Linv(5, 3) * L(3, 0)) + (Linv(5, 4) * L(4, 0)) + (Linv(5, 5) * L(5, 0)) + 0);
272 }
273 
const IMatrix & getTensor_link5() const
Definition: inertia_properties.h:92
Definition: declarations.h:27
Definition: declarations.h:31
iit::testirb4600::tpl::ForceTransforms< TRAIT > FTransforms
Definition: jsim.h:35
Cored::ForceVector ForceVector
Definition: rbd.h:143
Definition: rbd.h:175
#define F(i, j)
Definition: jsim.impl.h:19
Definition: inertia_properties.h:25
#define DATA
Definition: jsim.impl.h:14
const JSIM & update(const iit::testirb4600::JointState &)
Definition: jsim.impl.h:17
void transformInertia(const InertiaMat< Scalar > &I_A, const Mat66< Scalar > &XF, InertiaMat< Scalar > &I_B)
Definition: robcogen_commons.h:218
void computeInverse()
Definition: jsim.impl.h:207
void computeL()
Definition: jsim.impl.h:134
Definition: declarations.h:30
Definition: declarations.h:26
Definition: declarations.h:29
void computeLInverse()
Definition: jsim.impl.h:249
const IMatrix & getTensor_link4() const
Definition: inertia_properties.h:88
const IMatrix & getTensor_link3() const
Definition: inertia_properties.h:84
Definition: declarations.h:28
JSIM(IProperties &, FTransforms &)
Definition: jsim.impl.h:5
const IMatrix & getTensor_link1() const
Definition: inertia_properties.h:76
Column6d JointState
Definition: declarations.h:23
const IMatrix & getTensor_link2() const
Definition: inertia_properties.h:80