hpp-pinocchio  4.10.1
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
serialization.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 CNRS
3 // Author: Joseph Mirabel
4 //
5 // This file is part of hpp-pinocchio
6 // hpp-pinocchio is free software: you can redistribute it
7 // and/or modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation, either version
9 // 3 of the License, or (at your option) any later version.
10 //
11 // hpp-pinocchio is distributed in the hope that it will be
12 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Lesser Public License for more details. You should have
15 // received a copy of the GNU Lesser General Public License along with
16 // hpp-pinocchio If not, see
17 // <http://www.gnu.org/licenses/>.
18 
19 #ifndef HPP_PINOCCHIO_SERIALIZATION_HH
20 # define HPP_PINOCCHIO_SERIALIZATION_HH
21 
22 # include <boost/serialization/split_free.hpp>
23 # include <boost/serialization/shared_ptr.hpp>
24 # include <boost/serialization/weak_ptr.hpp>
25 
26 # include <hpp/pinocchio/fwd.hh>
27 
28 namespace hpp {
29 namespace serialization {
33 };
34 } // namespace pinocchio
35 } // namespace hpp
36 
37 
38 BOOST_SERIALIZATION_SPLIT_FREE(hpp::pinocchio::DevicePtr_t)
39 BOOST_SERIALIZATION_SPLIT_FREE(hpp::pinocchio::DeviceWkPtr_t)
40 
41 namespace boost {
42 namespace serialization {
43 template<class Archive>
44 inline void load (Archive& ar, hpp::pinocchio::DevicePtr_t& d, const unsigned int version)
45 {
46  load<Archive, hpp::pinocchio::Device> (ar, d, version);
48  archive_device_wrapper* adw = dynamic_cast<archive_device_wrapper*>(&ar);
49  if (adw) d = adw->device;
50 }
51 template<class Archive>
52 inline void load (Archive& ar, hpp::pinocchio::DeviceWkPtr_t& d, const unsigned int version)
53 {
54  load<Archive, hpp::pinocchio::Device> (ar, d, version);
56  archive_device_wrapper* adw = dynamic_cast<archive_device_wrapper*>(&ar);
57  if (adw) d = adw->device;
58 }
59 template<class Archive>
60 inline void load (Archive& ar, hpp::pinocchio::HumanoidRobotPtr_t& d, const unsigned int version)
61 {
62  load<Archive, hpp::pinocchio::HumanoidRobot> (ar, d, version);
64  archive_device_wrapper* adw = dynamic_cast<archive_device_wrapper*>(&ar);
65  if (adw) d = boost::dynamic_pointer_cast<hpp::pinocchio::HumanoidRobot>(adw->device);
66 }
67 template<class Archive>
68 inline void load (Archive& ar, hpp::pinocchio::HumanoidRobotWkPtr_t& d, const unsigned int version)
69 {
70  load<Archive, hpp::pinocchio::HumanoidRobot> (ar, d, version);
72  archive_device_wrapper* adw = dynamic_cast<archive_device_wrapper*>(&ar);
73  if (adw) d = boost::dynamic_pointer_cast<hpp::pinocchio::HumanoidRobot>(adw->device);
74 }
75 
76 template <class Archive, typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols>
77 inline void serialize(Archive & ar, Eigen::Array<_Scalar,_Rows,_Cols,_Options,_MaxRows,_MaxCols> & m, const unsigned int version)
78 {
79  (void) version;
80  Eigen::DenseIndex rows(m.rows()), cols(m.cols());
81  ar & BOOST_SERIALIZATION_NVP(rows);
82  ar & BOOST_SERIALIZATION_NVP(cols);
83  if (!Archive::is_saving::value)
84  m.resize(rows,cols);
85  if(m.size() > 0)
86  ar & make_nvp("data",make_array(m.data(), (size_t)m.size()));
87 }
88 
89 } // namespace serialization
90 } // namespace boost
91 
92 #endif // HPP_PINOCCHIO_SERIALIZATION_HH
Humanoid robot.
Definition: humanoid-robot.hh:34
boost::shared_ptr< Device > DevicePtr_t
Definition: fwd.hh:106
Definition: serialization.hh:25
Utility functions.
Definition: body.hh:30
boost::shared_ptr< HumanoidRobot > HumanoidRobotPtr_t
Definition: fwd.hh:109
virtual ~archive_device_wrapper()
Definition: serialization.hh:32
void serialize(Archive &ar, Eigen::Array< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &m, const unsigned int version)
Definition: serialization.hh:77
pinocchio::DevicePtr_t device
Definition: serialization.hh:31
void load(Archive &ar, hpp::pinocchio::HumanoidRobotWkPtr_t &d, const unsigned int version)
Definition: serialization.hh:68
Definition: serialization.hh:30