RobWorkProject
24.12.4-
|
The ContactDetector allows detailed control of the strategies used for contact detection between specific frames and geometry types. More...
#include <ContactDetector.hpp>
Inherits BaseContactDetector.
Classes | |
struct | StrategyTableRow |
One row in the strategy table, with a priority, match-rules, a strategy and associated ContactModels. More... | |
Public Types | |
typedef rw::core::Ptr< ContactDetector > | Ptr |
smart pointer type to this class | |
typedef std::list< StrategyTableRow > | StrategyTable |
Type for the strategy table. | |
Public Types inherited from BaseContactDetector | |
typedef rw::core::Ptr< BaseContactDetector > | Ptr |
smart pointer type to this class | |
Public Member Functions | |
ContactDetector (rw::core::Ptr< rw::models::WorkCell > workcell, rw::proximity::ProximityFilterStrategy::Ptr filter=NULL) | |
Contact detector for a workcell. More... | |
virtual | ~ContactDetector () |
Destruct contact detector. More... | |
virtual std::vector< Contact > | findContacts (const rw::kinematics::State &state) |
Find contacts in workcell. More... | |
virtual std::vector< Contact > | findContacts (const rw::kinematics::State &state, ContactDetectorData &data) |
Find contacts in workcell. More... | |
virtual std::vector< Contact > | findContacts (const rw::kinematics::State &state, ContactDetectorData &data, ContactDetectorTracking &tracking, rwsim::log::SimulatorLogScope *log=NULL) |
Find contacts in workcell while tracking known contacts. More... | |
virtual std::vector< Contact > | updateContacts (const rw::kinematics::State &state, ContactDetectorData &data, ContactDetectorTracking &tracking, rwsim::log::SimulatorLogScope *log=NULL) |
Updates previously found contacts. More... | |
Strategy table functions. | |
Functions used to construct and edit the strategy table. | |
virtual StrategyTable | getContactStategies () const |
Get the complete contact strategy table. More... | |
virtual StrategyTable | getContactStrategies (const std::string &frameA, const std::string &frameB) const |
Get the contact strategies that match the given frame names. More... | |
virtual StrategyTable | getContactStrategies (const std::string &frameA, rw::core::Ptr< const rw::geometry::GeometryData > geometryA, const std::string &frameB, rw::core::Ptr< const rw::geometry::GeometryData > geometryB) const |
Get the contact strategies that match the given frame names and geometries. More... | |
virtual void | addContactStrategy (rw::core::Ptr< ContactStrategy > strategy, std::size_t priority=0) |
Add a strategy to the strategy table that matches all frames. More... | |
virtual void | addContactStrategy (rw::proximity::ProximitySetupRule rule, rw::core::Ptr< ContactStrategy > strategy, std::size_t priority=0) |
Add a strategy that is only used for frames matching one rule. More... | |
virtual void | addContactStrategy (rw::proximity::ProximitySetup rules, rw::core::Ptr< ContactStrategy > strategy, std::size_t priority=0) |
Add a strategy that is used for frames that match a set of rules. More... | |
virtual void | addContactStrategy (StrategyTableRow &strategy, std::size_t priority=0) |
Add a strategy from an existing strategy table rule. More... | |
virtual void | removeContactStrategy (std::size_t priority=0) |
Remove the strategy with a certain priority in the table. More... | |
virtual void | clearStrategies () |
Remove all strategies and contact models in the table. | |
virtual void | setContactStrategies (StrategyTable strategies) |
Set a complete strategy table. More... | |
virtual void | setDefaultStrategies () |
Auto-generate a suitable general-purpose strategy table. More... | |
virtual void | setDefaultStrategies (const rw::core::PropertyMap &map) |
Auto-generate a suitable general-purpose strategy table with strategies using the given properties. More... | |
virtual void | printStrategyTable () const |
Print the current strategy table to standard output. | |
virtual void | printStrategyTable (std::ostream &out) const |
Print the current strategy table to given output stream. | |
Public Member Functions inherited from BaseContactDetector | |
BaseContactDetector (rw::core::Ptr< rw::models::WorkCell > workcell, rw::proximity::ProximityFilterStrategy::Ptr filter=NULL) | |
Contact detector for a workcell. More... | |
virtual | ~BaseContactDetector () |
Destruct contact detector. More... | |
void | setProximityFilterStrategy (rw::proximity::ProximityFilterStrategy::Ptr filter) |
Set a new broad-phase filter. More... | |
virtual rw::proximity::ProximityFilterStrategy::Ptr | getProximityFilterStrategy () const |
The broad-phase filter strategy used by the contact detector. | |
virtual double | getTimer () const |
The number of seconds measured used in contact detection. More... | |
virtual void | setTimer (double value=0) |
Set the value of a timer that will measure time used during contact detection. More... | |
Static Public Member Functions | |
static ContactDetector::Ptr | makeDefault (rw::core::Ptr< rw::models::WorkCell > workcell) |
Create a default workcell from a workcell, where the default strategies has been set. More... | |
static ContactDetector::Ptr | makeDefault (rw::core::Ptr< rw::models::WorkCell > workcell, const rw::core::PropertyMap &map) |
Create a default workcell from a workcell, where the default strategies has been set. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const ContactDetector &detector) |
Stream operator. More... | |
std::ostream & | operator<< (std::ostream &out, ContactDetector::Ptr detector) |
Stream operator. More... | |
Additional Inherited Members | |
Protected Attributes inherited from BaseContactDetector | |
rw::core::Ptr< rw::proximity::ProximityFilterStrategy > | _bpFilter |
rw::core::Ptr< rw::models::WorkCell > | _wc |
double | _timer |
The ContactDetector allows detailed control of the strategies used for contact detection between specific frames and geometry types.
A concrete strategy for contact detection is chosen by a rule-based lookup in a strategy table. For general purpose usage the contact detector can auto-generate the most suitable set of rules for a given workcell. The user can alter this table to specific needs, or create its own strategy table from scratch.
Each rule has a priority from 0 and upwards, where 0 is the highest priority. When finding contacts, the rule with priority 0 will be tested first. If no match is found, the next rule in the table will be tested.
The first condition for a match, will be that the frame names match a specific pattern. If the frame names match, each combination of geometries for the two frames is tested by calling the boolean match function on the ContactStrategy. If the geometries can not be handled by the strategy, the next strategy in the table will be tested. If the geometries can be handled by the strategy, this strategy is used for contact detection between this specific combination of geometries.
This way the user can easily extend the default contact detections strategy with own strategies. These strategies can be applied for specific frame names, specific geometry types or both.
ContactDetector | ( | rw::core::Ptr< rw::models::WorkCell > | workcell, |
rw::proximity::ProximityFilterStrategy::Ptr | filter = NULL |
||
) |
Contact detector for a workcell.
If no broad-phase filter is given, a default will be created for the workcell.
workcell | [in] the workcell. |
filter | [in] broad-phase filter to remove frames that are obviously not colliding. |
|
virtual |
Destruct contact detector.
The strategy table and stored contact models is cleared.
|
virtual |
Add a strategy to the strategy table that matches all frames.
strategy | [in/out] The strategy to add. Relevant ContactModels are automatically created. |
priority | [in] the priority of the new strategy (default is maximum priority - 0). |
|
virtual |
Add a strategy that is used for frames that match a set of rules.
rules | [in] The rules for the frame names that this strategy applies to. |
strategy | [in/out] The strategy to add. Relevant ContactModels are automatically created. |
priority | [in] the priority of the new strategy (default is maximum priority - 0). |
|
virtual |
Add a strategy that is only used for frames matching one rule.
rule | [in] The rule for the frame names that this strategy applies to. |
strategy | [in/out] The strategy to add. Relevant ContactModels are automatically created. |
priority | [in] the priority of the new strategy (default is maximum priority - 0). |
|
virtual |
Add a strategy from an existing strategy table rule.
strategy | [in/out] The strategy to add. The priority will be changed automatically, and relevant ContactModels are created automatically if not already present. |
priority | [in] the priority of the new strategy (default is maximum priority - 0). |
|
virtual |
Find contacts in workcell.
state | [in] The state for which to check for contacts. |
Implements BaseContactDetector.
|
virtual |
Find contacts in workcell.
Use of this function is encouraged if changes between consecutive calls are expected to be small. This will allow the detection algorithms to do certain speed-ups.
state | [in] The state for which to check for contacts. |
data | [in/out] Allows caching between contact detection calls, and makes it possible for detection algorithms to exploit spatial and temporal coherence. |
Implements BaseContactDetector.
|
virtual |
Find contacts in workcell while tracking known contacts.
state | [in] the state to find contacts for. |
data | [in/out] allows caching between contact detection calls, and makes it possible for detection algorithms to exploit spatial and temporal coherence. |
tracking | [in/out] the tracking data with information about known contacts. |
log | [in/out] (optional) store detailed logging information. |
Implements BaseContactDetector.
|
virtual |
Get the complete contact strategy table.
|
virtual |
Get the contact strategies that match the given frame names.
frameA | [in] the name of the first frame. |
frameB | [in] the name of the second frame. |
|
virtual |
Get the contact strategies that match the given frame names and geometries.
frameA | [in] the name of the first frame. |
geometryA | [in] the first geometry. |
frameB | [in] the name of the second frame. |
geometryB | [in] the second geometry. |
|
static |
Create a default workcell from a workcell, where the default strategies has been set.
workcell | [in] the workcell to create detector for. |
|
static |
Create a default workcell from a workcell, where the default strategies has been set.
workcell | [in] the workcell to create detector for. |
map | [in] the map to take properties from. |
|
virtual |
Remove the strategy with a certain priority in the table.
Contact models will removed for the relevant strategy, and updated for the other strategies in the table.
priority | the priority to remove. |
|
virtual |
Set a complete strategy table.
strategies | [in] the strategy table. |
|
virtual |
Auto-generate a suitable general-purpose strategy table.
This function will generate the most suitable default contact strategy for the workcell.
|
virtual |
Auto-generate a suitable general-purpose strategy table with strategies using the given properties.
This function will generate the most suitable default contact strategy for the workcell.
map | [in] the PropertyMap to use by all the strategies. |
|
virtual |
Updates previously found contacts.
state | [in] the new state to find the updated contacts for. |
data | [in/out] allows caching between contact detection calls, and makes it possible for detection algorithms to exploit spatial and temporal coherence. |
tracking | [in/out] the tracking data with information about known contacts. |
log | [in/out] (optional) store detailed logging information. |
Implements BaseContactDetector.
|
friend |
Stream operator.
out | [in/out] the stream to write to. |
detector | [in] the detector to print strategy table for. |
|
friend |
Stream operator.
out | [in/out] the stream to write to. |
detector | [in] the detector to print strategy table for. |