pinocchio  3.9.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
Loading...
Searching...
No Matches
data.hpp
1//
2// Copyright (c) 2015-2024 CNRS INRIA
3// Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France.
4//
5
6#ifndef __pinocchio_multibody_data_hpp__
7#define __pinocchio_multibody_data_hpp__
8
9#include "pinocchio/spatial/fwd.hpp"
10#include "pinocchio/math/tensor.hpp"
11
12#include "pinocchio/spatial/se3.hpp"
13#include "pinocchio/spatial/force.hpp"
14#include "pinocchio/spatial/motion.hpp"
15#include "pinocchio/spatial/inertia.hpp"
16#include "pinocchio/multibody/fwd.hpp"
17#include "pinocchio/multibody/joint/joint-generic.hpp"
18#include "pinocchio/container/aligned-vector.hpp"
19#include "pinocchio/algorithm/contact-cholesky.hpp"
20
21#include "pinocchio/serialization/serializable.hpp"
22
23#include <Eigen/Cholesky>
24#include <Eigen/StdVector>
25#include <Eigen/src/Core/util/Constants.h>
26
27#include <cstddef>
28#include <set>
29
30namespace pinocchio
31{
32
33 template<typename _Scalar, int _Options, template<typename, int> class JointCollectionTpl>
34 struct traits<DataTpl<_Scalar, _Options, JointCollectionTpl>>
35 {
36 typedef _Scalar Scalar;
37 };
38
39 template<typename _Scalar, int _Options, template<typename, int> class JointCollectionTpl>
40 struct DataTpl
41 : serialization::Serializable<DataTpl<_Scalar, _Options, JointCollectionTpl>>
42 , NumericalBase<DataTpl<_Scalar, _Options, JointCollectionTpl>>
43 {
44 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
45
46 typedef _Scalar Scalar;
47 enum
48 {
49 Options = _Options
50 };
51
52 typedef JointCollectionTpl<Scalar, Options> JointCollection;
53
55
56 typedef SE3Tpl<Scalar, Options> SE3;
57 typedef MotionTpl<Scalar, Options> Motion;
58 typedef ForceTpl<Scalar, Options> Force;
59 typedef InertiaTpl<Scalar, Options> Inertia;
60 typedef FrameTpl<Scalar, Options> Frame;
61
62 typedef pinocchio::Index Index;
63 typedef pinocchio::JointIndex JointIndex;
64 typedef pinocchio::GeomIndex GeomIndex;
65 typedef pinocchio::FrameIndex FrameIndex;
66 typedef std::vector<Index> IndexVector;
67
70
71 typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointModel) JointModelVector;
72 typedef PINOCCHIO_ALIGNED_STD_VECTOR(JointData) JointDataVector;
73
74 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Options> MatrixXs;
75 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1, Options> VectorXs;
76 typedef Eigen::Matrix<Scalar, 1, Eigen::Dynamic, Options | Eigen::RowMajor> RowVectorXs;
77 typedef Eigen::Matrix<Scalar, 3, 1, Options> Vector3;
78 typedef Eigen::Matrix<Scalar, 6, 1, Options> Vector6;
79
80 typedef Eigen::Matrix<Scalar, 6, 1, Options> Vector6c;
81 typedef Eigen::Matrix<Scalar, 1, 6, Eigen::RowMajor | Options> Vector6r;
82
84 typedef VectorXs ConfigVectorType;
85
89 typedef VectorXs TangentVectorType;
90
92 typedef Eigen::Matrix<Scalar, 6, Eigen::Dynamic, Options> Matrix6x;
94 typedef Eigen::Matrix<Scalar, 3, Eigen::Dynamic, Options> Matrix3x;
95
96 typedef Eigen::Matrix<Scalar, 6, 6, Options> Matrix6;
97 typedef Eigen::Matrix<Scalar, 6, 6, Eigen::RowMajor | Options> RowMatrix6;
98 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor | Options>
99 RowMatrixXs;
100
102 typedef Eigen::Matrix<Scalar, 6, 10, Options> BodyRegressorType;
103
106
107 // TODO Remove when API is stabilized
108 PINOCCHIO_COMPILER_DIAGNOSTIC_PUSH
109 PINOCCHIO_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
110 typedef ContactCholeskyDecompositionTpl<Scalar, Options> ContactCholeskyDecomposition;
111 PINOCCHIO_COMPILER_DIAGNOSTIC_POP
112
115 JointDataVector joints;
116
119
122
126
129 PINOCCHIO_ALIGNED_STD_VECTOR(Motion) oa_augmented;
130
133
137
140
143
148
153
158 PINOCCHIO_ALIGNED_STD_VECTOR(Force) of_augmented;
159
162
165
168
171
174
179 VectorXs nle;
180
184 VectorXs g;
185
188
193
196 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) dYcrb; // TODO: change with dense symmetric matrix6
197
199 MatrixXs M;
200
202 RowMatrixXs Minv;
203
205 MatrixXs C;
206
209
212
215
218
221
224
227
230
233
237
239 PINOCCHIO_ALIGNED_STD_VECTOR(Inertia) oinertias;
240
243
246
248 Matrix6 Itmp;
249
251 Matrix6 M6tmp;
252 RowMatrix6 M6tmpR;
253 RowMatrix6 M6tmpR2;
254
257
258 // ABA internal data
261 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) Yaba; // TODO: change with dense symmetric matrix6
262
265 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) oYaba; // TODO: change with dense symmetric matrix6
266
269 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6)
270 oYaba_contact; // TODO: change with dense symmetric matrix6
271
273 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) oL; // TODO: change with dense symmetric matrix6
274
276 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) oK; // TODO: change with dense symmetric matrix6
277
279 TangentVectorType u; // Joint Inertia
280
281 // CCRBA return quantities
285
286 // dCCRBA return quantities
291
297 Force hg;
298
305 Force dhg;
306
310 Inertia Ig;
311
313 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6x) Fcrb;
314
316 std::vector<int> lastChild;
317
319 std::vector<int> nvSubtree;
320
322 std::vector<int> start_idx_v_fromRow;
323
325 std::vector<int> end_idx_v_fromRow;
326
330
333 std::vector<JointIndex> mimic_subtree_joint;
334
337 MatrixXs U;
338
340 VectorXs D;
341
344 VectorXs Dinv;
345
347 VectorXs tmp;
348
350 std::vector<int> parents_fromRow;
351
353 std::vector<int> mimic_parents_fromRow;
354
356 std::vector<int> non_mimic_parents_fromRow;
357
361 std::vector<std::vector<int>> supports_fromRow;
362
364 std::vector<int> nvSubtree_fromRow;
365
375
378
381
385
389
392
395
398
401 RowMatrixXs dtau_dq;
402
404 RowMatrixXs dtau_dv;
405
408 RowMatrixXs ddq_dq;
409
412 RowMatrixXs ddq_dv;
413
416 RowMatrixXs ddq_dtau;
417
420 MatrixXs dvc_dq;
421 MatrixXs dac_dq;
422 MatrixXs dac_dv;
423 MatrixXs dac_da;
424
426 MatrixXs osim;
427
430 MatrixXs dlambda_dq;
431 MatrixXs dlambda_dv;
432 MatrixXs dlambda_dtau;
433 MatrixXs dlambda_dx_prox, drhs_prox;
434
436 PINOCCHIO_ALIGNED_STD_VECTOR(SE3) iMf;
437
442 PINOCCHIO_ALIGNED_STD_VECTOR(Vector3) com;
443
448 PINOCCHIO_ALIGNED_STD_VECTOR(Vector3) vcom;
449
454 PINOCCHIO_ALIGNED_STD_VECTOR(Vector3) acom;
455
458 std::vector<Scalar> mass;
459
465
468
471
474
475 // Temporary variables used in forward dynamics
476
478 MatrixXs JMinvJt;
479
481 Eigen::LLT<MatrixXs> llt_JMinvJt;
482
485 VectorXs lambda_c;
486
489 VectorXs lambda_c_prox;
490
492 VectorXs diff_lambda_c;
493
495 MatrixXs sDUiJt;
496
499
502
505 VectorXs impulse_c;
506
509
512
515
518
521
522 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6x) KA;
523 PINOCCHIO_ALIGNED_STD_VECTOR(MatrixXs) LA;
524 PINOCCHIO_ALIGNED_STD_VECTOR(VectorXs) lA;
525 PINOCCHIO_ALIGNED_STD_VECTOR(VectorXs) lambdaA;
526 PINOCCHIO_ALIGNED_STD_VECTOR(int) par_cons_ind;
527 PINOCCHIO_ALIGNED_STD_VECTOR(Motion) a_bias;
528 PINOCCHIO_ALIGNED_STD_VECTOR(MatrixXs) KAS;
529 PINOCCHIO_ALIGNED_STD_VECTOR(int) constraint_ind;
530 Eigen::LLT<MatrixXs> osim_llt;
531
532#if defined(_MSC_VER)
533 // Eigen tensor warning: Eigen\CXX11\src/Tensor/Tensor.h(76,1): warning C4554: '&': check
534 // operator precedence for possible error
535 #pragma warning(disable : 4554)
536#endif
537
540
541#if defined(_MSC_VER)
542 #pragma warning(default : 4554) // C4554 enabled after tensor definition
543#endif
544
546 ContactCholeskyDecomposition contact_chol;
547
550
553
554#if defined(_MSC_VER)
555 // Eigen tensor warning: Eigen\CXX11\src/Tensor/Tensor.h(76,1): warning C4554: '&': check
556 // operator precedence for possible error
557 #pragma warning(disable : 4554)
558#endif
559
563
567
571
577
578#if defined(_MSC_VER)
579 #pragma warning(default : 4554) // C4554 enabled after tensor definition
580#endif
581
582 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6)
583 extended_motion_propagator; // Stores force propagator to the base link
584 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) extended_motion_propagator2;
585 PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) spatial_inv_inertia; // Stores spatial inverse inertia
586 PINOCCHIO_ALIGNED_STD_VECTOR(size_t) accumulation_descendant;
587 PINOCCHIO_ALIGNED_STD_VECTOR(size_t) accumulation_ancestor;
588 PINOCCHIO_ALIGNED_STD_VECTOR(int) constraints_supported_dim;
589 PINOCCHIO_ALIGNED_STD_VECTOR(std::set<size_t>) constraints_supported;
590 PINOCCHIO_ALIGNED_STD_VECTOR(size_t) joints_supporting_constraints;
591 PINOCCHIO_ALIGNED_STD_VECTOR(size_t) accumulation_joints;
592 PINOCCHIO_ALIGNED_STD_VECTOR(std::vector<size_t>) constraints_on_joint;
593
599 explicit DataTpl(const Model & model);
600
605 {
606 }
607
608 private:
609 void computeLastChild(const Model & model);
610 void computeParents_fromRow(const Model & model);
611 void computeSupports_fromRow(const Model & model);
612 };
613
614} // namespace pinocchio
615
616/* --- Details -------------------------------------------------------------- */
617/* --- Details -------------------------------------------------------------- */
618/* --- Details -------------------------------------------------------------- */
619#include "pinocchio/multibody/data.hxx"
620
621#if PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION
622 #include "pinocchio/multibody/data.txx"
623#endif // PINOCCHIO_ENABLE_TEMPLATE_INSTANTIATION
624
625#endif // ifndef __pinocchio_multibody_data_hpp__
Main pinocchio namespace.
Definition treeview.dox:11
PINOCCHIO_ALIGNED_STD_VECTOR(Force) of_augmented
Vector of body forces expressed in the world frame. For each body, the force represents the sum of al...
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) oa_gf
Vector of joint accelerations expressed at the origin of the world including the gravity contribution...
PINOCCHIO_ALIGNED_STD_VECTOR(Force) h
Vector of spatial momenta expressed in the local frame of the joint.
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) a_gf
Vector of joint accelerations due to the gravity field.
PINOCCHIO_ALIGNED_STD_VECTOR(Inertia) Ycrb
Vector of sub-tree composite rigid body inertias, i.e. the apparent inertia of the subtree supported ...
DataTpl()
Default constructor.
Definition data.hpp:604
PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) B
Combined variations of the inertia matrix consistent with Christoffel symbols.
PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) dYcrb
Vector of sub-tree composite rigid body inertia time derivatives . See Data::Ycrb for more details.
PINOCCHIO_ALIGNED_STD_VECTOR(Force) oh
Vector of spatial momenta expressed at the origin of the world.
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) v
Vector of joint velocities expressed in the local frame of the joint.
PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) oYaba
Articulated Body Inertia matrix of the subtree expressed in the WORLD coordinate frame.
DataTpl(const Model &model)
Default constructor of pinocchio::Data from a pinocchio::Model.
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) oa
Vector of joint accelerations expressed at the origin of the world.
PINOCCHIO_ALIGNED_STD_VECTOR(SE3) liMi
Vector of relative joint placements (wrt the body parent).
Eigen::Matrix< Scalar, 6, 10, Options > BodyRegressorType
Definition data.hpp:102
Eigen::Matrix< Scalar, 6, Eigen::Dynamic, Options > Matrix6x
Definition data.hpp:92
PINOCCHIO_ALIGNED_STD_VECTOR(Inertia) oinertias
Rigid Body Inertia supported by the joint expressed in the world frame.
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) oa_drift
Vector of joint accelerations expressed at the origin of the world. These accelerations are used in t...
std::vector< std::vector< int > > supports_fromRow
Definition data.hpp:361
PINOCCHIO_ALIGNED_STD_VECTOR(SE3) oMi
Vector of absolute joint placements (wrt the world).
PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) doYcrb
Time variation of Composite Rigid Body Inertia expressed in the world frame.
PINOCCHIO_ALIGNED_STD_VECTOR(Force) f
Vector of body forces expressed in the local frame of the joint. For each body, the force represents ...
PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) Ivx
Left variation of the inertia matrix.
PINOCCHIO_COMPILER_DIAGNOSTIC_POP JointDataVector joints
Definition data.hpp:115
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) ov
Vector of joint velocities expressed at the origin of the world.
Eigen::Matrix< Scalar, 3, Eigen::Dynamic, Options > Matrix3x
Definition data.hpp:94
PINOCCHIO_ALIGNED_STD_VECTOR(Force) of
Vector of body forces expressed at the origin of the world. For each body, the force represents the s...
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) oa_augmented
Vector of joint accelerations expressed at the origin of the world. These accelerations are used in t...
PINOCCHIO_ALIGNED_STD_VECTOR(Motion) a
Vector of joint accelerations expressed in the local frame of the joint.
PINOCCHIO_ALIGNED_STD_VECTOR(SE3) oMf
Vector of absolute operationnel frame placements (wrt the world).
PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) vxI
Right variation of the inertia matrix.
PINOCCHIO_ALIGNED_STD_VECTOR(Matrix6) Yaba
Articulated Body Inertia matrix of the subtree expressed in the LOCAL coordinate frame of the joint.
PINOCCHIO_ALIGNED_STD_VECTOR(Inertia) oYcrb
Composite Rigid Body Inertia expressed in the world frame.
A Plucker coordinate frame attached to a parent joint inside a kinematic tree.
Definition frame.hpp:56
Common traits structure to fully define base classes for CRTP.
Definition fwd.hpp:72