GCC Code Coverage Report


Directory: ./
File: include/pinocchio/multibody/joint/joint-prismatic-unaligned.hpp
Date: 2025-04-30 16:14:33
Exec Total Coverage
Lines: 181 191 94.8%
Branches: 151 356 42.4%

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