Public Types | Public Member Functions | Private Attributes | List of all members
tesseract_collision::ContactResultMap Class Reference

This structure hold contact results for link pairs. More...

#include <types.h>

Public Types

using ConstIteratorType = typename tesseract_common::AlignedMap< KeyType, MappedType >::const_iterator
 
using ConstReferenceType = typename tesseract_common::AlignedMap< KeyType, MappedType >::const_reference
 
using ContainerType = tesseract_common::AlignedMap< KeyType, MappedType >
 
using FilterFn = std::function< void(PairType &)>
 
using KeyType = std::pair< std::string, std::string >
 
using MappedType = ContactResultVector
 
using PairType = typename std::pair< const KeyType, MappedType >
 

Public Member Functions

ContactResultaddContactResult (const KeyType &key, const MappedType &results)
 Add contact results for the provided key. More...
 
ContactResultaddContactResult (const KeyType &key, ContactResult result)
 Add contact results for the provided key. More...
 
void addInterpolatedCollisionResults (ContactResultMap &sub_segment_results, long sub_segment_index, long 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 result. More...
 
const ContactResultVectorat (const KeyType &key) const
 access specified element with bounds checking More...
 
ConstIteratorType begin () const
 returns an iterator to the beginning More...
 
ConstIteratorType cbegin () const
 returns an iterator to the beginning More...
 
ConstIteratorType cend () const
 returns an iterator to the end More...
 
void clear ()
 This is a consurvative clear. More...
 
long count () const
 Get the total number of contact results storted. More...
 
bool empty () const
 Check if results are present. More...
 
ConstIteratorType end () const
 returns an iterator to the end More...
 
void filter (const FilterFn &filter)
 Filter out results using the provided function. More...
 
ConstIteratorType find (const KeyType &key) const
 
void flattenCopyResults (ContactResultVector &v) const
 
void flattenMoveResults (ContactResultVector &v)
 
void flattenWrapperResults (std::vector< std::reference_wrapper< const ContactResult >> &v) const
 
void flattenWrapperResults (std::vector< std::reference_wrapper< ContactResult >> &v)
 
const ContainerTypegetContainer () const
 Get the underlying container. More...
 
std::string getSummary () const
 Get a brief summary of the most frequently colliding link pair. More...
 
bool operator!= (const ContactResultMap &rhs) const
 
bool operator== (const ContactResultMap &rhs) const
 
void release ()
 Fully clear all internal data. More...
 
ContactResultsetContactResult (const KeyType &key, const MappedType &results)
 Set contact results for the provided key. More...
 
ContactResultsetContactResult (const KeyType &key, ContactResult result)
 Set contact results for the provided key. More...
 
void shrinkToFit ()
 Remove map entries with no contact results. More...
 
std::size_t size () const
 Get the size of the map. More...
 

Private Attributes

long count_ { 0 }
 
ContainerType data_
 

Detailed Description

This structure hold contact results for link pairs.

A custom class was implemented to avoid a large number of heap allocations during motion which avoids full clearing the map. This class provides methods const container methods for access the internal map and has two distinct different when it comes to the clear, size and release methods.

The clear method does not call clear on the map but instead it loops over all entries and calls clear on the vector being stored. This allows the memory to remain with the map and not get release for each of the vectors stored in the map.

The size method loops over the map and counts those that have vectors which are not empty.

The release method actually calls clear on the internal map relasing all memory.

Todo:
This should be updated to leverage a object pool for ContactResultVector where in the set and add methods it would check it the pair exists and if not it would pull from the object pool.

Definition at line 155 of file types.h.

Member Typedef Documentation

◆ ConstIteratorType

Definition at line 163 of file types.h.

◆ ConstReferenceType

Definition at line 162 of file types.h.

◆ ContainerType

Definition at line 161 of file types.h.

◆ FilterFn

Definition at line 165 of file types.h.

◆ KeyType

using tesseract_collision::ContactResultMap::KeyType = std::pair<std::string, std::string>

Definition at line 159 of file types.h.

◆ MappedType

Definition at line 160 of file types.h.

◆ PairType

Definition at line 164 of file types.h.

Member Function Documentation

◆ addContactResult() [1/2]

ContactResult & tesseract_collision::ContactResultMap::addContactResult ( const KeyType key,
const MappedType results 
)

Add contact results for the provided key.

Parameters
keyThe key to append the results to
resultThe results to add

Definition at line 111 of file types.cpp.

◆ addContactResult() [2/2]

ContactResult & tesseract_collision::ContactResultMap::addContactResult ( const KeyType key,
ContactResult  result 
)

Add contact results for the provided key.

Parameters
keyThe key to append the results to
resultThe results to add

Definition at line 103 of file types.cpp.

◆ addInterpolatedCollisionResults()

void tesseract_collision::ContactResultMap::addInterpolatedCollisionResults ( ContactResultMap sub_segment_results,
long  sub_segment_index,
long  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 result.

This is copied from the trajopt utility processInterpolatedCollisionResults

Parameters
sub_segment_resultsThe interpolated results to process
sub_segment_indexThe current sub segment index
sub_segment_last_indexThe last sub segment index
active_link_namesThe active link names
segment_dtThe segment dt
discreteIf discrete contact checker was used
filterAn option filter to exclude results

Definition at line 146 of file types.cpp.

◆ at()

const ContactResultVector & tesseract_collision::ContactResultMap::at ( const KeyType key) const

access specified element with bounds checking

Definition at line 266 of file types.cpp.

◆ begin()

ContactResultMap::ConstIteratorType tesseract_collision::ContactResultMap::begin ( ) const

returns an iterator to the beginning

Definition at line 258 of file types.cpp.

◆ cbegin()

ContactResultMap::ConstIteratorType tesseract_collision::ContactResultMap::cbegin ( ) const

returns an iterator to the beginning

Definition at line 262 of file types.cpp.

◆ cend()

ContactResultMap::ConstIteratorType tesseract_collision::ContactResultMap::cend ( ) const

returns an iterator to the end

Definition at line 264 of file types.cpp.

◆ clear()

void tesseract_collision::ContactResultMap::clear ( )

This is a consurvative clear.

This does not call clear on the internal map but instead loops over each link pair entry and calls clear on the underlying vector. This way the vector capacity remains the same to avoid uneccessary heap allocation for subsequent contact requests.

Note
Use release to fully clear the internal data structure

Definition at line 231 of file types.cpp.

◆ count()

long tesseract_collision::ContactResultMap::count ( ) const

Get the total number of contact results storted.

Returns
The number of contact results

Definition at line 212 of file types.cpp.

◆ empty()

bool tesseract_collision::ContactResultMap::empty ( ) const

Check if results are present.

Returns

Definition at line 229 of file types.cpp.

◆ end()

ContactResultMap::ConstIteratorType tesseract_collision::ContactResultMap::end ( ) const

returns an iterator to the end

Definition at line 260 of file types.cpp.

◆ filter()

void tesseract_collision::ContactResultMap::filter ( const FilterFn filter)

Filter out results using the provided function.

Parameters
fnThe filter function

Definition at line 306 of file types.cpp.

◆ find()

ContactResultMap::ConstIteratorType tesseract_collision::ContactResultMap::find ( const KeyType key) const

Definition at line 268 of file types.cpp.

◆ flattenCopyResults()

void tesseract_collision::ContactResultMap::flattenCopyResults ( ContactResultVector v) const

Definition at line 282 of file types.cpp.

◆ flattenMoveResults()

void tesseract_collision::ContactResultMap::flattenMoveResults ( ContactResultVector v)

Definition at line 270 of file types.cpp.

◆ flattenWrapperResults() [1/2]

void tesseract_collision::ContactResultMap::flattenWrapperResults ( std::vector< std::reference_wrapper< const ContactResult >> &  v) const

Definition at line 298 of file types.cpp.

◆ flattenWrapperResults() [2/2]

void tesseract_collision::ContactResultMap::flattenWrapperResults ( std::vector< std::reference_wrapper< ContactResult >> &  v)

Definition at line 290 of file types.cpp.

◆ getContainer()

const ContactResultMap::ContainerType & tesseract_collision::ContactResultMap::getContainer ( ) const

Get the underlying container.

Warning
Do not use this for anything other than debugging or serialization

Definition at line 256 of file types.cpp.

◆ getSummary()

std::string tesseract_collision::ContactResultMap::getSummary ( ) const

Get a brief summary of the most frequently colliding link pair.

Returns
A string containing the collision summary

Definition at line 325 of file types.cpp.

◆ operator!=()

bool tesseract_collision::ContactResultMap::operator!= ( const ContactResultMap rhs) const

Definition at line 323 of file types.cpp.

◆ operator==()

bool tesseract_collision::ContactResultMap::operator== ( const ContactResultMap rhs) const

Definition at line 319 of file types.cpp.

◆ release()

void tesseract_collision::ContactResultMap::release ( )

Fully clear all internal data.

Definition at line 250 of file types.cpp.

◆ setContactResult() [1/2]

ContactResult & tesseract_collision::ContactResultMap::setContactResult ( const KeyType key,
const MappedType results 
)

Set contact results for the provided key.

Parameters
keyThe key to assign the provided results to
resultThe results to assign

Definition at line 133 of file types.cpp.

◆ setContactResult() [2/2]

ContactResult & tesseract_collision::ContactResultMap::setContactResult ( const KeyType key,
ContactResult  result 
)

Set contact results for the provided key.

Parameters
keyThe key to assign the provided results to
resultThe results to assign

Definition at line 122 of file types.cpp.

◆ shrinkToFit()

void tesseract_collision::ContactResultMap::shrinkToFit ( )

Remove map entries with no contact results.

Definition at line 243 of file types.cpp.

◆ size()

std::size_t tesseract_collision::ContactResultMap::size ( ) const

Get the size of the map.

This loops over the internal map and counts entries with contacts

Returns
The number of entries with contacts

Definition at line 214 of file types.cpp.

Member Data Documentation

◆ count_

long tesseract_collision::ContactResultMap::count_ { 0 }
private

Definition at line 296 of file types.h.

◆ data_

ContainerType tesseract_collision::ContactResultMap::data_
private

Definition at line 295 of file types.h.


The documentation for this class was generated from the following files:


tesseract_collision
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:53