Collision Checker
collision::CollisionChecker Class Reference

CollisionChecker can contain collision objects and their groups (such as ShapeGroup and TimeVariantCollisionObject) More...

#include <collision_checker.h>

Inheritance diagram for collision::CollisionChecker:
collision::ICollisionChecker

Public Member Functions

EIGEN_MAKE_ALIGNED_OPERATOR_NEW CollisionChecker ()
 
CollisionCheckerPtr clone_shared (void) const
 
void addCollisionObject (CollisionObjectConstPtr co)
 Adds a collision object into the CollisionChecker group structure. More...
 
bool rayTrace (const Eigen::Vector2d &point1, const Eigen::Vector2d &point2, std::vector< LineSegment > &intersect, bool remove_overlaps=true)
 adds a collision object to the CC More...
 
int collisionTime (CollisionObjectConstPtr co) const
 Returns timestep at which any of the objects contained in the CollisionChecker collides with the given object. More...
 
bool collide (CollisionObjectConstPtr co, int *collision_time=0) const
 Returns true if any of the objects contained in the CollisionChecker collide with the given object. More...
 
bool collide (CollisionObjectConstPtr co, CollisionObjectConstPtr &obstacle, bool ungroup_shape_groups=false, bool ungroup_TV_obstacles=false) const
 Returns true if any of the objects contained in the CollisionChecker collide with the given object. More...
 
bool collide (CollisionObjectConstPtr co, std::vector< CollisionObjectConstPtr > &obstacles, bool ungroup_shape_groups=false, bool ungroup_TV_obstacles=false) const
 Returns true if any of the objects contained in the CollisionChecker collide with the given object. More...
 
CollisionCheckerPtr windowQuery (const RectangleAABB &aabb) const
 Returns new CollisionChecker with all static objects within the window and all time-variant obstacles. Ungroups all shape groups. More...
 
PrimitiveCollisionCheckerPtr windowQueryPrimitive (const RectangleAABB &aabb) const
 Returns new PrimitiveCollisionChecker with all static objects within the window and all time-variant obstacles. Ungroups all shape groups. More...
 
CollisionCheckerPtr timeSlice (int time_idx) const
 Returns new CollisionChecker with objects that exist at a given timestep. More...
 
void print (std::ostringstream &stream) const
 
void toString (std::ostringstream &stream) const
 
int numberOfObstacles (void) const
 Returns number of contained CollisionObjects of any type. More...
 
std::vector< CollisionObjectConstPtrgetObstacles (void) const
 Returns a Vector with all contained CollisionObjects of any type. More...
 
- Public Member Functions inherited from collision::ICollisionChecker
virtual ~ICollisionChecker ()
 

Detailed Description

CollisionChecker can contain collision objects and their groups (such as ShapeGroup and TimeVariantCollisionObject)

The benefit of grouping objects in the CollisionChecker is that a broadphase structure is built for efficient filtering of candidate objects for the collision

Definition at line 45 of file collision_checker.h.

Constructor & Destructor Documentation

◆ CollisionChecker()

EIGEN_MAKE_ALIGNED_OPERATOR_NEW collision::CollisionChecker::CollisionChecker ( )
inline

Definition at line 52 of file collision_checker.h.

Member Function Documentation

◆ addCollisionObject()

void collision::CollisionChecker::addCollisionObject ( CollisionObjectConstPtr  co)
virtual

Adds a collision object into the CollisionChecker group structure.

Implements collision::ICollisionChecker.

Definition at line 25 of file collision_checker.cc.

◆ clone_shared()

CollisionCheckerPtr collision::CollisionChecker::clone_shared ( void  ) const

Definition at line 12 of file collision_checker.cc.

◆ collide() [1/3]

bool collision::CollisionChecker::collide ( CollisionObjectConstPtr  co,
int *  collision_time = 0 
) const

Returns true if any of the objects contained in the CollisionChecker collide with the given object.

Parameters
[in]cogiven object
[out]optionaloutput pointer for getting the time of the collision
Warning
The function is not thread-safe

Definition at line 68 of file collision_checker.cc.

◆ collide() [2/3]

bool collision::CollisionChecker::collide ( CollisionObjectConstPtr  co,
CollisionObjectConstPtr obstacle,
bool  ungroup_shape_groups = false,
bool  ungroup_TV_obstacles = false 
) const

Returns true if any of the objects contained in the CollisionChecker collide with the given object.

Parameters
[in]cogiven object
[in]ungroup_shape_groupswhen false, ShapeGroups will be treated as separate objects and included in the result. Otherwise, one of the colliding obstacles within the ShapeGroups will be added to the output Vector.
[in]ungroup_TV_obstacleswhen false, TimeVarintCollisionObjects will be treated as separate objects and included in the result. Otherwise, one of the colliding obstacles within the TimeVarintCollisionObject will be added to the output Vector.
[out]obstacleoutput reference for the colliding object
Warning
The function is not thread-safe

Definition at line 112 of file collision_checker.cc.

◆ collide() [3/3]

bool collision::CollisionChecker::collide ( CollisionObjectConstPtr  co,
std::vector< CollisionObjectConstPtr > &  obstacles,
bool  ungroup_shape_groups = false,
bool  ungroup_TV_obstacles = false 
) const

Returns true if any of the objects contained in the CollisionChecker collide with the given object.

Parameters
[in]cogiven object
[in]ungroup_shape_groupswhen false, ShapeGroups will be treated as separate objects and included in the result. Otherwise, the colliding obstacles within the ShapeGroups will be added to the output Vector.
[in]ungroup_TV_obstacleswhen false, TimeVariantCollisionObjects will be treated as separate objects and included in the result. Otherwise, the colliding obstacles within the TimeVariantCollisionObject will be added to the output Vector.
[out]obstaclesoutput Vector for colliding objects
Warning
The function is not thread-safe

Definition at line 235 of file collision_checker.cc.

◆ collisionTime()

int collision::CollisionChecker::collisionTime ( CollisionObjectConstPtr  co) const

Returns timestep at which any of the objects contained in the CollisionChecker collides with the given object.

The function returns -1 if there is no collision or timestep of the collision is not defined (such as for static obstacles)

Warning
The function is not thread-safe

Definition at line 42 of file collision_checker.cc.

◆ getObstacles()

std::vector< CollisionObjectConstPtr > collision::CollisionChecker::getObstacles ( void  ) const
virtual

Returns a Vector with all contained CollisionObjects of any type.

Implements collision::ICollisionChecker.

Definition at line 328 of file collision_checker.cc.

◆ numberOfObstacles()

int collision::CollisionChecker::numberOfObstacles ( void  ) const
virtual

Returns number of contained CollisionObjects of any type.

Implements collision::ICollisionChecker.

Definition at line 319 of file collision_checker.cc.

◆ print()

void collision::CollisionChecker::print ( std::ostringstream &  stream) const

Definition at line 332 of file collision_checker.cc.

◆ rayTrace()

bool collision::CollisionChecker::rayTrace ( const Eigen::Vector2d &  point1,
const Eigen::Vector2d &  point2,
std::vector< LineSegment > &  intersect,
bool  remove_overlaps = true 
)

adds a collision object to the CC

Performs raytracing for a given line segment. The function returns true if the line segment between the given two points collides with any object inside the CollisionChecker. In addition, the function returns Vector with the parts of the given line segment that belong to the occupied space.

The function finds all intersection points between the given line segment and all line segments or circles that the colliding objects are made of.

If the given line segment start or end point lies within an object, the line segment between this point inside the object and the point of collision is added.

If remove_overlaps is set to true, the function joins together all overlapping intervals for the final result.

Parameters
[in]point1line segment begin point
[in]point2line segment end point
[in]remove_overlapsif true, the the function joins together all overlapping intervals for the final result.
Warning
The function is not thread-safe

Definition at line 159 of file collision_checker.cc.

◆ timeSlice()

CollisionCheckerPtr collision::CollisionChecker::timeSlice ( int  time_idx) const

Returns new CollisionChecker with objects that exist at a given timestep.

Parameters
[in]time_idx- index of timestep of interest

Definition at line 302 of file collision_checker.cc.

◆ toString()

void collision::CollisionChecker::toString ( std::ostringstream &  stream) const

Definition at line 193 of file collision_checker.cc.

◆ windowQuery()

CollisionCheckerPtr collision::CollisionChecker::windowQuery ( const RectangleAABB aabb) const

Returns new CollisionChecker with all static objects within the window and all time-variant obstacles. Ungroups all shape groups.

Parameters
[in]aabb- reference to an axis-aligned rectangle representing the region of interest
Warning
The function is not thread-safe

Definition at line 285 of file collision_checker.cc.

◆ windowQueryPrimitive()

PrimitiveCollisionCheckerPtr collision::CollisionChecker::windowQueryPrimitive ( const RectangleAABB aabb) const

Returns new PrimitiveCollisionChecker with all static objects within the window and all time-variant obstacles. Ungroups all shape groups.

Parameters
[in]aabb- reference to a axis-aligned rectangle representing the region of interest
Warning
The function is not thread-safe

Definition at line 264 of file collision_checker.cc.


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