Directory: | ./ |
---|---|
File: | include/pinocchio/algorithm/compute-all-terms.hxx |
Date: | 2025-02-12 21:03:38 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 85 | 85 | 100.0% |
Branches: | 154 | 341 | 45.2% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // | ||
2 | // Copyright (c) 2015-2021 CNRS INRIA | ||
3 | // | ||
4 | |||
5 | #ifndef __pinocchio_compute_all_terms_hxx__ | ||
6 | #define __pinocchio_compute_all_terms_hxx__ | ||
7 | |||
8 | #include "pinocchio/multibody/visitor.hpp" | ||
9 | #include "pinocchio/spatial/act-on-set.hpp" | ||
10 | #include "pinocchio/algorithm/center-of-mass.hpp" | ||
11 | #include "pinocchio/algorithm/energy.hpp" | ||
12 | #include "pinocchio/algorithm/check.hpp" | ||
13 | |||
14 | namespace pinocchio | ||
15 | { | ||
16 | namespace impl | ||
17 | { | ||
18 | template< | ||
19 | typename Scalar, | ||
20 | int Options, | ||
21 | template<typename, int> class JointCollectionTpl, | ||
22 | typename ConfigVectorType, | ||
23 | typename TangentVectorType> | ||
24 | struct CATForwardStep | ||
25 | : public fusion::JointUnaryVisitorBase< | ||
26 | CATForwardStep<Scalar, Options, JointCollectionTpl, ConfigVectorType, TangentVectorType>> | ||
27 | { | ||
28 | typedef ModelTpl<Scalar, Options, JointCollectionTpl> Model; | ||
29 | typedef DataTpl<Scalar, Options, JointCollectionTpl> Data; | ||
30 | |||
31 | typedef boost::fusion:: | ||
32 | vector<const Model &, Data &, const ConfigVectorType &, const TangentVectorType &> | ||
33 | ArgsType; | ||
34 | |||
35 | template<typename JointModel> | ||
36 | 12774 | static void algo( | |
37 | const JointModelBase<JointModel> & jmodel, | ||
38 | JointDataBase<typename JointModel::JointDataDerived> & jdata, | ||
39 | const Model & model, | ||
40 | Data & data, | ||
41 | const Eigen::MatrixBase<ConfigVectorType> & q, | ||
42 | const Eigen::MatrixBase<TangentVectorType> & v) | ||
43 | { | ||
44 | typedef typename Model::JointIndex JointIndex; | ||
45 | typedef | ||
46 | typename SizeDepType<JointModel::NV>::template ColsReturn<typename Data::Matrix6x>::Type | ||
47 | ColsBlock; | ||
48 | |||
49 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | const JointIndex i = jmodel.id(); |
50 | 12774 | const JointIndex parent = model.parents[i]; | |
51 | |||
52 |
1/2✓ Branch 4 taken 6387 times.
✗ Branch 5 not taken.
|
12774 | jmodel.calc(jdata.derived(), q.derived(), v.derived()); |
53 | |||
54 | // CRBA | ||
55 |
6/10✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 6137 times.
✓ Branch 5 taken 250 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6137 times.
✓ Branch 9 taken 250 times.
✗ Branch 10 not taken.
✓ Branch 12 taken 6137 times.
✗ Branch 13 not taken.
|
12774 | data.liMi[i] = model.jointPlacements[i] * jdata.M(); |
56 | |||
57 | // Jacobian + NLE | ||
58 |
2/4✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 6387 times.
✗ Branch 6 not taken.
|
12774 | data.v[i] = jdata.v(); |
59 | |||
60 |
2/2✓ Branch 0 taken 6127 times.
✓ Branch 1 taken 260 times.
|
12774 | if (parent > 0) |
61 | { | ||
62 |
2/4✓ Branch 3 taken 6127 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6127 times.
✗ Branch 8 not taken.
|
12254 | data.oMi[i] = data.oMi[parent] * data.liMi[i]; |
63 |
2/4✓ Branch 3 taken 6127 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6127 times.
✗ Branch 8 not taken.
|
12254 | data.v[i] += data.liMi[i].actInv(data.v[parent]); |
64 | } | ||
65 | else | ||
66 |
1/2✓ Branch 3 taken 260 times.
✗ Branch 4 not taken.
|
520 | data.oMi[i] = data.liMi[i]; |
67 | |||
68 |
2/4✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6387 times.
✗ Branch 8 not taken.
|
12774 | data.ov[i] = data.oMi[i].act(data.v[i]); |
69 | |||
70 |
2/4✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6387 times.
✗ Branch 8 not taken.
|
12774 | data.oYcrb[i] = data.oMi[i].act(model.inertias[i]); |
71 |
1/2✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
|
12774 | data.doYcrb[i] = data.oYcrb[i].variation(data.ov[i]); |
72 | |||
73 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | ColsBlock J_cols = jmodel.jointCols(data.J); |
74 |
3/6✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6387 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6387 times.
✗ Branch 9 not taken.
|
12774 | J_cols = data.oMi[i].act(jdata.S()); |
75 | |||
76 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | ColsBlock dJ_cols = jmodel.jointCols(data.dJ); |
77 |
1/2✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
|
12774 | motionSet::motionAction(data.ov[i], J_cols, dJ_cols); |
78 | |||
79 |
8/16✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 6387 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6387 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 5 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 6382 times.
✗ Branch 14 not taken.
✓ Branch 15 taken 5 times.
✗ Branch 16 not taken.
✓ Branch 17 taken 6382 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 5 times.
✗ Branch 20 not taken.
|
12774 | data.a_gf[i] = data.a[i] = jdata.c() + (data.v[i] ^ jdata.v()); |
80 |
2/2✓ Branch 0 taken 6127 times.
✓ Branch 1 taken 260 times.
|
12774 | if (parent > 0) |
81 |
2/4✓ Branch 3 taken 6127 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6127 times.
✗ Branch 8 not taken.
|
12254 | data.a[i] += data.liMi[i].actInv(data.a[parent]); |
82 | |||
83 |
2/4✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6387 times.
✗ Branch 8 not taken.
|
12774 | data.a_gf[i] += data.liMi[i].actInv(data.a_gf[parent]); |
84 | |||
85 |
2/4✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6387 times.
✗ Branch 8 not taken.
|
12774 | data.h[i] = model.inertias[i] * data.v[i]; |
86 |
4/8✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 8 taken 6387 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 6387 times.
✗ Branch 12 not taken.
✓ Branch 15 taken 6387 times.
✗ Branch 16 not taken.
|
12774 | data.f[i] = model.inertias[i] * data.a_gf[i] + data.v[i].cross(data.h[i]); // -f_ext |
87 | } | ||
88 | }; | ||
89 | |||
90 | template<typename Scalar, int Options, template<typename, int> class JointCollectionTpl> | ||
91 | struct CATBackwardStep | ||
92 | : public fusion::JointUnaryVisitorBase<CATBackwardStep<Scalar, Options, JointCollectionTpl>> | ||
93 | { | ||
94 | typedef ModelTpl<Scalar, Options, JointCollectionTpl> Model; | ||
95 | typedef DataTpl<Scalar, Options, JointCollectionTpl> Data; | ||
96 | |||
97 | typedef boost::fusion::vector<const Model &, Data &> ArgsType; | ||
98 | |||
99 | template<typename JointModel> | ||
100 | 12774 | static void algo( | |
101 | const JointModelBase<JointModel> & jmodel, | ||
102 | JointDataBase<typename JointModel::JointDataDerived> & jdata, | ||
103 | const Model & model, | ||
104 | Data & data) | ||
105 | { | ||
106 | typedef typename Model::JointIndex JointIndex; | ||
107 | typedef | ||
108 | typename SizeDepType<JointModel::NV>::template ColsReturn<typename Data::Matrix6x>::Type | ||
109 | ColsBlock; | ||
110 | |||
111 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | const JointIndex i = jmodel.id(); |
112 | 12774 | const JointIndex parent = model.parents[i]; | |
113 | |||
114 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | ColsBlock J_cols = jmodel.jointCols(data.J); |
115 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | ColsBlock dJ_cols = jmodel.jointCols(data.dJ); |
116 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | ColsBlock Ag_cols = jmodel.jointCols(data.Ag); |
117 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
12774 | ColsBlock dAg_cols = jmodel.jointCols(data.dAg); |
118 | |||
119 | // Calc Ag = Y * S | ||
120 |
1/2✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
|
12774 | motionSet::inertiaAction(data.oYcrb[i], J_cols, Ag_cols); |
121 | |||
122 | // Calc dAg = Ivx + vxI | ||
123 |
3/6✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6387 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6387 times.
✗ Branch 9 not taken.
|
12774 | dAg_cols.noalias() = data.doYcrb[i] * J_cols; |
124 |
1/2✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
|
12774 | motionSet::inertiaAction<ADDTO>(data.oYcrb[i], dJ_cols, dAg_cols); |
125 | |||
126 | /* M[i,SUBTREE] = S'*F[1:6,SUBTREE] */ | ||
127 |
6/12✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6387 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6387 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 6387 times.
✗ Branch 12 not taken.
✓ Branch 14 taken 6387 times.
✗ Branch 15 not taken.
✓ Branch 17 taken 6387 times.
✗ Branch 18 not taken.
|
12774 | data.M.block(jmodel.idx_v(), jmodel.idx_v(), jmodel.nv(), data.nvSubtree[i]).noalias() = |
128 |
4/8✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6387 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 6387 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 6387 times.
✗ Branch 12 not taken.
|
12774 | J_cols.transpose() * data.Ag.middleCols(jmodel.idx_v(), data.nvSubtree[i]); |
129 | |||
130 |
8/13✓ Branch 2 taken 6387 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 6146 times.
✓ Branch 6 taken 241 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 6146 times.
✓ Branch 9 taken 241 times.
✗ Branch 10 not taken.
✓ Branch 11 taken 6146 times.
✓ Branch 12 taken 241 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 6146 times.
✗ Branch 15 not taken.
|
12774 | jmodel.jointVelocitySelector(data.nle) = jdata.S().transpose() * data.f[i]; |
131 | |||
132 |
1/2✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
|
12774 | data.oYcrb[parent] += data.oYcrb[i]; |
133 |
1/2✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
|
12774 | data.doYcrb[parent] += data.doYcrb[i]; |
134 |
2/4✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6387 times.
✗ Branch 8 not taken.
|
12774 | data.h[parent] += data.liMi[i].act(data.h[i]); |
135 |
2/4✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 7 taken 6387 times.
✗ Branch 8 not taken.
|
12774 | data.f[parent] += data.liMi[i].act(data.f[i]); |
136 | |||
137 | // CoM | ||
138 |
0/2✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
12774 | data.mass[i] = data.oYcrb[i].mass(); |
139 |
1/2✓ Branch 4 taken 6387 times.
✗ Branch 5 not taken.
|
12774 | data.com[i] = data.oMi[i].actInv(data.oYcrb[i].lever()); |
140 |
3/6✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 6387 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 6387 times.
✗ Branch 11 not taken.
|
12774 | data.vcom[i] = data.h[i].linear() / data.mass[i]; |
141 | } | ||
142 | }; | ||
143 | |||
144 | template< | ||
145 | typename Scalar, | ||
146 | int Options, | ||
147 | template<typename, int> class JointCollectionTpl, | ||
148 | typename ConfigVectorType, | ||
149 | typename TangentVectorType> | ||
150 | 262 | void computeAllTerms( | |
151 | const ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
152 | DataTpl<Scalar, Options, JointCollectionTpl> & data, | ||
153 | const Eigen::MatrixBase<ConfigVectorType> & q, | ||
154 | const Eigen::MatrixBase<TangentVectorType> & v) | ||
155 | { | ||
156 |
2/4✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 260 times.
✗ Branch 4 not taken.
|
262 | assert(model.check(data) && "data is not consistent with model."); |
157 |
1/24✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
|
262 | PINOCCHIO_CHECK_ARGUMENT_SIZE( |
158 | q.size(), model.nq, "The configuration vector is not of right size"); | ||
159 |
1/24✗ Branch 1 not taken.
✓ Branch 2 taken 260 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
|
262 | PINOCCHIO_CHECK_ARGUMENT_SIZE(v.size(), model.nv, "The velocity vector is not of right size"); |
160 | |||
161 | typedef DataTpl<Scalar, Options, JointCollectionTpl> Data; | ||
162 | |||
163 |
1/2✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
|
262 | data.v[0].setZero(); |
164 |
1/2✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
|
262 | data.a[0].setZero(); |
165 |
1/2✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
|
262 | data.h[0].setZero(); |
166 |
2/4✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 260 times.
✗ Branch 6 not taken.
|
262 | data.a_gf[0] = -model.gravity; |
167 |
1/2✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
|
262 | data.oYcrb[0].setZero(); |
168 | |||
169 | typedef CATForwardStep< | ||
170 | Scalar, Options, JointCollectionTpl, ConfigVectorType, TangentVectorType> | ||
171 | Pass1; | ||
172 |
2/2✓ Branch 0 taken 6387 times.
✓ Branch 1 taken 260 times.
|
6651 | for (JointIndex i = 1; i < (JointIndex)model.njoints; ++i) |
173 | { | ||
174 |
1/2✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
|
6389 | Pass1::run( |
175 | 6389 | model.joints[i], data.joints[i], | |
176 |
1/2✓ Branch 3 taken 6387 times.
✗ Branch 4 not taken.
|
12778 | typename Pass1::ArgsType(model, data, q.derived(), v.derived())); |
177 | } | ||
178 | |||
179 | typedef CATBackwardStep<Scalar, Options, JointCollectionTpl> Pass2; | ||
180 |
2/2✓ Branch 0 taken 6387 times.
✓ Branch 1 taken 260 times.
|
6651 | for (JointIndex i = (JointIndex)(model.njoints - 1); i > 0; --i) |
181 | { | ||
182 |
2/4✓ Branch 1 taken 6387 times.
✗ Branch 2 not taken.
✓ Branch 6 taken 6387 times.
✗ Branch 7 not taken.
|
6389 | Pass2::run(model.joints[i], data.joints[i], typename Pass2::ArgsType(model, data)); |
183 | } | ||
184 | |||
185 | // CoM | ||
186 |
0/2✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
262 | data.mass[0] = data.oYcrb[0].mass(); |
187 |
1/2✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
|
262 | data.com[0] = data.oYcrb[0].lever(); |
188 |
3/6✓ Branch 3 taken 260 times.
✗ Branch 4 not taken.
✓ Branch 6 taken 260 times.
✗ Branch 7 not taken.
✓ Branch 10 taken 260 times.
✗ Branch 11 not taken.
|
262 | data.vcom[0] = data.h[0].linear() / data.mass[0]; |
189 | |||
190 | // Centroidal | ||
191 | typedef Eigen::Block<typename Data::Matrix6x, 3, -1> Block3x; | ||
192 |
1/2✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
|
262 | const Block3x Ag_lin = data.Ag.template middleRows<3>(Force::LINEAR); |
193 |
1/2✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
|
262 | Block3x Ag_ang = data.Ag.template middleRows<3>(Force::ANGULAR); |
194 |
2/2✓ Branch 0 taken 7599 times.
✓ Branch 1 taken 260 times.
|
7870 | for (long i = 0; i < model.nv; ++i) |
195 |
4/8✓ Branch 1 taken 7599 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7599 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7599 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 7599 times.
✗ Branch 12 not taken.
|
7608 | Ag_ang.col(i) += Ag_lin.col(i).cross(data.com[0]); |
196 | |||
197 |
1/2✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
|
262 | const Block3x dAg_lin = data.dAg.template middleRows<3>(Force::LINEAR); |
198 |
1/2✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
|
262 | Block3x dAg_ang = data.dAg.template middleRows<3>(Force::ANGULAR); |
199 |
2/2✓ Branch 0 taken 7599 times.
✓ Branch 1 taken 260 times.
|
7870 | for (Eigen::DenseIndex i = 0; i < model.nv; ++i) |
200 |
7/14✓ Branch 1 taken 7599 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 7599 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 7599 times.
✗ Branch 9 not taken.
✓ Branch 12 taken 7599 times.
✗ Branch 13 not taken.
✓ Branch 15 taken 7599 times.
✗ Branch 16 not taken.
✓ Branch 18 taken 7599 times.
✗ Branch 19 not taken.
✓ Branch 21 taken 7599 times.
✗ Branch 22 not taken.
|
7608 | dAg_ang.col(i) += dAg_lin.col(i).cross(data.com[0]) + Ag_lin.col(i).cross(data.vcom[0]); |
201 | |||
202 |
1/2✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
|
262 | data.hg = data.h[0]; |
203 |
4/8✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 260 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 260 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 260 times.
✗ Branch 12 not taken.
|
262 | data.hg.angular() += data.hg.linear().cross(data.com[0]); |
204 | |||
205 |
1/2✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
|
262 | data.dhg = data.f[0]; |
206 |
4/8✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 260 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 260 times.
✗ Branch 9 not taken.
✓ Branch 11 taken 260 times.
✗ Branch 12 not taken.
|
262 | data.dhg.angular() += data.dhg.linear().cross(data.com[0]); |
207 | |||
208 | // Add the armature contribution | ||
209 |
2/4✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
|
262 | data.M.diagonal() += model.armature; |
210 | |||
211 | // JCoM | ||
212 |
3/6✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 260 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 260 times.
✗ Branch 9 not taken.
|
262 | data.Jcom = data.Ag.template middleRows<3>(Force::LINEAR) / data.mass[0]; |
213 | |||
214 |
0/2✗ Branch 4 not taken.
✗ Branch 5 not taken.
|
262 | data.Ig.mass() = data.oYcrb[0].mass(); |
215 |
1/2✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
|
262 | data.Ig.lever().setZero(); |
216 |
1/2✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
|
262 | data.Ig.inertia() = data.oYcrb[0].inertia(); |
217 | |||
218 | // Gravity | ||
219 |
4/8✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 260 times.
✗ Branch 8 not taken.
✓ Branch 10 taken 260 times.
✗ Branch 11 not taken.
|
262 | data.g.noalias() = |
220 |
3/6✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 260 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 260 times.
✗ Branch 8 not taken.
|
262 | -data.Ag.template middleRows<3>(Force::LINEAR).transpose() * model.gravity.linear(); |
221 | |||
222 | // Energy | ||
223 |
1/2✓ Branch 1 taken 260 times.
✗ Branch 2 not taken.
|
262 | ::pinocchio::computeMechanicalEnergy(model, data); |
224 | 262 | } | |
225 | } // namespace impl | ||
226 | |||
227 | template< | ||
228 | typename Scalar, | ||
229 | int Options, | ||
230 | template<typename, int> class JointCollectionTpl, | ||
231 | typename ConfigVectorType, | ||
232 | typename TangentVectorType> | ||
233 | 274 | void computeAllTerms( | |
234 | const ModelTpl<Scalar, Options, JointCollectionTpl> & model, | ||
235 | DataTpl<Scalar, Options, JointCollectionTpl> & data, | ||
236 | const Eigen::MatrixBase<ConfigVectorType> & q, | ||
237 | const Eigen::MatrixBase<TangentVectorType> & v) | ||
238 | { | ||
239 |
2/4✓ Branch 2 taken 260 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 260 times.
✗ Branch 6 not taken.
|
274 | pinocchio::impl::computeAllTerms(model, data, make_const_ref(q), make_const_ref(v)); |
240 | 274 | } | |
241 | |||
242 | } // namespace pinocchio | ||
243 | |||
244 | /// \endinternal | ||
245 | |||
246 | #endif // ifndef __pinocchio_compute_all_terms_hxx__ | ||
247 |