GCC Code Coverage Report


Directory: ./
File: include/pinocchio/serialization/joints-model.hpp
Date: 2025-04-30 16:14:33
Exec Total Coverage
Lines: 107 107 100.0%
Branches: 37 74 50.0%

Line Branch Exec Source
1 //
2 // Copyright (c) 2019 INRIA
3 //
4
5 #ifndef __pinocchio_serialization_joints_model_hpp__
6 #define __pinocchio_serialization_joints_model_hpp__
7
8 namespace pinocchio
9 {
10 template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl>
11 struct Serialize<JointModelCompositeTpl<Scalar, Options, JointCollectionTpl>>
12 {
13 template<typename Archive>
14 static void
15 28 run(Archive & ar, JointModelCompositeTpl<Scalar, Options, JointCollectionTpl> & joint)
16 {
17 using boost::serialization::make_nvp;
18
19
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_nq", joint.m_nq);
20
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_nv", joint.m_nv);
21
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_nvExtended", joint.m_nvExtended);
22
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_idx_q", joint.m_idx_q);
23
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_nqs", joint.m_nqs);
24
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_idx_v", joint.m_idx_v);
25
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_nvs", joint.m_nvs);
26
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_idx_vExtended", joint.m_idx_vExtended);
27
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_nvExtendeds", joint.m_nvExtendeds);
28
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("njoints", joint.njoints);
29
30
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("joints", joint.joints);
31
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("jointPlacements", joint.jointPlacements);
32 28 }
33 };
34 } // namespace pinocchio
35
36 namespace boost
37 {
38 namespace serialization
39 {
40
41 // For some older version of gcc, we have to rely on an additional namespace
42 // to avoid ambiguous call to boost::serialization::serialize
43 namespace fix
44 {
45 template<class Archive, typename Derived>
46 3696 void serialize(
47 Archive & ar, pinocchio::JointModelBase<Derived> & joint, const unsigned int version)
48 {
49 3696 split_free(ar, joint, version);
50 3696 }
51 } // namespace fix
52
53 template<class Archive, typename Derived>
54 2016 void save(
55 Archive & ar,
56 const pinocchio::JointModelBase<Derived> & joint,
57 const unsigned int /*version*/)
58 {
59
1/2
✓ Branch 1 taken 1008 times.
✗ Branch 2 not taken.
2016 const pinocchio::JointIndex i_id = joint.id();
60
3/6
✓ Branch 1 taken 1008 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1008 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 1008 times.
✗ Branch 8 not taken.
2016 const int i_q = joint.idx_q(), i_v = joint.idx_v(), i_vExtended = joint.idx_vExtended();
61
62
1/2
✓ Branch 2 taken 1008 times.
✗ Branch 3 not taken.
2016 ar & make_nvp("i_id", i_id);
63
1/2
✓ Branch 2 taken 1008 times.
✗ Branch 3 not taken.
2016 ar & make_nvp("i_q", i_q);
64
1/2
✓ Branch 2 taken 1008 times.
✗ Branch 3 not taken.
2016 ar & make_nvp("i_v", i_v);
65
1/2
✓ Branch 2 taken 1008 times.
✗ Branch 3 not taken.
2016 ar & make_nvp("i_vExtended", i_vExtended);
66 2016 }
67
68 template<typename Derived>
69 class SetJointIndexes
70 {
71 Derived & joint;
72
73 public:
74 1666 explicit SetJointIndexes(Derived & joint)
75 1666 : joint(joint) {};
76
77 1666 void run(pinocchio::JointIndex i_id, int i_q, int i_v, int i_vExtended)
78 {
79 1666 joint.setIndexes(i_id, i_q, i_v, i_vExtended);
80 1666 }
81 };
82
83 template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl>
84 class SetJointIndexes<pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl>>
85 {
86 pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl> & joint_m;
87
88 public:
89 7 explicit SetJointIndexes(
90 pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl> & joint)
91 7 : joint_m(joint) {};
92
93 7 void run(pinocchio::JointIndex i_id, int i_q, int i_v, int i_vExtended)
94 {
95 7 joint_m.setMimicIndexes(joint_m.jmodel().id(), i_q, i_v, joint_m.jmodel().idx_vExtended());
96 7 joint_m.setIndexes(i_id, 0, 0, i_vExtended);
97 7 }
98 };
99
100 template<class Archive, typename Derived>
101 void
102 1680 load(Archive & ar, pinocchio::JointModelBase<Derived> & joint, const unsigned int /*version*/)
103 {
104 pinocchio::JointIndex i_id;
105 int i_q, i_v, i_vExtended;
106
107
1/2
✓ Branch 2 taken 840 times.
✗ Branch 3 not taken.
1680 ar & make_nvp("i_id", i_id);
108
1/2
✓ Branch 2 taken 840 times.
✗ Branch 3 not taken.
1680 ar & make_nvp("i_q", i_q);
109
1/2
✓ Branch 2 taken 840 times.
✗ Branch 3 not taken.
1680 ar & make_nvp("i_v", i_v);
110
1/2
✓ Branch 2 taken 840 times.
✗ Branch 3 not taken.
1680 ar & make_nvp("i_vExtended", i_vExtended);
111
112
1/2
✓ Branch 3 taken 826 times.
✗ Branch 4 not taken.
1680 SetJointIndexes<Derived>(joint.derived()).run(i_id, i_q, i_v, i_vExtended);
113 1680 }
114
115 template<class Archive, typename Scalar, int Options, int axis>
116 1546 void serialize(
117 Archive & ar,
118 pinocchio::JointModelRevoluteTpl<Scalar, Options, axis> & joint,
119 const unsigned int version)
120 {
121 typedef pinocchio::JointModelRevoluteTpl<Scalar, Options, axis> JointType;
122 1546 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
123 1546 }
124
125 template<class Archive, typename Scalar, int Options, int axis>
126 84 void serialize(
127 Archive & ar,
128 pinocchio::JointModelRevoluteUnboundedTpl<Scalar, Options, axis> & joint,
129 const unsigned int version)
130 {
131 typedef pinocchio::JointModelRevoluteUnboundedTpl<Scalar, Options, axis> JointType;
132 84 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
133 84 }
134
135 template<class Archive, typename Scalar, int Options, int axis>
136 84 void serialize(
137 Archive & ar,
138 pinocchio::JointModelPrismaticTpl<Scalar, Options, axis> & joint,
139 const unsigned int version)
140 {
141 typedef pinocchio::JointModelPrismaticTpl<Scalar, Options, axis> JointType;
142 84 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
143 84 }
144
145 template<class Archive, typename Scalar, int Options, int axis>
146 84 void serialize(
147 Archive & ar,
148 pinocchio::JointModelHelicalTpl<Scalar, Options, axis> & joint,
149 const unsigned int version)
150 {
151 typedef pinocchio::JointModelHelicalTpl<Scalar, Options, axis> JointType;
152 84 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
153
1/2
✓ Branch 2 taken 42 times.
✗ Branch 3 not taken.
84 ar & make_nvp("m_pitch", joint.m_pitch);
154 84 }
155
156 template<class Archive, typename Scalar, int Options>
157 28 void serialize(
158 Archive & ar,
159 pinocchio::JointModelHelicalUnalignedTpl<Scalar, Options> & joint,
160 const unsigned int version)
161 {
162 typedef pinocchio::JointModelHelicalUnalignedTpl<Scalar, Options> JointType;
163 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
164
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("axis", joint.axis);
165
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("m_pitch", joint.m_pitch);
166 28 }
167
168 template<class Archive, typename Scalar, int Options>
169 78 void serialize(
170 Archive & ar,
171 pinocchio::JointModelFreeFlyerTpl<Scalar, Options> & joint,
172 const unsigned int version)
173 {
174 typedef pinocchio::JointModelFreeFlyerTpl<Scalar, Options> JointType;
175 78 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
176 78 }
177
178 template<class Archive, typename Scalar, int Options>
179 28 void serialize(
180 Archive & ar,
181 pinocchio::JointModelPlanarTpl<Scalar, Options> & joint,
182 const unsigned int version)
183 {
184 typedef pinocchio::JointModelPlanarTpl<Scalar, Options> JointType;
185 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
186 28 }
187
188 template<class Archive, typename Scalar, int Options>
189 28 void serialize(
190 Archive & ar,
191 pinocchio::JointModelSphericalTpl<Scalar, Options> & joint,
192 const unsigned int version)
193 {
194 typedef pinocchio::JointModelSphericalTpl<Scalar, Options> JointType;
195 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
196 28 }
197
198 template<class Archive, typename Scalar, int Options>
199 28 void serialize(
200 Archive & ar,
201 pinocchio::JointModelSphericalZYXTpl<Scalar, Options> & joint,
202 const unsigned int version)
203 {
204 typedef pinocchio::JointModelSphericalZYXTpl<Scalar, Options> JointType;
205 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
206 28 }
207
208 template<class Archive, typename Scalar, int Options>
209 28 void serialize(
210 Archive & ar,
211 pinocchio::JointModelTranslationTpl<Scalar, Options> & joint,
212 const unsigned int version)
213 {
214 typedef pinocchio::JointModelTranslationTpl<Scalar, Options> JointType;
215 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
216 28 }
217
218 template<class Archive, typename Scalar, int Options>
219 28 void serialize(
220 Archive & ar,
221 pinocchio::JointModelRevoluteUnalignedTpl<Scalar, Options> & joint,
222 const unsigned int version)
223 {
224 typedef pinocchio::JointModelRevoluteUnalignedTpl<Scalar, Options> JointType;
225 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
226
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("axis", joint.axis);
227 28 }
228
229 template<class Archive, typename Scalar, int Options>
230 28 void serialize(
231 Archive & ar,
232 pinocchio::JointModelRevoluteUnboundedUnalignedTpl<Scalar, Options> & joint,
233 const unsigned int version)
234 {
235 typedef pinocchio::JointModelRevoluteUnboundedUnalignedTpl<Scalar, Options> JointType;
236 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
237
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("axis", joint.axis);
238 28 }
239
240 template<class Archive, typename Scalar, int Options>
241 28 void serialize(
242 Archive & ar,
243 pinocchio::JointModelPrismaticUnalignedTpl<Scalar, Options> & joint,
244 const unsigned int version)
245 {
246 typedef pinocchio::JointModelPrismaticUnalignedTpl<Scalar, Options> JointType;
247 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
248
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("axis", joint.axis);
249 28 }
250
251 template<class Archive, typename Scalar, int Options>
252 28 void serialize(
253 Archive & ar,
254 pinocchio::JointModelUniversalTpl<Scalar, Options> & joint,
255 const unsigned int version)
256 {
257 typedef pinocchio::JointModelUniversalTpl<Scalar, Options> JointType;
258 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
259
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("axis1", joint.axis1);
260
1/2
✓ Branch 2 taken 14 times.
✗ Branch 3 not taken.
28 ar & make_nvp("axis2", joint.axis2);
261 28 }
262
263 template<
264 class Archive,
265 typename Scalar,
266 int Options,
267 template<typename S, int O> class JointCollectionTpl>
268 28 void serialize(
269 Archive & ar,
270 pinocchio::JointModelCompositeTpl<Scalar, Options, JointCollectionTpl> & joint,
271 const unsigned int version)
272 {
273 typedef pinocchio::JointModelCompositeTpl<Scalar, Options, JointCollectionTpl> JointType;
274 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
275
276 28 ::pinocchio::Serialize<JointType>::run(ar, joint);
277 28 }
278
279 template<
280 class Archive,
281 typename Scalar,
282 int Options,
283 template<typename S, int O> class JointCollectionTpl>
284 1512 void serialize(
285 Archive & ar,
286 pinocchio::JointModelTpl<Scalar, Options, JointCollectionTpl> & joint,
287 const unsigned int version)
288 {
289 typedef pinocchio::JointModelTpl<Scalar, Options, JointCollectionTpl> JointType;
290 1512 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
291
292 typedef typename JointCollectionTpl<Scalar, Options>::JointModelVariant JointModelVariant;
293
1/2
✓ Branch 3 taken 756 times.
✗ Branch 4 not taken.
1512 ar & make_nvp("base_variant", base_object<JointModelVariant>(joint));
294 1512 }
295
296 template<
297 class Archive,
298 typename Scalar,
299 int Options,
300 template<typename S, int O> class JointCollectionTpl>
301 28 void serialize(
302 Archive & ar,
303 pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl> & joint,
304 const unsigned int version)
305 {
306 typedef pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl> JointType;
307
1/2
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
28 ar & make_nvp("jmodel", joint.jmodel());
308
1/2
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
28 ar & make_nvp("scaling", joint.scaling());
309
1/2
✓ Branch 3 taken 14 times.
✗ Branch 4 not taken.
28 ar & make_nvp("offset", joint.offset());
310
311 28 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
312 28 }
313
314 } // namespace serialization
315 } // namespace boost
316
317 #endif // ifndef __pinocchio_serialization_joints_model_hpp__
318