Package org.robwork.sdurw_proximity
Class CollisionDetector
- java.lang.Object
-
- org.robwork.sdurw_proximity.ProximityCalculatorCollision
-
- org.robwork.sdurw_proximity.CollisionDetector
-
public class CollisionDetector extends ProximityCalculatorCollision
The CollisionDetector implements an efficient way of checking a
complete frame tree for collisions.
It relies on a BroadPhaseDetector to do initial filtering which removes obviously not
colliding frame pairs.
After the filtering the remaining frame pairs are tested for collision using an
CollisionStrategy which is a narrow phase collision detector.
The collision detector does not dictate a specific detection
strategy or algorithm, instead it relies on the CollisionStrategy interface for
the actual collision checking between two frames.
Note: The collision detector is not thread safe and as such should not be used by multiple
threads at a time.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCollisionDetector.CollisionDetectorQueryResultresult of a collision querystatic classCollisionDetector.CollisionDetectorQueryTypetypes of collision query
-
Constructor Summary
Constructors Constructor Description CollisionDetector(long cPtr, boolean cMemoryOwn)CollisionDetector(WorkCellPtr workcell)Collision detector for a workcell with only broad-phase collision checking.
The default collision setup stored in the workcell is used for
broad phase collision filtering as a static filter list.
Notice that no narrow phase checking is performed.
If broad-phase filter returns any frame-pairs, this will be taken as a collision.
CollisionDetector(WorkCellPtr workcell, CollisionStrategyPtr strategy)Collision detector for a workcell.
The collision detector is initialized with the strategy .
Notice that the collision detector will create and store models inside the strategy .
The default collision setup stored in the workcell is used for
broad phase collision filtering as a static filter list.
CollisionDetector(WorkCellPtr workcell, CollisionStrategyPtr strategy, ProximityFilterStrategyPtr filter)Collision detector for a workcell.
Collision checking is done for the provided collision setup alone.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddGeometry(FramePtr frame, GeometryPtr geometry)Add Geometry associated to frame
The current shape of the geometry is copied, hence later changes to geometry has no
effect
voiddelete()CollisionStrategyPtrgetCollisionStrategy()Get the narrow-phase collision strategy.static longgetCPtr(CollisionDetector obj)GeometryPtrgetGeometry(FramePtr frame, java.lang.String geometryId)Get the geometry from its IDvector_sgetGeometryIDs(FramePtr frame)return the ids of all the geometries of this frames.booleanhasGeometry(FramePtr frame, java.lang.String geometryId)Returns whether frame has an associated geometry with geometryId.booleaninCollision(State state)Check the workcell for collisions.
booleaninCollision(State state, FramePairVector result)Check the workcell for collisions.
booleaninCollision(State state, FramePairVector result, boolean stopAtFirstContact)Check the workcell for collisions.
booleaninCollision(State state, CollisionDetector.CollisionDetectorQueryResult result)Check the workcell for collisions.
booleaninCollision(State state, CollisionDetector.CollisionDetectorQueryResult result, boolean stopAtFirstContact)Check the workcell for collisions.
booleaninCollision(State state, ProximityData data)Check the workcell for collisions.static CollisionDetectorPtrmake(WorkCellPtr workcell, CollisionStrategyPtr strategy)voidremoveGeometry(FramePtr frame, java.lang.String geometryId)Removes geometry from CollisionDetector
The geometryId is used to match the collision model to the geometry.
voidremoveGeometry(FramePtr frame, GeometryPtr geometry)Removes geometry from CollisionDetector
The id of the geometry is used to match the collision model to the geometry.
-
Methods inherited from class org.robwork.sdurw_proximity.ProximityCalculatorCollision
addRule, calculate, calculate, calculate, getComputationTime, getCPtr, getNoOfCalls, getProximityFilterStrategy, getStrategy, removeRule, resetComputationTimeAndCount, setProximityFilterStrategy, setStrategy
-
-
-
-
Constructor Detail
-
CollisionDetector
public CollisionDetector(long cPtr, boolean cMemoryOwn)
-
CollisionDetector
public CollisionDetector(WorkCellPtr workcell)
Collision detector for a workcell with only broad-phase collision checking.
The default collision setup stored in the workcell is used for
broad phase collision filtering as a static filter list.
Notice that no narrow phase checking is performed.
If broad-phase filter returns any frame-pairs, this will be taken as a collision.
- Parameters:
workcell- [in] the workcell.
-
CollisionDetector
public CollisionDetector(WorkCellPtr workcell, CollisionStrategyPtr strategy)
Collision detector for a workcell.
The collision detector is initialized with the strategy .
Notice that the collision detector will create and store models inside the strategy .
The default collision setup stored in the workcell is used for
broad phase collision filtering as a static filter list.
- Parameters:
workcell- [in] the workcell.strategy- [in/out] the strategy for narrow-phase checking. The strategy will have
models added to it.
-
CollisionDetector
public CollisionDetector(WorkCellPtr workcell, CollisionStrategyPtr strategy, ProximityFilterStrategyPtr filter)
Collision detector for a workcell.
Collision checking is done for the provided collision setup alone.
- Parameters:
workcell- [in] the workcell.strategy- [in/out] the strategy for narrow-phase checking. The strategy will have
models added to it.filter- [in] proximity filter used to cull or filter frame-pairs that are obviously
not colliding
-
-
Method Detail
-
getCPtr
public static long getCPtr(CollisionDetector obj)
-
delete
public void delete()
- Overrides:
deletein classProximityCalculatorCollision
-
inCollision
public boolean inCollision(State state, CollisionDetector.CollisionDetectorQueryResult result, boolean stopAtFirstContact)
Check the workcell for collisions.
- Parameters:
state- [in] The state for which to check for collisions.result- [out] If non-NULL, the pairs of colliding frames are
inserted in result.stopAtFirstContact- [in] If result is non-NULL and
stopAtFirstContact is true, then only the first colliding pair is
inserted in result. By default all colliding pairs are inserted.
- Returns:
- true if a collision is detected; false otherwise.
-
inCollision
public boolean inCollision(State state, CollisionDetector.CollisionDetectorQueryResult result)
Check the workcell for collisions.
- Parameters:
state- [in] The state for which to check for collisions.result- [out] If non-NULL, the pairs of colliding frames are
inserted in result.
- Returns:
- true if a collision is detected; false otherwise.
-
inCollision
public boolean inCollision(State state)
Check the workcell for collisions.
- Parameters:
state- [in] The state for which to check for collisions.
- Returns:
- true if a collision is detected; false otherwise.
-
inCollision
public boolean inCollision(State state, ProximityData data)
Check the workcell for collisions.- Parameters:
state- [in] The state for which to check for collisions.data- [in/out] Defines parameters for the collision check, the results and also
enables caching inbetween calls to incollision- Returns:
- true if a collision is detected; false otherwise.
-
inCollision
public boolean inCollision(State state, FramePairVector result, boolean stopAtFirstContact)
Check the workcell for collisions.
- Parameters:
state- [in] The state for which to check for collisions.result- [out] Where to store pairs of colliding frames.stopAtFirstContact- [in] If result is non-NULL and
stopAtFirstContact is true, then only the first colliding pair is
inserted in result. By default all colliding pairs are inserted.
- Returns:
- true if a collision is detected; false otherwise.
-
inCollision
public boolean inCollision(State state, FramePairVector result)
Check the workcell for collisions.
- Parameters:
state- [in] The state for which to check for collisions.result- [out] Where to store pairs of colliding frames.
- Returns:
- true if a collision is detected; false otherwise.
-
getCollisionStrategy
public CollisionStrategyPtr getCollisionStrategy()
Get the narrow-phase collision strategy.- Returns:
- the strategy if set, otherwise NULL.
-
addGeometry
public boolean addGeometry(FramePtr frame, GeometryPtr geometry)
Add Geometry associated to frame
The current shape of the geometry is copied, hence later changes to geometry has no
effect
- Overrides:
addGeometryin classProximityCalculatorCollision- Parameters:
frame- [in] Frame to associate geometry togeometry- [in] Geometry to add- Returns:
- true if succesful, otherwise false
-
removeGeometry
public void removeGeometry(FramePtr frame, GeometryPtr geometry)
Removes geometry from CollisionDetector
The id of the geometry is used to match the collision model to the geometry.
- Overrides:
removeGeometryin classProximityCalculatorCollision- Parameters:
frame- [in] The frame which has the geometry associatedgeometry- [in] Geometry with the id to be removed
-
removeGeometry
public void removeGeometry(FramePtr frame, java.lang.String geometryId)
Removes geometry from CollisionDetector
The geometryId is used to match the collision model to the geometry.
- Overrides:
removeGeometryin classProximityCalculatorCollision- Parameters:
frame- [in] The frame which has the geometry associatedgeometryId- [in] Id of geometry to be removed
-
getGeometryIDs
public vector_s getGeometryIDs(FramePtr frame)
return the ids of all the geometries of this frames.- Overrides:
getGeometryIDsin classProximityCalculatorCollision
-
hasGeometry
public boolean hasGeometry(FramePtr frame, java.lang.String geometryId)
Returns whether frame has an associated geometry with geometryId.- Overrides:
hasGeometryin classProximityCalculatorCollision- Parameters:
frame- [in] Frame in questiongeometryId- [in] Id of the geometry
-
getGeometry
public GeometryPtr getGeometry(FramePtr frame, java.lang.String geometryId)
Get the geometry from its ID- Overrides:
getGeometryin classProximityCalculatorCollision- Parameters:
frame- [in] the frame of the geometrygeometryId- [in] the ID of the geometry- Returns:
- Pointer to the geometry
-
make
public static CollisionDetectorPtr make(WorkCellPtr workcell, CollisionStrategyPtr strategy)
-
-