serialization/geometry.hpp
Go to the documentation of this file.
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 
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>
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>
77  Archive & ar, pinocchio::GeometryObject * geometry_object_ptr, const unsigned int /*version*/)
78  {
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__
pinocchio::GeometryObject::Base
EIGEN_MAKE_ALIGNED_OPERATOR_NEW typedef ModelItem< GeometryObject > Base
Definition: multibody/geometry-object.hpp:93
pinocchio::GeometryObject::overrideMaterial
bool overrideMaterial
Decide whether to override the Material.
Definition: multibody/geometry-object.hpp:119
pinocchio::ModelItem::parentJoint
JointIndex parentJoint
Index of the parent joint.
Definition: model-item.hpp:28
boost::serialization::serialize
void serialize(Archive &ar, Eigen::Map< PlainObjectBase, MapOptions, StrideType > &m, const unsigned int version)
Definition: serialization/eigen.hpp:222
pinocchio::GeometryObject::meshScale
Eigen::Vector3d meshScale
Scaling vector applied to the GeometryObject::geometry object.
Definition: multibody/geometry-object.hpp:116
collision-with-point-clouds.collision_pair
collision_pair
Definition: collision-with-point-clouds.py:87
pinocchio::GeometryObject::meshColor
Eigen::Vector4d meshColor
RGBA color value of the GeometryObject::geometry object.
Definition: multibody/geometry-object.hpp:122
boost
pinocchio::ModelItem
Definition: model-item.hpp:13
pinocchio::GeometryObject
Definition: multibody/geometry-object.hpp:87
fcl.hpp
pinocchio::GeometryData
Definition: multibody/geometry.hpp:233
boost::serialization::make_nvp
const nvp< pinocchio::container::aligned_vector< T > > make_nvp(const char *name, pinocchio::container::aligned_vector< T > &t)
Definition: serialization/aligned-vector.hpp:37
boost::serialization::load_construct_data
void load_construct_data(Archive &ar, pinocchio::GeometryObject *geometry_object_ptr, const unsigned int)
Definition: serialization/geometry.hpp:76
pinocchio::ModelItem::placement
SE3 placement
Position of kinematic element in parent joint frame.
Definition: model-item.hpp:39
aligned-vector.hpp
pinocchio::CollisionPair
Definition: multibody/geometry.hpp:21
pinocchio::ModelItem::parentFrame
FrameIndex parentFrame
Index of the parent frame.
Definition: model-item.hpp:36
geometry.hpp
pinocchio::GeometryObject::meshPath
std::string meshPath
Absolute path to the mesh file (if the geometry pointee is also a Mesh)
Definition: multibody/geometry-object.hpp:113
pinocchio::GeometryObject::meshTexturePath
std::string meshTexturePath
Absolute path to the mesh texture file.
Definition: multibody/geometry-object.hpp:130
pinocchio::GeometryObject::geometry
CollisionGeometryPtr geometry
The FCL CollisionGeometry (might be a Mesh, a Geometry Primitive, etc.)
Definition: multibody/geometry-object.hpp:110
spatial.hpp
append-urdf-model-with-another-model.geom_model
geom_model
Definition: append-urdf-model-with-another-model.py:26
collisions.geom_data
geom_data
Definition: collisions.py:42
boost::serialization::save_construct_data
void save_construct_data(Archive &ar, const pinocchio::GeometryObject *geometry_object_ptr, const unsigned int)
Definition: serialization/geometry.hpp:66
pinocchio::GeometryObject::disableCollision
bool disableCollision
If true, no collision or distance check will be done between the Geometry and any other geometry.
Definition: multibody/geometry-object.hpp:134
serialization
Definition: serialization.py:1
pinocchio::GeometryModel
Definition: multibody/geometry.hpp:50
pinocchio::ModelItem::name
std::string name
Name of the kinematic element.
Definition: model-item.hpp:25


pinocchio
Author(s):
autogenerated on Sun Dec 22 2024 03:41:09