Class for configuring "collision filters"; collision filters limit the scope of various proximity queries.
The sole source of CollisionFilterManager instances is SceneGraph. See SceneGraph's documentation for details on acquiring an instance.
A SceneGraph instance contains the set of geometries with assigned proximity properties G = R ⋃ V ⋃ A = {g₀, g₁, ..., gₙ}, where R is the set of dynamic rigid geometries, V is the set of deformable geometries, and A is the set of anchored rigid geometries. These three sets are pairwise disjoint. Many proximity queries operate on pairs of geometries (e.g., (gᵢ, gⱼ)). Those queries operate on a theoretical set of candidate pairs, C ⊂ G × G. C lacks many geometry pairs that have been excluded from consideration. CollisionFilterManager excludes many pairs intrinsically and provides mechanisms for the users to exclude even more pairs.
Intrinsic Exclusions
User-Defined Exclusions
Geometry Active Status
In addition to excluding specific geometry pairs, a geometry can be declared inactive* (see Deactivate() and Activate()). An inactive geometry is essentially excluded from G. It still exists as a known geometry. So, adding or removing filters on that geometry is still valid. However, those declarations will have no apparent effect until the geometry is reactivated. An inactive geometry will simply never appear in any pair in the candidate set C.
We can define N as the set of inactive geometries and Gₐ = G - N as the set of active geometries.
Candidate Geometry Pairs
Therefore, the set of geometry pair candidates C for proximity queries is defined as:
C = (Gₐ × Gₐ) - (A × A) - F - I - U.
A CollisionFilterManager is a view into geometry data (either that owned by a SceneGraph instance or a SceneGraph context). The manager instance can be copied or moved and the resulting instance is a view into the same data. For both the original and the copy (or just the target when moving the manager), the source data must stay alive for at least as long as the manager instance.
Collision filtering is all about defining which geometry pairs are in the set C. The simplest way to modify the set C is through persistent modifications to a "base configuration" (via calls to Apply()). However, declarations can also be applied in a transient manner. Transient declarations form a history. The current definition of the set C is the result of applying the history of collision filter declarations to the persistent base configuration in order. That history can be modified:
The table below illustrates a sequence of operations and their effect on C. We define C's initial configuration as C = {P₁, P₂, ..., Pₙ} (for n geometry pairs). Each action is described as either persistent or transient.
| Line | C | Action |
|---|---|---|
| 1 | {P₁, P₂, ..., Pₙ} | Initial condition of the persistent base |
| 2 | {P₂, ..., Pₙ} | Remove P₁ from the persistent base |
| 3 | {P₂, ..., Pₙ₋₁} | Remove Pₙ from the persistent base |
| 4 | {P₂} | Remove all pairs except P₂ from the persistent base |
| 5 | {P₂, P₄, P₅} | Transient declaration #1 puts P₄ and P₅ into C |
| 6 | {P₂, P₃, P₄, P₅} | Transient declaration #2 puts P₃ and P₄ into C |
| 7 | {P₂, P₃, P₄} | Remove declaration #1. |
| 8 | {P₂, P₃, P₄} | Configuration flattened; #2 no longer exists |
Table 1: An example sequence of operations on collision filters.
Notes:
This example workflow above illustrates some key ideas in using transient declarations.
There is a custom API for applying a filter declaration as a transient declaration. It returns the id for the transient API (used to remove the declaration from the history sequence).
Attempting to change the persistent configuration when there are active transient declarations in the history will throw an exception.
#include <drake/geometry/collision_filter_manager.h>
Public Member Functions | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
| CollisionFilterManager (const CollisionFilterManager &)=default | |
| CollisionFilterManager & | operator= (const CollisionFilterManager &)=default |
| CollisionFilterManager (CollisionFilterManager &&)=default | |
| CollisionFilterManager & | operator= (CollisionFilterManager &&)=default |
Evaluating CollisionFilterDeclarations | |
| void | Apply (const CollisionFilterDeclaration &declaration) |
| Applies the given declaration to the geometry state managed by this instance. | |
| FilterId | ApplyTransient (const CollisionFilterDeclaration &declaration) |
| Applies the declaration as the newest transient modification to the collision filter configuration. | |
| bool | RemoveDeclaration (FilterId filter_id) |
| Attempts to remove the transient declaration from the history for the declaration associated with the given filter_id. | |
| bool | has_transient_history () const |
| Reports if there are any active transient filter declarations. | |
| bool | IsActive (FilterId filter_id) const |
| Reports if the transient collision filter declaration indicated by the given filter_id is part of the history. | |
Deactivating and reactivating geometries | |
By default every geometry is active and participates in proximity queries subject to the pairwise filters configured via Apply(). A geometry can also be "deactivated". An inactive geometry is omitted from the geometry set that populates the collision candidate pairs. Therefore, no collision candidate pair can include an inactive geometry until it is reactivated. See the class documentation for how active status participates in the definition of the candidate pair set C (the set Nₚ). Active status is independent of the declared pair-wise filters: Apply() never changes it just as activating and deactivating a geometry does not change the declared pair-wise filters between that geometry and others. Unlike Apply(), these may be called even when there is an active transient history. Apply() can reference an inactive geometry, but the effect of the declaration on any candidate pair including that geometry will not be apparent until the geometry is reactivated. Remember, GeometrySet instances can be instantiated using FrameId values. As documented in GeometrySet, specifying a frame is merely a shorthand for specifying all geometries attached to that frame at the time the ids are extracted from the GeometrySet. Activate() and Deactivate() still only operate on those extracted GeometryIds. They shouldn't be interpreted as (de)activating the frame and any subsequent geometries that may be added to those frames. | |
| void | Deactivate (const GeometrySet &geometry_set) |
| Marks every geometry in geometry_set inactive. | |
| void | Activate (const GeometrySet &geometry_set) |
| Marks every geometry in geometry_set active. | |
|
default |
|
default |
| void Activate | ( | const GeometrySet & | geometry_set | ) |
Marks every geometry in geometry_set active.
The inverse of calling Deactivate(). Activating an already-active geometry is a no-op. For more information, see the Activation documentation.
| std::exception | if geometry_set references invalid ids. |
| void Apply | ( | const CollisionFilterDeclaration & | declaration | ) |
Applies the given declaration to the geometry state managed by this instance.
The process of applying the collision filter data also validates it. The following polices are implemented during application:
| std::exception | if the declaration references invalid ids or there is an active history. |
| FilterId ApplyTransient | ( | const CollisionFilterDeclaration & | declaration | ) |
Applies the declaration as the newest transient modification to the collision filter configuration.
The declaration must be considered "valid", as defined for Apply().
| void Deactivate | ( | const GeometrySet & | geometry_set | ) |
Marks every geometry in geometry_set inactive.
The inverse of calling Activate(). Deactivating an already-inactive geometry is a no-op. For more information, see the Activation documentation.
| std::exception | if geometry_set references invalid ids. |
| bool has_transient_history | ( | ) | const |
Reports if there are any active transient filter declarations.
| bool IsActive | ( | FilterId | filter_id | ) | const |
Reports if the transient collision filter declaration indicated by the given filter_id is part of the history.
|
default |
|
default |
| bool RemoveDeclaration | ( | FilterId | filter_id | ) |
Attempts to remove the transient declaration from the history for the declaration associated with the given filter_id.
| filter_id | The id of the filter declaration to remove. |