pinocchio  3.7.0
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
 
Loading...
Searching...
No Matches
joints-model.hpp
1//
2// Copyright (c) 2019 INRIA
3//
4
5#ifndef __pinocchio_serialization_joints_model_hpp__
6#define __pinocchio_serialization_joints_model_hpp__
7
8namespace 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
16 {
17 using boost::serialization::make_nvp;
18
19 ar & make_nvp("m_nq", joint.m_nq);
20 ar & make_nvp("m_nv", joint.m_nv);
21 ar & make_nvp("m_nvExtended", joint.m_nvExtended);
22 ar & make_nvp("m_idx_q", joint.m_idx_q);
23 ar & make_nvp("m_nqs", joint.m_nqs);
24 ar & make_nvp("m_idx_v", joint.m_idx_v);
25 ar & make_nvp("m_nvs", joint.m_nvs);
26 ar & make_nvp("m_idx_vExtended", joint.m_idx_vExtended);
27 ar & make_nvp("m_nvExtendeds", joint.m_nvExtendeds);
28 ar & make_nvp("njoints", joint.njoints);
29
30 ar & make_nvp("joints", joint.joints);
31 ar & make_nvp("jointPlacements", joint.jointPlacements);
32 }
33 };
34} // namespace pinocchio
35
36namespace 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 void serialize(
47 Archive & ar, pinocchio::JointModelBase<Derived> & joint, const unsigned int version)
48 {
49 split_free(ar, joint, version);
50 }
51 } // namespace fix
52
53 template<class Archive, typename Derived>
54 void save(
55 Archive & ar,
57 const unsigned int /*version*/)
58 {
59 const pinocchio::JointIndex i_id = joint.id();
60 const int i_q = joint.idx_q(), i_v = joint.idx_v(), i_vExtended = joint.idx_vExtended();
61
62 ar & make_nvp("i_id", i_id);
63 ar & make_nvp("i_q", i_q);
64 ar & make_nvp("i_v", i_v);
65 ar & make_nvp("i_vExtended", i_vExtended);
66 }
67
68 template<typename Derived>
70 {
71 Derived & joint;
72
73 public:
74 explicit SetJointIndexes(Derived & joint)
75 : joint(joint) {};
76
77 void run(pinocchio::JointIndex i_id, int i_q, int i_v, int i_vExtended)
78 {
79 joint.setIndexes(i_id, i_q, i_v, i_vExtended);
80 }
81 };
82
83 template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl>
84 class SetJointIndexes<pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl>>
85 {
87
88 public:
89 explicit SetJointIndexes(
91 : joint_m(joint) {};
92
93 void run(pinocchio::JointIndex i_id, int i_q, int i_v, int i_vExtended)
94 {
95 joint_m.setMimicIndexes(joint_m.jmodel().id(), i_q, i_v, joint_m.jmodel().idx_vExtended());
96 joint_m.setIndexes(i_id, 0, 0, i_vExtended);
97 }
98 };
99
100 template<class Archive, typename Derived>
101 void
102 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 ar & make_nvp("i_id", i_id);
108 ar & make_nvp("i_q", i_q);
109 ar & make_nvp("i_v", i_v);
110 ar & make_nvp("i_vExtended", i_vExtended);
111
112 SetJointIndexes<Derived>(joint.derived()).run(i_id, i_q, i_v, i_vExtended);
113 }
114
115 template<class Archive, typename Scalar, int Options, int axis>
116 void serialize(
117 Archive & ar,
119 const unsigned int version)
120 {
122 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
123 }
124
125 template<class Archive, typename Scalar, int Options, int axis>
126 void serialize(
127 Archive & ar,
129 const unsigned int version)
130 {
132 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
133 }
134
135 template<class Archive, typename Scalar, int Options, int axis>
136 void serialize(
137 Archive & ar,
139 const unsigned int version)
140 {
142 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
143 }
144
145 template<class Archive, typename Scalar, int Options, int axis>
146 void serialize(
147 Archive & ar,
149 const unsigned int version)
150 {
152 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
153 ar & make_nvp("m_pitch", joint.m_pitch);
154 }
155
156 template<class Archive, typename Scalar, int Options>
157 void serialize(
158 Archive & ar,
160 const unsigned int version)
161 {
163 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
164 ar & make_nvp("axis", joint.axis);
165 ar & make_nvp("m_pitch", joint.m_pitch);
166 }
167
168 template<class Archive, typename Scalar, int Options>
169 void serialize(
170 Archive & ar,
172 const unsigned int version)
173 {
175 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
176 }
177
178 template<class Archive, typename Scalar, int Options>
179 void serialize(
180 Archive & ar,
182 const unsigned int version)
183 {
185 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
186 }
187
188 template<class Archive, typename Scalar, int Options>
189 void serialize(
190 Archive & ar,
192 const unsigned int version)
193 {
195 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
196 }
197
198 template<class Archive, typename Scalar, int Options>
199 void serialize(
200 Archive & ar,
202 const unsigned int version)
203 {
205 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
206 }
207
208 template<class Archive, typename Scalar, int Options>
209 void serialize(
210 Archive & ar,
212 const unsigned int version)
213 {
215 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
216 }
217
218 template<class Archive, typename Scalar, int Options>
219 void serialize(
220 Archive & ar,
222 const unsigned int version)
223 {
225 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
226 ar & make_nvp("axis", joint.axis);
227 }
228
229 template<class Archive, typename Scalar, int Options>
230 void serialize(
231 Archive & ar,
233 const unsigned int version)
234 {
236 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
237 ar & make_nvp("axis", joint.axis);
238 }
239
240 template<class Archive, typename Scalar, int Options>
241 void serialize(
242 Archive & ar,
244 const unsigned int version)
245 {
247 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
248 ar & make_nvp("axis", joint.axis);
249 }
250
251 template<class Archive, typename Scalar, int Options>
252 void serialize(
253 Archive & ar,
255 const unsigned int version)
256 {
258 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
259 ar & make_nvp("axis1", joint.axis1);
260 ar & make_nvp("axis2", joint.axis2);
261 }
262
263 template<
264 class Archive,
265 typename Scalar,
266 int Options,
267 template<typename S, int O> class JointCollectionTpl>
268 void serialize(
269 Archive & ar,
271 const unsigned int version)
272 {
274 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
275
277 }
278
279 template<
280 class Archive,
281 typename Scalar,
282 int Options,
283 template<typename S, int O> class JointCollectionTpl>
284 void serialize(
285 Archive & ar,
287 const unsigned int version)
288 {
290 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
291
292 typedef typename JointCollectionTpl<Scalar, Options>::JointModelVariant JointModelVariant;
293 ar & make_nvp("base_variant", base_object<JointModelVariant>(joint));
294 }
295
296 template<
297 class Archive,
298 typename Scalar,
299 int Options,
300 template<typename S, int O> class JointCollectionTpl>
301 void serialize(
302 Archive & ar,
304 const unsigned int version)
305 {
307 ar & make_nvp("jmodel", joint.jmodel());
308 ar & make_nvp("scaling", joint.scaling());
309 ar & make_nvp("offset", joint.offset());
310
311 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
312 }
313
314 } // namespace serialization
315} // namespace boost
316
317#endif // ifndef __pinocchio_serialization_joints_model_hpp__
Main pinocchio namespace.
Definition treeview.dox:11