RobWorkProject  23.9.11-
Classes | Public Types | Public Member Functions | List of all members
ProximityStrategyFCL Class Reference

This is a strategy wrapper for the Flexible Collision Library (FCL) More...

#include <ProximityStrategyFCL.hpp>

Inherits CollisionStrategy, DistanceStrategy, and DistanceMultiStrategy.

Classes

struct  FCLModel
 Datatype to hold the FCL bounding volume and related geometrical data. More...
 
struct  FCLProximityModel
 Datatype to hold the proximity models. More...
 

Public Types

enum class  BV {
  AABB , OBB , RSS , OBBRSS ,
  kIOS , KDOP16 , KDOP18 , KDOP24
}
 Supported bounding volumes. More...
 
typedef rw::core::Ptr< ProximityStrategyFCLPtr
 Smart pointer type for FCL Proximity strategy.
 
typedef rw::core::Ptr< fclCollisionGeometryFCLBVHModelPtr
 Type of internal collision geometry.
 
typedef std::vector< FCLModelFCLModelList
 Type for list of proximity models.
 
- Public Types inherited from CollisionStrategy
enum  QueryType { FirstContact , AllContacts }
 the type of query that is to be performed
 
typedef rw::core::Ptr< CollisionStrategyPtr
 smart pointer type to this class
 
using Result = CollisionResult
 
- Public Types inherited from ProximityStrategy
typedef rw::core::Ptr< ProximityStrategyPtr
 smart pointer type to this class
 
- Public Types inherited from DistanceStrategy
typedef rw::core::Ptr< DistanceStrategyPtr
 smart pointer type to this class
 
- Public Types inherited from DistanceMultiStrategy
typedef rw::core::Ptr< DistanceMultiStrategyPtr
 smart pointer type to this class
 

Public Member Functions

 ProximityStrategyFCL (BV bv=BV::RSS)
 Constructor. More...
 
virtual ~ProximityStrategyFCL ()
 Destructor.
 
virtual rw::proximity::ProximityModel::Ptr createModel ()
 creates an empty ProximityModel More...
 
void destroyModel (rw::proximity::ProximityModel *model)
 deallocates the memory used for model More...
 
bool addGeometry (rw::proximity::ProximityModel *model, const rw::geometry::Geometry &geom)
 
bool addGeometry (rw::proximity::ProximityModel *model, rw::core::Ptr< rw::geometry::Geometry > geom, bool forceCopy=false)
 
bool removeGeometry (rw::proximity::ProximityModel *model, const std::string &geomId)
 removes a geometry from a specific proximity model More...
 
std::vector< std::string > getGeometryIDs (rw::proximity::ProximityModel *model)
 the list of all geometry ids that are associated to the proximity model model is returned More...
 
std::vector< rw::core::Ptr< rw::geometry::Geometry > > getGeometries (rw::proximity::ProximityModel *model)
 the list of all geometry that are associated to the proximity model model is returned More...
 
void clear ()
 Clears any stored model information. More...
 
bool doInCollision (rw::proximity::ProximityModel::Ptr a, const rw::math::Transform3D<> &wTa, rw::proximity::ProximityModel::Ptr b, const rw::math::Transform3D<> &wTb, rw::proximity::ProximityStrategyData &data)
 Checks to see if two proximity models are in collision. More...
 
void getCollisionContacts (std::vector< rw::proximity::CollisionStrategy::Contact > &contacts, rw::proximity::ProximityStrategyData &data)
 this method interprets the collision query result and calculates a list of contacts to represent the collision geometry between the colliding geometries. More...
 
rw::proximity::DistanceStrategy::ResultdoDistance (rw::proximity::ProximityModel::Ptr a, const rw::math::Transform3D<> &wTa, rw::proximity::ProximityModel::Ptr b, const rw::math::Transform3D<> &wTb, class rw::proximity::ProximityStrategyData &data)
 Calculates the distance between two proximity models \( \mathcal{a} \) and \( \mathcal{b} \). More...
 
rw::proximity::DistanceMultiStrategy::ResultdoDistances (rw::proximity::ProximityModel::Ptr a, const rw::math::Transform3D<> &wTa, rw::proximity::ProximityModel::Ptr b, const rw::math::Transform3D<> &wTb, double tolerance, class rw::proximity::ProximityStrategyData &data)
 Calculates all distances between two given objects \( \mathcal{F}_a \) and \( \mathcal{F}_b \) where the distances are below a certain threshold. More...
 
void setBV (const BV &bv)
 Set the bounding volume. More...
 
BV getBV ()
 Get the bounding volume. More...
 
fclCollisionRequestgetCollisionRequest ()
 Get access to the CollisionRequest that is used with FCL collision query. More...
 
fclDistanceRequestgetDistanceRequest ()
 Get access to the DistanceRequest that is used with FCL distance query. More...
 
void setCollectFCLResults (bool enable)
 Specify if FCL results should be collected.
 
bool getCollectFCLResults ()
 Get whether FCL results should be collected or not.
 
std::vector< fclCollisionResult > & getCollisionResults ()
 Get access to the collected FCL collision results.
 
fclCollisionResultgetCollisionResult (std::size_t index)
 Get access to the collected FCL collision result. More...
 
fclDistanceResultgetDistanceResult ()
 Get access to the collected FCL distance result.
 
std::pair< rw::math::Vector3D<>, rw::math::Vector3D<> > getSurfaceNormals (rw::proximity::DistanceMultiStrategy::Result &res, int idx)
 Get the Surface Normals. More...
 
- Public Member Functions inherited from CollisionStrategy
virtual ~CollisionStrategy ()
 Destroys object.
 
bool inCollision (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb, QueryType type=FirstContact)
 Checks to see if two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \) are in collision. More...
 
bool inCollision (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb, class ProximityStrategyData &data, QueryType type=FirstContact)
 Checks to see if two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \) are in collision. More...
 
bool inCollision (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, ProximityStrategyData &data)
 Checks to see if two proximity models are in collision. More...
 
- Public Member Functions inherited from ProximityStrategy
virtual ~ProximityStrategy ()
 Destructor.
 
virtual bool addModel (rw::core::Ptr< rw::models::Object > object)
 Adds a Proximity model of a frame to this strategy. More...
 
virtual bool addModel (const rw::core::Ptr< rw::kinematics::Frame > frame, const rw::geometry::Geometry &faces)
 Adds a Proximity model to a frame where the geometry is copied in the underlying proximity strategy. More...
 
virtual bool addModel (const rw::core::Ptr< rw::kinematics::Frame > frame, rw::core::Ptr< rw::geometry::Geometry > faces, bool forceCopy=false)
 Adds a Proximity model to a frame. More...
 
virtual bool hasModel (const rw::core::Ptr< rw::kinematics::Frame > frame)
 Tells whether the frame has a proximity model in the strategy. More...
 
virtual void clearFrame (const rw::core::Ptr< rw::kinematics::Frame > frame)
 Clear (remove all) model information for frame frame.
 
virtual void clearFrames ()
 Clear (remove all) model information for all frames.
 
ProximityModel::Ptr getModel (const rw::core::Ptr< rw::kinematics::Frame > frame)
 get the proximitymodel associated to frame. If no model has been associated to frame then NULL is returned. More...
 
 DEPRECATED ("This function is deprecated due to a spelling mistake, use the correct " "spelling \"getGeometries\" instead") std
 
void useThreads (int threads)
 setNumber of threads the strategy may use More...
 
- Public Member Functions inherited from DistanceStrategy
virtual ~DistanceStrategy ()
 Destroys object.
 
Result distance (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb)
 Calculates the distance between two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \). More...
 
Resultdistance (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb, class ProximityStrategyData &data)
 Calculates the distance between two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \). More...
 
Resultdistance (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, class ProximityStrategyData &data)
 Calculates the distance between two proximity models \( \mathcal{a} \) and \( \mathcal{b} \). More...
 
Result distance (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb, double threshold)
 Calculates the distance between two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \) if the distance are within threshold. If the distance between the frames are larger than the threshold, the result will be inaccurate. More...
 
DistanceStrategy::Resultdistance (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb, double threshold, ProximityStrategyData &data)
 Calculates the distance between two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \) if the distance are within threshold. If the distance between the frames are larger than the threshold, the result will be inaccurate. More...
 
DistanceStrategy::Resultdistance (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, double threshold, ProximityStrategyData &data)
 Calculates the distance between two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \) if the distance are within threshold. If the distance between the frames are larger than the threshold, the result will be inaccurate. More...
 
- Public Member Functions inherited from DistanceMultiStrategy
virtual ~DistanceMultiStrategy ()
 Destroys object.
 
Result distances (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb, double tolerance)
 Calculates all distances between geometry of two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \). More...
 
Resultdistances (const rw::core::Ptr< kinematics::Frame > a, const math::Transform3D< double > &wTa, const rw::core::Ptr< kinematics::Frame > b, const math::Transform3D< double > &wTb, double tolerance, class ProximityStrategyData &data)
 Calculates all distances between geometry of two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \). More...
 
Resultdistances (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, double tolerance, class ProximityStrategyData &data)
 Calculates all distances between two given objects \( \mathcal{F}_a \) and \( \mathcal{F}_b \) where the distances are below a certain threshold. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CollisionStrategy
static CollisionStrategy::Ptr make (rw::core::Ptr< CollisionToleranceStrategy > strategy, double tolerance)
 A collision strategy constructed from a collision tolerance strategy and a resolution. More...
 
static CollisionStrategy::Ptr make (rw::core::Ptr< CollisionToleranceStrategy > strategy, const rw::kinematics::FrameMap< double > &frameToTolerance, double defaultTolerance)
 A collision strategy constructed from a collision tolerance strategy and a resolution. More...
 
- Protected Member Functions inherited from CollisionStrategy
virtual bool doInCollision (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, ProximityStrategyData &data)=0
 Checks to see if two proximity models are in collision. More...
 
 CollisionStrategy ()
 Creates object.
 
- Protected Member Functions inherited from ProximityStrategy
 ProximityStrategy ()
 Creates object.
 
- Protected Member Functions inherited from DistanceStrategy
virtual ResultdoDistance (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, class ProximityStrategyData &data)=0
 Calculates the distance between two proximity models \( \mathcal{a} \) and \( \mathcal{b} \). More...
 
virtual DistanceStrategy::ResultdoDistanceThreshold (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, double threshold, ProximityStrategyData &data)
 Calculates the distance between two given frames \( \mathcal{F}_a \) and \( \mathcal{F}_b \) if the distance are within threshold. If the distance between the frames are larger than the threshold, the result will be inaccurate. More...
 
 DistanceStrategy ()
 Creates object.
 
- Protected Member Functions inherited from DistanceMultiStrategy
virtual ResultdoDistances (ProximityModel::Ptr a, const math::Transform3D< double > &wTa, ProximityModel::Ptr b, const math::Transform3D< double > &wTb, double tolerance, class ProximityStrategyData &data)=0
 Calculates all distances between two given objects \( \mathcal{F}_a \) and \( \mathcal{F}_b \) where the distances are below a certain threshold. More...
 
 DistanceMultiStrategy ()
 Creates object.
 
- Protected Attributes inherited from ProximityStrategy
size_t _threads
 the number of threads the strategy may use
 

Detailed Description

This is a strategy wrapper for the Flexible Collision Library (FCL)

For further information check out https://github.com/flexible-collision-library/fcl

Member Enumeration Documentation

◆ BV

enum BV
strong

Supported bounding volumes.

Enumerator
AABB 

Axis-Aligned Bounding Boxes.

OBB 

Oriented Bounding Boxes.

RSS 

Rectangle Swept Spheres.

OBBRSS 

Mix of OBB and RSS.

kIOS 

Bounding volume as the intersection of a set of spheres.

KDOP16 

Discrete Oriented Polytope.

KDOP18 

Discrete Oriented Polytope.

KDOP24 

Discrete Oriented Polytope.

Constructor & Destructor Documentation

◆ ProximityStrategyFCL()

Constructor.

Parameters
bv[in] the bounding volume type to use.

Member Function Documentation

◆ addGeometry() [1/2]

bool addGeometry ( rw::proximity::ProximityModel model,
const rw::geometry::Geometry geom 
)
virtual

Parameters
model[in] the proximity model to add data to
geom[in] the geometry that is to be added
Exceptions
Exceptionwhen a bounding volume type has been chosen that is not supported.

Implements ProximityStrategy.

◆ addGeometry() [2/2]

bool addGeometry ( rw::proximity::ProximityModel model,
rw::core::Ptr< rw::geometry::Geometry geom,
bool  forceCopy = false 
)
virtual

Parameters
model
geom
forceCopy
Returns
Exceptions
Exceptionwhen a bounding volume type has been chosen that is not supported.

Implements ProximityStrategy.

◆ clear()

void clear ( )
virtual

Clears any stored model information.

Implements ProximityStrategy.

◆ createModel()

virtual rw::proximity::ProximityModel::Ptr createModel ( )
virtual

creates an empty ProximityModel

interface of ProximityStrategy

Implements ProximityStrategy.

◆ destroyModel()

void destroyModel ( rw::proximity::ProximityModel model)
virtual

deallocates the memory used for model

Parameters
model

Implements ProximityStrategy.

◆ doDistance()

Calculates the distance between two proximity models \( \mathcal{a} \) and \( \mathcal{b} \).

Interface of DistanceStrategy

Parameters
a[in] \( \mathcal{F}_a \)
wTa[in] \( \robabx{w}{a}{\mathbf{T}} \)
b[in] \( \mathcal{F}_b \)
wTb[in] \( \robabx{w}{b}{\mathbf{T}} \)
data
Returns
shortest distance if \( \mathcal{F}_a \) and \( \mathcal{F}_b \) are separated and not in collision.

◆ doDistances()

Calculates all distances between two given objects \( \mathcal{F}_a \) and \( \mathcal{F}_b \) where the distances are below a certain threshold.

Interface of DistanceMultiStrategy

Parameters
a[in] \( \mathcal{F}_a \)
wTa[in] \( \robabx{w}{a}{\mathbf{T}} \)
b[in] \( \mathcal{F}_b \)
wTb[in] \( \robabx{w}{b}{\mathbf{T}} \)
tolerance[in] point pairs that are closer than tolerance will be included in the result.
data
Returns
list of distances between all points that are closer than threshold.

◆ doInCollision()

Checks to see if two proximity models are in collision.

Interface of CollisionStrategy

Parameters
a[in] model 1
wTa[in] transform of model a
b[in] model 2
wTb[in] transform of model b
data[in/out] caching and result container
Returns
true if \( \mathcal{F}_a \) and \( \mathcal{F}_b \) are colliding, false otherwise.

◆ getBV()

BV getBV ( )
inline

Get the bounding volume.

Returns
the type of bounding volume used.

◆ getCollisionContacts()

void getCollisionContacts ( std::vector< rw::proximity::CollisionStrategy::Contact > &  contacts,
rw::proximity::ProximityStrategyData data 
)
virtual

this method interprets the collision query result and calculates a list of contacts to represent the collision geometry between the colliding geometries.

Please note that for most collisions a single point and normal is not sufficient to describe the complete collision area. However, it is typically a reasonable approximation. The approximation can hence be implementation specific.

Parameters
contacts[out] list of contacts that can be calculated from data
data[in] the result from the collision query
Note
Not implemented as nothing appears to be using this functionality

Implements CollisionStrategy.

◆ getCollisionRequest()

fclCollisionRequest& getCollisionRequest ( )

Get access to the CollisionRequest that is used with FCL collision query.

See the fcl/collision_data.h for the data structure, and look through their documentation for specifics on what solvers that can be chosen.

◆ getCollisionResult()

fclCollisionResult& getCollisionResult ( std::size_t  index)

Get access to the collected FCL collision result.

Exceptions
std::out_of_rangeexception if index is not within the bounds.

◆ getDistanceRequest()

fclDistanceRequest& getDistanceRequest ( )

Get access to the DistanceRequest that is used with FCL distance query.

See the fcl/collision_data.h for the data structure, and look through their documentation for specifics on what solvers that can be chosen.

Note
The rel_err and abs_err fields will be overwritten with the values that are supplied in the rw::proximity::ProximityStrategyData

◆ getGeometries()

std::vector<rw::core::Ptr<rw::geometry::Geometry> > getGeometries ( rw::proximity::ProximityModel model)
virtual

the list of all geometry that are associated to the proximity model model is returned

Parameters
model[in] the model containing the geometries
Returns
all geometry associated to the proximity model

Implements ProximityStrategy.

◆ getGeometryIDs()

std::vector<std::string> getGeometryIDs ( rw::proximity::ProximityModel model)
virtual

the list of all geometry ids that are associated to the proximity model model is returned

Parameters
model[in] the model containing the geometries
Returns
all geometry ids associated to the proximity model

Implements ProximityStrategy.

◆ getSurfaceNormals()

std::pair<rw::math::Vector3D<>, rw::math::Vector3D<> > getSurfaceNormals ( rw::proximity::DistanceMultiStrategy::Result res,
int  idx 
)
virtual

Get the Surface Normals.

Parameters
resthe result to get the normals from
idx
Returns
std::pair<rw::math::Vector3D<>, rw::math::Vector3D<>>

Implements DistanceMultiStrategy.

◆ removeGeometry()

bool removeGeometry ( rw::proximity::ProximityModel model,
const std::string &  geomId 
)
virtual

removes a geometry from a specific proximity model

Implements ProximityStrategy.

◆ setBV()

void setBV ( const BV bv)
inline

Set the bounding volume.

Parameters
bv[in] new bounding volume type.

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