Drake
Drake C++ Documentation
GeometrySet Class Reference

Detailed Description

The GeometrySet, as its name implies, is a convenience class for defining a set of geometries.

What makes it unique from a simple std::set<GeometryId> instance is that membership doesn't require explicit GeometryId enumeration; GeometryId values can be added to the set by adding the FrameId for the frame to which the geometries are rigidly affixed.

This class does no validation; it is a simple collection. Ultimately, it serves as the operand of various geometry operations (e.g., CollisionFilterDeclaration and CollisionFilterManager::Apply(). If the operation has a particular prerequisite on the members of a GeometrySet, it is the operation's responsibility to enforce that requirement.

More formally, the SceneGraph consists of a set of geometries, each associated with a unique identifier. As such, we can consider the set of all identifiers SG = {g₀, g₁, ..., gₙ} that belong to a SceneGraph. A GeometrySet should represent a subset of those identifiers, Gₛ ⊆ SG. The convenience of the GeometrySet class is how the subset is defined. Given a set of frame ids F = {f₀, f₁, ..., fₙ} and geometry ids G = {g₀, g₁, ..., gₘ}, Gₛ = G ⋃ geometry(f₀) ⋃ ... ⋃ geometry(fₙ) (where geometry(f) is the set of geometries rigidly affixed to frame f).

#include <drake/geometry/geometry_set.h>

Public Member Functions

 GeometrySet ()=default
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 GeometrySet (const GeometrySet &)=default
 
GeometrySetoperator= (const GeometrySet &)=default
 
 GeometrySet (GeometrySet &&)=default
 
GeometrySetoperator= (GeometrySet &&)=default
 
Explicit constructors

Various workflows may arise for operating on GeometrySet instances, e.g.

:

// Perform operation on previously existing collection of frame ids.
std::vector<FrameId> my_ids{...}; // Previously-defined vector of ids.
GeometrySet geometry_set;
geometry_set.Add(my_ids);
UnaryOperation(geometry_set);

or

// Perform operation between two frames.
set1.Add(frame1);
set2.Add(frame2);
BinaryOperation(set1, set2);

This set of constructors allow on-the-fly construction at the call site to create temporary instances when the group membership is a single id or a previously existing id. By doing so, the above cases become:

// Perform operation on previously existing collection of frame ids.
std::vector<FrameId> my_ids{...}; // Previously-defined vector of ids.
UnaryOperation(GeometrySet(my_ids));
// Perform operation between two frames.
BinaryOperation(GeometrySet(frame1), GeometrySet(frame2));

The following are all valid constructions – this is not an exhaustive list but a representative sampling:

// Assume that g_* and f_* are valid GeometryId and FrameId instances,
// respectively.
std::vector<GeometryId> g_vector{g_0, g_1, g_2};
std::set<GeometryId> g_set{g_3, g_4, g_5};
std::unordered_set<FrameId> f_set{f_0, f_1};
auto f_list = {f_2, f_3, f_4};
GeometrySet({g_0, g_1});
GeometrySet({f_0, f_1});
GeometrySet(g_vector, f_set);
GeometrySet(g_set, f_list);
// Note: construction on values of both geometry and frame identifiers
// requires passing in "collections" of ids; the initializer list is the
// simplest collection that serves the purpose. When both are provided,
// GeometryId always comes before FrameId.
GeometrySet({g_0}, {f_1});
GeometrySet({g_0}, f_set);
// etc.
 GeometrySet (GeometryId geometry_id)
 
 GeometrySet (FrameId frame_id)
 
template<typename Container >
 GeometrySet (const Container &ids)
 
template<typename Id >
 GeometrySet (std::initializer_list< Id > id_list)
 
template<typename Container >
 GeometrySet (std::initializer_list< GeometryId > geometry_ids, const Container &frame_ids)
 
template<typename Container >
 GeometrySet (const Container &geometry_ids, std::initializer_list< FrameId > frame_ids)
 
 GeometrySet (std::initializer_list< GeometryId > geometry_ids, std::initializer_list< FrameId > frame_ids)
 
template<typename ContainerG , typename ContainerF , typename = typename std::enable_if_t< std::is_same_v<typename ContainerG::value_type, GeometryId> && std::is_same_v<typename ContainerF::value_type, FrameId>>>
 GeometrySet (const ContainerG &geometry_ids, const ContainerF &frame_ids)
 
Methods for adding to the set

The interface for adding geometries to the set is simply an overload of the Add() method.

For maximum flexibility, the Add method can take:

  • a single geometry id
  • a single frame id
  • an iterable object containing geometry ids
  • an iterable object containing frame ids
  • two iterable objects, the first containing geometry ids, the second containing frame ids.
  • another GeometrySet instance.

NOTE: the iterable objects don't have to be the same type. The "iterable" can also be an initializer list. All of the following invocations are valid (this isn't an exhaustive list, but a representative set):

// Assuming that f_* are valid FrameId instances and g_* are valid GeometryId
// instances.
group.Add(f_1);
group.Add(g_1);
std::vector<FrameId> frame_ids{f_2, f_3, f_4};
group.Add(frame_ids);
std::vector<GeometryId> geometry_ids{g_2, g_3, g_4};
group.Add(geometry_ids);
// This is valid, but redundant; the ids in those vectors have already been
// added.
group.Add(geometry_ids, frame_ids);
// Mismatched iterable types.
std::set<FrameId> frame_set{f_5, f_6, f_7};
group.Add({g_7, g_8}, frame_set);
void Add (GeometryId geometry_id)
 
void Add (FrameId frame_id)
 
template<typename Container >
std::enable_if_t< std::is_same_v< typename Container::value_type, GeometryId > > Add (const Container &geometry_ids)
 
template<typename Container >
std::enable_if_t< std::is_same_v< typename Container::value_type, FrameId > > Add (const Container &frame_ids)
 
void Add (std::initializer_list< FrameId > frame_ids)
 
void Add (std::initializer_list< GeometryId > geometry_ids)
 
template<typename ContainerG , typename ContainerF >
std::enable_if_t< std::is_same_v< typename ContainerG::value_type, GeometryId > &&std::is_same_v< typename ContainerF::value_type, FrameId > > Add (const ContainerG &geometry_ids, const ContainerF &frame_ids)
 
template<typename ContainerF >
std::enable_if_t< std::is_same_v< typename ContainerF::value_type, FrameId > > Add (std::initializer_list< GeometryId > geometry_ids, const ContainerF &frame_ids)
 
template<typename ContainerG >
std::enable_if_t< std::is_same_v< typename ContainerG::value_type, GeometryId > > Add (const ContainerG &geometry_ids, std::initializer_list< FrameId > frame_ids)
 
void Add (const GeometrySet &other)
 

Friends

class GeometrySetTester
 
template<typename >
class GeometryState
 

Constructor & Destructor Documentation

◆ GeometrySet() [1/11]

GeometrySet ( const GeometrySet )
default

◆ GeometrySet() [2/11]

GeometrySet ( GeometrySet &&  )
default

◆ GeometrySet() [3/11]

GeometrySet ( )
default

◆ GeometrySet() [4/11]

GeometrySet ( GeometryId  geometry_id)
explicit

◆ GeometrySet() [5/11]

GeometrySet ( FrameId  frame_id)
explicit

◆ GeometrySet() [6/11]

GeometrySet ( const Container &  ids)
explicit

◆ GeometrySet() [7/11]

GeometrySet ( std::initializer_list< Id >  id_list)
explicit

◆ GeometrySet() [8/11]

GeometrySet ( std::initializer_list< GeometryId geometry_ids,
const Container &  frame_ids 
)
explicit

◆ GeometrySet() [9/11]

GeometrySet ( const Container &  geometry_ids,
std::initializer_list< FrameId frame_ids 
)
explicit

◆ GeometrySet() [10/11]

GeometrySet ( std::initializer_list< GeometryId geometry_ids,
std::initializer_list< FrameId frame_ids 
)
explicit

◆ GeometrySet() [11/11]

GeometrySet ( const ContainerG &  geometry_ids,
const ContainerF &  frame_ids 
)

Member Function Documentation

◆ Add() [1/10]

void Add ( GeometryId  geometry_id)

◆ Add() [2/10]

void Add ( FrameId  frame_id)

◆ Add() [3/10]

std::enable_if_t< std::is_same_v<typename Container::value_type, GeometryId> > Add ( const Container &  geometry_ids)

◆ Add() [4/10]

std::enable_if_t< std::is_same_v<typename Container::value_type, FrameId> > Add ( const Container &  frame_ids)

◆ Add() [5/10]

void Add ( std::initializer_list< FrameId frame_ids)

◆ Add() [6/10]

void Add ( std::initializer_list< GeometryId geometry_ids)

◆ Add() [7/10]

std::enable_if_t< std::is_same_v<typename ContainerG::value_type, GeometryId> && std::is_same_v<typename ContainerF::value_type, FrameId> > Add ( const ContainerG &  geometry_ids,
const ContainerF &  frame_ids 
)

◆ Add() [8/10]

std::enable_if_t< std::is_same_v<typename ContainerF::value_type, FrameId> > Add ( std::initializer_list< GeometryId geometry_ids,
const ContainerF &  frame_ids 
)

◆ Add() [9/10]

std::enable_if_t< std::is_same_v<typename ContainerG::value_type, GeometryId> > Add ( const ContainerG &  geometry_ids,
std::initializer_list< FrameId frame_ids 
)

◆ Add() [10/10]

void Add ( const GeometrySet other)

◆ operator=() [1/2]

GeometrySet& operator= ( const GeometrySet )
default

◆ operator=() [2/2]

GeometrySet& operator= ( GeometrySet &&  )
default

Friends And Related Function Documentation

◆ GeometrySetTester

friend class GeometrySetTester
friend

◆ GeometryState

friend class GeometryState
friend

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