RobWorkProject  24.12.4-
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ProximityCalculator< T > Class Template Reference

The Proximity calculator implements an efficient and standardized way of using the following proximity strategies: More...

#include <ProximityCalculator.hpp>

Public Types

typedef T Strategy
 the strategy used for detection
 
typedef rw::core::Ptr< ProximityCalculatorPtr
 smart pointer type to this class
 
typedef rw::core::Ptr< const ProximityCalculatorCPtr
 smart pointer type to this const class
 
typedef rw::core::Ptr< std::vector< ProximityStrategyData > > ResultType
 the type used to store results in.
 

Public Member Functions

 ProximityCalculator (rw::core::Ptr< rw::kinematics::Frame > root, rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< Strategy > strategy, const rw::kinematics::State &initial_state)
 Proximity calculations for a given tree, collision setup and primitive Proximity calculator. Uses proximity strategy given by the workcell. More...
 
 ProximityCalculator (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< Strategy > strategy)
 Construct proximity calculator for a WorkCell with an associated proximity strategy. More...
 
 ProximityCalculator (const ProximityCalculator &)=delete
 Copy constructor is non-existent. Copying is not possible!
 
ProximityCalculatoroperator= (const ProximityCalculator &)=delete
 Assignment operator is non-existent. Copying is not possible!
 
ProximityStrategyData calculate (const rw::kinematics::State &state, rw::core::Ptr< ProximityStrategyData > settings=rw::core::Ptr< ProximityStrategyData >(), rw::core::Ptr< std::vector< ProximityStrategyData >> results=rw::core::Ptr< std::vector< ProximityStrategyData >>())
 Performece the Proximity calculation based on the chosen strategy type. As the varius strategies usese differenct settings all settings will be extracted from settings. If more then the default result is needed (first collision or shortest distance) result can given to get the extra info. More...
 
rw::core::Ptr< ProximityFilterStrategygetProximityFilterStrategy () const
 The Proximity Filter strategy of the ProximityCalculator.
 
void setProximityFilterStrategy (rw::core::Ptr< ProximityFilterStrategy > proxStrategy)
 Set the Proximity Filter strategy of the ProximityCalculator. More...
 
void setStrategy (rw::core::Ptr< Strategy > strategy)
 Set a new strategy. OBS. models are stored in the strategy, so make sure that the new strategy includes all nessesary models. More...
 
rw::core::Ptr< StrategygetStrategy () const
 Get the ProximityStrategy. More...
 
bool addGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const rw::core::Ptr< rw::geometry::Geometry > &geometry)
 Add Geometry associated to frame. More...
 
void removeGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const rw::core::Ptr< rw::geometry::Geometry > &geometry)
 Removes geometry from ProximityCalculator. More...
 
void removeGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string geometryId)
 Removes geometry from ProximityCalculator. More...
 
void addRule (const rw::proximity::ProximitySetupRule &rule)
 Adds rule specifying inclusion/exclusion of frame pairs in Proximity calculation.
 
void removeRule (const rw::proximity::ProximitySetupRule &rule)
 Removes rule specifying inclusion/exclusion of frame pairs in Proximity calculation.
 
double getComputationTime () const
 Get the computation time used in the inCollision functions. More...
 
size_t getNoOfCalls () const
 Get the number of times the inCollision functions have been called. More...
 
void resetComputationTimeAndCount ()
 Reset the counter for inCollision invocations and the computation timer.
 
std::vector< std::string > getGeometryIDs (rw::core::Ptr< rw::kinematics::Frame > frame)
 return the ids of all the geometries of this frames.
 
bool hasGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string &geometryId)
 Returns whether frame has an associated geometry with geometryId. More...
 
rw::core::Ptr< rw::geometry::GeometrygetGeometry (rw::core::Ptr< rw::kinematics::Frame > frame, const std::string &geometryId)
 Get the geometry from its ID. More...
 

Static Public Member Functions

template<class R >
static rw::core::Ptr< ProximityCalculator< R > > make (rw::core::Ptr< rw::models::WorkCell > workcell, rw::core::Ptr< R > strategy)
 static function to make a new ProximityCalculator More...
 

Detailed Description

template<class T>
class rw::proximity::ProximityCalculator< T >

The Proximity calculator implements an efficient and standardized way of using the following proximity strategies:

CollisionStrategy DistanceStrategy MultiDistanceStrategy

The Calculate function is designed to fit the chosen strategy individually implementing a fitting aproach for calculating the respective proximity.

The CollisionDetector 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 Proximity calculator does not dictate a specific detection strategy or algorithm, instead it relies on the CollisionStrategy interface for the actual collision checking between two frames.

Distance and MultiDistance Calculator A list of frame pairs is contained within the Proximity calculator, that specifies which frames are to be checked against each other. The method of used for distance calculation relies on the DistanceStrategy chosen.

Constructor & Destructor Documentation

◆ ProximityCalculator() [1/2]

Proximity calculations for a given tree, collision setup and primitive Proximity calculator. Uses proximity strategy given by the workcell.

Parameters
root[in] - the root of the Frame tree. must be non-NULL. No ownership of the pointer is taken
workcell[in] - the workcell to do the proximity calculations in.
strategy[in] - the primitive strategy of proximity calculations. must be non-NULL.
initial_state[in] - the work cell state to use for the initial traversal of the tree.

◆ ProximityCalculator() [2/2]

Construct proximity calculator for a WorkCell with an associated proximity strategy.

The ProximityCalculator extracts information about the tree and the CollisionSetup from workcell.

The ProximityCalculator is initialized with the strategy . Notice that the ProximityCalculator will create and store models inside the strategy .

Parameters
workcell[in] the workcell to check
strategy[in] the ProximityStrategy to use

Member Function Documentation

◆ addGeometry()

bool addGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const rw::core::Ptr< rw::geometry::Geometry > &  geometry 
)

Add Geometry associated to frame.

The current shape of the geometry is copied, hence later changes to geometry has no effect

Parameters
frame[in] Frame to associate geometry to
geometry[in] Geometry to add
Returns
true if succesful, otherwise false

◆ calculate()

ProximityStrategyData calculate ( const rw::kinematics::State state,
rw::core::Ptr< ProximityStrategyData settings = rw::core::PtrProximityStrategyData >(),
rw::core::Ptr< std::vector< ProximityStrategyData >>  results = rw::core::Ptr< std::vector< ProximityStrategyData >>() 
)

Performece the Proximity calculation based on the chosen strategy type. As the varius strategies usese differenct settings all settings will be extracted from settings. If more then the default result is needed (first collision or shortest distance) result can given to get the extra info.

Parameters
state[in] The state the proximity calculation should be done in.
settings[in] The settings used for the calculations. Different settings are used for different ProximityStrategies:

For CollisionStrategy the Collision Query Type is used. if not given only first collision is detected

For DistanceStrategy no settings are used and it is expected to be null, otherwise an exception is thrown.

For DistanceMultiStrategy the tolerance is used which is the maximum distance allowed for the result to be recorded. if not given the tolerance is set to the largest finite double

Parameters
results[in/out] Defines parameters for the ProximityCalculation, stores the results and also enables caching inbetween calls.
Returns
If no result is available an empty ProximityStrategyData is returned. else for Collisions the first contact is returned and for distance the shortest distance is returned

◆ getComputationTime()

double getComputationTime ( ) const
inline

Get the computation time used in the inCollision functions.

Returns
the total computation time.

◆ getGeometry()

rw::core::Ptr<rw::geometry::Geometry> getGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const std::string &  geometryId 
)

Get the geometry from its ID.

Parameters
frame[in] the frame of the geometry
geometryId[in] the ID of the geometry
Returns
Pointer to the geometry

◆ getNoOfCalls()

size_t getNoOfCalls ( ) const
inline

Get the number of times the inCollision functions have been called.

Returns
number of calls to inCollision functions.

◆ getStrategy()

rw::core::Ptr<Strategy> getStrategy ( ) const
inline

Get the ProximityStrategy.

Returns
the strategy if set, otherwise NULL.

◆ hasGeometry()

bool hasGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const std::string &  geometryId 
)

Returns whether frame has an associated geometry with geometryId.

Parameters
frame[in] Frame in question
geometryId[in] Id of the geometry

◆ make()

static rw::core::Ptr<ProximityCalculator<R> > make ( rw::core::Ptr< rw::models::WorkCell workcell,
rw::core::Ptr< R >  strategy 
)
inlinestatic

static function to make a new ProximityCalculator

Construct proximity calculator for a WorkCell with an associated proximity strategy.

The ProximityCalculator extracts information about the tree and the CollisionSetup from workcell.

The ProximityCalculator is initialized with the strategy . Notice that the ProximityCalculator will create and store models inside the strategy .

Parameters
workcell[in] the workcell to check
strategy[in] the ProximityStrategy to use

◆ removeGeometry() [1/2]

void removeGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const rw::core::Ptr< rw::geometry::Geometry > &  geometry 
)

Removes geometry from ProximityCalculator.

The id of the geometry is used to match the proximity model to the geometry.

Parameters
frame[in] The frame which has the geometry associated
geometry[in] Geometry with the id to be removed

◆ removeGeometry() [2/2]

void removeGeometry ( rw::core::Ptr< rw::kinematics::Frame frame,
const std::string  geometryId 
)

Removes geometry from ProximityCalculator.

The geometryId is used to match the proximity model to the geometry.

Parameters
frame[in] The frame which has the geometry associated
geometryId[in] Id of geometry to be removed

◆ setProximityFilterStrategy()

void setProximityFilterStrategy ( rw::core::Ptr< ProximityFilterStrategy proxStrategy)
inline

Set the Proximity Filter strategy of the ProximityCalculator.

Parameters
proxStrategy[in] the new ProximityFilterStrategy. The strategy is not copied so changes to the strategy will affect the calculator

◆ setStrategy()

void setStrategy ( rw::core::Ptr< Strategy strategy)

Set a new strategy. OBS. models are stored in the strategy, so make sure that the new strategy includes all nessesary models.

Parameters
strategy[in] the new strategy

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