se2ez
|
A collisions manager that uses Box2D as the underlying collision checking engine. More...
#include <collision.h>
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... | |
![]() | |
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 | |
![]() | |
using | SignedDistanceMap = tf::EigenMap< std::string, SignedDistance > |
A map of frame names to their signed distances. More... | |
![]() | |
ACMPtr | acm_ {nullptr} |
ACM for collision manager. More... | |
A collisions manager that uses Box2D as the underlying collision checking engine.
Definition at line 41 of file collision.h.
|
private |
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.
|
private |
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.
Box2DCollisionManager::Box2DCollisionManager | ( | const RobotPtr & | robot | ) |
Constructor.
[in] | robot | Robot to construct collision manager for. |
Box2D Collision manager
Definition at line 263 of file collision.cpp.
|
virtual |
Destructor.
Definition at line 268 of file collision.cpp.
|
delete |
|
delete |
|
private |
Check all Box2D contacts in the world, and call a callback function for each.
[in] | callback | Callback function to call for each collision. |
Definition at line 316 of file collision.cpp.
|
private |
Check all potential collisions in the world, and call a callback function for each.
[in] | callback | Callback function to call for each pair. |
Definition at line 337 of file collision.cpp.
|
overridevirtual |
Check if a state is in collision.
[in] | state | State to check for collisions using an allowed collision map. |
Implements se2ez::CollisionManager.
Definition at line 371 of file collision.cpp.
|
overridevirtual |
Check if a state is in collision.
[in] | state | State to check for collisions using an allowed collision map. |
[out] | frames | What frames are in collision. |
Implements se2ez::CollisionManager.
Definition at line 380 of file collision.cpp.
|
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.
|
private |
Compute distance from a contact.
[in] | contact | Contact. |
Definition at line 437 of file collision.cpp.
|
private |
Compute distances between two Box2DShapes.
[in] | fa | First shape. |
[in] | fb | Second shape. |
Definition at line 396 of file collision.cpp.
|
overridevirtual |
Computes the signed distance of a scene to collision.
[in] | state | State to computed signed distance for. |
Implements se2ez::CollisionManager.
Definition at line 457 of file collision.cpp.
|
overridevirtual |
Computes the signed distance of a scene to collision.
[in] | state | State to computed signed distance for. |
[out] | frames | Distance of frame to collision. |
Implements se2ez::CollisionManager.
Definition at line 504 of file collision.cpp.
|
private |
Updates internal world structure based upon robot state.
[in] | state | State to update to. |
Definition at line 301 of file collision.cpp.
|
private |
Mutex for collision checking.
Definition at line 134 of file collision.h.
|
private |
Robot model used for collision checking.
Definition at line 131 of file collision.h.
|
private |
Map of frames to Box2D shapes.
Definition at line 133 of file collision.h.
|
private |
Box2D world model.
Definition at line 132 of file collision.h.