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:
In contrast, the following pieces of data do depend on input pose data and cannot be performed with the SceneGraphInspector (see the QueryObject instead):
A SceneGraphInspector cannot be instantiated explicitly. Nor can it be copied or moved. A reference to a SceneGraphInspector instance can be acquired from
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.
T | The 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 | |
SceneGraphInspector & | operator= (const SceneGraphInspector &)=delete |
SceneGraphInspector (SceneGraphInspector &&)=delete | |
SceneGraphInspector & | operator= (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... | |
std::vector< SourceId > | GetAllSourceIds () const |
Returns all of the source ids in the scene graph. More... | |
std::vector< FrameId > | GetAllFrameIds () const |
Returns all of the frame ids in the scene graph. More... | |
FrameId | world_frame_id () const |
Reports the id for the world frame. More... | |
int | num_geometries () const |
Reports the total number of geometries in the scene graph. More... | |
std::vector< GeometryId > | GetAllGeometryIds (std::optional< Role > role=std::nullopt) const |
Returns the set of all ids for registered geometries. More... | |
std::unordered_set< GeometryId > | GetGeometryIds (const GeometrySet &geometry_set, std::optional< Role > role=std::nullopt) const |
Returns the geometry ids that are implied by the given GeometrySet and role . More... | |
int | NumGeometriesWithRole (Role role) const |
Reports the total number of geometries in the scene graph with the indicated role. More... | |
int | NumDeformableGeometriesWithRole (Role role) const |
Reports the total number of deformable geometries in the scene graph with the indicated role. More... | |
int | NumDynamicGeometries () const |
Reports the total number of dynamic geometries in the scene graph. More... | |
int | NumAnchoredGeometries () const |
Reports the total number of anchored non-deformable 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... | |
const GeometryVersion & | geometry_version () const |
Returns the geometry version that can be used to detect changes to the geometry data associated with geometry roles. More... | |
Sources and source-related data | |
bool | SourceIsRegistered (SourceId source_id) const |
Reports true if the given source_id maps to a registered source. More... | |
const std::string & | GetName (SourceId source_id) const |
Reports the name for the source with the given source_id . More... | |
int | NumFramesForSource (SourceId source_id) const |
Reports the number of frames registered to the source with the given source_id . More... | |
const std::unordered_set< FrameId > & | FramesForSource (SourceId source_id) const |
Reports the ids of all of the frames registered to the source with the given source 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 frame_id) const |
Reports the name of the geometry source that registered the frame with the given frame_id . More... | |
const std::string & | GetName (FrameId frame_id) const |
Reports the name of the frame with the given frame_id . More... | |
FrameId | GetParentFrame (FrameId frame_id) const |
Reports the FrameId of the parent of frame_id . More... | |
int | GetFrameGroup (FrameId frame_id) const |
Reports the frame group for the frame with the given frame_id . More... | |
int | NumGeometriesForFrame (FrameId frame_id) const |
Reports the number of geometries affixed to the frame with the given frame_id . More... | |
int | NumGeometriesForFrameWithRole (FrameId frame_id, Role role) const |
Reports the total number of geometries with the given role directly registered to the frame with the given frame_id . More... | |
std::vector< GeometryId > | GetGeometries (FrameId frame_id, const std::optional< Role > &role=std::nullopt) const |
Returns geometry ids that have been registered directly to the frame indicated by frame_id . More... | |
GeometryId | GetGeometryIdByName (FrameId frame_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 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 geometry_id) const |
Reports the name of the geometry source that registered the geometry with the given geometry_id . More... | |
FrameId | GetFrameId (GeometryId geometry_id) const |
Reports the id of the frame to which the given geometry with the given geometry_id is registered. More... | |
const std::string & | GetName (GeometryId geometry_id) const |
Reports the stored, canonical name of the geometry with the given geometry_id (see GeometryInstance for details). More... | |
const Shape & | GetShape (GeometryId geometry_id) const |
Returns the shape specified for the geometry with the given geometry_id . More... | |
const math::RigidTransform< double > & | GetPoseInFrame (GeometryId geometry_id) const |
Reports the pose of the geometry G with the given geometry_id in its registered frame F. More... | |
std::variant< std::monostate, const TriangleSurfaceMesh< double > *, const VolumeMesh< double > * > | maybe_get_hydroelastic_mesh (GeometryId geometry_id) const |
Returns the mesh used to represent this geometry in hydroelastic contact calculations, if it exists. More... | |
const GeometryProperties * | GetProperties (GeometryId geometry_id, Role role) const |
Return a pointer to the const properties indicated by role of the geometry with the given geometry_id . More... | |
const ProximityProperties * | GetProximityProperties (GeometryId geometry_id) const |
Returns a pointer to the const proximity properties of the geometry with the given geometry_id . More... | |
const IllustrationProperties * | GetIllustrationProperties (GeometryId geometry_id) const |
Returns a pointer to the const illustration properties of the geometry with the given geometry_id . More... | |
const PerceptionProperties * | GetPerceptionProperties (GeometryId geometry_id) const |
Returns a pointer to the const perception properties of the geometry with the given geometry_id . More... | |
const VolumeMesh< double > * | GetReferenceMesh (GeometryId geometry_id) const |
Returns the reference mesh of the geometry with the given geometry_id , measured and expressed in the geometry's frame, G. More... | |
const std::vector< internal::RenderMesh > & | GetDrivenRenderMeshes (GeometryId geometry_id, Role role) const |
Returns the render mesh representation of the driven meshes associated with the given role of the geometry with the given geometry_id . More... | |
bool | IsDeformableGeometry (GeometryId geometry_id) const |
Returns true if the geometry with the given geometry_id is deformable. More... | |
std::vector< GeometryId > | GetAllDeformableGeometryIds () const |
Returns all geometry ids that correspond to deformable geometries. More... | |
const PolygonSurfaceMesh< double > * | GetConvexHull (GeometryId geometry_id) const |
Returns the convex hull (a polytope) associated with the given geometry_id , if it exists. More... | |
bool | CollisionFiltered (GeometryId geometry_id1, GeometryId geometry_id2) const |
Reports true if the two geometries with given ids geometry_id1 and geometry_id2 , define a collision pair that has been filtered out. More... | |
std::unique_ptr< GeometryInstance > | CloneGeometryInstance (GeometryId geometry_id) const |
Obtains a new GeometryInstance that copies the geometry indicated by the given geometry_id . More... | |
Friends | |
class | SceneGraph< T > |
class | QueryObject< T > |
class | SceneGraphInspectorTester |
|
delete |
|
delete |
Reports if the frame with given frame_id
was registered to the source with the given source_id
.
frame_id | The query frame id. |
source_id | The query source id. |
frame_id
was registered on source_id
. std::exception | If frame_id does not map to a registered frame or source_id does not map to a registered source. |
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.
geometry_id | The query geometry id. |
source_id | The query source id. |
geometry_id
was registered on source_id
. std::exception | If geometry_id does not map to a registered geometry or source_id does not map to a registered source. |
std::unique_ptr<GeometryInstance> CloneGeometryInstance | ( | GeometryId | geometry_id | ) | const |
Obtains a new GeometryInstance that copies the geometry indicated by the given geometry_id
.
std::exception | if the geometry_id does not refer to a valid geometry. |
bool CollisionFiltered | ( | GeometryId | geometry_id1, |
GeometryId | geometry_id2 | ||
) | const |
Reports true if the two geometries with given ids geometry_id1
and geometry_id2
, define a collision pair that has been filtered out.
std::exception | if either id does not map to a registered geometry or if any of the geometries do not have a proximity role. |
Reports the ids of all of the frames registered to the source with the given source source_id
.
std::exception | if source_id does not map to a registered source. |
const GeometryVersion& geometry_version | ( | ) | const |
Returns the geometry version that can be used to detect changes to the geometry data associated with geometry roles.
The reference returned should not be persisted. If it needs to be persisted, it should be copied.
std::vector<GeometryId> GetAllDeformableGeometryIds | ( | ) | const |
Returns all geometry ids that correspond to deformable geometries.
The order is guaranteed to be stable and consistent.
std::vector<FrameId> GetAllFrameIds | ( | ) | const |
Returns all of the frame ids in the scene graph.
The order is guaranteed to be stable and consistent. The ids include the world frame's id.
std::vector<GeometryId> GetAllGeometryIds | ( | std::optional< Role > | role = std::nullopt | ) | const |
Returns the set of all ids for registered geometries.
The order is guaranteed to be stable and consistent.
role | The requested role; if omitted, all geometries are returned. |
std::vector<SourceId> GetAllSourceIds | ( | ) | const |
Returns all of the source ids in the scene graph.
The order is guaranteed to be stable and consistent. The first element is the SceneGraph-internal source.
std::set<std::pair<GeometryId, GeometryId> > GetCollisionCandidates | ( | ) | const |
Returns all pairs of geometries that are candidates for collision (in no particular order).
See CollisionFilterDeclaration and CollisionFilterManager::Apply() 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().
const PolygonSurfaceMesh<double>* GetConvexHull | ( | GeometryId | geometry_id | ) | const |
Returns the convex hull (a polytope) associated with the given geometry_id
, if it exists.
Basic primitive shapes don't have convex hulls (including, arbitrarily, Box). But Mesh and Convex shapes do. Alternatively, if you already have a Mesh or Convex you can call Mesh::GetConvexHull() or Convex::GetConvexHull(), respectively.
const std::vector<internal::RenderMesh>& GetDrivenRenderMeshes | ( | GeometryId | geometry_id, |
Role | role | ||
) | const |
Returns the render mesh representation of the driven meshes associated with the given role
of the geometry with the given geometry_id
.
geometry_id | The identifier for the queried geometry. |
role | The role whose driven mesh representations are acquired. |
std::exception | if geometry_id does not map to a registered deformable geometry with the given role or if role is Role::kUnassigned. |
Reports the frame group for the frame with the given frame_id
.
std::exception | if frame_id does not map to a registered frame. |
FrameId GetFrameId | ( | GeometryId | geometry_id | ) | const |
Reports the id of the frame to which the given geometry with the given geometry_id
is registered.
std::exception | if geometry_id does not map to a registered geometry. |
std::vector<GeometryId> GetGeometries | ( | FrameId | frame_id, |
const std::optional< Role > & | role = std::nullopt |
||
) | const |
Returns geometry ids that have been registered directly to the frame indicated by frame_id
.
If a role
is provided, only geometries with that role assigned will be returned, otherwise all geometries will be returned. The order of the ids is guaranteed to be stable and consistent.
frame_id | The id of the frame in question. |
role | The requested role; if omitted, all geometries registered to the frame are returned. |
std::exception | if id does not map to a registered frame. |
GeometryId GetGeometryIdByName | ( | FrameId | frame_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 frame_id
.
frame_id | The frame_id of the frame whose geometry is being queried. |
role | The assigned role of the desired geometry. |
name | The name of the geometry to query for. The name will be canonicalized prior to lookup (see GeometryInstance for details). |
std::exception | if no such geometry exists, multiple geometries have that name, or if the frame_id does not map to a registered frame. |
std::unordered_set<GeometryId> GetGeometryIds | ( | const GeometrySet & | geometry_set, |
std::optional< Role > | role = std::nullopt |
||
) | const |
Returns the geometry ids that are implied by the given GeometrySet and role
.
Remember that a GeometrySet can reference a FrameId in place of the ids of the individual geometries affixed to it. If a role
is provided, only geometries with that role assigned will be returned, otherwise all geometries will be returned.
role
can have the effect of filtering geometries from the given geometry_set` – if a GeometryId is an explicit member of the geometry set but does not have the requested role, it will not be contained in the output.geometry_set | The encoding of the set of geometries. |
role | The requested role; if omitted, all geometries registered to the frame are returned. |
const IllustrationProperties* GetIllustrationProperties | ( | GeometryId | geometry_id | ) | const |
Returns a pointer to the const illustration properties of the geometry with the given geometry_id
.
geometry_id | The identifier for the queried geometry. |
nullptr
if there are no such properties). std::exception | if geometry_id does not map to a registered geometry. |
const std::string& GetName | ( | SourceId | source_id | ) | const |
Reports the name for the source with the given source_id
.
std::exception | if source_id does not map to a registered source. |
const std::string& GetName | ( | FrameId | frame_id | ) | const |
Reports the name of the frame with the given frame_id
.
std::exception | if frame_id does not map to a registered frame. |
const std::string& GetName | ( | GeometryId | geometry_id | ) | const |
Reports the stored, canonical name of the geometry with the given geometry_id
(see GeometryInstance for details).
std::exception | if geometry_id does not map to a registered geometry. |
const std::string& GetOwningSourceName | ( | FrameId | frame_id | ) | const |
Reports the name of the geometry source that registered the frame with the given frame_id
.
std::exception | If frame_id does not map to a registered frame. |
const std::string& GetOwningSourceName | ( | GeometryId | geometry_id | ) | const |
Reports the name of the geometry source that registered the geometry with the given geometry_id
.
std::exception | If geometry_id does not map to a registered geometry. |
Reports the FrameId of the parent of frame_id
.
std::exception | if frame_id does not map to a registered frame. |
const PerceptionProperties* GetPerceptionProperties | ( | GeometryId | geometry_id | ) | const |
Returns a pointer to the const perception properties of the geometry with the given geometry_id
.
geometry_id | The identifier for the queried geometry. |
nullptr
if there are no such properties). std::exception | if geometry_id does not map to a registered geometry. |
const math::RigidTransform<double>& GetPoseInFrame | ( | GeometryId | geometry_id | ) | const |
Reports the pose of the geometry G with the given geometry_id
in its registered frame F.
std::exception | if geometry_id does not map to a registered geometry. |
const GeometryProperties* GetProperties | ( | GeometryId | geometry_id, |
Role | role | ||
) | const |
Return a pointer to the const properties indicated by role
of the geometry with the given geometry_id
.
geometry_id | The identifier for the queried geometry. |
role | The role whose properties are acquired. |
nullptr
if there are no such properties). std::exception | if geometry_id does not map to a registered geometry. |
const ProximityProperties* GetProximityProperties | ( | GeometryId | geometry_id | ) | const |
Returns a pointer to the const proximity properties of the geometry with the given geometry_id
.
geometry_id | The identifier for the queried geometry. |
nullptr
if there are no such properties). std::exception | if geometry_id does not map to a registered geometry. |
const VolumeMesh<double>* GetReferenceMesh | ( | GeometryId | geometry_id | ) | const |
Returns the reference mesh of the geometry with the given geometry_id
, measured and expressed in the geometry's frame, G.
geometry_id | The identifier for the queried geometry. |
nullptr
if the geometry is rigid. std::exception | if geometry_id does not map to a registered geometry. |
const Shape& GetShape | ( | GeometryId | geometry_id | ) | const |
Returns the shape specified for the geometry with the given geometry_id
.
In order to extract the details of the shape, it should be passed through an implementation of a ShapeReifier.
bool IsDeformableGeometry | ( | GeometryId | geometry_id | ) | const |
Returns true if the geometry with the given geometry_id
is deformable.
geometry_id | The identifier for the queried geometry. |
std::exception | if geometry_id does not map to a registered geometry. |
std::variant<std::monostate, const TriangleSurfaceMesh<double>*, const VolumeMesh<double>*> maybe_get_hydroelastic_mesh | ( | GeometryId | geometry_id | ) | const |
Returns the mesh used to represent this geometry in hydroelastic contact calculations, if it exists.
Most primitives (sphere, cylinder, etc.) are actually represented by discrete approximations (i.e., the mesh). If there is no mesh, the returned variant will hold neither the TriangleSurfaceMesh<double> nor the VolumeMesh<double> alternatives. If either alternative is present, the pointer is guaranteed to be non-null.
Just because hydroelastic properties have been assigned to a geometry does not* mean there is necessarily a mesh associated with it. Some shape types (e.g., half space) have non-mesh representations.
The result can be tested as follows:
geometry_id | The id of the geometry to query. |
int num_frames | ( | ) | const |
Reports the total number of frames registered in the scene graph (including the world frame).
int num_geometries | ( | ) | const |
Reports the total number of geometries in the scene graph.
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.
int NumAnchoredGeometries | ( | ) | const |
Reports the total number of anchored non-deformable geometries.
This should provide the same answer as calling NumGeometriesForFrame() with the world frame id.
Reports the total number of deformable geometries in the scene graph with the indicated role.
int NumDynamicGeometries | ( | ) | const |
Reports the total number of dynamic geometries in the scene graph.
This include all deformable geometries.
Reports the number of frames registered to the source with the given source_id
.
std::exception | if source_id does not map to a registered source. |
Reports the number of geometries affixed to the frame with the given frame_id
.
This count does not include geometries attached to frames that are descendants of this frame.
std::exception | if frame_id does not map to a registered frame. |
Reports the total number of geometries with the given role
directly registered to the frame with the given frame_id
.
This count does not include geometries attached to frames that are descendants of this frame.
std::exception | if frame_id does not map to a registered frame. |
Reports the total number of geometries in the scene graph with the indicated role.
|
delete |
|
delete |
bool SourceIsRegistered | ( | SourceId | source_id | ) | const |
Reports true
if the given source_id
maps to a registered source.
FrameId world_frame_id | ( | ) | const |
Reports the id for the world frame.
|
friend |
|
friend |
|
friend |