GCC Code Coverage Report


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