coal/serialization/collision_data.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2021 INRIA
3 //
4 
5 #ifndef COAL_SERIALIZATION_COLLISION_DATA_H
6 #define COAL_SERIALIZATION_COLLISION_DATA_H
7 
8 #include "coal/collision_data.h"
10 
11 namespace boost {
12 namespace serialization {
13 
14 template <class Archive>
15 void save(Archive& ar, const coal::Contact& contact,
16  const unsigned int /*version*/) {
17  ar& make_nvp("b1", contact.b1);
18  ar& make_nvp("b2", contact.b2);
19  ar& make_nvp("normal", contact.normal);
20  ar& make_nvp("nearest_points", contact.nearest_points);
21  ar& make_nvp("pos", contact.pos);
22  ar& make_nvp("penetration_depth", contact.penetration_depth);
23 }
24 
25 template <class Archive>
26 void load(Archive& ar, coal::Contact& contact, const unsigned int /*version*/) {
27  ar >> make_nvp("b1", contact.b1);
28  ar >> make_nvp("b2", contact.b2);
29  ar >> make_nvp("normal", contact.normal);
30  std::array<coal::Vec3s, 2> nearest_points;
31  ar >> make_nvp("nearest_points", nearest_points);
32  contact.nearest_points[0] = nearest_points[0];
33  contact.nearest_points[1] = nearest_points[1];
34  ar >> make_nvp("pos", contact.pos);
35  ar >> make_nvp("penetration_depth", contact.penetration_depth);
36  contact.o1 = NULL;
37  contact.o2 = NULL;
38 }
39 
41 
42 template <class Archive>
43 void serialize(Archive& ar, coal::QueryRequest& query_request,
44  const unsigned int /*version*/) {
45  ar& make_nvp("gjk_initial_guess", query_request.gjk_initial_guess);
46  // TODO: use gjk_initial_guess instead
49  ar& make_nvp("enable_cached_gjk_guess",
50  query_request.enable_cached_gjk_guess);
52  ar& make_nvp("cached_gjk_guess", query_request.cached_gjk_guess);
53  ar& make_nvp("cached_support_func_guess",
54  query_request.cached_support_func_guess);
55  ar& make_nvp("gjk_max_iterations", query_request.gjk_max_iterations);
56  ar& make_nvp("gjk_tolerance", query_request.gjk_tolerance);
57  ar& make_nvp("gjk_variant", query_request.gjk_variant);
58  ar& make_nvp("gjk_convergence_criterion",
59  query_request.gjk_convergence_criterion);
60  ar& make_nvp("gjk_convergence_criterion_type",
61  query_request.gjk_convergence_criterion_type);
62  ar& make_nvp("epa_max_iterations", query_request.epa_max_iterations);
63  ar& make_nvp("epa_tolerance", query_request.epa_tolerance);
64  ar& make_nvp("collision_distance_threshold",
65  query_request.collision_distance_threshold);
66  ar& make_nvp("enable_timings", query_request.enable_timings);
67 }
68 
69 template <class Archive>
70 void serialize(Archive& ar, coal::QueryResult& query_result,
71  const unsigned int /*version*/) {
72  ar& make_nvp("cached_gjk_guess", query_result.cached_gjk_guess);
73  ar& make_nvp("cached_support_func_guess",
74  query_result.cached_support_func_guess);
75 }
76 
77 template <class Archive>
78 void serialize(Archive& ar, coal::CollisionRequest& collision_request,
79  const unsigned int /*version*/) {
80  ar& make_nvp("base", boost::serialization::base_object<coal::QueryRequest>(
81  collision_request));
82  ar& make_nvp("num_max_contacts", collision_request.num_max_contacts);
83  ar& make_nvp("enable_contact", collision_request.enable_contact);
86  ar& make_nvp("enable_distance_lower_bound",
87  collision_request.enable_distance_lower_bound);
89  ar& make_nvp("security_margin", collision_request.security_margin);
90  ar& make_nvp("break_distance", collision_request.break_distance);
91  ar& make_nvp("distance_upper_bound", collision_request.distance_upper_bound);
92 }
93 
94 template <class Archive>
95 void save(Archive& ar, const coal::CollisionResult& collision_result,
96  const unsigned int /*version*/) {
97  ar& make_nvp("base", boost::serialization::base_object<coal::QueryResult>(
98  collision_result));
99  ar& make_nvp("contacts", collision_result.getContacts());
100  ar& make_nvp("distance_lower_bound", collision_result.distance_lower_bound);
101  ar& make_nvp("nearest_points", collision_result.nearest_points);
102  ar& make_nvp("normal", collision_result.normal);
103 }
104 
105 template <class Archive>
106 void load(Archive& ar, coal::CollisionResult& collision_result,
107  const unsigned int /*version*/) {
108  ar >> make_nvp("base", boost::serialization::base_object<coal::QueryResult>(
109  collision_result));
110  std::vector<coal::Contact> contacts;
111  ar >> make_nvp("contacts", contacts);
112  collision_result.clear();
113  for (size_t k = 0; k < contacts.size(); ++k)
114  collision_result.addContact(contacts[k]);
115  ar >> make_nvp("distance_lower_bound", collision_result.distance_lower_bound);
116  std::array<coal::Vec3s, 2> nearest_points;
117  ar >> make_nvp("nearest_points", nearest_points);
118  collision_result.nearest_points[0] = nearest_points[0];
119  collision_result.nearest_points[1] = nearest_points[1];
120  ar >> make_nvp("normal", collision_result.normal);
121 }
122 
124 
125 template <class Archive>
126 void serialize(Archive& ar, coal::DistanceRequest& distance_request,
127  const unsigned int /*version*/) {
128  ar& make_nvp("base", boost::serialization::base_object<coal::QueryRequest>(
129  distance_request));
132  ar& make_nvp("enable_nearest_points", distance_request.enable_nearest_points);
134  ar& make_nvp("enable_signed_distance",
135  distance_request.enable_signed_distance);
136  ar& make_nvp("rel_err", distance_request.rel_err);
137  ar& make_nvp("abs_err", distance_request.abs_err);
138 }
139 
140 template <class Archive>
141 void save(Archive& ar, const coal::DistanceResult& distance_result,
142  const unsigned int /*version*/) {
143  ar& make_nvp("base", boost::serialization::base_object<coal::QueryResult>(
144  distance_result));
145  ar& make_nvp("min_distance", distance_result.min_distance);
146  ar& make_nvp("nearest_points", distance_result.nearest_points);
147  ar& make_nvp("normal", distance_result.normal);
148  ar& make_nvp("b1", distance_result.b1);
149  ar& make_nvp("b2", distance_result.b2);
150 }
151 
152 template <class Archive>
153 void load(Archive& ar, coal::DistanceResult& distance_result,
154  const unsigned int /*version*/) {
155  ar >> make_nvp("base", boost::serialization::base_object<coal::QueryResult>(
156  distance_result));
157  ar >> make_nvp("min_distance", distance_result.min_distance);
158  std::array<coal::Vec3s, 2> nearest_points;
159  ar >> make_nvp("nearest_points", nearest_points);
160  distance_result.nearest_points[0] = nearest_points[0];
161  distance_result.nearest_points[1] = nearest_points[1];
162  ar >> make_nvp("normal", distance_result.normal);
163  ar >> make_nvp("b1", distance_result.b1);
164  ar >> make_nvp("b2", distance_result.b2);
165  distance_result.o1 = NULL;
166  distance_result.o2 = NULL;
167 }
168 
170 
171 } // namespace serialization
172 } // namespace boost
173 
178 
179 #endif // ifndef COAL_SERIALIZATION_COLLISION_DATA_H
coal::Contact::pos
Vec3s pos
contact position, in world space
Definition: coal/collision_data.h:102
coal::QueryResult::cached_support_func_guess
support_func_guess_t cached_support_func_guess
stores the last support function vertex index, when relevant.
Definition: coal/collision_data.h:280
fwd.h
coal::QueryRequest::gjk_convergence_criterion
GJKConvergenceCriterion gjk_convergence_criterion
convergence criterion used to stop GJK
Definition: coal/collision_data.h:198
boost::serialization::load
void load(Archive &ar, coal::BVSplitter< BV > &splitter_, const unsigned int)
Definition: coal/serialization/BV_splitter.h:44
coal::DistanceResult::o1
const CollisionGeometry * o1
collision object 1
Definition: coal/collision_data.h:1068
coal::QueryRequest::gjk_tolerance
CoalScalar gjk_tolerance
tolerance for the GJK algorithm. Note: This tolerance determines the precision on the estimated dista...
Definition: coal/collision_data.h:192
coal::QueryRequest::gjk_initial_guess
GJKInitialGuess gjk_initial_guess
Definition: coal/collision_data.h:172
coal::QueryRequest::epa_tolerance
CoalScalar epa_tolerance
tolerance for EPA. Note: This tolerance determines the precision on the estimated distance between tw...
Definition: coal/collision_data.h:211
coal::CollisionRequest::enable_contact
bool enable_contact
whether the contact information (normal, penetration depth and contact position) will return.
Definition: coal/collision_data.h:317
coal::QueryRequest::cached_support_func_guess
support_func_guess_t cached_support_func_guess
the support function initial guess set by user
Definition: coal/collision_data.h:183
COAL_COMPILER_DIAGNOSTIC_PUSH
#define COAL_COMPILER_DIAGNOSTIC_PUSH
Definition: include/coal/fwd.hh:120
coal::DistanceResult::b1
int b1
information about the nearest point in object 1 if object 1 is mesh or point cloud,...
Definition: coal/collision_data.h:1077
boost::serialization::serialize
void serialize(Archive &ar, coal::AABB &aabb, const unsigned int)
Definition: coal/serialization/AABB.h:15
coal::Contact::normal
Vec3s normal
contact normal, pointing from o1 to o2. The normal defined as the normalized separation vector: norma...
Definition: coal/collision_data.h:88
coal::QueryResult
base class for all query results
Definition: coal/collision_data.h:275
coal::CollisionRequest::security_margin
CoalScalar security_margin
Distance below which objects are considered in collision. See Collision.
Definition: coal/collision_data.h:328
coal::QueryResult::cached_gjk_guess
Vec3s cached_gjk_guess
stores the last GJK ray when relevant.
Definition: coal/collision_data.h:277
collision_data.h
coal::CollisionRequest::enable_distance_lower_bound
bool enable_distance_lower_bound
Whether a lower bound on distance is returned when objects are disjoint.
Definition: coal/collision_data.h:321
coal::DistanceResult::normal
Vec3s normal
normal.
Definition: coal/collision_data.h:1061
boost
coal::QueryRequest::enable_timings
bool enable_timings
enable timings when performing collision/distance request
Definition: coal/collision_data.h:214
coal::CollisionResult::nearest_points
std::array< Vec3s, 2 > nearest_points
nearest points. A CollisionResult can have multiple contacts. The nearest points in CollisionResults ...
Definition: coal/collision_data.h:414
coal::Contact::o2
const CollisionGeometry * o2
collision object 2
Definition: coal/collision_data.h:63
COAL_SERIALIZATION_DECLARE_EXPORT
#define COAL_SERIALIZATION_DECLARE_EXPORT(T)
Definition: coal/serialization/fwd.h:30
coal::QueryRequest::cached_gjk_guess
Vec3s cached_gjk_guess
the gjk initial guess set by user
Definition: coal/collision_data.h:180
coal::Contact::b2
int b2
contact primitive in object 2 if object 2 is mesh or point cloud, it is the triangle or point id if o...
Definition: coal/collision_data.h:75
coal::DistanceResult::o2
const CollisionGeometry * o2
collision object 2
Definition: coal/collision_data.h:1071
coal::Contact::penetration_depth
CoalScalar penetration_depth
penetration depth
Definition: coal/collision_data.h:105
coal::QueryRequest::gjk_convergence_criterion_type
GJKConvergenceCriterionType gjk_convergence_criterion_type
convergence criterion used to stop GJK
Definition: coal/collision_data.h:201
coal::CollisionResult::distance_lower_bound
CoalScalar distance_lower_bound
Definition: coal/collision_data.h:401
coal::DistanceRequest::abs_err
CoalScalar abs_err
Definition: coal/collision_data.h:1014
COAL_SERIALIZATION_SPLIT
#define COAL_SERIALIZATION_SPLIT(Type)
Definition: coal/serialization/fwd.h:24
coal::QueryRequest::gjk_max_iterations
size_t gjk_max_iterations
maximum iteration for the GJK algorithm
Definition: coal/collision_data.h:186
coal::DistanceResult::min_distance
CoalScalar min_distance
minimum distance between two objects. If two objects are in collision and DistanceRequest::enable_sig...
Definition: coal/collision_data.h:1058
coal::DistanceRequest
request to the distance computation
Definition: coal/collision_data.h:985
coal::CollisionResult::clear
void clear()
clear the results obtained
Definition: coal/collision_data.h:483
coal::Contact::nearest_points
std::array< Vec3s, 2 > nearest_points
nearest points associated to this contact.
Definition: coal/collision_data.h:99
coal::CollisionResult::addContact
void addContact(const Contact &c)
add one contact into result structure
Definition: coal/collision_data.h:431
coal::CollisionResult
collision result
Definition: coal/collision_data.h:390
coal::CollisionRequest
request to the collision algorithm
Definition: coal/collision_data.h:311
coal::QueryRequest::epa_max_iterations
size_t epa_max_iterations
max number of iterations for EPA
Definition: coal/collision_data.h:204
coal::DistanceResult
distance result
Definition: coal/collision_data.h:1051
coal::Contact
Contact information returned by collision.
Definition: coal/collision_data.h:58
coal::QueryRequest
base class for all query requests
Definition: coal/collision_data.h:170
coal::DistanceResult::b2
int b2
information about the nearest point in object 2 if object 2 is mesh or point cloud,...
Definition: coal/collision_data.h:1083
coal::QueryRequest::gjk_variant
GJKVariant gjk_variant
whether to enable the Nesterov accleration of GJK
Definition: coal/collision_data.h:195
coal::DistanceRequest::rel_err
CoalScalar rel_err
error threshold for approximate distance
Definition: coal/collision_data.h:1013
coal::Contact::o1
const CollisionGeometry * o1
collision object 1
Definition: coal/collision_data.h:60
coal::CollisionRequest::num_max_contacts
size_t num_max_contacts
The maximum number of contacts that can be returned.
Definition: coal/collision_data.h:313
coal::CollisionResult::normal
Vec3s normal
normal associated to nearest_points. Same as CollisionResult::nearest_points but for the normal.
Definition: coal/collision_data.h:405
COAL_COMPILER_DIAGNOSTIC_POP
#define COAL_COMPILER_DIAGNOSTIC_POP
Definition: include/coal/fwd.hh:121
coal::DistanceRequest::enable_signed_distance
bool enable_signed_distance
whether to compute the penetration depth when objects are in collision. Turning this off can save com...
Definition: coal/collision_data.h:1010
COAL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
#define COAL_COMPILER_DIAGNOSTIC_IGNORED_DEPRECECATED_DECLARATIONS
Definition: include/coal/fwd.hh:122
boost::serialization::save
void save(Archive &ar, const coal::BVSplitter< BV > &splitter_, const unsigned int)
Definition: coal/serialization/BV_splitter.h:30
coal::CollisionResult::getContacts
void getContacts(std::vector< Contact > &contacts_) const
get all the contacts
Definition: coal/collision_data.h:475
coal::QueryRequest::enable_cached_gjk_guess
bool enable_cached_gjk_guess
whether enable gjk initial guess @Deprecated Use gjk_initial_guess instead
Definition: coal/collision_data.h:177
coal::Contact::b1
int b1
contact primitive in object 1 if object 1 is mesh or point cloud, it is the triangle or point id if o...
Definition: coal/collision_data.h:69
coal::QueryRequest::collision_distance_threshold
CoalScalar collision_distance_threshold
threshold below which a collision is considered.
Definition: coal/collision_data.h:217
coal::CollisionRequest::break_distance
CoalScalar break_distance
Distance below which bounding volumes are broken down. See Collision.
Definition: coal/collision_data.h:332
coal::DistanceResult::nearest_points
std::array< Vec3s, 2 > nearest_points
nearest points. See CollisionResult::nearest_points.
Definition: coal/collision_data.h:1065
coal::CollisionRequest::distance_upper_bound
CoalScalar distance_upper_bound
Distance above which GJK solver makes an early stopping. GJK stops searching for the closest points w...
Definition: coal/collision_data.h:340


hpp-fcl
Author(s):
autogenerated on Sat Nov 23 2024 03:44:57