pinocchio  3.9.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 ar & make_nvp("jointNames", joint.jointNames);
33 }
34 };
35} // namespace pinocchio
36
37namespace boost
38{
39 namespace serialization
40 {
41
42 // For some older version of gcc, we have to rely on an additional namespace
43 // to avoid ambiguous call to boost::serialization::serialize
44 namespace fix
45 {
46 template<class Archive, typename Derived>
47 void serialize(
48 Archive & ar, pinocchio::JointModelBase<Derived> & joint, const unsigned int version)
49 {
50 split_free(ar, joint, version);
51 }
52 } // namespace fix
53
54 template<class Archive, typename Derived>
55 void save(
56 Archive & ar,
57 const pinocchio::JointModelBase<Derived> & joint,
58 const unsigned int /*version*/)
59 {
60 const pinocchio::JointIndex i_id = joint.id();
61 const int i_q = joint.idx_q(), i_v = joint.idx_v(), i_vExtended = joint.idx_vExtended();
62
63 ar & make_nvp("i_id", i_id);
64 ar & make_nvp("i_q", i_q);
65 ar & make_nvp("i_v", i_v);
66 ar & make_nvp("i_vExtended", i_vExtended);
67 }
68
69 template<typename Derived>
70 class SetJointIndexes
71 {
72 Derived & joint;
73
74 public:
75 explicit SetJointIndexes(Derived & joint)
76 : joint(joint) {};
77
78 void run(pinocchio::JointIndex i_id, int i_q, int i_v, int i_vExtended)
79 {
80 joint.setIndexes(i_id, i_q, i_v, i_vExtended);
81 }
82 };
83
84 template<typename Scalar, int Options, template<typename S, int O> class JointCollectionTpl>
85 class SetJointIndexes<pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl>>
86 {
88
89 public:
90 explicit SetJointIndexes(
92 : joint_m(joint) {};
93
94 void run(pinocchio::JointIndex i_id, int i_q, int i_v, int i_vExtended)
95 {
96 joint_m.setMimicIndexes(joint_m.jmodel().id(), i_q, i_v, joint_m.jmodel().idx_vExtended());
97 joint_m.setIndexes(i_id, 0, 0, i_vExtended);
98 }
99 };
100
101 template<class Archive, typename Derived>
102 void
103 load(Archive & ar, pinocchio::JointModelBase<Derived> & joint, const unsigned int /*version*/)
104 {
105 pinocchio::JointIndex i_id;
106 int i_q, i_v, i_vExtended;
107
108 ar & make_nvp("i_id", i_id);
109 ar & make_nvp("i_q", i_q);
110 ar & make_nvp("i_v", i_v);
111 ar & make_nvp("i_vExtended", i_vExtended);
112
113 SetJointIndexes<Derived>(joint.derived()).run(i_id, i_q, i_v, i_vExtended);
114 }
115
116 template<class Archive, typename Scalar, int Options, int axis>
117 void serialize(
118 Archive & ar,
120 const unsigned int version)
121 {
123 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
124 }
125
126 template<class Archive, typename Scalar, int Options, int axis>
127 void serialize(
128 Archive & ar,
130 const unsigned int version)
131 {
133 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
134 }
135
136 template<class Archive, typename Scalar, int Options, int axis>
137 void serialize(
138 Archive & ar,
139 pinocchio::JointModelPrismaticTpl<Scalar, Options, axis> & joint,
140 const unsigned int version)
141 {
142 typedef pinocchio::JointModelPrismaticTpl<Scalar, Options, axis> JointType;
143 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
144 }
145
146 template<class Archive, typename Scalar, int Options, int axis>
147 void serialize(
148 Archive & ar,
149 pinocchio::JointModelHelicalTpl<Scalar, Options, axis> & joint,
150 const unsigned int version)
151 {
152 typedef pinocchio::JointModelHelicalTpl<Scalar, Options, axis> JointType;
153 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
154 ar & make_nvp("m_pitch", joint.m_pitch);
155 }
156
157 template<class Archive, typename Scalar, int Options>
158 void serialize(
159 Archive & ar,
160 pinocchio::JointModelHelicalUnalignedTpl<Scalar, Options> & joint,
161 const unsigned int version)
162 {
163 typedef pinocchio::JointModelHelicalUnalignedTpl<Scalar, Options> JointType;
164 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
165 ar & make_nvp("axis", joint.axis);
166 ar & make_nvp("m_pitch", joint.m_pitch);
167 }
168
169 template<class Archive, typename Scalar, int Options>
170 void serialize(
171 Archive & ar,
172 pinocchio::JointModelFreeFlyerTpl<Scalar, Options> & joint,
173 const unsigned int version)
174 {
175 typedef pinocchio::JointModelFreeFlyerTpl<Scalar, Options> JointType;
176 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
177 }
178
179 template<class Archive, typename Scalar, int Options>
180 void serialize(
181 Archive & ar,
182 pinocchio::JointModelPlanarTpl<Scalar, Options> & joint,
183 const unsigned int version)
184 {
185 typedef pinocchio::JointModelPlanarTpl<Scalar, Options> JointType;
186 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
187 }
188
189 template<class Archive, typename Scalar, int Options>
190 void serialize(
191 Archive & ar,
192 pinocchio::JointModelSphericalTpl<Scalar, Options> & joint,
193 const unsigned int version)
194 {
195 typedef pinocchio::JointModelSphericalTpl<Scalar, Options> JointType;
196 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
197 }
198
199 template<class Archive, typename Scalar, int Options>
200 void serialize(
201 Archive & ar,
202 pinocchio::JointModelSphericalZYXTpl<Scalar, Options> & joint,
203 const unsigned int version)
204 {
205 typedef pinocchio::JointModelSphericalZYXTpl<Scalar, Options> JointType;
206 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
207 }
208
209 template<class Archive, typename Scalar, int Options>
210 void serialize(
211 Archive & ar,
212 pinocchio::JointModelEllipsoidTpl<Scalar, Options> & joint,
213 const unsigned int version)
214 {
215 typedef pinocchio::JointModelEllipsoidTpl<Scalar, Options> JointType;
216 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
217 ar & make_nvp("radius_x", joint.radius_x);
218 ar & make_nvp("radius_y", joint.radius_y);
219 ar & make_nvp("radius_z", joint.radius_z);
220 }
221
222 template<class Archive, typename Scalar, int Options>
223 void serialize(
224 Archive & ar,
225 pinocchio::JointModelTranslationTpl<Scalar, Options> & joint,
226 const unsigned int version)
227 {
228 typedef pinocchio::JointModelTranslationTpl<Scalar, Options> JointType;
229 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
230 }
231
232 template<class Archive, typename Scalar, int Options>
233 void serialize(
234 Archive & ar,
235 pinocchio::JointModelRevoluteUnalignedTpl<Scalar, Options> & joint,
236 const unsigned int version)
237 {
238 typedef pinocchio::JointModelRevoluteUnalignedTpl<Scalar, Options> JointType;
239 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
240 ar & make_nvp("axis", joint.axis);
241 }
242
243 template<class Archive, typename Scalar, int Options>
244 void serialize(
245 Archive & ar,
246 pinocchio::JointModelRevoluteUnboundedUnalignedTpl<Scalar, Options> & joint,
247 const unsigned int version)
248 {
249 typedef pinocchio::JointModelRevoluteUnboundedUnalignedTpl<Scalar, Options> JointType;
250 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
251 ar & make_nvp("axis", joint.axis);
252 }
253
254 template<class Archive, typename Scalar, int Options>
255 void serialize(
256 Archive & ar,
257 pinocchio::JointModelPrismaticUnalignedTpl<Scalar, Options> & joint,
258 const unsigned int version)
259 {
260 typedef pinocchio::JointModelPrismaticUnalignedTpl<Scalar, Options> JointType;
261 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
262 ar & make_nvp("axis", joint.axis);
263 }
264
265 template<class Archive, typename Scalar, int Options>
266 void serialize(
267 Archive & ar,
268 pinocchio::JointModelUniversalTpl<Scalar, Options> & joint,
269 const unsigned int version)
270 {
271 typedef pinocchio::JointModelUniversalTpl<Scalar, Options> JointType;
272 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
273 ar & make_nvp("axis1", joint.axis1);
274 ar & make_nvp("axis2", joint.axis2);
275 }
276
277 template<
278 class Archive,
279 typename Scalar,
280 int Options,
281 template<typename S, int O> class JointCollectionTpl>
282 void serialize(
283 Archive & ar,
284 pinocchio::JointModelCompositeTpl<Scalar, Options, JointCollectionTpl> & joint,
285 const unsigned int version)
286 {
287 typedef pinocchio::JointModelCompositeTpl<Scalar, Options, JointCollectionTpl> JointType;
288 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
289
290 ::pinocchio::Serialize<JointType>::run(ar, joint);
291 }
292
293 template<
294 class Archive,
295 typename Scalar,
296 int Options,
297 template<typename S, int O> class JointCollectionTpl>
298 void serialize(
299 Archive & ar,
300 pinocchio::JointModelTpl<Scalar, Options, JointCollectionTpl> & joint,
301 const unsigned int version)
302 {
303 typedef pinocchio::JointModelTpl<Scalar, Options, JointCollectionTpl> JointType;
304 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
305
306 typedef typename JointCollectionTpl<Scalar, Options>::JointModelVariant JointModelVariant;
307 ar & make_nvp("base_variant", base_object<JointModelVariant>(joint));
308 }
309
310 template<
311 class Archive,
312 typename Scalar,
313 int Options,
314 template<typename S, int O> class JointCollectionTpl>
315 void serialize(
316 Archive & ar,
317 pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl> & joint,
318 const unsigned int version)
319 {
320 typedef pinocchio::JointModelMimicTpl<Scalar, Options, JointCollectionTpl> JointType;
321 ar & make_nvp("jmodel", joint.jmodel());
322 ar & make_nvp("scaling", joint.scaling());
323 ar & make_nvp("offset", joint.offset());
324
325 fix::serialize(ar, *static_cast<pinocchio::JointModelBase<JointType> *>(&joint), version);
326 }
327
328 } // namespace serialization
329} // namespace boost
330
331#endif // ifndef __pinocchio_serialization_joints_model_hpp__
Main pinocchio namespace.
Definition treeview.dox:11
std::vector< int > m_idx_q
Keep information of both the dimension and the position of the joints in the composition.
std::vector< std::string > jointNames
Vector of names for each joint inside the composite.
std::vector< int > m_nvExtendeds
Dimension of the segment in the jacobian matrix.
std::vector< int > m_nvs
Dimension of the segment in the tangent vector.
JointModelVector joints
Vector of joints contained in the joint composite.
std::vector< int > m_nqs
Dimension of the segment in the config vector.
std::vector< int > m_idx_vExtended
Index in the jacobian matrix.
std::vector< int > m_idx_v
Index in the tangent vector.
int njoints
Number of joints contained in the JointModelComposite.
int m_nq
Dimensions of the config and tangent space of the composite joint.
Vector3 axis1
3d main axii of the joint.