GCC Code Coverage Report


Directory: ./
File: include/pinocchio/multibody/joint/joint-prismatic.hpp
Date: 2025-04-30 16:14:33
Exec Total Coverage
Lines: 172 180 95.6%
Branches: 130 318 40.9%

Line Branch Exec Source
1 //
2 // Copyright (c) 2015-2020 CNRS INRIA
3 // Copyright (c) 2015-2016 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4 //
5
6 #ifndef __pinocchio_multibody_joint_prismatic_hpp__
7 #define __pinocchio_multibody_joint_prismatic_hpp__
8
9 #include "pinocchio/macros.hpp"
10 #include "pinocchio/multibody/joint/joint-base.hpp"
11 #include "pinocchio/multibody/joint-motion-subspace.hpp"
12 #include "pinocchio/spatial/inertia.hpp"
13 #include "pinocchio/spatial/spatial-axis.hpp"
14 #include "pinocchio/utils/axis-label.hpp"
15
16 namespace pinocchio
17 {
18
19 template<typename Scalar, int Options, int _axis>
20 struct MotionPrismaticTpl;
21
22 template<typename Scalar, int Options, int axis>
23 struct SE3GroupAction<MotionPrismaticTpl<Scalar, Options, axis>>
24 {
25 typedef MotionTpl<Scalar, Options> ReturnType;
26 };
27
28 template<typename Scalar, int Options, int axis, typename MotionDerived>
29 struct MotionAlgebraAction<MotionPrismaticTpl<Scalar, Options, axis>, MotionDerived>
30 {
31 typedef MotionTpl<Scalar, Options> ReturnType;
32 };
33
34 template<typename _Scalar, int _Options, int _axis>
35 struct traits<MotionPrismaticTpl<_Scalar, _Options, _axis>>
36 {
37 typedef _Scalar Scalar;
38 enum
39 {
40 Options = _Options
41 };
42 typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3;
43 typedef Eigen::Matrix<Scalar, 6, 1, Options> Vector6;
44 typedef Eigen::Matrix<Scalar, 4, 4, Options> Matrix4;
45 typedef Eigen::Matrix<Scalar, 6, 6, Options> Matrix6;
46 typedef typename PINOCCHIO_EIGEN_REF_CONST_TYPE(Vector6) ToVectorConstReturnType;
47 typedef typename PINOCCHIO_EIGEN_REF_TYPE(Vector6) ToVectorReturnType;
48 typedef Vector3 AngularType;
49 typedef Vector3 LinearType;
50 typedef const Vector3 ConstAngularType;
51 typedef const Vector3 ConstLinearType;
52 typedef Matrix6 ActionMatrixType;
53 typedef Matrix4 HomogeneousMatrixType;
54 typedef MotionTpl<Scalar, Options> MotionPlain;
55 typedef MotionPlain PlainReturnType;
56 enum
57 {
58 LINEAR = 0,
59 ANGULAR = 3
60 };
61 }; // struct traits MotionPrismaticTpl
62
63 template<typename _Scalar, int _Options, int _axis>
64 struct MotionPrismaticTpl : MotionBase<MotionPrismaticTpl<_Scalar, _Options, _axis>>
65 {
66 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
67 MOTION_TYPEDEF_TPL(MotionPrismaticTpl);
68
69 enum
70 {
71 axis = _axis
72 };
73
74 typedef SpatialAxis<_axis + LINEAR> Axis;
75 typedef typename Axis::CartesianAxis3 CartesianAxis3;
76
77 42 MotionPrismaticTpl()
78 {
79 42 }
80 19152 MotionPrismaticTpl(const Scalar & v)
81 19182 : m_v(v)
82 {
83 19182 }
84
85 6202 inline PlainReturnType plain() const
86 {
87
1/2
✓ Branch 1 taken 3101 times.
✗ Branch 2 not taken.
12404 return Axis() * m_v;
88 }
89
90 template<typename OtherScalar>
91 MotionPrismaticTpl __mult__(const OtherScalar & alpha) const
92 {
93 return MotionPrismaticTpl(alpha * m_v);
94 }
95
96 template<typename Derived>
97 14 void addTo(MotionDense<Derived> & other) const
98 {
99 typedef typename MotionDense<Derived>::Scalar OtherScalar;
100
3/6
✓ Branch 2 taken 7 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
14 other.linear()[_axis] += (OtherScalar)m_v;
101 }
102
103 template<typename MotionDerived>
104 38 void setTo(MotionDense<MotionDerived> & other) const
105 {
106
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 19 times.
152 for (Eigen::DenseIndex k = 0; k < 3; ++k)
107 {
108
6/9
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 38 times.
✓ Branch 4 taken 54 times.
✓ Branch 5 taken 3 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 3 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 3 times.
✗ Branch 12 not taken.
114 other.linear()[k] = k == axis ? m_v : Scalar(0);
109 }
110
1/2
✓ Branch 2 taken 19 times.
✗ Branch 3 not taken.
38 other.angular().setZero();
111 38 }
112
113 template<typename S2, int O2, typename D2>
114 10 void se3Action_impl(const SE3Tpl<S2, O2> & m, MotionDense<D2> & v) const
115 {
116
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
10 v.angular().setZero();
117
4/8
✓ Branch 3 taken 5 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 5 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 5 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 5 times.
✗ Branch 13 not taken.
10 v.linear().noalias() = m_v * (m.rotation().col(axis));
118 10 }
119
120 template<typename S2, int O2>
121 10 MotionPlain se3Action_impl(const SE3Tpl<S2, O2> & m) const
122 {
123 10 MotionPlain res;
124
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
10 se3Action_impl(m, res);
125 10 return res;
126 }
127
128 template<typename S2, int O2, typename D2>
129 22 void se3ActionInverse_impl(const SE3Tpl<S2, O2> & m, MotionDense<D2> & v) const
130 {
131 // Linear
132
5/10
✓ Branch 3 taken 11 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 11 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 11 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 11 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 11 times.
✗ Branch 16 not taken.
22 v.linear().noalias() = m_v * (m.rotation().transpose().col(axis));
133
134 // Angular
135
1/2
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
22 v.angular().setZero();
136 22 }
137
138 template<typename S2, int O2>
139 22 MotionPlain se3ActionInverse_impl(const SE3Tpl<S2, O2> & m) const
140 {
141 22 MotionPlain res;
142
0/2
✗ Branch 1 not taken.
✗ Branch 2 not taken.
22 se3ActionInverse_impl(m, res);
143 22 return res;
144 }
145
146 template<typename M1, typename M2>
147 24 void motionAction(const MotionDense<M1> & v, MotionDense<M2> & mout) const
148 {
149 // Linear
150
3/6
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 12 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
24 CartesianAxis3::alphaCross(-m_v, v.angular(), mout.linear());
151
152 // Angular
153
1/2
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 mout.angular().setZero();
154 24 }
155
156 template<typename M1>
157 24 MotionPlain motionAction(const MotionDense<M1> & v) const
158 {
159 24 MotionPlain res;
160
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
24 motionAction(v, res);
161 24 return res;
162 }
163
164 6434 Scalar & linearRate()
165 {
166 6434 return m_v;
167 }
168 const Scalar & linearRate() const
169 {
170 return m_v;
171 }
172
173 102 bool isEqual_impl(const MotionPrismaticTpl & other) const
174 {
175 102 return internal::comparison_eq(m_v, other.m_v);
176 }
177
178 protected:
179 Scalar m_v;
180 }; // struct MotionPrismaticTpl
181
182 template<typename Scalar, int Options, int axis, typename MotionDerived>
183 typename MotionDerived::MotionPlain operator+(
184 const MotionPrismaticTpl<Scalar, Options, axis> & m1, const MotionDense<MotionDerived> & m2)
185 {
186 typename MotionDerived::MotionPlain res(m2);
187 res += m1;
188 return res;
189 }
190
191 template<typename MotionDerived, typename S2, int O2, int axis>
192 EIGEN_STRONG_INLINE typename MotionDerived::MotionPlain
193 18 operator^(const MotionDense<MotionDerived> & m1, const MotionPrismaticTpl<S2, O2, axis> & m2)
194 {
195 18 return m2.motionAction(m1);
196 }
197
198 template<typename Scalar, int Options, int axis>
199 struct TransformPrismaticTpl;
200
201 template<typename _Scalar, int _Options, int _axis>
202 struct traits<TransformPrismaticTpl<_Scalar, _Options, _axis>>
203 {
204 enum
205 {
206 axis = _axis,
207 Options = _Options,
208 LINEAR = 0,
209 ANGULAR = 3
210 };
211 typedef _Scalar Scalar;
212 typedef SE3Tpl<Scalar, Options> PlainType;
213 typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3;
214 typedef Eigen::Matrix<Scalar, 3, 3, Options> Matrix3;
215 typedef typename Matrix3::IdentityReturnType AngularType;
216 typedef AngularType AngularRef;
217 typedef AngularType ConstAngularRef;
218 typedef Vector3 LinearType;
219 typedef const Vector3 LinearRef;
220 typedef const Vector3 ConstLinearRef;
221 typedef typename traits<PlainType>::ActionMatrixType ActionMatrixType;
222 typedef typename traits<PlainType>::HomogeneousMatrixType HomogeneousMatrixType;
223 }; // traits TransformPrismaticTpl
224
225 template<typename Scalar, int Options, int axis>
226 struct SE3GroupAction<TransformPrismaticTpl<Scalar, Options, axis>>
227 {
228 typedef typename traits<TransformPrismaticTpl<Scalar, Options, axis>>::PlainType ReturnType;
229 };
230
231 template<typename _Scalar, int _Options, int axis>
232 struct TransformPrismaticTpl : SE3Base<TransformPrismaticTpl<_Scalar, _Options, axis>>
233 {
234 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
235 PINOCCHIO_SE3_TYPEDEF_TPL(TransformPrismaticTpl);
236
237 typedef SpatialAxis<axis + LINEAR> Axis;
238 typedef typename Axis::CartesianAxis3 CartesianAxis3;
239
240 42 TransformPrismaticTpl()
241 {
242 42 }
243 19132 TransformPrismaticTpl(const Scalar & displacement)
244 19162 : m_displacement(displacement)
245 {
246 19162 }
247
248 36904 PlainType plain() const
249 {
250 36904 PlainType res(PlainType::Identity());
251
2/4
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
36904 res.rotation().setIdentity();
252
3/6
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4 times.
✗ Branch 8 not taken.
36904 res.translation()[axis] = m_displacement;
253
254 36904 return res;
255 }
256
257 36904 operator PlainType() const
258 {
259 36904 return plain();
260 }
261
262 template<typename S2, int O2>
263 typename SE3GroupAction<TransformPrismaticTpl>::ReturnType
264 se3action(const SE3Tpl<S2, O2> & m) const
265 {
266 typedef typename SE3GroupAction<TransformPrismaticTpl>::ReturnType ReturnType;
267 ReturnType res(m);
268 res.translation()[axis] += m_displacement;
269
270 return res;
271 }
272
273 8 const Scalar & displacement() const
274 {
275 8 return m_displacement;
276 }
277 37118 Scalar & displacement()
278 {
279 37118 return m_displacement;
280 }
281
282 8 ConstLinearRef translation() const
283 {
284
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
16 return CartesianAxis3() * displacement();
285 };
286 5 AngularType rotation() const
287 {
288
1/2
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
8 return AngularType(3, 3);
289 }
290
291 102 bool isEqual(const TransformPrismaticTpl & other) const
292 {
293 102 return internal::comparison_eq(m_displacement, other.m_displacement);
294 }
295
296 protected:
297 Scalar m_displacement;
298 };
299
300 template<typename Scalar, int Options, int axis>
301 struct JointMotionSubspacePrismaticTpl;
302
303 template<typename _Scalar, int _Options, int axis>
304 struct traits<JointMotionSubspacePrismaticTpl<_Scalar, _Options, axis>>
305 {
306 typedef _Scalar Scalar;
307 enum
308 {
309 Options = _Options
310 };
311 enum
312 {
313 LINEAR = 0,
314 ANGULAR = 3
315 };
316 typedef MotionPrismaticTpl<Scalar, Options, axis> JointMotion;
317 typedef Eigen::Matrix<Scalar, 1, 1, Options> JointForce;
318 typedef Eigen::Matrix<Scalar, 6, 1, Options> DenseBase;
319 typedef Eigen::Matrix<Scalar, 1, 1, Options> ReducedSquaredMatrix;
320
321 typedef DenseBase MatrixReturnType;
322 typedef const DenseBase ConstMatrixReturnType;
323
324 typedef typename ReducedSquaredMatrix::IdentityReturnType StDiagonalMatrixSOperationReturnType;
325 }; // traits ConstraintRevolute
326
327 template<typename Scalar, int Options, int axis>
328 struct SE3GroupAction<JointMotionSubspacePrismaticTpl<Scalar, Options, axis>>
329 {
330 typedef Eigen::Matrix<Scalar, 6, 1, Options> ReturnType;
331 };
332
333 template<typename Scalar, int Options, int axis, typename MotionDerived>
334 struct MotionAlgebraAction<JointMotionSubspacePrismaticTpl<Scalar, Options, axis>, MotionDerived>
335 {
336 typedef Eigen::Matrix<Scalar, 6, 1, Options> ReturnType;
337 };
338
339 template<typename Scalar, int Options, int axis, typename ForceDerived>
340 struct ConstraintForceOp<JointMotionSubspacePrismaticTpl<Scalar, Options, axis>, ForceDerived>
341 {
342 typedef typename ForceDense<
343 ForceDerived>::ConstLinearType::template ConstFixedSegmentReturnType<1>::Type ReturnType;
344 };
345
346 template<typename Scalar, int Options, int axis, typename ForceSet>
347 struct ConstraintForceSetOp<JointMotionSubspacePrismaticTpl<Scalar, Options, axis>, ForceSet>
348 {
349 typedef typename Eigen::MatrixBase<ForceSet>::ConstRowXpr ReturnType;
350 };
351
352 template<typename _Scalar, int _Options, int axis>
353 struct JointMotionSubspacePrismaticTpl
354 : JointMotionSubspaceBase<JointMotionSubspacePrismaticTpl<_Scalar, _Options, axis>>
355 {
356 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
357 PINOCCHIO_CONSTRAINT_TYPEDEF_TPL(JointMotionSubspacePrismaticTpl)
358 enum
359 {
360 NV = 1
361 };
362
363 typedef SpatialAxis<LINEAR + axis> Axis;
364
365 19197 JointMotionSubspacePrismaticTpl() {};
366
367 template<typename Vector1Like>
368 20 JointMotion __mult__(const Eigen::MatrixBase<Vector1Like> & v) const
369 {
370 EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(Vector1Like, 1);
371
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
20 assert(v.size() == 1);
372
0/2
✗ Branch 2 not taken.
✗ Branch 3 not taken.
20 return JointMotion(v[0]);
373 }
374
375 template<typename S2, int O2>
376 typename SE3GroupAction<JointMotionSubspacePrismaticTpl>::ReturnType
377 40 se3Action(const SE3Tpl<S2, O2> & m) const
378 {
379
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
40 typename SE3GroupAction<JointMotionSubspacePrismaticTpl>::ReturnType res;
380
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
40 MotionRef<DenseBase> v(res);
381
4/8
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 20 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 20 times.
✗ Branch 11 not taken.
40 v.linear() = m.rotation().col(axis);
382
2/4
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 20 times.
✗ Branch 5 not taken.
40 v.angular().setZero();
383 80 return res;
384 }
385
386 template<typename S2, int O2>
387 typename SE3GroupAction<JointMotionSubspacePrismaticTpl>::ReturnType
388 38 se3ActionInverse(const SE3Tpl<S2, O2> & m) const
389 {
390
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
38 typename SE3GroupAction<JointMotionSubspacePrismaticTpl>::ReturnType res;
391
1/2
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
38 MotionRef<DenseBase> v(res);
392
5/10
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 19 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 19 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 19 times.
✗ Branch 14 not taken.
38 v.linear() = m.rotation().transpose().col(axis);
393
2/4
✓ Branch 1 taken 19 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 19 times.
✗ Branch 5 not taken.
38 v.angular().setZero();
394 76 return res;
395 }
396
397 108 int nv_impl() const
398 {
399 108 return NV;
400 }
401
402 struct TransposeConst : JointMotionSubspaceTransposeBase<JointMotionSubspacePrismaticTpl>
403 {
404 const JointMotionSubspacePrismaticTpl & ref;
405 38 TransposeConst(const JointMotionSubspacePrismaticTpl & ref)
406 38 : ref(ref)
407 {
408 38 }
409
410 template<typename ForceDerived>
411 typename ConstraintForceOp<JointMotionSubspacePrismaticTpl, ForceDerived>::ReturnType
412 24 operator*(const ForceDense<ForceDerived> & f) const
413 {
414
1/2
✓ Branch 2 taken 12 times.
✗ Branch 3 not taken.
24 return f.linear().template segment<1>(axis);
415 }
416
417 /* [CRBA] MatrixBase operator* (Constraint::Transpose S, ForceSet::Block) */
418 template<typename Derived>
419 typename ConstraintForceSetOp<JointMotionSubspacePrismaticTpl, Derived>::ReturnType
420 8 operator*(const Eigen::MatrixBase<Derived> & F)
421 {
422
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
8 assert(F.rows() == 6);
423 8 return F.row(LINEAR + axis);
424 }
425
426 }; // struct TransposeConst
427 38 TransposeConst transpose() const
428 {
429 38 return TransposeConst(*this);
430 }
431
432 /* CRBA joint operators
433 * - ForceSet::Block = ForceSet
434 * - ForceSet operator* (Inertia Y,Constraint S)
435 * - MatrixBase operator* (Constraint::Transpose S, ForceSet::Block)
436 * - SE3::act(ForceSet::Block)
437 */
438 122 DenseBase matrix_impl() const
439 {
440
1/2
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
122 DenseBase S;
441
1/2
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
122 MotionRef<DenseBase> v(S);
442
1/2
✓ Branch 1 taken 61 times.
✗ Branch 2 not taken.
122 v << Axis();
443 244 return S;
444 }
445
446 template<typename MotionDerived>
447 typename MotionAlgebraAction<JointMotionSubspacePrismaticTpl, MotionDerived>::ReturnType
448 12 motionAction(const MotionDense<MotionDerived> & m) const
449 {
450
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 typename MotionAlgebraAction<JointMotionSubspacePrismaticTpl, MotionDerived>::ReturnType res;
451
1/2
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
12 MotionRef<DenseBase> v(res);
452
2/4
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
12 v = m.cross(Axis());
453 24 return res;
454 }
455
456 102 bool isEqual(const JointMotionSubspacePrismaticTpl &) const
457 {
458 102 return true;
459 }
460
461 }; // struct JointMotionSubspacePrismaticTpl
462
463 template<typename S1, int O1, typename S2, int O2, int axis>
464 struct MultiplicationOp<InertiaTpl<S1, O1>, JointMotionSubspacePrismaticTpl<S2, O2, axis>>
465 {
466 typedef Eigen::Matrix<S2, 6, 1, O2> ReturnType;
467 };
468
469 /* [CRBA] ForceSet operator* (Inertia Y,Constraint S) */
470 namespace impl
471 {
472 template<typename S1, int O1, typename S2, int O2>
473 struct LhsMultiplicationOp<InertiaTpl<S1, O1>, JointMotionSubspacePrismaticTpl<S2, O2, 0>>
474 {
475 typedef InertiaTpl<S1, O1> Inertia;
476 typedef JointMotionSubspacePrismaticTpl<S2, O2, 0> Constraint;
477 typedef typename MultiplicationOp<Inertia, Constraint>::ReturnType ReturnType;
478 3 static inline ReturnType run(const Inertia & Y, const Constraint & /*constraint*/)
479 {
480
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 ReturnType res;
481
482 /* Y(:,0) = ( 1,0, 0, 0 , z , -y ) */
483
2/10
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 3 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
3 const S1 &m = Y.mass(), &y = Y.lever()[1], &z = Y.lever()[2];
484
6/24
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 3 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 3 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 3 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 3 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
3 res << m, S1(0), S1(0), S1(0), m * z, -m * y;
485
486 6 return res;
487 }
488 };
489
490 template<typename S1, int O1, typename S2, int O2>
491 struct LhsMultiplicationOp<InertiaTpl<S1, O1>, JointMotionSubspacePrismaticTpl<S2, O2, 1>>
492 {
493 typedef InertiaTpl<S1, O1> Inertia;
494 typedef JointMotionSubspacePrismaticTpl<S2, O2, 1> Constraint;
495 typedef typename MultiplicationOp<Inertia, Constraint>::ReturnType ReturnType;
496 2 static inline ReturnType run(const Inertia & Y, const Constraint & /*constraint*/)
497 {
498
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ReturnType res;
499
500 /* Y(:,1) = ( 0,1, 0, -z , 0 , x) */
501
2/10
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
2 const S1 &m = Y.mass(), &x = Y.lever()[0], &z = Y.lever()[2];
502
503
6/24
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
2 res << S1(0), m, S1(0), -m * z, S1(0), m * x;
504
505 4 return res;
506 }
507 };
508
509 template<typename S1, int O1, typename S2, int O2>
510 struct LhsMultiplicationOp<InertiaTpl<S1, O1>, JointMotionSubspacePrismaticTpl<S2, O2, 2>>
511 {
512 typedef InertiaTpl<S1, O1> Inertia;
513 typedef JointMotionSubspacePrismaticTpl<S2, O2, 2> Constraint;
514 typedef typename MultiplicationOp<Inertia, Constraint>::ReturnType ReturnType;
515 2 static inline ReturnType run(const Inertia & Y, const Constraint & /*constraint*/)
516 {
517
1/2
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
2 ReturnType res;
518
519 /* Y(:,2) = ( 0,0, 1, y , -x , 0) */
520
2/10
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
2 const S1 &m = Y.mass(), &x = Y.lever()[0], &y = Y.lever()[1];
521
522
6/24
✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 2 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 2 times.
✗ Branch 11 not taken.
✓ Branch 13 taken 2 times.
✗ Branch 14 not taken.
✓ Branch 16 taken 2 times.
✗ Branch 17 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
2 res << S1(0), S1(0), m, m * y, -m * x, S1(0);
523
524 4 return res;
525 }
526 };
527 } // namespace impl
528
529 template<typename M6Like, typename S2, int O2, int axis>
530 struct MultiplicationOp<Eigen::MatrixBase<M6Like>, JointMotionSubspacePrismaticTpl<S2, O2, axis>>
531 {
532 typedef typename M6Like::ConstColXpr ReturnType;
533 };
534
535 /* [ABA] operator* (Inertia Y,Constraint S) */
536 namespace impl
537 {
538 template<typename M6Like, typename Scalar, int Options, int axis>
539 struct LhsMultiplicationOp<
540 Eigen::MatrixBase<M6Like>,
541 JointMotionSubspacePrismaticTpl<Scalar, Options, axis>>
542 {
543 typedef JointMotionSubspacePrismaticTpl<Scalar, Options, axis> Constraint;
544 typedef
545 typename MultiplicationOp<Eigen::MatrixBase<M6Like>, Constraint>::ReturnType ReturnType;
546 static inline ReturnType
547 12 run(const Eigen::MatrixBase<M6Like> & Y, const Constraint & /*constraint*/)
548 {
549 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(M6Like, 6, 6);
550 12 return Y.derived().col(Inertia::LINEAR + axis);
551 }
552 };
553 } // namespace impl
554
555 template<typename _Scalar, int _Options, int _axis>
556 struct JointPrismaticTpl
557 {
558 typedef _Scalar Scalar;
559
560 enum
561 {
562 Options = _Options,
563 axis = _axis
564 };
565 };
566
567 template<typename _Scalar, int _Options, int axis>
568 struct traits<JointPrismaticTpl<_Scalar, _Options, axis>>
569 {
570 enum
571 {
572 NQ = 1,
573 NV = 1,
574 NVExtended = 1
575 };
576 typedef _Scalar Scalar;
577 enum
578 {
579 Options = _Options
580 };
581 typedef JointDataPrismaticTpl<Scalar, Options, axis> JointDataDerived;
582 typedef JointModelPrismaticTpl<Scalar, Options, axis> JointModelDerived;
583 typedef JointMotionSubspacePrismaticTpl<Scalar, Options, axis> Constraint_t;
584 typedef TransformPrismaticTpl<Scalar, Options, axis> Transformation_t;
585 typedef MotionPrismaticTpl<Scalar, Options, axis> Motion_t;
586 typedef MotionZeroTpl<Scalar, Options> Bias_t;
587
588 // [ABA]
589 typedef Eigen::Matrix<Scalar, 6, NV, Options> U_t;
590 typedef Eigen::Matrix<Scalar, NV, NV, Options> D_t;
591 typedef Eigen::Matrix<Scalar, 6, NV, Options> UD_t;
592
593 typedef Eigen::Matrix<Scalar, NQ, 1, Options> ConfigVector_t;
594 typedef Eigen::Matrix<Scalar, NV, 1, Options> TangentVector_t;
595
596 typedef boost::mpl::true_ is_mimicable_t;
597
598 PINOCCHIO_JOINT_DATA_BASE_ACCESSOR_DEFAULT_RETURN_TYPE
599 };
600
601 template<typename _Scalar, int _Options, int axis>
602 struct traits<JointDataPrismaticTpl<_Scalar, _Options, axis>>
603 {
604 typedef JointPrismaticTpl<_Scalar, _Options, axis> JointDerived;
605 typedef _Scalar Scalar;
606 };
607
608 template<typename _Scalar, int _Options, int axis>
609 struct traits<JointModelPrismaticTpl<_Scalar, _Options, axis>>
610 {
611 typedef JointPrismaticTpl<_Scalar, _Options, axis> JointDerived;
612 typedef _Scalar Scalar;
613 };
614
615 template<typename _Scalar, int _Options, int axis>
616 struct JointDataPrismaticTpl
617 : public JointDataBase<JointDataPrismaticTpl<_Scalar, _Options, axis>>
618 {
619 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
620 typedef JointPrismaticTpl<_Scalar, _Options, axis> JointDerived;
621 PINOCCHIO_JOINT_DATA_TYPEDEF_TEMPLATE(JointDerived);
622 2712 PINOCCHIO_JOINT_DATA_BASE_DEFAULT_ACCESSOR
623
624 ConfigVector_t joint_q;
625 TangentVector_t joint_v;
626
627 Constraint_t S;
628 Transformation_t M;
629 Motion_t v;
630 Bias_t c;
631
632 // [ABA] specific data
633 U_t U;
634 D_t Dinv;
635 UD_t UDinv;
636 D_t StU;
637
638 19155 JointDataPrismaticTpl()
639
1/2
✓ Branch 2 taken 9578 times.
✗ Branch 3 not taken.
19155 : joint_q(ConfigVector_t::Zero())
640
3/5
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 9562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
19155 , joint_v(TangentVector_t::Zero())
641
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
19155 , M((Scalar)0)
642
2/4
✓ Branch 1 taken 16 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
19155 , v((Scalar)0)
643
3/5
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 9562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
19155 , U(U_t::Zero())
644
3/5
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 9562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
19155 , Dinv(D_t::Zero())
645
3/5
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 9562 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✗ Branch 5 not taken.
19155 , UDinv(UD_t::Zero())
646
3/5
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 9562 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 16 times.
✗ Branch 7 not taken.
57465 , StU(D_t::Zero())
647 {
648 19155 }
649
650 900 static std::string classname()
651 {
652
2/4
✓ Branch 3 taken 450 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 450 times.
✗ Branch 7 not taken.
1800 return std::string("JointDataP") + axisLabel<axis>();
653 }
654 9 std::string shortname() const
655 {
656 18 return classname();
657 }
658
659 }; // struct JointDataPrismaticTpl
660
661 template<typename NewScalar, typename Scalar, int Options, int axis>
662 struct CastType<NewScalar, JointModelPrismaticTpl<Scalar, Options, axis>>
663 {
664 typedef JointModelPrismaticTpl<NewScalar, Options, axis> type;
665 };
666
667 template<typename _Scalar, int _Options, int axis>
668 struct JointModelPrismaticTpl
669 : public JointModelBase<JointModelPrismaticTpl<_Scalar, _Options, axis>>
670 {
671 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
672 typedef JointPrismaticTpl<_Scalar, _Options, axis> JointDerived;
673 PINOCCHIO_JOINT_TYPEDEF_TEMPLATE(JointDerived);
674
675 typedef JointModelBase<JointModelPrismaticTpl> Base;
676 using Base::id;
677 using Base::idx_q;
678 using Base::idx_v;
679 using Base::idx_vExtended;
680 using Base::setIndexes;
681
682 typedef Eigen::Matrix<Scalar, 3, 1, _Options> Vector3;
683
684 18680 JointDataDerived createData() const
685 {
686 18680 return JointDataDerived();
687 }
688
689 2 const std::vector<bool> hasConfigurationLimit() const
690 {
691
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 return {true};
692 }
693
694 2 const std::vector<bool> hasConfigurationLimitInTangent() const
695 {
696
1/2
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
2 return {true};
697 }
698
699 template<typename ConfigVector>
700 36950 void calc(JointDataDerived & data, const typename Eigen::MatrixBase<ConfigVector> & qs) const
701 {
702
0/4
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
36950 data.joint_q[0] = qs[idx_q()];
703 36950 data.M.displacement() = data.joint_q[0];
704 36950 }
705
706 template<typename TangentVector>
707 void
708 6 calc(JointDataDerived & data, const Blank, const typename Eigen::MatrixBase<TangentVector> & vs)
709 const
710 {
711 6 data.joint_v[0] = vs[idx_v()];
712 6 data.v.linearRate() = data.joint_v[0];
713 6 }
714
715 template<typename ConfigVector, typename TangentVector>
716 6260 void calc(
717 JointDataDerived & data,
718 const typename Eigen::MatrixBase<ConfigVector> & qs,
719 const typename Eigen::MatrixBase<TangentVector> & vs) const
720 {
721 6260 calc(data, qs.derived());
722
723
0/4
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
6260 data.joint_v[0] = vs[idx_v()];
724 6260 data.v.linearRate() = data.joint_v[0];
725 6260 }
726
727 template<typename VectorLike, typename Matrix6Like>
728 46 void calc_aba(
729 JointDataDerived & data,
730 const Eigen::MatrixBase<VectorLike> & armature,
731 const Eigen::MatrixBase<Matrix6Like> & I,
732 const bool update_I) const
733 {
734
1/2
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
46 data.U = I.col(Inertia::LINEAR + axis);
735
6/12
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 1 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 1 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 1 times.
✗ Branch 18 not taken.
46 data.Dinv[0] = Scalar(1) / (I(Inertia::LINEAR + axis, Inertia::LINEAR + axis) + armature[0]);
736
2/4
✓ Branch 3 taken 23 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 23 times.
✗ Branch 7 not taken.
46 data.UDinv.noalias() = data.U * data.Dinv[0];
737
738
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 17 times.
46 if (update_I)
739
3/6
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 6 taken 6 times.
✗ Branch 7 not taken.
✓ Branch 9 taken 6 times.
✗ Branch 10 not taken.
12 PINOCCHIO_EIGEN_CONST_CAST(Matrix6Like, I).noalias() -= data.UDinv * data.U.transpose();
740 46 }
741
742 117353 static std::string classname()
743 {
744
2/4
✓ Branch 3 taken 58675 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 58675 times.
✗ Branch 7 not taken.
234706 return std::string("JointModelP") + axisLabel<axis>();
745 }
746 18 std::string shortname() const
747 {
748 58252 return classname();
749 }
750
751 Vector3 getMotionAxis() const
752 {
753 switch (axis)
754 {
755 case 0:
756 return Vector3::UnitX();
757 case 1:
758 return Vector3::UnitY();
759 case 2:
760 return Vector3::UnitZ();
761 default:
762 assert(false && "must never happen");
763 break;
764 }
765 }
766
767 /// \returns An expression of *this with the Scalar type casted to NewScalar.
768 template<typename NewScalar>
769 16 JointModelPrismaticTpl<NewScalar, Options, axis> cast() const
770 {
771 typedef JointModelPrismaticTpl<NewScalar, Options, axis> ReturnType;
772 16 ReturnType res;
773 16 res.setIndexes(id(), idx_q(), idx_v(), idx_vExtended());
774 16 return res;
775 }
776
777 }; // struct JointModelPrismaticTpl
778
779 typedef JointPrismaticTpl<context::Scalar, context::Options, 0> JointPX;
780 typedef JointDataPrismaticTpl<context::Scalar, context::Options, 0> JointDataPX;
781 typedef JointModelPrismaticTpl<context::Scalar, context::Options, 0> JointModelPX;
782
783 typedef JointPrismaticTpl<context::Scalar, context::Options, 1> JointPY;
784 typedef JointDataPrismaticTpl<context::Scalar, context::Options, 1> JointDataPY;
785 typedef JointModelPrismaticTpl<context::Scalar, context::Options, 1> JointModelPY;
786
787 typedef JointPrismaticTpl<context::Scalar, context::Options, 2> JointPZ;
788 typedef JointDataPrismaticTpl<context::Scalar, context::Options, 2> JointDataPZ;
789 typedef JointModelPrismaticTpl<context::Scalar, context::Options, 2> JointModelPZ;
790
791 template<typename Scalar, int Options, int axis>
792 struct ConfigVectorAffineTransform<JointPrismaticTpl<Scalar, Options, axis>>
793 {
794 typedef LinearAffineTransform Type;
795 };
796 } // namespace pinocchio
797
798 #include <boost/type_traits.hpp>
799
800 namespace boost
801 {
802 template<typename Scalar, int Options, int axis>
803 struct has_nothrow_constructor<::pinocchio::JointModelPrismaticTpl<Scalar, Options, axis>>
804 : public integral_constant<bool, true>
805 {
806 };
807
808 template<typename Scalar, int Options, int axis>
809 struct has_nothrow_copy<::pinocchio::JointModelPrismaticTpl<Scalar, Options, axis>>
810 : public integral_constant<bool, true>
811 {
812 };
813
814 template<typename Scalar, int Options, int axis>
815 struct has_nothrow_constructor<::pinocchio::JointDataPrismaticTpl<Scalar, Options, axis>>
816 : public integral_constant<bool, true>
817 {
818 };
819
820 template<typename Scalar, int Options, int axis>
821 struct has_nothrow_copy<::pinocchio::JointDataPrismaticTpl<Scalar, Options, axis>>
822 : public integral_constant<bool, true>
823 {
824 };
825 } // namespace boost
826
827 #endif // ifndef __pinocchio_multibody_joint_prismatic_hpp__
828