se2ez
se2ez::Box2DCollisionManager Class Reference

A collisions manager that uses Box2D as the underlying collision checking engine. More...

#include <collision.h>

Inheritance diagram for se2ez::Box2DCollisionManager:
[legend]

Public Member Functions

 Box2DCollisionManager (const RobotPtr &robot)
 Constructor. More...
 
virtual ~Box2DCollisionManager ()
 Destructor. More...
 
void compile () override
 Compiles internal data structures for collision checking. Needs to be called if the robot is updated. More...
 
 Box2DCollisionManager (const Box2DCollisionManager &)=delete
 
 Box2DCollisionManager (Box2DCollisionManager &&)=delete
 
bool collide (StatePtr &state) override
 Check if a state is in collision. More...
 
bool collide (StatePtr &state, std::set< std::string > &frames) override
 Check if a state is in collision. More...
 
SignedDistance distance (StatePtr &state) override
 Computes the signed distance of a scene to collision. More...
 
SignedDistance distance (StatePtr &state, SignedDistanceMap &frames) override
 Computes the signed distance of a scene to collision. More...
 
- Public Member Functions inherited from se2ez::CollisionManager
 CollisionManager ()
 Constructor. More...
 
virtual void setACM (const ACMPtr &acm)
 Sets a new ACM to use. More...
 
virtual ACMPtr getACM ()
 Gets the current ACM. More...
 

Private Types

using ContactCallback = std::function< bool(const Box2DShape *, const Box2DShape *, const Box2DContact &)>
 Callback function for checking contacts. Takes in as argument the two fixtures that are a part of the collision, as well as the contact information. Returns true if iteration should continue, false if it should terminate early. More...
 
using PotentialCallback = std::function< bool(const Box2DShape *, const Box2DShape *)>
 Callback function for checking all potential collisions. Takes in as argument the two fixtures that are a part of the collision. Returns true if iteration should continue, false if it should terminate early. More...
 

Private Member Functions

void update (StatePtr &state)
 Updates internal world structure based upon robot state. More...
 
bool checkContacts (const ContactCallback &callback)
 Check all Box2D contacts in the world, and call a callback function for each. More...
 
bool checkPotentials (const PotentialCallback &callback)
 Check all potential collisions in the world, and call a callback function for each. More...
 
SignedDistance computeDistance (const Box2DContact &contact) const
 Compute distance from a contact. More...
 
SignedDistance computeDistance (const Box2DShape *fa, const Box2DShape *fb) const
 Compute distances between two Box2DShapes. More...
 

Private Attributes

const RobotPtr robot_
 Robot model used for collision checking. More...
 
Box2DWorldPtr world_ {nullptr}
 Box2D world model. More...
 
std::map< std::string, std::vector< Box2DShapePtr > > shapes_
 Map of frames to Box2D shapes. More...
 
std::mutex mutex_
 Mutex for collision checking. More...
 

Additional Inherited Members

- Public Types inherited from se2ez::CollisionManager
using SignedDistanceMap = tf::EigenMap< std::string, SignedDistance >
 A map of frame names to their signed distances. More...
 
- Protected Attributes inherited from se2ez::CollisionManager
ACMPtr acm_ {nullptr}
 ACM for collision manager. More...
 

Detailed Description

A collisions manager that uses Box2D as the underlying collision checking engine.

Definition at line 41 of file collision.h.

Member Typedef Documentation

◆ ContactCallback

Callback function for checking contacts. Takes in as argument the two fixtures that are a part of the collision, as well as the contact information. Returns true if iteration should continue, false if it should terminate early.

Definition at line 98 of file collision.h.

◆ PotentialCallback

Callback function for checking all potential collisions. Takes in as argument the two fixtures that are a part of the collision. Returns true if iteration should continue, false if it should terminate early.

Definition at line 110 of file collision.h.

Constructor & Destructor Documentation

◆ Box2DCollisionManager() [1/3]

Box2DCollisionManager::Box2DCollisionManager ( const RobotPtr robot)

Constructor.

Parameters
[in]robotRobot to construct collision manager for.

Box2D Collision manager

Definition at line 263 of file collision.cpp.

◆ ~Box2DCollisionManager()

Box2DCollisionManager::~Box2DCollisionManager ( )
virtual

Destructor.

Definition at line 268 of file collision.cpp.

◆ Box2DCollisionManager() [2/3]

se2ez::Box2DCollisionManager::Box2DCollisionManager ( const Box2DCollisionManager )
delete

◆ Box2DCollisionManager() [3/3]

se2ez::Box2DCollisionManager::Box2DCollisionManager ( Box2DCollisionManager &&  )
delete

Member Function Documentation

◆ checkContacts()

bool Box2DCollisionManager::checkContacts ( const ContactCallback callback)
private

Check all Box2D contacts in the world, and call a callback function for each.

Parameters
[in]callbackCallback function to call for each collision.
Returns
True if checked all without terminating, false if terminated early.

Definition at line 316 of file collision.cpp.

◆ checkPotentials()

bool Box2DCollisionManager::checkPotentials ( const PotentialCallback callback)
private

Check all potential collisions in the world, and call a callback function for each.

Parameters
[in]callbackCallback function to call for each pair.
Returns
True if checked all without terminating, false if terminated early.

Definition at line 337 of file collision.cpp.

◆ collide() [1/2]

bool Box2DCollisionManager::collide ( StatePtr state)
overridevirtual

Check if a state is in collision.

Parameters
[in]stateState to check for collisions using an allowed collision map.
Returns
Returns true if state is in collision, false otherwise.

Implements se2ez::CollisionManager.

Definition at line 371 of file collision.cpp.

◆ collide() [2/2]

bool Box2DCollisionManager::collide ( StatePtr state,
std::set< std::string > &  frames 
)
overridevirtual

Check if a state is in collision.

Parameters
[in]stateState to check for collisions using an allowed collision map.
[out]framesWhat frames are in collision.
Returns
Returns true if state is in collision, false otherwise.

Implements se2ez::CollisionManager.

Definition at line 380 of file collision.cpp.

◆ compile()

void Box2DCollisionManager::compile ( )
overridevirtual

Compiles internal data structures for collision checking. Needs to be called if the robot is updated.

Implements se2ez::CollisionManager.

Definition at line 272 of file collision.cpp.

◆ computeDistance() [1/2]

CollisionManager::SignedDistance Box2DCollisionManager::computeDistance ( const Box2DContact contact) const
private

Compute distance from a contact.

Parameters
[in]contactContact.
Returns
distance between shapes in contact.

Definition at line 437 of file collision.cpp.

◆ computeDistance() [2/2]

CollisionManager::SignedDistance Box2DCollisionManager::computeDistance ( const Box2DShape fa,
const Box2DShape fb 
) const
private

Compute distances between two Box2DShapes.

Parameters
[in]faFirst shape.
[in]fbSecond shape.
Returns
distance between shapes.

Definition at line 396 of file collision.cpp.

◆ distance() [1/2]

CollisionManager::SignedDistance Box2DCollisionManager::distance ( StatePtr state)
overridevirtual

Computes the signed distance of a scene to collision.

Parameters
[in]stateState to computed signed distance for.
Returns
Returns signed distance.

Implements se2ez::CollisionManager.

Definition at line 457 of file collision.cpp.

◆ distance() [2/2]

CollisionManager::SignedDistance Box2DCollisionManager::distance ( StatePtr state,
SignedDistanceMap frames 
)
overridevirtual

Computes the signed distance of a scene to collision.

Parameters
[in]stateState to computed signed distance for.
[out]framesDistance of frame to collision.
Returns
Returns signed distance.

Implements se2ez::CollisionManager.

Definition at line 504 of file collision.cpp.

◆ update()

void Box2DCollisionManager::update ( StatePtr state)
private

Updates internal world structure based upon robot state.

Parameters
[in]stateState to update to.

Definition at line 301 of file collision.cpp.

Member Data Documentation

◆ mutex_

std::mutex se2ez::Box2DCollisionManager::mutex_
private

Mutex for collision checking.

Definition at line 134 of file collision.h.

◆ robot_

const RobotPtr se2ez::Box2DCollisionManager::robot_
private

Robot model used for collision checking.

Definition at line 131 of file collision.h.

◆ shapes_

std::map<std::string, std::vector<Box2DShapePtr> > se2ez::Box2DCollisionManager::shapes_
private

Map of frames to Box2D shapes.

Definition at line 133 of file collision.h.

◆ world_

Box2DWorldPtr se2ez::Box2DCollisionManager::world_ {nullptr}
private

Box2D world model.

Definition at line 132 of file collision.h.


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