Tesseract
Motion Planning Environment
Loading...
Searching...
No Matches
types.h
Go to the documentation of this file.
1
26#ifndef TESSERACT_COLLISION_TYPES_H
27#define TESSERACT_COLLISION_TYPES_H
28
31#include <Eigen/Core>
32#include <Eigen/Geometry>
33#include <vector>
34#include <memory>
35#include <map>
36#include <array>
37#include <unordered_map>
38#include <functional>
44
45namespace tesseract_collision
46{
47using CollisionShapesConst = std::vector<tesseract_geometry::Geometry::ConstPtr>;
53
59using IsContactAllowedFn = std::function<bool(const std::string&, const std::string&)>;
60
62{
67};
68
70{
71 FIRST = 0,
72 CLOSEST = 1,
73 ALL = 2,
74 LIMITED = 3
75};
76
77static const std::vector<std::string> ContactTestTypeStrings = {
78 "FIRST",
79 "CLOSEST",
80 "ALL",
81 "LIMITED",
82};
83
85{
86 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
87
89 double distance{ std::numeric_limits<double>::max() };
91 std::array<int, 2> type_id{ 0, 0 };
93 std::array<std::string, 2> link_names;
95 std::array<int, 2> shape_id{ -1, -1 };
97 std::array<int, 2> subshape_id{ -1, -1 };
99 std::array<Eigen::Vector3d, 2> nearest_points{ Eigen::Vector3d::Zero(), Eigen::Vector3d::Zero() };
101 std::array<Eigen::Vector3d, 2> nearest_points_local{ Eigen::Vector3d::Zero(), Eigen::Vector3d::Zero() };
103 std::array<Eigen::Isometry3d, 2> transform{ Eigen::Isometry3d::Identity(), Eigen::Isometry3d::Identity() };
110 Eigen::Vector3d normal{ Eigen::Vector3d::Zero() };
112 std::array<double, 2> cc_time{ -1, -1 };
114 std::array<ContinuousCollisionType, 2> cc_type{ ContinuousCollisionType::CCType_None,
121 std::array<Eigen::Isometry3d, 2> cc_transform{ Eigen::Isometry3d::Identity(), Eigen::Isometry3d::Identity() };
122
126 bool single_contact_point{ false };
127
128 ContactResult() = default;
129
131 void clear();
132};
133
135
154{
155public:
156 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
157 using KeyType = std::pair<std::string, std::string>;
162 using PairType = typename std::pair<const KeyType, MappedType>;
163 using FilterFn = std::function<void(PairType&)>;
164
171
177 ContactResult& addContactResult(const KeyType& key, const MappedType& results);
178
185
191 ContactResult& setContactResult(const KeyType& key, const MappedType& results);
192
204 void addInterpolatedCollisionResults(ContactResultMap& sub_segment_results,
205 int sub_segment_index,
206 int sub_segment_last_index,
207 const std::vector<std::string>& active_link_names,
208 double segment_dt,
209 bool discrete,
210 const ContactResultMap::FilterFn& filter = nullptr);
211
212 // Flatten functions
215 void flattenWrapperResults(std::vector<std::reference_wrapper<ContactResult>>& v);
216 void flattenWrapperResults(std::vector<std::reference_wrapper<const ContactResult>>& v) const;
217
222 void filter(const FilterFn& filter);
223
228 long count() const;
229
235 std::size_t size() const;
236
241 bool empty() const;
242
250 void clear();
251
253 void release();
254
259 const ContainerType& getContainer() const;
260
262 // Iterators //
264
265 ConstIteratorType begin() const;
267 ConstIteratorType end() const;
271 ConstIteratorType cend() const;
272
274 // Element Access //
276
277 const ContactResultVector& at(const KeyType& key) const;
278 ConstIteratorType find(const KeyType& key) const;
279
280private:
282 long count_{ 0 };
283};
284
290using IsContactResultValidFn = std::function<bool(const ContactResult&)>;
291
294{
297
300
303
307
310
312};
313
319{
320 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
321
322 ContactTestData() = default;
323 ContactTestData(const std::vector<std::string>& active,
328
330 const std::vector<std::string>* active = nullptr;
331
334
337
340
343
345 bool done = false;
346};
347
357{
359 NONE,
361 DISCRETE,
368};
369
373{
375 NONE,
377 ASSIGN,
379 AND,
381 OR,
382};
383
394{
397
399 CollisionMarginOverrideType margin_data_override_type{ CollisionMarginOverrideType::NONE };
402
407
410 std::unordered_map<std::string, bool> modify_object_enabled;
411};
412
418{
421 ContactRequest request = ContactRequest(),
423 double longest_valid_segment_length = 0.005);
424
427
434};
435} // namespace tesseract_collision
436
437#endif // TESSERACT_COLLISION_TYPES_H
This structure hold contact results for link pairs.
Definition: types.h:154
const ContactResultVector & at(const KeyType &key) const
access specified element with bounds checking
Definition: types.cpp:211
tesseract_common::AlignedMap< KeyType, MappedType > ContainerType
Definition: types.h:159
std::size_t size() const
Get the size of the map.
Definition: types.cpp:166
ContactResult & setContactResult(const KeyType &key, ContactResult result)
Set contact results for the provided key.
Definition: types.cpp:77
std::function< void(PairType &)> FilterFn
Definition: types.h:163
long count_
Definition: types.h:282
bool empty() const
Check if results are present.
Definition: types.cpp:181
void clear()
This is a consurvative clear.
Definition: types.cpp:183
typename std::pair< const KeyType, MappedType > PairType
Definition: types.h:162
void addInterpolatedCollisionResults(ContactResultMap &sub_segment_results, int sub_segment_index, int sub_segment_last_index, const std::vector< std::string > &active_link_names, double segment_dt, bool discrete, const ContactResultMap::FilterFn &filter=nullptr)
This processes interpolated contact results by updating the cc_time and cc_type and then adds the res...
Definition: types.cpp:99
void flattenWrapperResults(std::vector< std::reference_wrapper< ContactResult > > &v)
Definition: types.cpp:235
ConstIteratorType cbegin() const
returns an iterator to the beginning
Definition: types.cpp:207
void flattenMoveResults(ContactResultVector &v)
Definition: types.cpp:215
ConstIteratorType end() const
returns an iterator to the end
Definition: types.cpp:205
std::pair< std::string, std::string > KeyType
Definition: types.h:157
ConstIteratorType cend() const
returns an iterator to the end
Definition: types.cpp:209
long count() const
Get the total number of contact results storted.
Definition: types.cpp:164
void release()
Fully clear all internal data.
Definition: types.cpp:195
const ContainerType & getContainer() const
Get the underlying container.
Definition: types.cpp:201
typename tesseract_common::AlignedMap< KeyType, MappedType >::const_reference ConstReferenceType
Definition: types.h:160
ContactResultVector MappedType
Definition: types.h:158
ContactResult & addContactResult(const KeyType &key, ContactResult result)
Add contact results for the provided key.
Definition: types.cpp:60
ConstIteratorType begin() const
returns an iterator to the beginning
Definition: types.cpp:203
void flattenCopyResults(ContactResultVector &v) const
Definition: types.cpp:227
ConstIteratorType find(const KeyType &key) const
Definition: types.cpp:213
typename tesseract_common::AlignedMap< KeyType, MappedType >::const_iterator ConstIteratorType
Definition: types.h:161
ContainerType data_
Definition: types.h:281
Definition: allowed_collision_matrix.h:23
Stores information about how the margins allowed between collision objects.
Definition: collision_margin_data.h:74
std::shared_ptr< const Geometry > ConstPtr
Definition: geometry.h:63
std::shared_ptr< Geometry > Ptr
Definition: geometry.h:62
auto filter
Definition: collision_core_unit.cpp:532
This is used to store collision margin information.
default_margin
Definition: collision_margin_data_unit.cpp:70
Common Tesseract Macros.
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
Definition: create_convex_hull.cpp:36
Definition: bullet_cast_bvh_manager.h:49
tesseract_geometry::Geometry::Ptr CollisionShapePtr
Definition: types.h:49
tesseract_geometry::Geometry::ConstPtr CollisionShapeConstPtr
Definition: types.h:48
std::vector< tesseract_geometry::Geometry::ConstPtr > CollisionShapesConst
Definition: types.h:47
ContinuousCollisionType
Definition: types.h:62
std::function< bool(const ContactResult &)> IsContactResultValidFn
Should return true if contact results are valid, otherwise false.
Definition: types.h:290
static const std::vector< std::string > ContactTestTypeStrings
Definition: types.h:77
tesseract_common::AlignedVector< ContactResult > ContactResultVector
Definition: types.h:134
ACMOverrideType
Identifies how the provided AllowedCollisionMatrix should be applied relative to the isAllowedFn in t...
Definition: types.h:373
@ OR
New IsContactAllowedFn combines the contact manager fn and the ACM generated fn with and OR.
@ AND
New IsContactAllowedFn combines the contact manager fn and the ACM generated fn with and AND.
@ ASSIGN
Replace the current IsContactAllowedFn with one generated from the ACM provided.
std::function< bool(const std::string &, const std::string &)> IsContactAllowedFn
Should return true if contact allowed, otherwise false.
Definition: types.h:59
ContactTestType
Definition: types.h:70
CollisionEvaluatorType
High level descriptor used in planners and utilities to specify what kind of collision check is desir...
Definition: types.h:357
@ LVS_DISCRETE
Discrete contact manager interpolating using longest valid segment.
@ DISCRETE
Discrete contact manager using only steps specified.
@ CONTINUOUS
Continuous contact manager using only steps specified.
@ LVS_CONTINUOUS
Continuous contact manager interpolating using longest valid segment.
tesseract_common::PairsCollisionMarginData PairsCollisionMarginData
Definition: types.h:52
std::vector< T, Eigen::aligned_allocator< T > > AlignedVector
Enable easy switching to std::filesystem when available.
Definition: types.h:50
std::map< Key, Value, std::less< Key >, Eigen::aligned_allocator< std::pair< const Key, Value > > > AlignedMap
Definition: types.h:53
std::unordered_map< tesseract_common::LinkNamesPair, double, tesseract_common::PairHash > PairsCollisionMarginData
Definition: collision_margin_data.h:70
CollisionMarginOverrideType
Identifies how the provided contact margin data should be applied.
Definition: collision_margin_data.h:46
This is a high level structure containing common information that collision checking utilities need....
Definition: types.h:418
ContactManagerConfig contact_manager_config
Used to configure the contact manager prior to a series of checks.
Definition: types.h:426
ContactRequest contact_request
ContactRequest that will be used for this check. Default test type: FIRST.
Definition: types.h:429
double longest_valid_segment_length
Longest valid segment to use if type supports lvs. Default: 0.005.
Definition: types.h:433
CollisionEvaluatorType type
Specifies the type of collision check to be performed. Default: DISCRETE.
Definition: types.h:431
Contains parameters used to configure a contact manager before a series of contact checks.
Definition: types.h:394
ACMOverrideType acm_override_type
Specifies how to combine the IsContactAllowedFn from acm with the one preset in the contact manager.
Definition: types.h:406
tesseract_common::AllowedCollisionMatrix acm
Additional AllowedCollisionMatrix to consider for this collision check.
Definition: types.h:404
std::unordered_map< std::string, bool > modify_object_enabled
Each key is an object name. Objects will be enabled/disabled based on the value. Objects that aren't ...
Definition: types.h:410
CollisionMarginData margin_data
Stores information about how the margins allowed between collision objects.
Definition: types.h:401
CollisionMarginOverrideType margin_data_override_type
Identify how the collision margin data should be applied to the contact manager.
Definition: types.h:399
The ContactRequest struct.
Definition: types.h:294
bool calculate_distance
This enables the calculation of distance data if two objects are within the contact threshold.
Definition: types.h:302
ContactTestType type
This controls the exit condition for the contact test type.
Definition: types.h:296
IsContactResultValidFn is_valid
This provides a user defined function approve/reject contact results.
Definition: types.h:309
long contact_limit
This is used if the ContactTestType is set to LIMITED, where the test will exit when number of contac...
Definition: types.h:306
bool calculate_penetration
This enables the calculation of penetration contact data if two objects are in collision.
Definition: types.h:299
Eigen::Vector3d normal
The normal vector to move the two objects out of contact in world coordinates.
Definition: types.h:110
void clear()
reset to default values
Definition: types.cpp:31
std::array< std::string, 2 > link_names
The two links that are in contact.
Definition: types.h:93
bool single_contact_point
Some collision checkers only provide a single contact point for a given pair. This is used to indicat...
Definition: types.h:126
EIGEN_MAKE_ALIGNED_OPERATOR_NEW double distance
The distance between two links.
Definition: types.h:89
std::array< Eigen::Isometry3d, 2 > transform
The transform of link in world coordinates.
Definition: types.h:103
std::array< Eigen::Vector3d, 2 > nearest_points
The nearest point on both links in world coordinates.
Definition: types.h:99
std::array< int, 2 > subshape_id
Some shapes like octomap and mesh have subshape (boxes and triangles)
Definition: types.h:97
std::array< Eigen::Isometry3d, 2 > cc_transform
The transform of link in world coordinates at its desired final location. Note: This is not the locat...
Definition: types.h:121
std::array< double, 2 > cc_time
This is between 0 and 1 indicating the point of contact.
Definition: types.h:112
std::array< Eigen::Vector3d, 2 > nearest_points_local
The nearest point on both links in local(link) coordinates.
Definition: types.h:101
std::array< int, 2 > shape_id
The two shapes that are in contact. Each link can be made up of multiple shapes.
Definition: types.h:95
std::array< ContinuousCollisionType, 2 > cc_type
The type of continuous contact.
Definition: types.h:114
std::array< int, 2 > type_id
A user defined type id that is added to the contact shapes.
Definition: types.h:91
This data is intended only to be used internal to the collision checkers as a container and should no...
Definition: types.h:319
CollisionMarginData collision_margin_data
The current contact_distance threshold.
Definition: types.h:333
ContactRequest req
The type of contact request data.
Definition: types.h:339
bool done
Indicate if search is finished.
Definition: types.h:345
ContactResultMap * res
Distance query results information.
Definition: types.h:342
const std::vector< std::string > * active
A vector of active links.
Definition: types.h:330
IsContactAllowedFn fn
The allowed collision function used to check if two links should be excluded from collision checking.
Definition: types.h:336
EIGEN_MAKE_ALIGNED_OPERATOR_NEW ContactTestData()=default
Common Tesseract Types.
v
Definition: tesseract_common_unit.cpp:369
Tesseract Geometries.