spatial.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2015-2021 CNRS INRIA
3 //
4 
5 #include <iostream>
6 
16 
17 #include <boost/test/unit_test.hpp>
18 #include <boost/utility/binary.hpp>
19 
20 BOOST_AUTO_TEST_SUITE(BOOST_TEST_MODULE)
21 
23 {
24  using namespace pinocchio;
25  typedef SE3::HomogeneousMatrixType HomogeneousMatrixType;
26  typedef SE3::ActionMatrixType ActionMatrixType;
27  typedef SE3::Vector3 Vector3;
28  typedef Eigen::Matrix<double, 4, 1> Vector4;
29 
30  const SE3 identity = SE3::Identity();
31 
33  typedef SE3::Vector4 Vector4;
34  Quaternion quat(Vector4::Random().normalized());
35 
36  SE3 m_from_quat(quat, Vector3::Random());
37 
38  SE3 amb = SE3::Random();
39  SE3 bmc = SE3::Random();
40  SE3 amc = amb * bmc;
41 
42  HomogeneousMatrixType aMb = amb;
43  HomogeneousMatrixType bMc = bmc;
44 
45  // Test internal product
46  HomogeneousMatrixType aMc = amc;
47  BOOST_CHECK(aMc.isApprox(aMb * bMc));
48 
49  HomogeneousMatrixType bMa = amb.inverse();
50  BOOST_CHECK(bMa.isApprox(aMb.inverse()));
51 
52  // Test point action
53  Vector3 p = Vector3::Random();
54  Vector4 p4;
55  p4.head(3) = p;
56  p4[3] = 1;
57 
58  Vector3 Mp = (aMb * p4).head(3);
59  BOOST_CHECK(amb.act(p).isApprox(Mp));
60 
61  Vector3 Mip = (aMb.inverse() * p4).head(3);
62  BOOST_CHECK(amb.actInv(p).isApprox(Mip));
63 
64  // Test action matrix
65  ActionMatrixType aXb = amb;
66  ActionMatrixType bXc = bmc;
67  ActionMatrixType aXc = amc;
68  BOOST_CHECK(aXc.isApprox(aXb * bXc));
69 
70  ActionMatrixType bXa = amb.inverse();
71  BOOST_CHECK(bXa.isApprox(aXb.inverse()));
72 
73  ActionMatrixType X_identity = identity.toActionMatrix();
74  BOOST_CHECK(X_identity.isIdentity());
75 
76  ActionMatrixType X_identity_inverse = identity.toActionMatrixInverse();
77  BOOST_CHECK(X_identity_inverse.isIdentity());
78 
79  // Test dual action matrix
80  BOOST_CHECK(aXb.inverse().transpose().isApprox(amb.toDualActionMatrix()));
81 
82  // Test isIdentity
83  BOOST_CHECK(identity.isIdentity());
84 
85  // Test isApprox
86  BOOST_CHECK(identity.isApprox(identity));
87 
88  // Test cast
89  typedef SE3Tpl<float> SE3f;
90  SE3f::Matrix3 rot_float(amb.rotation().cast<float>());
91  SE3f amb_float = amb.cast<float>();
92  BOOST_CHECK(amb_float.isApprox(amb.cast<float>()));
93 
94  SE3f amb_float2(amb);
95  BOOST_CHECK(amb_float.isApprox(amb_float2));
96 
97  // Test actInv
98  const SE3 M = SE3::Random();
99  const SE3 Minv = M.inverse();
100 
101  BOOST_CHECK(Minv.actInv(Minv).isIdentity());
102  BOOST_CHECK(M.actInv(identity).isApprox(Minv));
103 
104  // Test normalization
105  {
106  const double prec = Eigen::NumTraits<double>::dummy_precision();
107  SE3 M(SE3::Random());
108  M.rotation() += prec * SE3::Matrix3::Random();
109  BOOST_CHECK(!M.isNormalized());
110 
111  SE3 M_normalized = M.normalized();
112  BOOST_CHECK(M_normalized.isNormalized());
113 
114  M.normalize();
115  BOOST_CHECK(M.isNormalized());
116  }
117 }
118 
120 {
121  using namespace pinocchio;
122  typedef SE3::ActionMatrixType ActionMatrixType;
123  typedef Motion::Vector6 Vector6;
124 
125  SE3 amb = SE3::Random();
126  SE3 bmc = SE3::Random();
127  SE3 amc = amb * bmc;
128 
130  Motion bv2 = Motion::Random();
131 
132  typedef MotionBase<Motion> Base;
133 
134  Vector6 bv_vec = bv;
135  Vector6 bv2_vec = bv2;
136 
137  // std::stringstream
138  std::stringstream ss;
139  ss << bv << std::endl;
140  BOOST_CHECK(!ss.str().empty());
141 
142  // Test .+.
143  Vector6 bvPbv2_vec = bv + bv2;
144  BOOST_CHECK(bvPbv2_vec.isApprox(bv_vec + bv2_vec));
145 
146  Motion bplus = static_cast<Base &>(bv) + static_cast<Base &>(bv2);
147  BOOST_CHECK((bv + bv2).isApprox(bplus));
148 
149  Motion v_not_zero(Vector6::Ones());
150  BOOST_CHECK(!v_not_zero.isZero());
151 
152  Motion v_zero(Vector6::Zero());
153  BOOST_CHECK(v_zero.isZero());
154 
155  // Test == and !=
156  BOOST_CHECK(bv == bv);
157  BOOST_CHECK(!(bv != bv));
158 
159  // Test -.
160  Vector6 Mbv_vec = -bv;
161  BOOST_CHECK(Mbv_vec.isApprox(-bv_vec));
162 
163  // Test .+=.
164  Motion bv3 = bv;
165  bv3 += bv2;
166  BOOST_CHECK(bv3.toVector().isApprox(bv_vec + bv2_vec));
167 
168  // Test .=V6
169  bv3 = bv2_vec;
170  BOOST_CHECK(bv3.toVector().isApprox(bv2_vec));
171 
172  // Test scalar*M6
173  Motion twicebv(2. * bv);
174  BOOST_CHECK(twicebv.isApprox(Motion(2. * bv.toVector())));
175 
176  // Test M6*scalar
177  Motion bvtwice(bv * 2.);
178  BOOST_CHECK(bvtwice.isApprox(twicebv));
179 
180  // Test M6/scalar
181  Motion bvdividedbytwo(bvtwice / 2.);
182  BOOST_CHECK(bvdividedbytwo.isApprox(bv));
183 
184  // Test constructor from V6
185  Motion bv4(bv2_vec);
186  BOOST_CHECK(bv4.toVector().isApprox(bv2_vec));
187 
188  // Test action
189  ActionMatrixType aXb = amb;
190  BOOST_CHECK(amb.act(bv).toVector().isApprox(aXb * bv_vec));
191 
192  // Test action inverse
193  ActionMatrixType bXc = bmc;
194  BOOST_CHECK(bmc.actInv(bv).toVector().isApprox(bXc.inverse() * bv_vec));
195 
196  // Test double action
197  Motion cv = Motion::Random();
198  bv = bmc.act(cv);
199  BOOST_CHECK(amb.act(bv).toVector().isApprox(amc.act(cv).toVector()));
200 
201  // Simple test for cross product vxv
202  Motion vxv = bv.cross(bv);
203  BOOST_CHECK_SMALL(
204  vxv.toVector().tail(3).norm(),
205  1e-3); // previously ensure that (vxv.toVector().tail(3).isMuchSmallerThan(1e-3));
206 
207  // Test Action Matrix
208  Motion v2xv = bv2.cross(bv);
209  Motion::ActionMatrixType actv2 = bv2.toActionMatrix();
210 
211  BOOST_CHECK(v2xv.toVector().isApprox(actv2 * bv.toVector()));
212 
213  // Test Dual Action Matrix
214  Force f(bv.toVector());
215  Force v2xf = bv2.cross(f);
216  Motion::ActionMatrixType dualactv2 = bv2.toDualActionMatrix();
217 
218  BOOST_CHECK(v2xf.toVector().isApprox(dualactv2 * f.toVector()));
219  BOOST_CHECK(dualactv2.isApprox(-actv2.transpose()));
220 
221  // Simple test for cross product vxf
222  Force vxf = bv.cross(f);
223  BOOST_CHECK(vxf.linear().isApprox(bv.angular().cross(f.linear())));
224  BOOST_CHECK_SMALL(
225  vxf.angular().norm(),
226  1e-3); // previously ensure that ( vxf.angular().isMuchSmallerThan(1e-3));
227 
228  // Test frame change for vxf
229  Motion av = Motion::Random();
230  Force af = Force::Random();
231  bv = amb.actInv(av);
232  Force bf = amb.actInv(af);
233  Force avxf = av.cross(af);
234  Force bvxf = bv.cross(bf);
235  BOOST_CHECK(avxf.toVector().isApprox(amb.act(bvxf).toVector()));
236 
237  // Test frame change for vxv
238  av = Motion::Random();
239  Motion aw = Motion::Random();
240  bv = amb.actInv(av);
241  Motion bw = amb.actInv(aw);
242  Motion avxw = av.cross(aw);
243  Motion bvxw = bv.cross(bw);
244  BOOST_CHECK(avxw.toVector().isApprox(amb.act(bvxw).toVector()));
245 
246  // Test isApprox
247  bv.toVector().setOnes();
248  const double eps = 1e-6;
249  BOOST_CHECK(bv == bv);
250  BOOST_CHECK(bv.isApprox(bv));
251  Motion bv_approx(bv);
252  bv_approx.linear()[0] += eps;
253  BOOST_CHECK(bv_approx.isApprox(bv, eps));
254 
255  // Test ref() method
256  {
258  BOOST_CHECK(a.ref().isApprox(a));
259 
260  const Motion b(a);
261  BOOST_CHECK(b.isApprox(a.ref()));
262  }
263 
264  // Test cast
265  {
266  typedef MotionTpl<float> Motionf;
268  Motionf a_float = a.cast<float>();
269  BOOST_CHECK(a_float.isApprox(a.cast<float>()));
270 
271  Motionf a_float2(a);
272  BOOST_CHECK(a_float.isApprox(a_float2));
273  }
274 }
275 
276 BOOST_AUTO_TEST_CASE(test_motion_ref)
277 {
278  using namespace pinocchio;
279  typedef Motion::Vector6 Vector6;
280 
281  typedef MotionRef<Vector6> MotionV6;
282 
284  MotionV6 v(v_ref.toVector());
285 
286  BOOST_CHECK(v_ref.isApprox(v));
287 
288  MotionV6::MotionPlain v2(v * 2.);
289  Motion v2_ref(v_ref * 2.);
290 
291  BOOST_CHECK(v2_ref.isApprox(v2));
292 
293  v2 = v_ref + v;
294  BOOST_CHECK(v2_ref.isApprox(v2));
295 
296  v = v2;
297  BOOST_CHECK(v2.isApprox(v));
298 
299  v2 = v - v;
300  BOOST_CHECK(v2.isApprox(Motion::Zero()));
301 
302  SE3 M(SE3::Identity());
303  v2 = M.act(v);
304  BOOST_CHECK(v2.isApprox(v));
305 
306  v2 = M.actInv(v);
307  BOOST_CHECK(v2.isApprox(v));
308 
309  Motion v3(Motion::Random());
310  v_ref.setRandom();
311  v = v_ref;
312  v2 = v.cross(v3);
313  v2_ref = v_ref.cross(v3);
314 
315  BOOST_CHECK(v2.isApprox(v2_ref));
316 
317  v.setRandom();
318  v.setZero();
319  BOOST_CHECK(v.isApprox(Motion::Zero()));
320 
321  // Test ref() method
322  {
323  Vector6 v6(Vector6::Random());
324  MotionV6 a(v6);
325  BOOST_CHECK(a.ref().isApprox(a));
326 
327  const Motion b(a);
328  BOOST_CHECK(b.isApprox(a.ref()));
329  }
330 }
331 
332 BOOST_AUTO_TEST_CASE(test_motion_zero)
333 {
334  using namespace pinocchio;
335  Motion v((MotionZero()));
336 
337  BOOST_CHECK(v.toVector().isZero());
338  BOOST_CHECK(MotionZero() == Motion::Zero());
339 
340  // SE3.act
341  SE3 m(SE3::Random());
342  BOOST_CHECK(m.act(MotionZero()) == Motion::Zero());
343  BOOST_CHECK(m.actInv(MotionZero()) == Motion::Zero());
344 
345  // Motion.cross
346  Motion v2(Motion::Random());
347  BOOST_CHECK(v2.cross(MotionZero()) == Motion::Zero());
348 }
349 
351 {
352  using namespace pinocchio;
353  typedef SE3::ActionMatrixType ActionMatrixType;
354  typedef Force::Vector6 Vector6;
355 
356  SE3 amb = SE3::Random();
357  SE3 bmc = SE3::Random();
358  SE3 amc = amb * bmc;
359 
360  Force bf = Force::Random();
361  Force bf2 = Force::Random();
362 
363  Vector6 bf_vec = bf;
364  Vector6 bf2_vec = bf2;
365 
366  // std::stringstream
367  std::stringstream ss;
368  ss << bf << std::endl;
369  BOOST_CHECK(!ss.str().empty());
370 
371  // Test .+.
372  Vector6 bfPbf2_vec = bf + bf2;
373  BOOST_CHECK(bfPbf2_vec.isApprox(bf_vec + bf2_vec));
374 
375  // Test -.
376  Vector6 Mbf_vec = -bf;
377  BOOST_CHECK(Mbf_vec.isApprox(-bf_vec));
378 
379  // Test .+=.
380  Force bf3 = bf;
381  bf3 += bf2;
382  BOOST_CHECK(bf3.toVector().isApprox(bf_vec + bf2_vec));
383 
384  // Test .= V6
385  bf3 = bf2_vec;
386  BOOST_CHECK(bf3.toVector().isApprox(bf2_vec));
387 
388  // Test constructor from V6
389  Force bf4(bf2_vec);
390  BOOST_CHECK(bf4.toVector().isApprox(bf2_vec));
391 
392  // Test action
393  ActionMatrixType aXb = amb;
394  BOOST_CHECK(amb.act(bf).toVector().isApprox(aXb.inverse().transpose() * bf_vec));
395 
396  // Test action inverse
397  ActionMatrixType bXc = bmc;
398  BOOST_CHECK(bmc.actInv(bf).toVector().isApprox(bXc.transpose() * bf_vec));
399 
400  // Test double action
401  Force cf = Force::Random();
402  bf = bmc.act(cf);
403  BOOST_CHECK(amb.act(bf).toVector().isApprox(amc.act(cf).toVector()));
404 
405  // Simple test for cross product
406  // Force vxv = bf.cross(bf);
407  // ensure that (vxv.toVector().isMuchSmallerThan(bf.toVector()));
408 
409  Force f_not_zero(Vector6::Ones());
410  BOOST_CHECK(!f_not_zero.isZero());
411 
412  Force f_zero(Vector6::Zero());
413  BOOST_CHECK(f_zero.isZero());
414 
415  // Test isApprox
416 
417  BOOST_CHECK(bf == bf);
418  bf.setRandom();
419  bf2.setZero();
420  BOOST_CHECK(bf == bf);
421  BOOST_CHECK(bf != bf2);
422  BOOST_CHECK(bf.isApprox(bf));
423  BOOST_CHECK(!bf.isApprox(bf2));
424 
425  const double eps = 1e-6;
426  Force bf_approx(bf);
427  bf_approx.linear()[0] += 2. * eps;
428  BOOST_CHECK(!bf_approx.isApprox(bf, eps));
429 
430  // Test ref() method
431  {
432  Force a(Force::Random());
433  BOOST_CHECK(a.ref().isApprox(a));
434 
435  const Force b(a);
436  BOOST_CHECK(b.isApprox(a.ref()));
437  }
438 
439  // Test cast
440  {
441  typedef ForceTpl<float> Forcef;
442  Force a(Force::Random());
443  Forcef a_float = a.cast<float>();
444  BOOST_CHECK(a_float.isApprox(a.cast<float>()));
445 
446  Forcef a_float2(a);
447  BOOST_CHECK(a_float.isApprox(a_float2));
448  }
449 
450  // Test scalar multiplication
451  const double alpha = 1.5;
452  Force b(Force::Random());
453  Force alpha_f = alpha * b;
454  Force f_alpha = b * alpha;
455 
456  BOOST_CHECK(alpha_f == f_alpha);
457 }
458 
459 BOOST_AUTO_TEST_CASE(test_force_ref)
460 {
461  using namespace pinocchio;
462  typedef Force::Vector6 Vector6;
463 
464  typedef ForceRef<Vector6> ForceV6;
465 
466  Force f_ref(Force::Random());
467  ForceV6 f(f_ref.toVector());
468 
469  BOOST_CHECK(f_ref.isApprox(f));
470 
471  ForceV6::ForcePlain f2(f * 2.);
472  Force f2_ref(f_ref * 2.);
473 
474  BOOST_CHECK(f2_ref.isApprox(f2));
475 
476  f2 = f_ref + f;
477  BOOST_CHECK(f2_ref.isApprox(f2));
478 
479  f = f2;
480  BOOST_CHECK(f2.isApprox(f));
481 
482  f2 = f - f;
483  BOOST_CHECK(f2.isApprox(Force::Zero()));
484 
485  SE3 M(SE3::Identity());
486  f2 = M.act(f);
487  BOOST_CHECK(f2.isApprox(f));
488 
489  f2 = M.actInv(f);
490  BOOST_CHECK(f2.isApprox(f));
491 
493  f_ref.setRandom();
494  f = f_ref;
495  f2 = v.cross(f);
496  f2_ref = v.cross(f_ref);
497 
498  BOOST_CHECK(f2.isApprox(f2_ref));
499 
500  f.setRandom();
501  f.setZero();
502  BOOST_CHECK(f.isApprox(Force::Zero()));
503 
504  // Test ref() method
505  {
506  Vector6 v6(Vector6::Random());
507  ForceV6 a(v6);
508  BOOST_CHECK(a.ref().isApprox(a));
509 
510  const Force b(a);
511  BOOST_CHECK(b.isApprox(a.ref()));
512  }
513 }
514 
515 BOOST_AUTO_TEST_CASE(test_Inertia)
516 {
517  using namespace pinocchio;
518  typedef Inertia::Matrix6 Matrix6;
519 
520  Inertia aI = Inertia::Random();
521  Matrix6 matI = aI;
522  BOOST_CHECK_EQUAL(matI(0, 0), aI.mass());
523  BOOST_CHECK_EQUAL(matI(1, 1), aI.mass());
524  BOOST_CHECK_EQUAL(matI(2, 2), aI.mass()); // 1,1 before unifying
525 
526  BOOST_CHECK_SMALL(
527  (matI - matI.transpose()).norm(),
528  matI.norm()); // previously ensure that( (matI-matI.transpose()).isMuchSmallerThan(matI) );
529  BOOST_CHECK_SMALL(
530  (matI.topRightCorner<3, 3>() * aI.lever()).norm(),
531  aI.lever().norm()); // previously ensure that(
532  // (matI.topRightCorner<3,3>()*aI.lever()).isMuchSmallerThan(aI.lever()) );
533 
534  Inertia I1 = Inertia::Identity();
535  BOOST_CHECK(I1.matrix().isApprox(Matrix6::Identity()));
536 
537  // Test motion-to-force map
538  Motion v = Motion::Random();
539  Force f = I1 * v;
540  BOOST_CHECK(f.toVector().isApprox(v.toVector()));
541 
542  // Test Inertia group application
543  SE3 bma = SE3::Random();
544  Inertia bI = bma.act(aI);
545  Matrix6 bXa = bma;
546  BOOST_CHECK((bma.rotation() * aI.inertia().matrix() * bma.rotation().transpose())
547  .isApprox(bI.inertia().matrix()));
548  BOOST_CHECK((bXa.transpose().inverse() * aI.matrix() * bXa.inverse()).isApprox(bI.matrix()));
549 
550  // Test inverse action
551  BOOST_CHECK((bXa.transpose() * bI.matrix() * bXa).isApprox(bma.actInv(bI).matrix()));
552 
553  // Test vxIv cross product
554  v = Motion::Random();
555  f = aI * v;
556  Force vxf = v.cross(f);
557  Force vxIv = aI.vxiv(v);
558  BOOST_CHECK(vxf.toVector().isApprox(vxIv.toVector()));
559 
560  // Test operator+
561  I1 = Inertia::Random();
562  Inertia I2 = Inertia::Random();
563  BOOST_CHECK((I1.matrix() + I2.matrix()).isApprox((I1 + I2).matrix()));
564 
565  // Test operator-
566  {
567  I1 = Inertia::Random();
568  Inertia I2 = Inertia::Random();
569  Inertia Isum = I1 + I2;
570  Inertia I1_other = Isum - I2;
571  BOOST_CHECK(I1_other.matrix().isApprox(I1.matrix()));
572  }
573 
574  // Test operator +=
575  Inertia I12 = I1;
576  I12 += I2;
577  BOOST_CHECK((I1.matrix() + I2.matrix()).isApprox(I12.matrix()));
578 
579  // Test operator -=
580  {
581  Inertia I2 = Inertia::Random();
582  Inertia Isum = I1 + I2;
583 
584  Inertia I1_other = Isum;
585  I1_other -= I2;
586  BOOST_CHECK((I1_other.matrix()).isApprox(I1.matrix()));
587  }
588 
589  // Test operator vtiv
590  double kinetic_ref = v.toVector().transpose() * aI.matrix() * v.toVector();
591  double kinetic = aI.vtiv(v);
592  BOOST_CHECK_SMALL(kinetic_ref - kinetic, 1e-12);
593 
594  // Test constructor (Matrix6)
595  Inertia I1_bis(I1.matrix());
596  BOOST_CHECK(I1.matrix().isApprox(I1_bis.matrix()));
597 
598  // Test Inertia from ellipsoid
599  const double sphere_mass = 5.;
600  const double sphere_radius = 2.;
601  I1 = Inertia::FromSphere(sphere_mass, sphere_radius);
602  const double L_sphere = 2. / 5. * sphere_mass * sphere_radius * sphere_radius;
603  BOOST_CHECK_SMALL(I1.mass() - sphere_mass, 1e-12);
604  BOOST_CHECK(I1.lever().isZero());
605  BOOST_CHECK(
606  I1.inertia().matrix().isApprox(Symmetric3(L_sphere, 0., L_sphere, 0., 0., L_sphere).matrix()));
607 
608  // Test Inertia from ellipsoid
609  I1 = Inertia::FromEllipsoid(2., 3., 4., 5.);
610  BOOST_CHECK_SMALL(I1.mass() - 2, 1e-12);
611  BOOST_CHECK_SMALL(I1.lever().norm(), 1e-12);
612  BOOST_CHECK(I1.inertia().matrix().isApprox(Symmetric3(16.4, 0., 13.6, 0., 0., 10.).matrix()));
613 
614  // Test Inertia from Cylinder
615  I1 = Inertia::FromCylinder(2., 4., 6.);
616  BOOST_CHECK_SMALL(I1.mass() - 2, 1e-12);
617  BOOST_CHECK_SMALL(I1.lever().norm(), 1e-12);
618  BOOST_CHECK(I1.inertia().matrix().isApprox(Symmetric3(14., 0., 14., 0., 0., 16.).matrix()));
619 
620  // Test Inertia from Box
621  I1 = Inertia::FromBox(2., 6., 12., 18.);
622  BOOST_CHECK_SMALL(I1.mass() - 2, 1e-12);
623  BOOST_CHECK_SMALL(I1.lever().norm(), 1e-12);
624  BOOST_CHECK(I1.inertia().matrix().isApprox(Symmetric3(78., 0., 60., 0., 0., 30.).matrix()));
625 
626  // Test Inertia From Capsule
627  I1 = Inertia::FromCapsule(1., 2., 3);
628  BOOST_CHECK_SMALL(I1.mass() - 1, 1e-12);
629  BOOST_CHECK_SMALL(I1.lever().norm(), 1e-12);
630  BOOST_CHECK(I1.inertia().matrix().isApprox(
631  Symmetric3(3.79705882, 0., 3.79705882, 0., 0., 1.81176471).matrix(),
632  1e-5)); // Computed with hppfcl::Capsule
633 
634  // Copy operator
635  Inertia aI_copy(aI);
636  BOOST_CHECK(aI_copy == aI);
637 
638  // Test isZero
639  Inertia I_not_zero = Inertia::Identity();
640  BOOST_CHECK(!I_not_zero.isZero());
641 
642  Inertia I_zero = Inertia::Zero();
643  BOOST_CHECK(I_zero.isZero());
644 
645  // Test isApprox
646  const double eps = 1e-6;
647  BOOST_CHECK(aI == aI);
648  BOOST_CHECK(aI.isApprox(aI));
649  Inertia aI_approx(aI);
650  aI_approx.mass() += eps / 2.;
651  BOOST_CHECK(aI_approx.isApprox(aI, eps));
652 
653  // Test Variation
654  Inertia::Matrix6 aIvariation = aI.variation(v);
655 
656  Motion::ActionMatrixType vAction = v.toActionMatrix();
657  Motion::ActionMatrixType vDualAction = v.toDualActionMatrix();
658 
659  Inertia::Matrix6 aImatrix = aI.matrix();
660  Inertia::Matrix6 aIvariation_ref = vDualAction * aImatrix - aImatrix * vAction;
661 
662  BOOST_CHECK(aIvariation.isApprox(aIvariation_ref));
663  BOOST_CHECK(vxIv.isApprox(Force(aIvariation * v.toVector())));
664 
665  // Test vxI operator
666  {
667  typedef Inertia::Matrix6 Matrix6;
670 
671  const Matrix6 M_ref(v.toDualActionMatrix() * I.matrix());
672  Matrix6 M;
673  Inertia::vxi(v, I, M);
674 
675  BOOST_CHECK(M.isApprox(M_ref));
676  BOOST_CHECK(I.vxi(v).isApprox(M_ref));
677  }
678 
679  // Test Ivx operator
680  {
681  typedef Inertia::Matrix6 Matrix6;
684 
685  const Matrix6 M_ref(I.matrix() * v.toActionMatrix());
686  Matrix6 M;
687  Inertia::ivx(v, I, M);
688 
689  BOOST_CHECK(M.isApprox(M_ref));
690  BOOST_CHECK(I.ivx(v).isApprox(M_ref));
691  }
692 
693  // Test variation against vxI - Ivx operator
694  {
695  typedef Inertia::Matrix6 Matrix6;
698 
699  Matrix6 Ivariation = I.variation(v);
700 
701  Matrix6 M1;
702  Inertia::vxi(v, I, M1);
703  Matrix6 M2;
704  Inertia::ivx(v, I, M2);
705  Matrix6 M3(M1 - M2);
706 
707  BOOST_CHECK(M3.isApprox(Ivariation));
708  }
709 
710  // Test inverse
711  {
713  Inertia::Matrix6 I_inv = I.inverse();
714 
715  BOOST_CHECK(I_inv.isApprox(I.matrix().inverse()));
716  }
717 
718  // Test dynamic parameters
719  {
721 
723 
724  BOOST_CHECK_CLOSE(v[0], I.mass(), 1e-12);
725 
726  BOOST_CHECK(v.segment<3>(1).isApprox(I.mass() * I.lever()));
727 
728  Eigen::Matrix3d I_o = I.inertia() + I.mass() * skew(I.lever()).transpose() * skew(I.lever());
729  Eigen::Matrix3d I_ov;
730  I_ov << v[4], v[5], v[7], v[5], v[6], v[8], v[7], v[8], v[9];
731 
732  BOOST_CHECK(I_o.isApprox(I_ov));
733 
735  BOOST_CHECK(I2.isApprox(I));
736  }
737 
738  // Test disp
739  std::cout << aI << std::endl;
740 
741  // Test Inertia parametrizations
742  {
745 
746  Inertia::Vector10 eta;
747  eta.setRandom();
748  LogCholeskyParameters log_cholesky = LogCholeskyParameters(eta);
749 
750  // Convert logcholesky parametrization to pseudo-inertia
751  PseudoInertia pseudo = log_cholesky.toPseudoInertia();
752  Eigen::Matrix4d pseudo_matrix = pseudo.toMatrix();
753  // Convert logcholesky to inertia tpl
754  Inertia I_from_log_cholesky = Inertia::FromLogCholeskyParameters(log_cholesky);
755 
756  // Check if conversion from inertia tpl to pseudo inertia gives same result as from logcholesky
757  // parametrization to pseudo-inertia
758  Eigen::Matrix4d pseudo_from_inertia = I_from_log_cholesky.toPseudoInertia().toMatrix();
759  BOOST_CHECK(pseudo_matrix.isApprox(pseudo_from_inertia, 1e-10));
760 
761  // // Check if log-cholesky parametrization to pseudo-inertia gives same result as their
762  // calculations
763  double alpha = log_cholesky.parameters[0];
764  double d1 = log_cholesky.parameters[1];
765  double d2 = log_cholesky.parameters[2];
766  double d3 = log_cholesky.parameters[3];
767  double s12 = log_cholesky.parameters[4];
768  double s23 = log_cholesky.parameters[5];
769  double s13 = log_cholesky.parameters[6];
770  double t1 = log_cholesky.parameters[7];
771  double t2 = log_cholesky.parameters[8];
772  double t3 = log_cholesky.parameters[9];
773 
774  double exp_alpha = std::exp(alpha);
775  double exp_d1 = std::exp(d1);
776  double exp_d2 = std::exp(d2);
777  double exp_d3 = std::exp(d3);
778 
779  Eigen::Matrix4d U;
780  // clang-format off
781  U << exp_d1, s12, s13, t1,
782  0, exp_d2, s23, t2,
783  0, 0, exp_d3, t3,
784  0, 0, 0, 1;
785  // clang-format on
786  U *= exp_alpha;
787 
788  Eigen::Matrix4d pseudo_chol = U * U.transpose();
789  BOOST_CHECK(pseudo_matrix.isApprox(pseudo_chol, 1e-10));
790 
791  // Additional checks: Convert back from pseudo-inertia to inertia and validate
792  Inertia I_back = pseudo.toInertia();
793  BOOST_CHECK_CLOSE(I_back.mass(), I_from_log_cholesky.mass(), 1e-12);
794  BOOST_CHECK(I_back.lever().isApprox(I_from_log_cholesky.lever(), 1e-12));
795  BOOST_CHECK(I_back.inertia().isApprox(I_from_log_cholesky.inertia(), 1e-12));
796 
797  // Convert Inertia to dynamic parameters
798  Inertia::Vector10 dynamic_params_inertia = I_from_log_cholesky.toDynamicParameters();
799 
800  // Convert log Cholesky to dynamic parameters
801  Inertia::Vector10 dynamic_params_log_cholesky = log_cholesky.toDynamicParameters();
802 
803  // Compare dynamic parameters from Inertia and log Cholesky
804  BOOST_CHECK(dynamic_params_inertia.isApprox(dynamic_params_log_cholesky, 1e-10));
805 
806  // Convert Pseudo Inertia to dynamic parameters
807  PseudoInertia pseudo_inertia = PseudoInertia::FromMatrix(pseudo_matrix);
808  Inertia::Vector10 dynamic_params_pseudo_inertia = pseudo_inertia.toDynamicParameters();
809 
810  // Compare dynamic parameters from Inertia and Pseudo Inertia
811  BOOST_CHECK(dynamic_params_inertia.isApprox(dynamic_params_pseudo_inertia, 1e-10));
812 
813  // Compare dynamic parameters from log Cholesky and Pseudo Inertia
814  BOOST_CHECK(dynamic_params_log_cholesky.isApprox(dynamic_params_pseudo_inertia, 1e-10));
815 
816  // Calculate Jacobian of logcholesky parametrization
817  Eigen::Matrix<double, 10, 10> jacobian = log_cholesky.calculateJacobian();
818 
819  // Check if determinant is non-zero
820  BOOST_CHECK(std::abs(jacobian.determinant()) > 1e-10);
821 
822  // Check physical consistency by positive definiteness of pseudo inertia
823  Eigen::SelfAdjointEigenSolver<Eigen::Matrix4d> eigensolver(pseudo_matrix);
824  BOOST_CHECK((eigensolver.eigenvalues().array() > 0).all());
825 
826  // Test disp
827  std::cout << I_from_log_cholesky << std::endl;
828  std::cout << log_cholesky << std::endl;
829  std::cout << pseudo_inertia << std::endl;
830  }
831 }
832 
833 BOOST_AUTO_TEST_CASE(cast_inertia)
834 {
835  using namespace pinocchio;
837 
838  typedef InertiaTpl<long double> Inertiald;
839 
840  BOOST_CHECK(Y.cast<double>() == Y);
841  BOOST_CHECK(Y.cast<long double>().cast<double>() == Y);
842 
843  Inertiald Y2(Y);
844  BOOST_CHECK(Y2.isApprox(Y.cast<long double>()));
845 }
846 
847 BOOST_AUTO_TEST_CASE(test_ActOnSet)
848 {
849  using namespace pinocchio;
850  const int N = 20;
851  typedef Eigen::Matrix<double, 6, N> Matrix6N;
852  SE3 jMi = SE3::Random();
853  Motion v = Motion::Random();
854 
855  // Forcet SET
858  Matrix6N iF = Matrix6N::Random(), jF, jFinv, jF_ref, jFinv_ref;
859 
860  // forceSet::se3Action
861  forceSet::se3Action(jMi, iF, jF);
862  for (int k = 0; k < N; ++k)
863  BOOST_CHECK(jMi.act(Force(iF.col(k))).toVector().isApprox(jF.col(k)));
864 
865  jF_ref = jMi.toDualActionMatrix() * iF;
866  BOOST_CHECK(jF_ref.isApprox(jF));
867 
868  forceSet::se3ActionInverse(jMi.inverse(), iF, jFinv);
869  BOOST_CHECK(jFinv.isApprox(jF));
871 
872  Matrix6N iF2 = Matrix6N::Random();
873  jF_ref += jMi.toDualActionMatrix() * iF2;
874 
875  forceSet::se3Action<ADDTO>(jMi, iF2, jF);
876  BOOST_CHECK(jF.isApprox(jF_ref));
877 
878  Matrix6N iF3 = Matrix6N::Random();
879  jF_ref -= jMi.toDualActionMatrix() * iF3;
880 
881  forceSet::se3Action<RMTO>(jMi, iF3, jF);
882  BOOST_CHECK(jF.isApprox(jF_ref));
883 
884  // forceSet::se3ActionInverse
885  forceSet::se3ActionInverse(jMi, iF, jFinv);
886  jFinv_ref = jMi.inverse().toDualActionMatrix() * iF;
887  BOOST_CHECK(jFinv_ref.isApprox(jFinv));
888 
889  jFinv_ref += jMi.inverse().toDualActionMatrix() * iF2;
890  forceSet::se3ActionInverse<ADDTO>(jMi, iF2, jFinv);
891  BOOST_CHECK(jFinv.isApprox(jFinv_ref));
892 
893  jFinv_ref -= jMi.inverse().toDualActionMatrix() * iF3;
894  forceSet::se3ActionInverse<RMTO>(jMi, iF3, jFinv);
895  BOOST_CHECK(jFinv.isApprox(jFinv_ref));
896 
897  // forceSet::motionAction
898  forceSet::motionAction(v, iF, jF);
899  for (int k = 0; k < N; ++k)
900  BOOST_CHECK(v.cross(Force(iF.col(k))).toVector().isApprox(jF.col(k)));
901 
902  jF_ref = v.toDualActionMatrix() * iF;
903  BOOST_CHECK(jF.isApprox(jF_ref));
904 
905  jF_ref += v.toDualActionMatrix() * iF2;
906  forceSet::motionAction<ADDTO>(v, iF2, jF);
907  BOOST_CHECK(jF.isApprox(jF_ref));
908 
909  jF_ref -= v.toDualActionMatrix() * iF3;
910  forceSet::motionAction<RMTO>(v, iF3, jF);
911  BOOST_CHECK(jF.isApprox(jF_ref));
912 
913  // Motion SET
916  Matrix6N iV = Matrix6N::Random(), jV, jV_ref, jVinv, jVinv_ref;
917 
918  // motionSet::se3Action
919  motionSet::se3Action(jMi, iV, jV);
920  for (int k = 0; k < N; ++k)
921  BOOST_CHECK(jMi.act(Motion(iV.col(k))).toVector().isApprox(jV.col(k)));
922 
923  jV_ref = jMi.toActionMatrix() * iV;
924  BOOST_CHECK(jV.isApprox(jV_ref));
925 
926  motionSet::se3ActionInverse(jMi.inverse(), iV, jVinv);
927  BOOST_CHECK(jVinv.isApprox(jV));
929 
930  Matrix6N iV2 = Matrix6N::Random();
931  jV_ref += jMi.toActionMatrix() * iV2;
932  motionSet::se3Action<ADDTO>(jMi, iV2, jV);
933  BOOST_CHECK(jV.isApprox(jV_ref));
934 
935  Matrix6N iV3 = Matrix6N::Random();
936  jV_ref -= jMi.toActionMatrix() * iV3;
937  motionSet::se3Action<RMTO>(jMi, iV3, jV);
938  BOOST_CHECK(jV.isApprox(jV_ref));
939 
940  // motionSet::se3ActionInverse
941  motionSet::se3ActionInverse(jMi, iV, jVinv);
942  jVinv_ref = jMi.inverse().toActionMatrix() * iV;
943  BOOST_CHECK(jVinv.isApprox(jVinv_ref));
944 
945  jVinv_ref += jMi.inverse().toActionMatrix() * iV2;
946  motionSet::se3ActionInverse<ADDTO>(jMi, iV2, jVinv);
947  BOOST_CHECK(jVinv.isApprox(jVinv_ref));
948 
949  jVinv_ref -= jMi.inverse().toActionMatrix() * iV3;
950  motionSet::se3ActionInverse<RMTO>(jMi, iV3, jVinv);
951  BOOST_CHECK(jVinv.isApprox(jVinv_ref));
952 
953  // motionSet::motionAction
954  motionSet::motionAction(v, iV, jV);
955  for (int k = 0; k < N; ++k)
956  BOOST_CHECK(v.cross(Motion(iV.col(k))).toVector().isApprox(jV.col(k)));
957 
958  jV_ref = v.toActionMatrix() * iV;
959  BOOST_CHECK(jV.isApprox(jV_ref));
960 
961  jV_ref += v.toActionMatrix() * iV2;
962  motionSet::motionAction<ADDTO>(v, iV2, jV);
963  BOOST_CHECK(jV.isApprox(jV_ref));
964 
965  jV_ref -= v.toActionMatrix() * iV3;
966  motionSet::motionAction<RMTO>(v, iV3, jV);
967  BOOST_CHECK(jV.isApprox(jV_ref));
968 
969  // motionSet::inertiaAction
970  const Inertia I(Inertia::Random());
971  motionSet::inertiaAction(I, iV, jV);
972  for (int k = 0; k < N; ++k)
973  BOOST_CHECK((I * (Motion(iV.col(k)))).toVector().isApprox(jV.col(k)));
974 
975  jV_ref = I.matrix() * iV;
976  BOOST_CHECK(jV.isApprox(jV_ref));
977 
978  jV_ref += I.matrix() * iV2;
979  motionSet::inertiaAction<ADDTO>(I, iV2, jV);
980  BOOST_CHECK(jV.isApprox(jV_ref));
981 
982  jV_ref -= I.matrix() * iV3;
983  motionSet::inertiaAction<RMTO>(I, iV3, jV);
984  BOOST_CHECK(jV.isApprox(jV_ref));
985 
986  // motionSet::act
987  Force f = Force::Random();
988  motionSet::act(iV, f, jF);
989  for (int k = 0; k < N; ++k)
990  BOOST_CHECK(Motion(iV.col(k)).cross(f).toVector().isApprox(jF.col(k)));
991 
992  for (int k = 0; k < N; ++k)
993  jF_ref.col(k) = Force(Motion(iV.col(k)).cross(f)).toVector();
994  BOOST_CHECK(jF.isApprox(jF_ref));
995 
996  for (int k = 0; k < N; ++k)
997  jF_ref.col(k) += Force(Motion(iV2.col(k)).cross(f)).toVector();
998  motionSet::act<ADDTO>(iV2, f, jF);
999  BOOST_CHECK(jF.isApprox(jF_ref));
1000 
1001  for (int k = 0; k < N; ++k)
1002  jF_ref.col(k) -= Force(Motion(iV3.col(k)).cross(f)).toVector();
1003  motionSet::act<RMTO>(iV3, f, jF);
1004  BOOST_CHECK(jF.isApprox(jF_ref));
1005 }
1006 
1008 {
1009  using namespace pinocchio;
1010  typedef SE3::Vector3 Vector3;
1011  typedef Motion::Vector6 Vector6;
1012 
1013  Vector3 v3(Vector3::Random());
1014  Vector6 v6(Vector6::Random());
1015 
1016  Vector3 res1 = unSkew(skew(v3));
1017  BOOST_CHECK(res1.isApprox(v3));
1018 
1019  Vector3 res2 = unSkew(skew(v6.head<3>()));
1020  BOOST_CHECK(res2.isApprox(v6.head<3>()));
1021 
1022  Vector3 res3 = skew(v3) * v3;
1023  BOOST_CHECK(res3.isZero());
1024 
1025  Vector3 rhs(Vector3::Random());
1026  Vector3 res41 = skew(v3) * rhs;
1027  Vector3 res42 = v3.cross(rhs);
1028 
1029  BOOST_CHECK(res41.isApprox(res42));
1030 }
1031 
1033 {
1034  using namespace pinocchio;
1035  typedef SE3::Vector3 Vector3;
1036  typedef SE3::Matrix3 Matrix3;
1037 
1038  Vector3 v(Vector3::Random());
1039  Matrix3 M(Matrix3::Random());
1040  Matrix3 Mcopy(M);
1041 
1042  addSkew(v, M);
1043  Matrix3 Mref = Mcopy + skew(v);
1044  BOOST_CHECK(M.isApprox(Mref));
1045 
1046  Mref += skew(-v);
1047  addSkew(-v, M);
1048  BOOST_CHECK(M.isApprox(Mcopy));
1049 
1050  M.setZero();
1051  addSkew(v, M);
1052  BOOST_CHECK(M.isApprox(skew(v)));
1053 }
1054 
1055 BOOST_AUTO_TEST_CASE(test_skew_square)
1056 {
1057  using namespace pinocchio;
1058  typedef SE3::Vector3 Vector3;
1059  typedef SE3::Matrix3 Matrix3;
1060 
1061  Vector3 u(Vector3::Random());
1062  Vector3 v(Vector3::Random());
1063 
1064  Matrix3 ref = skew(u) * skew(v);
1065 
1066  Matrix3 res = skewSquare(u, v);
1067 
1068  BOOST_CHECK(res.isApprox(ref));
1069 }
1070 
1071 template<int axis>
1073 {
1075  typedef double Scalar;
1076  typedef Eigen::Matrix<Scalar, 3, 1> Vector3;
1077 
1078  static void run()
1079  {
1080  const Scalar alpha = static_cast<Scalar>(rand()) / static_cast<Scalar>(RAND_MAX);
1081  const Vector3 r1 = Axis() * alpha;
1082  const Vector3 r2 = alpha * Axis();
1083 
1084  BOOST_CHECK(r1.isApprox(r2));
1085 
1086  for (int k = 0; k < Axis::dim; ++k)
1087  {
1088  if (k == axis)
1089  {
1090  BOOST_CHECK(r1[k] == alpha);
1091  BOOST_CHECK(r2[k] == alpha);
1092  }
1093  else
1094  {
1095  BOOST_CHECK(r1[k] == Scalar(0));
1096  BOOST_CHECK(r2[k] == Scalar(0));
1097  }
1098  }
1099  }
1100 };
1101 
1102 BOOST_AUTO_TEST_CASE(test_cartesian_axis)
1103 {
1104  using namespace Eigen;
1105  using namespace pinocchio;
1106  Vector3d v(Vector3d::Random());
1107  const double alpha = 3;
1108  Vector3d v2(alpha * v);
1109 
1110  BOOST_CHECK(XAxis::cross(v).isApprox(Vector3d::Unit(0).cross(v)));
1111  BOOST_CHECK(YAxis::cross(v).isApprox(Vector3d::Unit(1).cross(v)));
1112  BOOST_CHECK(ZAxis::cross(v).isApprox(Vector3d::Unit(2).cross(v)));
1113  BOOST_CHECK(XAxis::alphaCross(alpha, v).isApprox(Vector3d::Unit(0).cross(v2)));
1114  BOOST_CHECK(YAxis::alphaCross(alpha, v).isApprox(Vector3d::Unit(1).cross(v2)));
1115  BOOST_CHECK(ZAxis::alphaCross(alpha, v).isApprox(Vector3d::Unit(2).cross(v2)));
1116 
1120 
1121  // test Vector value
1122  BOOST_CHECK(XAxis::vector() == Vector3d::UnitX());
1123  BOOST_CHECK(YAxis::vector() == Vector3d::UnitY());
1124  BOOST_CHECK(ZAxis::vector() == Vector3d::UnitZ());
1125 }
1126 
1127 template<int axis>
1129 {
1131  typedef double Scalar;
1133 
1134  static void run()
1135  {
1136  const Scalar alpha = static_cast<Scalar>(rand()) / static_cast<Scalar>(RAND_MAX);
1137  const Motion r1 = Axis() * alpha;
1138  const Motion r2 = alpha * Axis();
1139 
1140  BOOST_CHECK(r1.isApprox(r2));
1141 
1142  for (int k = 0; k < Axis::dim; ++k)
1143  {
1144  if (k == axis)
1145  {
1146  BOOST_CHECK(r1.toVector()[k] == alpha);
1147  BOOST_CHECK(r2.toVector()[k] == alpha);
1148  }
1149  else
1150  {
1151  BOOST_CHECK(r1.toVector()[k] == Scalar(0));
1152  BOOST_CHECK(r2.toVector()[k] == Scalar(0));
1153  }
1154  }
1155  }
1156 };
1157 
1158 BOOST_AUTO_TEST_CASE(test_spatial_axis)
1159 {
1160  using namespace pinocchio;
1161 
1162  Motion v(Motion::Random());
1163  Force f(Force::Random());
1164 
1165  Motion vaxis;
1166  vaxis << AxisVX();
1167  BOOST_CHECK(AxisVX::cross(v).isApprox(vaxis.cross(v)));
1168  BOOST_CHECK(v.cross(AxisVX()).isApprox(v.cross(vaxis)));
1169  BOOST_CHECK(AxisVX::cross(f).isApprox(vaxis.cross(f)));
1170 
1171  vaxis << AxisVY();
1172  BOOST_CHECK(AxisVY::cross(v).isApprox(vaxis.cross(v)));
1173  BOOST_CHECK(v.cross(AxisVY()).isApprox(v.cross(vaxis)));
1174  BOOST_CHECK(AxisVY::cross(f).isApprox(vaxis.cross(f)));
1175 
1176  vaxis << AxisVZ();
1177  BOOST_CHECK(AxisVZ::cross(v).isApprox(vaxis.cross(v)));
1178  BOOST_CHECK(v.cross(AxisVZ()).isApprox(v.cross(vaxis)));
1179  BOOST_CHECK(AxisVZ::cross(f).isApprox(vaxis.cross(f)));
1180 
1181  vaxis << AxisWX();
1182  BOOST_CHECK(AxisWX::cross(v).isApprox(vaxis.cross(v)));
1183  BOOST_CHECK(v.cross(AxisWX()).isApprox(v.cross(vaxis)));
1184  BOOST_CHECK(AxisWX::cross(f).isApprox(vaxis.cross(f)));
1185 
1186  vaxis << AxisWY();
1187  BOOST_CHECK(AxisWY::cross(v).isApprox(vaxis.cross(v)));
1188  BOOST_CHECK(v.cross(AxisWY()).isApprox(v.cross(vaxis)));
1189  BOOST_CHECK(AxisWY::cross(f).isApprox(vaxis.cross(f)));
1190 
1191  vaxis << AxisWZ();
1192  BOOST_CHECK(AxisWZ::cross(v).isApprox(vaxis.cross(v)));
1193  BOOST_CHECK(v.cross(AxisWZ()).isApprox(v.cross(vaxis)));
1194  BOOST_CHECK(AxisWZ::cross(f).isApprox(vaxis.cross(f)));
1195 
1196  // Test operation Axis * Scalar
1203 
1204  // Operations of Constraint on forces Sxf
1205  typedef Motion::ActionMatrixType ActionMatrixType;
1206  typedef ActionMatrixType::ColXpr ColType;
1207  typedef ForceRef<ColType> ForceRefOnColType;
1208  typedef MotionRef<ColType> MotionRefOnColType;
1209  ActionMatrixType Sxf, Sxf_ref;
1210  ActionMatrixType S(ActionMatrixType::Identity());
1211 
1212  SpatialAxis<0>::cross(f, ForceRefOnColType(Sxf.col(0)));
1213  SpatialAxis<1>::cross(f, ForceRefOnColType(Sxf.col(1)));
1214  SpatialAxis<2>::cross(f, ForceRefOnColType(Sxf.col(2)));
1215  SpatialAxis<3>::cross(f, ForceRefOnColType(Sxf.col(3)));
1216  SpatialAxis<4>::cross(f, ForceRefOnColType(Sxf.col(4)));
1217  SpatialAxis<5>::cross(f, ForceRefOnColType(Sxf.col(5)));
1218 
1219  for (int k = 0; k < 6; ++k)
1220  {
1221  MotionRefOnColType Scol(S.col(k));
1222  ForceRefOnColType(Sxf_ref.col(k)) = Scol.cross(f);
1223  }
1224 
1225  BOOST_CHECK(Sxf.isApprox(Sxf_ref));
1226 }
1227 
1228 BOOST_AUTO_TEST_SUITE_END()
pinocchio::InertiaTpl< context::Scalar, context::Options >
pinocchio::PseudoInertiaTpl
A structure representing a pseudo inertia matrix.
Definition: spatial/fwd.hpp:62
act-on-set.hpp
Eigen
test-cpp2pybind11.m
m
Definition: test-cpp2pybind11.py:25
pinocchio::InertiaTpl< context::Scalar, context::Options >::FromEllipsoid
static InertiaTpl FromEllipsoid(const Scalar mass, const Scalar x, const Scalar y, const Scalar z)
Computes the Inertia of an ellipsoid defined by its mass and main semi-axis dimensions (x,...
Definition: spatial/inertia.hpp:389
test_scalar_multiplication_cartesian_axis::Axis
pinocchio::CartesianAxis< axis > Axis
Definition: spatial.cpp:1074
pinocchio::SE3Tpl< context::Scalar, context::Options >::Vector3
traits< SE3Tpl >::Vector3 Vector3
Definition: spatial/se3-tpl.hpp:55
d1
float d1
Mref
Mref
pinocchio::InertiaTpl::lever
const Vector3 & lever() const
Definition: spatial/inertia.hpp:848
pinocchio::motionSet::act
static void act(const Eigen::MatrixBase< Mat > &iV, const ForceDense< ForceDerived > &f, Eigen::MatrixBase< MatRet > const &jF)
Action of a motion set on a force object. The input motion set is represented by a 6xN matrix whose e...
test_scalar_multiplication::Scalar
double Scalar
Definition: spatial.cpp:1131
pinocchio::SE3Tpl::inverse
SE3Tpl inverse() const
aXb = bXa.inverse()
Definition: spatial/se3-tpl.hpp:149
pinocchio::u
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorIn1 > const Eigen::MatrixBase< ConfigVectorIn2 > const Scalar & u
Definition: joint-configuration.hpp:1139
pinocchio::motionSet::inertiaAction
static void inertiaAction(const InertiaTpl< Scalar, Options > &I, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Action of an Inertia matrix on a set of motions, represented by a 6xN matrix whose columns represent ...
pinocchio::InertiaTpl::variation
Matrix6 variation(const MotionDense< MotionDerived > &v) const
Definition: spatial/inertia.hpp:749
pinocchio::AxisWY
SpatialAxis< 4 > AxisWY
Definition: spatial-axis.hpp:151
quat
quat
pinocchio::MotionZero
MotionZeroTpl< context::Scalar, context::Options > MotionZero
Definition: spatial/fwd.hpp:71
pinocchio::AxisVX
SpatialAxis< 0 > AxisVX
Definition: spatial-axis.hpp:146
pinocchio.explog.exp
def exp(x)
Definition: bindings/python/pinocchio/explog.py:13
pinocchio::motionSet::motionAction
static void motionAction(const MotionDense< MotionDerived > &v, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Action of a motion on a set of motions, represented by a 6xN matrix whose columns represent a spatial...
pinocchio::SE3Tpl< context::Scalar, context::Options >
pinocchio::PseudoInertiaTpl::toDynamicParameters
Vector10 toDynamicParameters() const
Converts the PseudoInertiaTpl object to dynamic parameters.
Definition: spatial/inertia.hpp:1021
pinocchio::PseudoInertiaTpl::toInertia
InertiaTpl< Scalar, Options > toInertia() const
Converts the PseudoInertiaTpl object to an InertiaTpl object.
Definition: spatial/inertia.hpp:1053
Base
BVNodeBase Base
pinocchio::forceSet::se3ActionInverse
static void se3ActionInverse(const SE3Tpl< Scalar, Options > &m, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Inverse SE3 action on a set of forces, represented by a 6xN matrix whose each column represent a spat...
pinocchio::SE3Tpl::isNormalized
bool isNormalized(const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Definition: spatial/se3-tpl.hpp:390
ref
list ref
inertia.hpp
pinocchio::LogCholeskyParametersTpl::toPseudoInertia
PseudoInertia toPseudoInertia() const
Converts the LogCholeskyParametersTpl object to a PseudoInertiaTpl object.
Definition: spatial/inertia.hpp:1171
pinocchio::Symmetric3Tpl::isApprox
bool isApprox(const Symmetric3Tpl &other, const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Definition: spatial/symmetric3.hpp:146
pinocchio::LogCholeskyParametersTpl::parameters
Vector10 parameters
10-dimensional vector of log Cholesky parameters
Definition: spatial/inertia.hpp:1113
test_scalar_multiplication_cartesian_axis::Vector3
Eigen::Matrix< Scalar, 3, 1 > Vector3
Definition: spatial.cpp:1076
PINOCCHIO_COMPILER_DIAGNOSTIC_POP
#define PINOCCHIO_COMPILER_DIAGNOSTIC_POP
Definition: include/pinocchio/macros.hpp:130
pinocchio::AxisVY
SpatialAxis< 1 > AxisVY
Definition: spatial-axis.hpp:147
explog.hpp
quadrotor-ocp.cf
cf
Definition: quadrotor-ocp.py:22
pinocchio::InertiaTpl::vxiv
Force vxiv(const MotionDense< MotionDerived > &v) const
Definition: spatial/inertia.hpp:891
pinocchio::PseudoInertia
PseudoInertiaTpl< context::Scalar, context::Options > PseudoInertia
Definition: spatial/fwd.hpp:72
test_scalar_multiplication_cartesian_axis::Scalar
double Scalar
Definition: spatial.cpp:1075
pinocchio::res
ReturnType res
Definition: spatial/classic-acceleration.hpp:57
motion.hpp
pinocchio::LogCholeskyParameters
LogCholeskyParametersTpl< context::Scalar, context::Options > LogCholeskyParameters
Definition: spatial/fwd.hpp:73
autodiff-rnea.f
f
Definition: autodiff-rnea.py:24
pinocchio::forceSet::motionAction
static void motionAction(const MotionDense< MotionDerived > &v, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
Action of a motion on a set of forces, represented by a 6xN matrix whose each column represent a spat...
PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
#define PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_MAYBE_UNINITIALIZED
Definition: include/pinocchio/macros.hpp:134
pinocchio::motionSet::se3ActionInverse
static void se3ActionInverse(const SE3Tpl< Scalar, Options > &m, const Eigen::MatrixBase< Mat > &iV, Eigen::MatrixBase< MatRet > const &jV)
Inverse SE3 action on a set of motions, represented by a 6xN matrix whose column represent a spatial ...
b
Vec3f b
pinocchio::MotionBase
Definition: spatial/fwd.hpp:42
skew.hpp
pinocchio::MotionZeroTpl
Definition: context/casadi.hpp:23
pinocchio::InertiaTpl::toPseudoInertia
PseudoInertia toPseudoInertia() const
Convert the InertiaTpl object to a 4x4 pseudo inertia matrix.
Definition: spatial/inertia.hpp:591
pinocchio::AxisWZ
SpatialAxis< 5 > AxisWZ
Definition: spatial-axis.hpp:152
pinocchio::SE3Tpl< context::Scalar, context::Options >::Matrix3
traits< SE3Tpl >::Matrix3 Matrix3
Definition: spatial/se3-tpl.hpp:56
pinocchio::python::context::Quaternion
Eigen::Quaternion< Scalar, Options > Quaternion
Definition: bindings/python/context/generic.hpp:49
pinocchio::InertiaTpl< context::Scalar, context::Options >::Zero
static InertiaTpl Zero()
Definition: spatial/inertia.hpp:337
dpendulum.p
p
Definition: dpendulum.py:7
simulation-contact-dynamics.S
S
Definition: simulation-contact-dynamics.py:80
reachable-workspace-with-collisions.alpha
float alpha
Definition: reachable-workspace-with-collisions.py:162
pinocchio::InertiaTpl::inertia
const Symmetric3 & inertia() const
Definition: spatial/inertia.hpp:852
pinocchio::CartesianAxis::dim
@ dim
Definition: cartesian-axis.hpp:19
bv
BV bv
pinocchio::InertiaTpl::mass
Scalar mass() const
Definition: spatial/inertia.hpp:844
pinocchio::InertiaTpl< context::Scalar, context::Options >::FromLogCholeskyParameters
static InertiaTpl FromLogCholeskyParameters(const LogCholeskyParameters &log_cholesky)
Create an InertiaTpl object from log Cholesky parameters.
Definition: spatial/inertia.hpp:604
test_scalar_multiplication_cartesian_axis
Definition: spatial.cpp:1072
test_scalar_multiplication::Axis
pinocchio::SpatialAxis< axis > Axis
Definition: spatial.cpp:1130
cartesian-axis.hpp
t2
dictionary t2
pinocchio::SE3Tpl< context::Scalar, context::Options >::Vector4
traits< SE3Tpl >::Vector4 Vector4
Definition: spatial/se3-tpl.hpp:58
dcrba.Mp
Mp
Definition: dcrba.py:449
pinocchio::skew
void skew(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3 > &M)
Computes the skew representation of a given 3d vector, i.e. the antisymmetric matrix representation o...
Definition: skew.hpp:22
pinocchio::LogCholeskyParametersTpl
A structure representing log Cholesky parameters.
Definition: spatial/fwd.hpp:64
se3.hpp
test_scalar_multiplication
Definition: spatial.cpp:1128
anymal-simulation.N
int N
Definition: anymal-simulation.py:53
cartpole.v
v
Definition: cartpole.py:153
pinocchio::SE3Tpl::rotation
ConstAngularRef rotation() const
Definition: se3-base.hpp:48
pinocchio::ForceTpl
Definition: context/casadi.hpp:25
pinocchio::InertiaTpl< context::Scalar, context::Options >::FromCapsule
static InertiaTpl FromCapsule(const Scalar mass, const Scalar radius, const Scalar height)
Computes the Inertia of a capsule defined by its mass, radius and length along the Z axis....
Definition: spatial/inertia.hpp:439
pinocchio::SE3Tpl::isIdentity
bool isIdentity(const Scalar &prec=Eigen::NumTraits< Scalar >::dummy_precision()) const
Definition: spatial/se3-tpl.hpp:347
pinocchio::forceSet::se3Action
static void se3Action(const SE3Tpl< Scalar, Options > &m, const Eigen::MatrixBase< Mat > &iF, Eigen::MatrixBase< MatRet > const &jF)
SE3 action on a set of forces, represented by a 6xN matrix whose each column represent a spatial forc...
pinocchio::InertiaTpl< context::Scalar, context::Options >::Random
static InertiaTpl Random()
Definition: spatial/inertia.hpp:361
PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
#define PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
macros for pragma push/pop/ignore deprecated warnings
Definition: include/pinocchio/macros.hpp:129
M
M
pinocchio::context::Vector3
Eigen::Matrix< Scalar, 3, 1, Options > Vector3
Definition: context/generic.hpp:53
axis
axis
pinocchio::LogCholeskyParametersTpl::calculateJacobian
Matrix10 calculateJacobian() const
Calculates the Jacobian of the log Cholesky parameters.
Definition: spatial/inertia.hpp:1191
test_scalar_multiplication_cartesian_axis::run
static void run()
Definition: spatial.cpp:1078
pinocchio::PseudoInertiaTpl::FromMatrix
static PseudoInertiaTpl FromMatrix(const Matrix4 &pseudo_inertia)
Constructs a PseudoInertiaTpl object from a 4x4 pseudo inertia matrix.
Definition: spatial/inertia.hpp:986
pinocchio::InertiaTpl::toDynamicParameters
Vector10 toDynamicParameters() const
Definition: spatial/inertia.hpp:541
pinocchio::jacobian
void jacobian(const ConstraintModelTpl< Scalar, Options, ConstraintCollectionTpl > &cmodel, ConstraintDataTpl< Scalar, Options, ConstraintCollectionTpl > &cdata, const ModelTpl< Scalar, Options, JointCollectionTpl > &model, const DataTpl< Scalar, Options, JointCollectionTpl > &data, const Eigen::MatrixBase< JacobianMatrix > &jacobian_matrix)
Definition: constraint-model-visitor.hpp:199
pinocchio::MotionTpl::Random
static MotionTpl Random()
Definition: motion-tpl.hpp:140
pinocchio::Motion
MotionTpl<::CppAD::AD< double >, 0 > Motion
Definition: context/cppad.hpp:37
pinocchio::ForceTpl::Random
static ForceTpl Random()
Definition: force-tpl.hpp:114
pinocchio::skewSquare
void skewSquare(const Eigen::MatrixBase< V1 > &u, const Eigen::MatrixBase< V2 > &v, const Eigen::MatrixBase< Matrix3 > &C)
Computes the square cross product linear operator C(u,v) such that for any vector w,...
Definition: skew.hpp:182
pinocchio::Symmetric3Tpl::matrix
Matrix3 matrix() const
Definition: spatial/symmetric3.hpp:304
a
Vec3f a
pinocchio::v
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > const Eigen::MatrixBase< TangentVectorType > & v
Definition: joint-configuration.hpp:1084
pinocchio::SE3Tpl< context::Scalar, context::Options >::Quaternion
Eigen::Quaternion< Scalar, Options > Quaternion
Definition: spatial/se3-tpl.hpp:54
pinocchio::InertiaTpl< context::Scalar, context::Options >::Vector10
Eigen::Matrix< Scalar, 10, 1, Options > Vector10
Definition: spatial/inertia.hpp:275
pinocchio::SE3Tpl::cast
SE3Tpl< NewScalar, Options > cast() const
Definition: spatial/se3-tpl.hpp:379
pinocchio::ForceRef
Definition: force-ref.hpp:53
pinocchio::Symmetric3Tpl< context::Scalar, context::Options >
pinocchio::Force
ForceTpl< context::Scalar, context::Options > Force
Definition: spatial/fwd.hpp:68
pinocchio::SE3Tpl::Random
static SE3Tpl Random()
Definition: spatial/se3-tpl.hpp:154
ocp.U
U
Definition: ocp.py:80
pinocchio::InertiaTpl< context::Scalar, context::Options >::FromDynamicParameters
static InertiaTpl FromDynamicParameters(const Eigen::MatrixBase< Vector10Like > &params)
Definition: spatial/inertia.hpp:561
pinocchio::InertiaTpl< context::Scalar, context::Options >::Identity
static InertiaTpl Identity()
Definition: spatial/inertia.hpp:349
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(test_SE3)
Definition: spatial.cpp:22
pinocchio::MotionTpl::Zero
static MotionTpl Zero()
Definition: motion-tpl.hpp:136
r2
r2
spatial-axis.hpp
pinocchio::SE3Tpl::Identity
static SE3Tpl Identity()
Definition: spatial/se3-tpl.hpp:136
pinocchio::cross
void cross(const Eigen::MatrixBase< Vector3 > &v, const Eigen::MatrixBase< Matrix3xIn > &Min, const Eigen::MatrixBase< Matrix3xOut > &Mout)
Applies the cross product onto the columns of M.
Definition: skew.hpp:228
boost::fusion
Definition: fusion.hpp:27
test_scalar_multiplication::run
static void run()
Definition: spatial.cpp:1134
pinocchio::LogCholeskyParametersTpl::toDynamicParameters
Vector10 toDynamicParameters() const
Converts the LogCholeskyParametersTpl object to dynamic parameters.
Definition: spatial/inertia.hpp:1126
pinocchio::AxisWX
SpatialAxis< 3 > AxisWX
Definition: spatial-axis.hpp:150
test_scalar_multiplication::Motion
pinocchio::MotionTpl< Scalar > Motion
Definition: spatial.cpp:1132
dcrba.eps
int eps
Definition: dcrba.py:458
pinocchio::PseudoInertiaTpl::toMatrix
Matrix4 toMatrix() const
Converts the PseudoInertiaTpl object to a 4x4 matrix.
Definition: spatial/inertia.hpp:971
simulation-contact-dynamics.v_ref
v_ref
Definition: simulation-contact-dynamics.py:55
Y
Y
pinocchio::InertiaTpl< context::Scalar, context::Options >::FromBox
static InertiaTpl FromBox(const Scalar mass, const Scalar x, const Scalar y, const Scalar z)
Computes the Inertia of a box defined by its mass and main dimensions (x,y,z).
Definition: spatial/inertia.hpp:423
pinocchio::ForceTpl::Zero
static ForceTpl Zero()
Definition: force-tpl.hpp:110
pinocchio::InertiaTpl< context::Scalar, context::Options >::FromSphere
static InertiaTpl FromSphere(const Scalar mass, const Scalar radius)
Computes the Inertia of a sphere defined by its mass and its radius.
Definition: spatial/inertia.hpp:374
Base
pinocchio::motionSet::se3Action
static void se3Action(const SE3Tpl< Scalar, Options > &m, const Eigen::MatrixBase< Mat > &iV, Eigen::MatrixBase< MatRet > const &jV)
SE3 action on a set of motions, represented by a 6xN matrix whose column represent a spatial motion.
pinocchio.utils.rand
def rand(n)
Definition: bindings/python/pinocchio/utils.py:41
pinocchio::MotionTpl
Definition: context/casadi.hpp:27
pinocchio::unSkew
void unSkew(const Eigen::MatrixBase< Matrix3 > &M, const Eigen::MatrixBase< Vector3 > &v)
Inverse of skew operator. From a given skew-symmetric matrix M of dimension 3x3, it extracts the supp...
Definition: skew.hpp:93
pinocchio::AxisVZ
SpatialAxis< 2 > AxisVZ
Definition: spatial-axis.hpp:148
force.hpp
pinocchio::InertiaTpl< context::Scalar, context::Options >::FromCylinder
static InertiaTpl FromCylinder(const Scalar mass, const Scalar radius, const Scalar length)
Computes the Inertia of a cylinder defined by its mass, radius and length along the Z axis.
Definition: spatial/inertia.hpp:406
pinocchio::MotionRef
Definition: context/casadi.hpp:38
pinocchio::SpatialAxis
Definition: spatial-axis.hpp:16
simulation-closed-kinematic-chains.rhs
rhs
Definition: simulation-closed-kinematic-chains.py:138
pinocchio::addSkew
void addSkew(const Eigen::MatrixBase< Vector3Like > &v, const Eigen::MatrixBase< Matrix3Like > &M)
Add skew matrix represented by a 3d vector to a given matrix, i.e. add the antisymmetric matrix repre...
Definition: skew.hpp:68
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27
isApprox
bool isApprox(const Box &s1, const Box &s2, const FCL_REAL tol)
pinocchio::CartesianAxis
Definition: cartesian-axis.hpp:14


pinocchio
Author(s):
autogenerated on Thu Dec 19 2024 03:41:32