Simox  2.3.50
VirtualRobot::CDManager Class Reference

Public Member Functions

 CDManager (CollisionCheckerPtr colChecker=CollisionCheckerPtr())
 if pColChecker is not set, the global collision checker is used More...
 
virtual ~CDManager ()
 
void addCollisionModel (SceneObjectSetPtr m)
 
void addCollisionModelPair (SceneObjectSetPtr m1, SceneObjectSetPtr m2)
 
void addCollisionModelPair (SceneObjectPtr m1, SceneObjectSetPtr m2)
 
void addCollisionModelPair (SceneObjectPtr m1, SceneObjectPtr m2)
 
void addCollisionModel (SceneObjectPtr m)
 
bool hasSceneObjectSet (SceneObjectSetPtr m)
 
bool hasSceneObject (SceneObjectPtr m)
 
bool isInCollision ()
 Returns true if one of the specified collision checks report a collision. More...
 
bool isInCollision (SceneObjectSetPtr m)
 
float getDistance ()
 Returns minimum distance of all sets that have been added for consideration. More...
 
float getDistance (SceneObjectSetPtr m)
 
float getDistance (Eigen::Vector3f &P1, Eigen::Vector3f &P2, int &trID1, int &trID2)
 Stores min dist position and collision IDs. More...
 
float getDistance (SceneObjectSetPtr m, Eigen::Vector3f &P1, Eigen::Vector3f &P2, int &trID1, int &trID2)
 
std::vector< SceneObjectSetPtrgetSceneObjectSets ()
 All SceneObjectSets that have been added. More...
 
CollisionCheckerPtr getCollisionChecker ()
 

Protected Member Functions

bool _hasSceneObjectSet (SceneObjectSetPtr m)
 
bool isInCollision (SceneObjectSetPtr m, std::vector< SceneObjectSetPtr > &sets)
 
float getDistance (SceneObjectSetPtr m, std::vector< SceneObjectSetPtr > &sets, Eigen::Vector3f &P1, Eigen::Vector3f &P2, int &trID1, int &trID2)
 
float getDistance (SceneObjectSetPtr m, std::vector< SceneObjectSetPtr > &sets)
 

Protected Attributes

std::vector< SceneObjectSetPtrcolModels
 
CollisionCheckerPtr colChecker
 
std::map< SceneObjectSetPtr, std::vector< SceneObjectSetPtr > > colModelPairs
 

Detailed Description

A framework that can handle different sets of collision models. With a collision detection manager (cdm) multiple sets collision models can be specified for convenient collision detection or distance calculations. Two methods can be used to add collisionModelSets: addCollisionModel(): All added sets are checked against each other. addCollisionModelPair(): Only the specific pairs are checked.

The methods can be safely mixed.

See also
CollsionModelSet

Constructor & Destructor Documentation

VirtualRobot::CDManager::CDManager ( CollisionCheckerPtr  colChecker = CollisionCheckerPtr())

if pColChecker is not set, the global collision checker is used

VirtualRobot::CDManager::~CDManager ( )
virtual

Member Function Documentation

bool VirtualRobot::CDManager::_hasSceneObjectSet ( SceneObjectSetPtr  m)
protected

Performs also a check for sets with only one object added in order to cover potentionally added single SceneObjects.

void VirtualRobot::CDManager::addCollisionModel ( SceneObjectSetPtr  m)

Sets of SceneObjects can be added. All added SceneObjectSets sets are checked against each other. Internally for all SceneObjectSets that have been added earlier, the method addCollisionModelPair() is called.

void VirtualRobot::CDManager::addCollisionModel ( SceneObjectPtr  m)

Here single collision models can be added. Internally they are wrapped by a SceneObjectSet.

void VirtualRobot::CDManager::addCollisionModelPair ( SceneObjectSetPtr  m1,
SceneObjectSetPtr  m2 
)

Here, a specific pair of SceneObjectSets can be added. m1 and m2 will only be checked against each other and will not be checked against the other SceneObjectSets, that may be part of this CDManager.

void VirtualRobot::CDManager::addCollisionModelPair ( SceneObjectPtr  m1,
SceneObjectSetPtr  m2 
)
void VirtualRobot::CDManager::addCollisionModelPair ( SceneObjectPtr  m1,
SceneObjectPtr  m2 
)
CollisionCheckerPtr VirtualRobot::CDManager::getCollisionChecker ( )
float VirtualRobot::CDManager::getDistance ( )

Returns minimum distance of all sets that have been added for consideration.

float VirtualRobot::CDManager::getDistance ( SceneObjectSetPtr  m)

Calculates the shortest distance of m to all added SceneObjectSets. m may be an already added SceneObjectSets.

float VirtualRobot::CDManager::getDistance ( Eigen::Vector3f &  P1,
Eigen::Vector3f &  P2,
int &  trID1,
int &  trID2 
)

Stores min dist position and collision IDs.

float VirtualRobot::CDManager::getDistance ( SceneObjectSetPtr  m,
Eigen::Vector3f &  P1,
Eigen::Vector3f &  P2,
int &  trID1,
int &  trID2 
)

Calculates the shortest distance of SceneObjectSet m to all added colModels. Stores nearest positions and corresponding IDs, where P1 and trID1 is used to store the data of m and P2 and trID2 is used to store the data of this CDManager.

float VirtualRobot::CDManager::getDistance ( SceneObjectSetPtr  m,
std::vector< SceneObjectSetPtr > &  sets,
Eigen::Vector3f &  P1,
Eigen::Vector3f &  P2,
int &  trID1,
int &  trID2 
)
protected
float VirtualRobot::CDManager::getDistance ( SceneObjectSetPtr  m,
std::vector< SceneObjectSetPtr > &  sets 
)
protected
std::vector< SceneObjectSetPtr > VirtualRobot::CDManager::getSceneObjectSets ( )

All SceneObjectSets that have been added.

bool VirtualRobot::CDManager::hasSceneObject ( SceneObjectPtr  m)
bool VirtualRobot::CDManager::hasSceneObjectSet ( SceneObjectSetPtr  m)
bool VirtualRobot::CDManager::isInCollision ( )

Returns true if one of the specified collision checks report a collision.

bool VirtualRobot::CDManager::isInCollision ( SceneObjectSetPtr  m)

Checks if the model m collides with one of the added colModels. (all SceneObjectSets that have been added are considered) It is allowed to use an already added SceneObjectSets. Returns true if there is a collision.

bool VirtualRobot::CDManager::isInCollision ( SceneObjectSetPtr  m,
std::vector< SceneObjectSetPtr > &  sets 
)
protected

Field Documentation

CollisionCheckerPtr VirtualRobot::CDManager::colChecker
protected
std::map<SceneObjectSetPtr, std::vector<SceneObjectSetPtr> > VirtualRobot::CDManager::colModelPairs
protected
std::vector< SceneObjectSetPtr > VirtualRobot::CDManager::colModels
protected