Drake
SceneGraphInspector< T > Class Template Reference

Detailed Description

template<typename T>
class drake::geometry::SceneGraphInspector< T >

The SceneGraphInspector serves as a mechanism to query the topological structure of a SceneGraph instance.

The topological structure consists of all of the SceneGraph data that does not depend on input pose data. Including, but not limited to:

  • names of frames and geometries
  • hierarchies (parents of geometries, parents of frames, etc.)
  • geometry parameters (e.g., contact, rendering, visualization)
  • fixed poses of geometries relative to frames

In contrast, the following pieces of data do depend on input pose data and cannot be performed with the SceneGraphInspector (see the QueryObject instead):

  • world pose of frames or geometry
  • collision queries
  • proximity queries

A SceneGraphInspector cannot be instantiated explicitly. Nor can it be copied or moved. A reference to a SceneGraphInspector instance can be acquired from

  • a SceneGraph instance (to inspect the state of the system's model), or
  • a QueryObject instance (to inspect the state of the scene graph data stored in the context).

The reference should not be persisted (and, as previously indicated, cannot be copied). SceneGraphInspector instances are cheap; they can be created, queried, and thrown out. If there is any doubt about the valid lifespan of a SceneGraphInspector, throw out the old instance and request a new instance.

Template Parameters
TThe scalar of the associated SceneGraph instance. The template parameter is provided for the sake of compatibility, although no queries (or their results) depend on the scalar.

#include <drake/geometry/scene_graph_inspector.h>

Public Member Functions

Does not allow copy, move, or assignment
 SceneGraphInspector (const SceneGraphInspector &)=delete
 
SceneGraphInspectoroperator= (const SceneGraphInspector &)=delete
 
 SceneGraphInspector (SceneGraphInspector &&)=delete
 
SceneGraphInspectoroperator= (SceneGraphInspector &&)=delete
 
Scene-graph wide data
int num_sources () const
 Reports the number of registered sources – whether they have registered frames/geometries or not. More...
 
int num_frames () const
 Reports the total number of frames registered in the scene graph (including the world frame). More...
 
GeometryState< T >::FrameIdRange all_frame_ids () const
 Provides a range object for all of the frame ids in the scene graph. More...
 
int num_geometries () const
 Reports the total number of geometries in the scene graph. More...
 
const std::vector< GeometryIdGetAllGeometryIds () const
 Returns the set of all ids for registered geometries. More...
 
const std::vector< GeometryIdall_geometry_ids () const
 Returns the set of all ids for registered geometries. More...
 
int NumGeometriesWithRole (Role role) const
 Reports the total number of geometries in the scene graph with the indicated role. More...
 
int GetNumDynamicGeometries () const
 Reports the total number of dynamic geometries in the scene graph. More...
 
int GetNumAnchoredGeometries () const
 Reports the total number of anchored geometries. More...
 
std::set< std::pair< GeometryId, GeometryId > > GetCollisionCandidates () const
 Returns all pairs of geometries that are candidates for collision (in no particular order). More...
 
Sources and source-related data
bool SourceIsRegistered (SourceId id) const
 Reports true if the given id maps to a registered source. More...
 
const std::string & GetSourceName (SourceId id) const
 Reports the name for the source with the given id. More...
 
int NumFramesForSource (SourceId id) const
 Reports the number of frames registered to the source with the given id. More...
 
const std::unordered_set< FrameId > & FramesForSource (SourceId id) const
 Reports the ids of all of the frames registered to the source with the given source id. More...
 
Frames and their properties
bool BelongsToSource (FrameId frame_id, SourceId source_id) const
 Reports if the frame with given frame_id was registered to the source with the given source_id. More...
 
const std::string & GetOwningSourceName (FrameId id) const
 Reports the name of the geometry source that registered the frame with the given id. More...
 
const std::string & GetName (FrameId id) const
 Reports the name of the frame with the given id. More...
 
int GetFrameGroup (FrameId id) const
 Reports the frame group for the frame with the given id. More...
 
int NumGeometriesForFrame (FrameId id) const
 Reports the number of geometries affixed to the frame with the given id. More...
 
int NumGeometriesForFrameWithRole (FrameId id, Role role) const
 Reports the total number of geometries with the given role directly registered to the frame with the given id. More...
 
GeometryId GetGeometryIdByName (FrameId id, Role role, const std::string &name) const
 Reports the id of the geometry with the given name and role, attached to the frame with the given frame id. More...
 
Geometries and their properties
bool BelongsToSource (GeometryId geometry_id, SourceId source_id) const
 Reports if the given geometry id was registered to the source with the given source id. More...
 
const std::string & GetOwningSourceName (GeometryId id) const
 Reports the name of the geometry source that registered the geometry with the given id. More...
 
FrameId GetFrameId (GeometryId id) const
 Reports the id of the frame to which the given geometry with the given id is registered. More...
 
const std::string & GetName (GeometryId id) const
 Reports the stored, canonical name of the geometry with the given id (see GeometryInstance for details). More...
 
const ShapeGetShape (GeometryId id) const
 Returns the shape specified for the geometry with the given id. More...
 
const Isometry3< doubleX_PG (GeometryId id) const
 Reports the pose of the geometry G with the given id in its registered topological parent P. More...
 
const math::RigidTransform< double > & GetPoseInParent (GeometryId id) const
 Reports the pose of the geometry G with the given id in its registered topological parent P, X_PG. More...
 
const Isometry3< doubleX_FG (GeometryId id) const
 Reports the pose of the geometry G with the given id in its registered frame F (regardless of whether its topological parent is another geometry P or not). More...
 
const math::RigidTransform< double > & GetPoseInFrame (GeometryId id) const
 Reports the pose of the geometry G with the given id in its registered frame F (regardless of whether its topological parent is another geometry P or not). More...
 
const ProximityPropertiesGetProximityProperties (GeometryId id) const
 Returns a pointer to the const proximity properties of the geometry with the given id. More...
 
const IllustrationPropertiesGetIllustrationProperties (GeometryId id) const
 Returns a pointer to the const illustration properties of the geometry with the given id. More...
 
const PerceptionPropertiesGetPerceptionProperties (GeometryId id) const
 Returns a pointer to the const perception properties of the geometry with the given id. More...
 
bool CollisionFiltered (GeometryId id1, GeometryId id2) const
 Reports true if the two geometries with given ids id1 and id2, define a collision pair that has been filtered out. More...
 
void Reify (GeometryId id, ShapeReifier *reifier) const
 Introspects the geometry indicated by the given id. More...
 

Friends

class SceneGraph< T >
 
class QueryObject< T >
 
class SceneGraphInspectorTester
 

Constructor & Destructor Documentation

◆ SceneGraphInspector() [1/2]

SceneGraphInspector ( const SceneGraphInspector< T > &  )
delete

◆ SceneGraphInspector() [2/2]

Member Function Documentation

◆ all_frame_ids()

GeometryState<T>::FrameIdRange all_frame_ids ( ) const

Provides a range object for all of the frame ids in the scene graph.

The order is not generally guaranteed; but it will be consistent as long as there are no changes to the topology. This is intended to be used as:

for (FrameId id : inspector.all_frame_ids()) {
...
}

This includes the id for the world frame.

◆ all_geometry_ids()

const std::vector<GeometryId> all_geometry_ids ( ) const

Returns the set of all ids for registered geometries.

The order is not guaranteed to have any particular meaning. But the order is guaranteed to remain fixed between topological changes (e.g., removal or addition of geometry/frames). (Deprecated.)

Deprecated:
"Please use GetAllGeometryIds() instead"
This will be removed from Drake on or after "2019-11-01" .

◆ BelongsToSource() [1/2]

bool BelongsToSource ( FrameId  frame_id,
SourceId  source_id 
) const

Reports if the frame with given frame_id was registered to the source with the given source_id.

Parameters
frame_idThe query frame id.
source_idThe query source id.
Returns
True if frame_id was registered on source_id.
Exceptions
std::logic_errorIf frame_id does not map to a registered frame or source_id does not map to a registered source.

◆ BelongsToSource() [2/2]

bool BelongsToSource ( GeometryId  geometry_id,
SourceId  source_id 
) const

Reports if the given geometry id was registered to the source with the given source id.

Parameters
geometry_idThe query geometry id.
source_idThe query source id.
Returns
True if geometry_id was registered on source_id.
Exceptions
std::logic_errorIf geometry_id does not map to a registered geometry or source_id does not map to a registered source.

◆ CollisionFiltered()

bool CollisionFiltered ( GeometryId  id1,
GeometryId  id2 
) const

Reports true if the two geometries with given ids id1 and id2, define a collision pair that has been filtered out.

Exceptions
std::logic_errorif either id does not map to a registered geometry or if any of the geometries do not have a proximity role.

◆ FramesForSource()

const std::unordered_set<FrameId>& FramesForSource ( SourceId  id) const

Reports the ids of all of the frames registered to the source with the given source id.

Exceptions
std::logic_errorif id does not map to a registered source.

◆ GetAllGeometryIds()

const std::vector<GeometryId> GetAllGeometryIds ( ) const

Returns the set of all ids for registered geometries.

The order is not guaranteed to have any particular meaning. But the order is guaranteed to remain fixed until a topological change is made (e.g., removal or addition of geometry/frames).

◆ GetCollisionCandidates()

std::set<std::pair<GeometryId, GeometryId> > GetCollisionCandidates ( ) const

Returns all pairs of geometries that are candidates for collision (in no particular order).

See SceneGraph::ExcludeCollisionsBetween() or SceneGraph::ExcludeCollisionsWithin() for information on why a particular pair may not be a candidate. For candidate pair (A, B), the candidate is always guaranteed to be reported in a fixed order (i.e., always (A, B) and never (B, A)). This is the same ordering as would be returned by, e.g., QueryObject::ComputePointPairPenetration().

◆ GetFrameGroup()

int GetFrameGroup ( FrameId  id) const

Reports the frame group for the frame with the given id.

Exceptions
std::logic_errorif id does not map to a registered frame.

◆ GetFrameId()

FrameId GetFrameId ( GeometryId  id) const

Reports the id of the frame to which the given geometry with the given id is registered.

Exceptions
std::logic_errorif id does not map to a registered geometry.

◆ GetGeometryIdByName()

GeometryId GetGeometryIdByName ( FrameId  id,
Role  role,
const std::string &  name 
) const

Reports the id of the geometry with the given name and role, attached to the frame with the given frame id.

Parameters
idThe id of the frame whose geometry is being queried.
roleThe assigned role of the desired geometry.
nameThe name of the geometry to query for. The name will be canonicalized prior to lookup (see GeometryInstance for details).
Returns
The id of the queried geometry.
Exceptions
std::logic_errorif no such geometry exists, multiple geometries have that name, or if the id does not map to a registered frame.

◆ GetIllustrationProperties()

const IllustrationProperties* GetIllustrationProperties ( GeometryId  id) const

Returns a pointer to the const illustration properties of the geometry with the given id.

Parameters
idThe identifier for the queried geometry.
Returns
A pointer to the properties (or nullptr if there are no such properties).
Exceptions
std::logic_errorif id does not map to a registered geometry.

◆ GetName() [1/2]

const std::string& GetName ( FrameId  id) const

Reports the name of the frame with the given id.

Exceptions
std::logic_errorif id does not map to a registered frame.

◆ GetName() [2/2]

const std::string& GetName ( GeometryId  id) const

Reports the stored, canonical name of the geometry with the given id (see GeometryInstance for details).

Exceptions
std::logic_errorif id does not map to a registered geometry.

◆ GetNumAnchoredGeometries()

int GetNumAnchoredGeometries ( ) const

Reports the total number of anchored geometries.

This should provide the same answer as calling GetNumFrameGeometries() with the world frame id.

◆ GetNumDynamicGeometries()

int GetNumDynamicGeometries ( ) const

Reports the total number of dynamic geometries in the scene graph.

◆ GetOwningSourceName() [1/2]

const std::string& GetOwningSourceName ( FrameId  id) const

Reports the name of the geometry source that registered the frame with the given id.

Exceptions
std::logic_errorIf id does not map to a registered frame.

◆ GetOwningSourceName() [2/2]

const std::string& GetOwningSourceName ( GeometryId  id) const

Reports the name of the geometry source that registered the geometry with the given id.

Exceptions
std::logic_errorIf id does not map to a registered geometry.

◆ GetPerceptionProperties()

const PerceptionProperties* GetPerceptionProperties ( GeometryId  id) const

Returns a pointer to the const perception properties of the geometry with the given id.

Parameters
idThe identifier for the queried geometry.
Returns
A pointer to the properties (or nullptr if there are no such properties).
Exceptions
std::logic_errorif id does not map to a registered geometry.

◆ GetPoseInFrame()

const math::RigidTransform<double>& GetPoseInFrame ( GeometryId  id) const

Reports the pose of the geometry G with the given id in its registered frame F (regardless of whether its topological parent is another geometry P or not).

If the geometry was registered directly to the frame F, then X_PG = X_FG.

See also
GetPoseInParent()
Exceptions
std::logic_errorif id does not map to a registered geometry.

◆ GetPoseInParent()

const math::RigidTransform<double>& GetPoseInParent ( GeometryId  id) const

Reports the pose of the geometry G with the given id in its registered topological parent P, X_PG.

That topological parent may be a frame F or another geometry. If the geometry was registered directly to F, then X_PG = X_FG.

See also
GetPoseInFrame()
Exceptions
std::logic_errorif id does not map to a registered geometry.

◆ GetProximityProperties()

const ProximityProperties* GetProximityProperties ( GeometryId  id) const

Returns a pointer to the const proximity properties of the geometry with the given id.

Parameters
idThe identifier for the queried geometry.
Returns
A pointer to the properties (or nullptr if there are no such properties).
Exceptions
std::logic_errorif id does not map to a registered geometry.

◆ GetShape()

const Shape& GetShape ( GeometryId  id) const

Returns the shape specified for the geometry with the given id.

In order to extract the details of the shape, it should be passed through an implementation of a ShapeReifier.

◆ GetSourceName()

const std::string& GetSourceName ( SourceId  id) const

Reports the name for the source with the given id.

Exceptions
std::logic_errorif id does not map to a registered source.

◆ num_frames()

int num_frames ( ) const

Reports the total number of frames registered in the scene graph (including the world frame).

◆ num_geometries()

int num_geometries ( ) const

Reports the total number of geometries in the scene graph.

◆ num_sources()

int num_sources ( ) const

Reports the number of registered sources – whether they have registered frames/geometries or not.

This will always be at least 1; the SceneGraph itself counts as a source.

◆ NumFramesForSource()

int NumFramesForSource ( SourceId  id) const

Reports the number of frames registered to the source with the given id.

Exceptions
std::logic_errorif id does not map to a registered source.

◆ NumGeometriesForFrame()

int NumGeometriesForFrame ( FrameId  id) const

Reports the number of geometries affixed to the frame with the given id.

This count does not include geometries attached to frames that are descendants of this frame.

Exceptions
std::logic_errorif id does not map to a registered frame.

◆ NumGeometriesForFrameWithRole()

int NumGeometriesForFrameWithRole ( FrameId  id,
Role  role 
) const

Reports the total number of geometries with the given role directly registered to the frame with the given id.

This count does not include geometries attached to frames that are descendants of this frame.

Exceptions
std::logic_errorif id does not map to a registered frame.

◆ NumGeometriesWithRole()

int NumGeometriesWithRole ( Role  role) const

Reports the total number of geometries in the scene graph with the indicated role.

◆ operator=() [1/2]

SceneGraphInspector& operator= ( SceneGraphInspector< T > &&  )
delete

◆ operator=() [2/2]

SceneGraphInspector& operator= ( const SceneGraphInspector< T > &  )
delete

◆ Reify()

void Reify ( GeometryId  id,
ShapeReifier reifier 
) const

Introspects the geometry indicated by the given id.

The geometry will be passed into the provided reifier. This is the mechanism by which external code can discover and respond to the different types of geometries stored in SceneGraph. See ShapeToString as an example.

Exceptions
std::logic_errorif the id does not refer to a valid geometry.

◆ SourceIsRegistered()

bool SourceIsRegistered ( SourceId  id) const

Reports true if the given id maps to a registered source.

◆ X_FG()

const Isometry3<double> X_FG ( GeometryId  id) const

Reports the pose of the geometry G with the given id in its registered frame F (regardless of whether its topological parent is another geometry P or not).

If the geometry was registered directly to the frame F, then X_PG = X_FG.

Exceptions
std::logic_errorif id does not map to a registered geometry. (Deprecated.)
Deprecated:
"Simply use GetPoseInFrame()"
This will be removed from Drake on or after "2019-11-01" .

◆ X_PG()

const Isometry3<double> X_PG ( GeometryId  id) const

Reports the pose of the geometry G with the given id in its registered topological parent P.

That topological parent may be a frame F or another geometry. If the geometry was registered directly to F, then X_PG = X_FG.

Exceptions
std::logic_errorif id does not map to a registered geometry. (Deprecated.)
Deprecated:
"Simply use GetPoseInParent()"
This will be removed from Drake on or after "2019-11-01" .

Friends And Related Function Documentation

◆ QueryObject< T >

friend class QueryObject< T >
friend

◆ SceneGraph< T >

friend class SceneGraph< T >
friend

◆ SceneGraphInspectorTester

friend class SceneGraphInspectorTester
friend

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