Simox  2.3.74.0
VirtualRobot::CDManager Class Reference

Public Member Functions

 CDManager (CollisionCheckerPtr colChecker=CollisionCheckerPtr())
 if pColChecker is not set, the global collision checker is used More...
 
 CDManager (const CDManager &)=default
 
virtual ~CDManager ()
 
void addCollisionModel (SceneObjectSetPtr m)
 
void addCollisionModelPair (SceneObjectSetPtr m1, SceneObjectSetPtr m2)
 
void addCollisionModelPair (SceneObjectPtr m1, SceneObjectSetPtr m2)
 
void addCollisionModelPair (SceneObjectPtr m1, SceneObjectPtr m2)
 
template<class SetT >
std::enable_if< std::is_base_of< SceneObjectSet, SetT >::value >::type addCollisionModelPair (const std::shared_ptr< SetT > &m1, const std::shared_ptr< SetT > &m2)
 
void addCollisionModel (SceneObjectPtr m)
 
void addCollisionModel (const std::vector< RobotNodePtr > &nodes, const std::string &setName="")
 
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

◆ CDManager() [1/2]

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

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

◆ CDManager() [2/2]

VirtualRobot::CDManager::CDManager ( const CDManager )
default

◆ ~CDManager()

VirtualRobot::CDManager::~CDManager ( )
virtualdefault

Member Function Documentation

◆ _hasSceneObjectSet()

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.

◆ addCollisionModel() [1/3]

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.

◆ addCollisionModel() [2/3]

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

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

◆ addCollisionModel() [3/3]

void VirtualRobot::CDManager::addCollisionModel ( const std::vector< RobotNodePtr > &  nodes,
const std::string &  setName = "" 
)

◆ addCollisionModelPair() [1/4]

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.

◆ addCollisionModelPair() [2/4]

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

◆ addCollisionModelPair() [3/4]

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

◆ addCollisionModelPair() [4/4]

template<class SetT >
std::enable_if<std::is_base_of<SceneObjectSet, SetT>::value>::type VirtualRobot::CDManager::addCollisionModelPair ( const std::shared_ptr< SetT > &  m1,
const std::shared_ptr< SetT > &  m2 
)
inline

◆ getCollisionChecker()

CollisionCheckerPtr VirtualRobot::CDManager::getCollisionChecker ( )

◆ getDistance() [1/6]

float VirtualRobot::CDManager::getDistance ( )

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

◆ getDistance() [2/6]

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

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

◆ getDistance() [3/6]

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

Stores min dist position and collision IDs.

◆ getDistance() [4/6]

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.

◆ getDistance() [5/6]

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

◆ getDistance() [6/6]

float VirtualRobot::CDManager::getDistance ( SceneObjectSetPtr  m,
std::vector< SceneObjectSetPtr > &  sets 
)
protected

◆ getSceneObjectSets()

std::vector< SceneObjectSetPtr > VirtualRobot::CDManager::getSceneObjectSets ( )

All SceneObjectSets that have been added.

◆ hasSceneObject()

bool VirtualRobot::CDManager::hasSceneObject ( SceneObjectPtr  m)

◆ hasSceneObjectSet()

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

◆ isInCollision() [1/3]

bool VirtualRobot::CDManager::isInCollision ( )

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

◆ isInCollision() [2/3]

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.

◆ isInCollision() [3/3]

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

Field Documentation

◆ colChecker

CollisionCheckerPtr VirtualRobot::CDManager::colChecker
protected

◆ colModelPairs

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

◆ colModels

std::vector< SceneObjectSetPtr > VirtualRobot::CDManager::colModels
protected