GCC Code Coverage Report


Directory: ./
File: include/pinocchio/multibody/joint/joint-revolute-unaligned.hpp
Date: 2025-04-30 16:14:33
Exec Total Coverage
Lines: 188 196 95.9%
Branches: 175 415 42.2%

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