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 geometry G = D ⋃ A = {g₀, g₁, ..., gₙ}
, where D is the set of dynamic geometries and A is the set of anchored geometries (by definition D ⋂ A = ∅
). Gₚ ⊂ G
is the subset of geometries that have a proximity role (with an analogous interpretation of Dₚ
and Aₚ
). Many proximity queries operate on pairs of geometries (e.g., (gᵢ, gⱼ)). The set of proximity candidate pairs for such queries is initially defined as C = (Gₚ × Gₚ) - (Aₚ × Aₚ) - Fₚ - Iₚ
, where:
Gₚ × Gₚ = {(gᵢ, gⱼ)}, ∀ gᵢ, gⱼ ∈ Gₚ
is the Cartesian product of the set of SceneGraph proximity geometries.Aₚ × Aₚ
represents all pairs consisting only of anchored geometries; an anchored geometry is never tested against another anchored geometry.Fₚ = {(gᵢ, gⱼ)} ∀ i, j
, such that gᵢ, gⱼ ∈ Dₚ
and frame(gᵢ) == frame(gⱼ)
; the pairs where both geometries are rigidly affixed to the same frame.Iₚ = {(g, g)}, ∀ g ∈ Gₚ
is the set of all pairs consisting of a geometry with itself; there is no meaningful proximity query on a geometry with itself.Only pairs contained in C will be included in pairwise proximity operations.
The manager provides an interface to modify the set C. Changes to C are articulated with CollisionFilterDeclaration. Once a change has been declared it is applied via the manager's API to change the configuration of C.
There are limits to how C can be modified.
∀ (gᵢ, gⱼ) ∈ C
, both gᵢ and gⱼ must be registered with SceneGraph; you can't inject arbitrary ids. Attempting to do so will result in an error.Aₚ × Aₚ
, Fₚ
, or Iₚ
can ever be added to C. Excluding those pairs is a SceneGraph invariant. Attempts to do so will be ignored.The current configuration of C depends on the sequence of filter declarations that have been applied in the manager. Changing the order can change the end result.
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 | |
void | Apply (const CollisionFilterDeclaration &declaration) |
Applies the given declaration to the geometry state managed by this instance. More... | |
FilterId | ApplyTransient (const CollisionFilterDeclaration &declaration) |
Applies the declaration as the newest transient modification to the collision filter configuration. More... | |
bool | RemoveDeclaration (FilterId filter_id) |
Attempts to remove the transient declaration from the history for the declaration associated with the given filter_id . More... | |
bool | has_transient_history () const |
Reports if there are any active transient filter declarations. More... | |
bool | IsActive (FilterId filter_id) const |
Reports if the transient collision filter declaration indicated by the given filter_id is part of the history. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
CollisionFilterManager (const CollisionFilterManager &)=default | |
CollisionFilterManager & | operator= (const CollisionFilterManager &)=default |
CollisionFilterManager (CollisionFilterManager &&)=default | |
CollisionFilterManager & | operator= (CollisionFilterManager &&)=default |
Friends | |
template<typename > | |
class | GeometryState |
|
default |
|
default |
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().
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. |
true
iff is_active(filter_id)
returns true
before calling this method (i.e., filter_id
refers to an existent filter that has successfully been removed).
|
friend |