RobWorkProject
24.12.4-
|
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< ProximityCalculator > | Ptr |
smart pointer type to this class | |
typedef rw::core::Ptr< const ProximityCalculator > | CPtr |
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! | |
ProximityCalculator & | operator= (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< ProximityFilterStrategy > | getProximityFilterStrategy () 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< Strategy > | getStrategy () 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::Geometry > | getGeometry (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... | |
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.
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.
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 | ( | rw::core::Ptr< rw::models::WorkCell > | workcell, |
rw::core::Ptr< Strategy > | strategy | ||
) |
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 .
workcell | [in] the workcell to check |
strategy | [in] the ProximityStrategy to use |
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
frame | [in] Frame to associate geometry to |
geometry | [in] Geometry to add |
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.
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
results | [in/out] Defines parameters for the ProximityCalculation, stores the results and also enables caching inbetween calls. |
|
inline |
Get the computation time used in the inCollision functions.
rw::core::Ptr<rw::geometry::Geometry> getGeometry | ( | rw::core::Ptr< rw::kinematics::Frame > | frame, |
const std::string & | geometryId | ||
) |
Get the geometry from its ID.
frame | [in] the frame of the geometry |
geometryId | [in] the ID of the geometry |
|
inline |
Get the number of times the inCollision functions have been called.
|
inline |
Get the ProximityStrategy.
bool hasGeometry | ( | rw::core::Ptr< rw::kinematics::Frame > | frame, |
const std::string & | geometryId | ||
) |
Returns whether frame has an associated geometry with geometryId.
frame | [in] Frame in question |
geometryId | [in] Id of the geometry |
|
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 .
workcell | [in] the workcell to check |
strategy | [in] the ProximityStrategy to use |
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.
frame | [in] The frame which has the geometry associated |
geometry | [in] Geometry with the id to be removed |
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.
frame | [in] The frame which has the geometry associated |
geometryId | [in] Id of geometry to be removed |
|
inline |
Set the Proximity Filter strategy of the ProximityCalculator.
proxStrategy | [in] the new ProximityFilterStrategy. The strategy is not copied so changes to the strategy will affect the calculator |
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.
strategy | [in] the new strategy |