RobWorkProject
Classes | Public Types | 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>

Classes

struct  QueryResult
 result of a collision query More...
 

Public Types

enum  QueryType { AllContactsFullInfo, AllContactsNoInfo, FirstContactFullInfo, FirstContactNoInfo }
 types of collision query More...
 
typedef rw::common::Ptr< CollisionDetectorPtr
 smart pointer type to this class
 
typedef rw::common::Ptr< const CollisionDetectorCPtr
 smart pointer type to this const class
 

Public Member Functions

 CollisionDetector (rw::common::Ptr< rw::models::WorkCell > workcell)
 Collision detector for a workcell with only broad-phase collision checking. More...
 
 CollisionDetector (rw::common::Ptr< rw::models::WorkCell > workcell, CollisionStrategy::Ptr strategy)
 Collision detector for a workcell. More...
 
 CollisionDetector (rw::common::Ptr< rw::models::WorkCell > workcell, CollisionStrategy::Ptr strategy, ProximityFilterStrategy::Ptr filter)
 Collision detector for a workcell. Collision checking is done for the provided collision setup alone. More...
 
 CollisionDetector (const CollisionDetector &)=delete
 Copy constructor is non-existent. Copying is not possible!
 
CollisionDetectoroperator= (const CollisionDetector &)=delete
 Assignment operator is non-existent. Copying is not possible!
 
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, class ProximityData &data) const
 Check the workcell for collisions. More...
 
ProximityFilterStrategy::Ptr getProximityFilterStrategy () const
 The broad phase collision strategy of the collision checker.
 
CollisionStrategy::Ptr getCollisionStrategy () const
 Get the narrow-phase collision strategy. More...
 
void addGeometry (rw::kinematics::Frame *frame, const rw::common::Ptr< rw::geometry::Geometry > geometry)
 Add Geometry associated to frame. More...
 
void removeGeometry (rw::kinematics::Frame *frame, const rw::common::Ptr< rw::geometry::Geometry > geometry)
 Removes geometry from CollisionDetector. More...
 
void removeGeometry (rw::kinematics::Frame *frame, const std::string geometryId)
 Removes geometry from CollisionDetector. More...
 
void addRule (const ProximitySetupRule &rule)
 Adds rule specifying inclusion/exclusion of frame pairs in collision detection.
 
void removeRule (const ProximitySetupRule &rule)
 Removes rule specifying inclusion/exclusion of frame pairs in collision detection.
 
double getComputationTime () const
 Get the computation time used in the inCollision functions. More...
 
int 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::kinematics::Frame *frame)
 return the ids of all the geometries of this frames.
 
bool hasGeometry (rw::kinematics::Frame *frame, const std::string &geometryId)
 Returns whether frame has an associated geometry with geometryId. 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
AllContactsNoInfo 

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

FirstContactFullInfo 

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

FirstContactNoInfo 

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

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()

void addGeometry ( rw::kinematics::Frame frame,
const rw::common::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()

CollisionStrategy::Ptr getCollisionStrategy ( ) const
inline

Get the narrow-phase collision strategy.

Returns
the strategy if set, otherwise NULL.

◆ getComputationTime()

double getComputationTime ( ) const
inline

Get the computation time used in the inCollision functions.

Returns
the total computation time.

◆ getNoOfCalls()

int getNoOfCalls ( ) const
inline

Get the number of times the inCollision functions have been called.

Returns
number of calls to inCollision functions.

◆ hasGeometry()

bool hasGeometry ( 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/2]

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/2]

bool inCollision ( const kinematics::State state,
class 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.

◆ removeGeometry() [1/2]

void removeGeometry ( rw::kinematics::Frame frame,
const rw::common::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::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: