RobWorkProject  24.5.15-
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
CollisionDetector Class Reference

The CollisionDetector implements an efficient way of checking a complete frame tree for collisions. More...

#include <CollisionDetector.hpp>

Inherits ProximityCalculator< rw::proximity::CollisionStrategy >.

Classes

struct  QueryResult
 result of a collision query More...
 

Public Types

enum  QueryType { AllContactsFullInfo , AllContactsNoInfo , FirstContactFullInfo , FirstContactNoInfo }
 types of collision query More...
 
typedef rw::core::Ptr< CollisionDetectorPtr
 smart pointer type to this class
 
typedef rw::core::Ptr< const CollisionDetectorCPtr
 smart pointer type to this const class
 
- Public Types inherited from ProximityCalculator< rw::proximity::CollisionStrategy >
typedef rw::proximity::CollisionStrategy Strategy
 the strategy used for detection
 
typedef rw::core::Ptr< ProximityCalculatorPtr
 smart pointer type to this class
 
typedef rw::core::Ptr< const ProximityCalculatorCPtr
 smart pointer type to this const class
 
typedef rw::core::Ptr< std::vector< ProximityStrategyData > > ResultType
 the type used to store results in.
 

Public Member Functions

 CollisionDetector (rw::core::Ptr< rw::models::WorkCell > workcell)
 Collision detector for a workcell with only broad-phase collision checking. More...
 
 CollisionDetector (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< rw::proximity::CollisionStrategy > strategy)
 Collision detector for a workcell. More...
 
 CollisionDetector (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< rw::proximity::CollisionStrategy > strategy, rw::core::Ptr< ProximityFilterStrategy > filter)
 Collision detector for a workcell. Collision checking is done for the provided collision setup alone. More...
 
bool inCollision (const kinematics::State &state, QueryResult *result=0, bool stopAtFirstContact=false) const
 Check the workcell for collisions. More...
 
bool inCollision (const kinematics::State &state, rw::proximity::ProximityData &data) const
 Check the workcell for collisions. More...
 
bool inCollision (const rw::kinematics::State &state, std::vector< std::pair< rw::kinematics::Frame *, rw::kinematics::Frame * >> &result, bool stopAtFirstContact=false)
 Check the workcell for collisions. More...
 
rw::core::Ptr< rw::proximity::CollisionStrategygetCollisionStrategy () const
 Get the narrow-phase collision strategy. More...
 
bool addGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const rw::core::Ptr< rw::geometry::Geometry > geometry)
 Add Geometry associated to frame. More...
 
void removeGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const rw::core::Ptr< rw::geometry::Geometry > geometry)
 Removes geometry from CollisionDetector. More...
 
void removeGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string geometryId)
 Removes geometry from CollisionDetector. More...
 
std::vector< std::string > getGeometryIDs (rw::core::Ptr< rw::kinematics::Frame > frame)
 return the ids of all the geometries of this frames.
 
bool hasGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string &geometryId)
 Returns whether frame has an associated geometry with geometryId. More...
 
rw::core::Ptr< rw::geometry::GeometrygetGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string &geometryId)
 Get the geometry from its ID. More...
 
- Public Member Functions inherited from ProximityCalculator< rw::proximity::CollisionStrategy >
 ProximityCalculator (rw::core::Ptr< rw::kinematics::Frame > root, rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< Strategy > strategy, const rw::kinematics::State &initial_state)
 Proximity calculations for a given tree, collision setup and primitive Proximity calculator. Uses proximity strategy given by the workcell. More...
 
 ProximityCalculator (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< Strategy > strategy)
 Construct proximity calculator for a WorkCell with an associated proximity strategy. More...
 
 ProximityCalculator (const ProximityCalculator &)=delete
 Copy constructor is non-existent. Copying is not possible!
 
ProximityCalculatoroperator= (const ProximityCalculator &)=delete
 Assignment operator is non-existent. Copying is not possible!
 
ProximityStrategyData calculate (const rw::kinematics::State &state, rw::core::Ptr< ProximityStrategyData > settings=rw::core::Ptr< ProximityStrategyData >(), rw::core::Ptr< std::vector< ProximityStrategyData >> results=rw::core::Ptr< std::vector< ProximityStrategyData >>())
 Performece the Proximity calculation based on the chosen strategy type. As the varius strategies usese differenct settings all settings will be extracted from settings. If more then the default result is needed (first collision or shortest distance) result can given to get the extra info. More...
 
rw::core::Ptr< ProximityFilterStrategygetProximityFilterStrategy () const
 The Proximity Filter strategy of the ProximityCalculator.
 
void setProximityFilterStrategy (rw::core::Ptr< ProximityFilterStrategy > proxStrategy)
 Set the Proximity Filter strategy of the ProximityCalculator. More...
 
void setStrategy (rw::core::Ptr< Strategy > strategy)
 Set a new strategy. OBS. models are stored in the strategy, so make sure that the new strategy includes all nessesary models. More...
 
rw::core::Ptr< StrategygetStrategy () const
 Get the ProximityStrategy. More...
 
bool addGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const rw::core::Ptr< rw::geometry::Geometry > &geometry)
 Add Geometry associated to frame. More...
 
void removeGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const rw::core::Ptr< rw::geometry::Geometry > &geometry)
 Removes geometry from ProximityCalculator. More...
 
void removeGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string geometryId)
 Removes geometry from ProximityCalculator. More...
 
void addRule (const rw::proximity::ProximitySetupRule &rule)
 Adds rule specifying inclusion/exclusion of frame pairs in Proximity calculation.
 
void removeRule (const rw::proximity::ProximitySetupRule &rule)
 Removes rule specifying inclusion/exclusion of frame pairs in Proximity calculation.
 
double getComputationTime () const
 Get the computation time used in the inCollision functions. More...
 
size_t getNoOfCalls () const
 Get the number of times the inCollision functions have been called. More...
 
void resetComputationTimeAndCount ()
 Reset the counter for inCollision invocations and the computation timer.
 
std::vector< std::string > getGeometryIDs (rw::core::Ptr< rw::kinematics::Frame > frame)
 return the ids of all the geometries of this frames.
 
bool hasGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string &geometryId)
 Returns whether frame has an associated geometry with geometryId. More...
 
rw::core::Ptr< rw::geometry::GeometrygetGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string &geometryId)
 Get the geometry from its ID. More...
 

Static Public Member Functions

static rw::core::Ptr< rw::proximity::CollisionDetectormake (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< rw::proximity::CollisionStrategy > strategy)
 
- Static Public Member Functions inherited from ProximityCalculator< rw::proximity::CollisionStrategy >
static rw::core::Ptr< ProximityCalculator< R > > make (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< R > strategy)
 static function to make a new ProximityCalculator More...
 

Detailed Description

The CollisionDetector implements an efficient way of checking a complete frame tree for collisions.

It relies on a BroadPhaseDetector to do initial filtering which removes obviously not colliding frame pairs.

After the filtering the remaining frame pairs are tested for collision using an CollisionStrategy which is a narrow phase collision detector.

The collision detector does not dictate a specific detection strategy or algorithm, instead it relies on the CollisionStrategy interface for the actual collision checking between two frames.

Note
The collision detector is not thread safe and as such should not be used by multiple threads at a time.

Member Enumeration Documentation

◆ QueryType

enum QueryType

types of collision query

Enumerator
AllContactsFullInfo 

find all collisions and return full collision information eg. CollisionStrategy::AllContact

AllContactsNoInfo 

find all collisions but without collision information eg. CollisionStrategy::FirstContact

FirstContactFullInfo 

return on first contact and include full collision information eg. CollisionStrategy::AllContact

FirstContactNoInfo 

return on first collision but without collision information eg. CollisionStrategy::FirstContact

Constructor & Destructor Documentation

◆ CollisionDetector() [1/3]

Collision detector for a workcell with only broad-phase collision checking.

The default collision setup stored in the workcell is used for broad phase collision filtering as a static filter list.

Notice that no narrow phase checking is performed. If broad-phase filter returns any frame-pairs, this will be taken as a collision.

Parameters
workcell[in] the workcell.

◆ CollisionDetector() [2/3]

Collision detector for a workcell.

The collision detector is initialized with the strategy . Notice that the collision detector will create and store models inside the strategy .

The default collision setup stored in the workcell is used for broad phase collision filtering as a static filter list.

Parameters
workcell[in] the workcell.
strategy[in/out] the strategy for narrow-phase checking. The strategy will have models added to it.

◆ CollisionDetector() [3/3]

Collision detector for a workcell. Collision checking is done for the provided collision setup alone.

Parameters
workcell[in] the workcell.
strategy[in/out] the strategy for narrow-phase checking. The strategy will have models added to it.
filter[in] proximity filter used to cull or filter frame-pairs that are obviously not colliding

Member Function Documentation

◆ addGeometry()

bool addGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const rw::core::Ptr< rw::geometry::Geometry geometry 
)

Add Geometry associated to frame.

The current shape of the geometry is copied, hence later changes to geometry has no effect

Parameters
frame[in] Frame to associate geometry to
geometry[in] Geometry to add

◆ getCollisionStrategy()

rw::core::Ptr<rw::proximity::CollisionStrategy> getCollisionStrategy ( ) const
inline

Get the narrow-phase collision strategy.

Returns
the strategy if set, otherwise NULL.

◆ getGeometry()

rw::core::Ptr<rw::geometry::Geometry> getGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const std::string &  geometryId 
)

Get the geometry from its ID.

Parameters
frame[in] the frame of the geometry
geometryId[in] the ID of the geometry
Returns
Pointer to the geometry

◆ hasGeometry()

bool hasGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const std::string &  geometryId 
)

Returns whether frame has an associated geometry with geometryId.

Parameters
frame[in] Frame in question
geometryId[in] Id of the geometry

◆ inCollision() [1/3]

bool inCollision ( const kinematics::State state,
QueryResult result = 0,
bool  stopAtFirstContact = false 
) const

Check the workcell for collisions.

Parameters
state[in] The state for which to check for collisions.
result[out] If non-NULL, the pairs of colliding frames are inserted in result.
stopAtFirstContact[in] If result is non-NULL and stopAtFirstContact is true, then only the first colliding pair is inserted in result. By default all colliding pairs are inserted.
Returns
true if a collision is detected; false otherwise.

◆ inCollision() [2/3]

bool inCollision ( const kinematics::State state,
rw::proximity::ProximityData data 
) const

Check the workcell for collisions.

Parameters
state[in] The state for which to check for collisions.
data[in/out] Defines parameters for the collision check, the results and also enables caching inbetween calls to incollision
Returns
true if a collision is detected; false otherwise.

◆ inCollision() [3/3]

bool inCollision ( const rw::kinematics::State state,
std::vector< std::pair< rw::kinematics::Frame *, rw::kinematics::Frame * >> &  result,
bool  stopAtFirstContact = false 
)
inline

Check the workcell for collisions.

Parameters
state[in] The state for which to check for collisions.
result[out] Where to store pairs of colliding frames.
stopAtFirstContact[in] If result is non-NULL and stopAtFirstContact is true, then only the first colliding pair is inserted in result. By default all colliding pairs are inserted.
Returns
true if a collision is detected; false otherwise.

◆ removeGeometry() [1/2]

void removeGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const rw::core::Ptr< rw::geometry::Geometry geometry 
)

Removes geometry from CollisionDetector.

The id of the geometry is used to match the collision model to the geometry.

Parameters
frame[in] The frame which has the geometry associated
geometry[in] Geometry with the id to be removed

◆ removeGeometry() [2/2]

void removeGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const std::string  geometryId 
)

Removes geometry from CollisionDetector.

The geometryId is used to match the collision model to the geometry.

Parameters
frame[in] The frame which has the geometry associated
geometryId[in] Id of geometry to be removed

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