Line |
Branch |
Exec |
Source |
1 |
|
|
// |
2 |
|
|
// Copyright (c) 2021-2024 INRIA |
3 |
|
|
// |
4 |
|
|
|
5 |
|
|
#ifndef __pinocchio_serialization_multibody_geometry_hpp__ |
6 |
|
|
#define __pinocchio_serialization_multibody_geometry_hpp__ |
7 |
|
|
|
8 |
|
|
#include <boost/serialization/vector.hpp> |
9 |
|
|
#include <boost/serialization/map.hpp> |
10 |
|
|
#include <boost/serialization/shared_ptr.hpp> |
11 |
|
|
|
12 |
|
|
#ifdef PINOCCHIO_WITH_HPP_FCL |
13 |
|
|
#define HPP_FCL_SKIP_EIGEN_BOOST_SERIALIZATION |
14 |
|
|
#include <hpp/fcl/serialization/collision_data.h> |
15 |
|
|
#undef HPP_FCL_SKIP_EIGEN_BOOST_SERIALIZATION |
16 |
|
|
#include <hpp/fcl/serialization/geometric_shapes.h> |
17 |
|
|
#include <hpp/fcl/serialization/hfield.h> |
18 |
|
|
#if HPP_FCL_VERSION_AT_LEAST(3, 0, 0) |
19 |
|
|
#include <hpp/fcl/serialization/octree.h> |
20 |
|
|
#endif |
21 |
|
|
#include <hpp/fcl/serialization/convex.h> |
22 |
|
|
#include <hpp/fcl/serialization/BVH_model.h> |
23 |
|
|
#endif // PINOCCHIO_WITH_HPP_FCL |
24 |
|
|
|
25 |
|
|
#include "pinocchio/multibody/geometry.hpp" |
26 |
|
|
#include "pinocchio/serialization/aligned-vector.hpp" |
27 |
|
|
#include "pinocchio/serialization/spatial.hpp" |
28 |
|
|
#include "pinocchio/serialization/fcl.hpp" |
29 |
|
|
|
30 |
|
|
namespace boost |
31 |
|
|
{ |
32 |
|
|
namespace serialization |
33 |
|
|
{ |
34 |
|
|
template<class Archive> |
35 |
|
✗ |
void serialize( |
36 |
|
|
Archive & ar, pinocchio::CollisionPair & collision_pair, const unsigned int /*version*/) |
37 |
|
|
{ |
38 |
|
✗ |
ar & make_nvp("pair", base_object<pinocchio::CollisionPair::Base>(collision_pair)); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
template<class Archive, typename Derived> |
42 |
|
✗ |
void serialize( |
43 |
|
|
Archive & ar, pinocchio::ModelItem<Derived> & model_item, const unsigned int /*version*/) |
44 |
|
|
{ |
45 |
|
✗ |
ar & make_nvp("name", model_item.name); |
46 |
|
✗ |
ar & make_nvp("parentFrame", model_item.parentFrame); |
47 |
|
✗ |
ar & make_nvp("parentJoint", model_item.parentJoint); |
48 |
|
✗ |
ar & make_nvp("placement", model_item.placement); |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
template<class Archive> |
52 |
|
✗ |
void serialize( |
53 |
|
|
Archive & ar, pinocchio::GeometryObject & geometry_object, const unsigned int /*version*/) |
54 |
|
|
{ |
55 |
|
✗ |
ar & make_nvp("base", base_object<pinocchio::GeometryObject::Base>(geometry_object)); |
56 |
|
✗ |
ar & make_nvp("geometry", geometry_object.geometry); |
57 |
|
✗ |
ar & make_nvp("meshPath", geometry_object.meshPath); |
58 |
|
✗ |
ar & make_nvp("meshScale", geometry_object.meshScale); |
59 |
|
✗ |
ar & make_nvp("overrideMaterial", geometry_object.overrideMaterial); |
60 |
|
✗ |
ar & make_nvp("meshColor", geometry_object.meshColor); |
61 |
|
✗ |
ar & make_nvp("meshTexturePath", geometry_object.meshTexturePath); |
62 |
|
✗ |
ar & make_nvp("disableCollision", geometry_object.disableCollision); |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
template<class Archive> |
66 |
|
✗ |
void save_construct_data( |
67 |
|
|
Archive & ar, |
68 |
|
|
const pinocchio::GeometryObject * geometry_object_ptr, |
69 |
|
|
const unsigned int /*version*/) |
70 |
|
|
{ |
71 |
|
✗ |
ar << make_nvp( |
72 |
|
|
"base", *static_cast<const pinocchio::GeometryObject::Base *>(geometry_object_ptr)); |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
template<class Archive> |
76 |
|
✗ |
void load_construct_data( |
77 |
|
|
Archive & ar, pinocchio::GeometryObject * geometry_object_ptr, const unsigned int /*version*/) |
78 |
|
|
{ |
79 |
|
✗ |
pinocchio::GeometryObject::Base base_obj; |
80 |
|
✗ |
ar >> make_nvp("base", base_obj); |
81 |
|
|
|
82 |
|
✗ |
new (geometry_object_ptr) pinocchio::GeometryObject( |
83 |
|
|
base_obj.name, base_obj.parentJoint, base_obj.parentFrame, base_obj.placement, nullptr); |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
template<class Archive> |
87 |
|
|
void |
88 |
|
✗ |
serialize(Archive & ar, pinocchio::GeometryModel & geom_model, const unsigned int /*version*/) |
89 |
|
|
{ |
90 |
|
✗ |
ar & make_nvp("ngeoms", geom_model.ngeoms); |
91 |
|
✗ |
ar & make_nvp("geometryObjects", geom_model.geometryObjects); |
92 |
|
✗ |
ar & make_nvp("collisionPairs", geom_model.collisionPairs); |
93 |
|
✗ |
ar & make_nvp("collisionPairMapping", geom_model.collisionPairMapping); |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
template<class Archive> |
97 |
|
|
void |
98 |
|
✗ |
serialize(Archive & ar, pinocchio::GeometryData & geom_data, const unsigned int /*version*/) |
99 |
|
|
{ |
100 |
|
✗ |
ar & make_nvp("oMg", geom_data.oMg); |
101 |
|
|
|
102 |
|
✗ |
ar & make_nvp("activeCollisionPairs", geom_data.activeCollisionPairs); |
103 |
|
|
|
104 |
|
|
#ifdef PINOCCHIO_WITH_HPP_FCL |
105 |
|
|
// TODO(jcarpent): check whether the archive has been registered with HPP_FCL module ON or |
106 |
|
|
// OFF. |
107 |
|
✗ |
ar & make_nvp("distanceRequests", geom_data.distanceRequests); |
108 |
|
✗ |
ar & make_nvp("distanceResults", geom_data.distanceResults); |
109 |
|
✗ |
ar & make_nvp("collisionRequests", geom_data.collisionRequests); |
110 |
|
✗ |
ar & make_nvp("collisionResults", geom_data.collisionResults); |
111 |
|
|
|
112 |
|
✗ |
ar & make_nvp("radius", geom_data.radius); |
113 |
|
|
|
114 |
|
✗ |
ar & make_nvp("collisionPairIndex", geom_data.collisionPairIndex); |
115 |
|
|
#endif // PINOCCHIO_WITH_HPP_FCL |
116 |
|
|
|
117 |
|
✗ |
ar & make_nvp("innerObjects", geom_data.innerObjects); |
118 |
|
✗ |
ar & make_nvp("outerObjects", geom_data.outerObjects); |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
} // namespace serialization |
122 |
|
|
} // namespace boost |
123 |
|
|
|
124 |
|
|
#endif // ifndef __pinocchio_serialization_multibody_geometry_hpp__ |
125 |
|
|
|