Drake
GeometryState< T > Class Template Reference

The context-dependent state of GeometryWorld. More...

#include <drake/geometry/geometry_state.h>

Public Types

using FrameIdRange = MapKeyRange< FrameId, internal::InternalFrame >
 An object that represents the range of FrameId values in the state. More...
 

Public Member Functions

 GeometryState ()
 Default constructor. More...
 
template<class T1 = T>
std::enable_if<!std::is_same< T1, double >::value, GeometryState< T > & >::type operator= (const GeometryState< double > &other)
 Allow assignment from a GeometryState<double> to a GeometryState<T>. More...
 
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable
 GeometryState (const GeometryState &)=default
 
GeometryStateoperator= (const GeometryState &)=default
 
 GeometryState (GeometryState &&)=default
 
GeometryStateoperator= (GeometryState &&)=default
 
State introspection

Various methods that allow reading the state's properties and values.

int get_num_sources () const
 Reports the number of registered sources – whether they have frames or not. More...
 
int get_num_frames () const
 Reports the total number of frames – across all sources. More...
 
int get_num_geometries () const
 Reports the total number of dynamic geometries. More...
 
int get_num_anchored_geometries () const
 Reports the total number of anchored geometries. More...
 
bool source_is_registered (SourceId source_id) const
 Reports true if the given source_id references a registered source. More...
 
const std::vector< GeometryId > & get_geometry_ids () const
 The set of all dynamic geometries registered to the world. More...
 
FrameIdRange get_frame_ids () const
 Provides a range object for all of the frame ids in the world. More...
 
int get_frame_group (FrameId frame_id) const
 Reports the frame group for the given frame. More...
 
const std::string & get_frame_name (FrameId frame_id) const
 Reports the name of the frame. More...
 
const Isometry3< T > & get_pose_in_world (FrameId frame_id) const
 Reports the pose of the frame with the given id. More...
 
const Isometry3< T > & get_pose_in_world (GeometryId geometry_id) const
 Reports the pose of the geometry with the given id. More...
 
const Isometry3< T > & get_pose_in_parent (FrameId frame_id) const
 Reports the pose of the frame with the given id relative to its parent frame. More...
 
const std::string & get_source_name (SourceId id) const
 Reports the source name for the given source id. More...
 
const Isometry3< double > & GetPoseInFrame (GeometryId geometry_id) const
 Reports the pose, relative to the registered frame, for the geometry the given identifier refers to. More...
 
const Isometry3< double > & GetPoseInParent (GeometryId geometry_id) const
 Reports the pose of identified dynamic geometry, relative to its registered parent. More...
 
State management

The methods that modify the state including: adding/removing entities from the state, modifying values in the state, etc.

SourceId RegisterNewSource (const std::string &name="")
 Registers a new, named source into the state. More...
 
FrameId RegisterFrame (SourceId source_id, const GeometryFrame &frame)
 Registers a new frame for the given source, the id of the new frame is returned. More...
 
FrameId RegisterFrame (SourceId source_id, FrameId parent_id, const GeometryFrame &frame)
 Registers a new frame for the given source as a child of a previously registered frame. More...
 
GeometryId RegisterGeometry (SourceId source_id, FrameId frame_id, std::unique_ptr< GeometryInstance > geometry)
 Registers a GeometryInstance with the state. More...
 
GeometryId RegisterGeometryWithParent (SourceId source_id, GeometryId geometry_id, std::unique_ptr< GeometryInstance > geometry)
 Registers a GeometryInstance with the state. More...
 
GeometryId RegisterAnchoredGeometry (SourceId source_id, std::unique_ptr< GeometryInstance > geometry)
 Registers a GeometryInstance with the state as anchored geometry. More...
 
void ClearSource (SourceId source_id)
 Removes all frames and geometry registered from the identified source. More...
 
void RemoveFrame (SourceId source_id, FrameId frame_id)
 Removes the given frame from the the indicated source's frames. More...
 
void RemoveGeometry (SourceId source_id, GeometryId geometry_id)
 Removes the given geometry from the the indicated source's geometries. More...
 
Relationship queries

Various methods that map identifiers for one type of entity to its related entities.

bool BelongsToSource (FrameId frame_id, SourceId source_id) const
 Reports if the given frame id was registered to the given source id. More...
 
bool BelongsToSource (GeometryId geometry_id, SourceId source_id) const
 Reports if the given geometry id was ultimately registered to the given source id. More...
 
FrameId GetFrameId (GeometryId geometry_id) const
 Retrieves the frame id on which the given geometry id is registered. More...
 
const FrameIdSetGetFramesForSource (SourceId source_id) const
 Returns the set of frames registered to the given source. More...
 
std::unique_ptr< GeometryState< AutoDiffXd > > ToAutoDiffXd () const
 Scalar conversion. More...
 

Friends

template<typename >
class GeometryState
 
class GeometrySystem< T >
 
template<class U >
class GeometryStateTester
 
void DispatchLoadMessage (const GeometryState< double > &)
 

Detailed Description

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

The context-dependent state of GeometryWorld.

This serves as an AbstractValue in the context. GeometryWorld's time-dependent state includes more than just values; objects can be added to or removed from the world over time. Therefore, GeometryWorld's context-dependent state includes values and structure – the topology of the world.

Template Parameters
TThe scalar type. Must be a valid Eigen scalar.

Instantiated templates for the following kinds of T's are provided:

  • double
  • AutoDiffXd

They are already available to link against in the containing library. No other values for T are currently supported.

Member Typedef Documentation

An object that represents the range of FrameId values in the state.

It is used in range-based for loops to iterate through registered frames.

Constructor & Destructor Documentation

GeometryState ( const GeometryState< T > &  )
default
GeometryState ( GeometryState< T > &&  )
default

Default constructor.

Member Function Documentation

bool BelongsToSource ( FrameId  frame_id,
SourceId  source_id 
) const

Reports if the given frame id was registered to 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 the frame_id does not map to a frame or the identified source is not registered.

Here is the call graph for this function:

Here is the caller graph for this function:

bool BelongsToSource ( GeometryId  geometry_id,
SourceId  source_id 
) const

Reports if the given geometry id was ultimately registered to 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 the geometry_id does not map to a valid geometry or the identified source is not registered

Here is the call graph for this function:

void ClearSource ( SourceId  source_id)

Removes all frames and geometry registered from the identified source.

The source remains registered and further frames and geometry can be registered on it.

Parameters
source_idThe identifier for the source to clear.
Exceptions
std::logic_errorIf the source_id does not map to a registered source.

Here is the call graph for this function:

Here is the caller graph for this function:

int get_frame_group ( FrameId  frame_id) const

Reports the frame group for the given frame.

Parameters
frame_idThe identifier of the queried frame.
Returns
The frame group of the identified frame.
Exceptions
std::logic_errorif the frame id is not valid.

Here is the call graph for this function:

Here is the caller graph for this function:

FrameIdRange get_frame_ids ( ) const
inline

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

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 : state.get_frame_ids()) {
...
}

Here is the call graph for this function:

const std::string & get_frame_name ( FrameId  frame_id) const

Reports the name of the frame.

Parameters
frame_idThe identifier of the queried frame.
Returns
The name of the identified frame.
Exceptions
std::logic_errorif the frame id is not valid.

Here is the call graph for this function:

Here is the caller graph for this function:

const std::vector<GeometryId>& get_geometry_ids ( ) const
inline

The set of all dynamic geometries registered to the world.

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

int get_num_anchored_geometries ( ) const
inline

Reports the total number of anchored geometries.

Here is the call graph for this function:

int get_num_frames ( ) const
inline

Reports the total number of frames – across all sources.

Here is the caller graph for this function:

int get_num_geometries ( ) const
inline

Reports the total number of dynamic geometries.

int get_num_sources ( ) const
inline

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

const Isometry3< T > & get_pose_in_parent ( FrameId  frame_id) const

Reports the pose of the frame with the given id relative to its parent frame.

If the frame's parent is the world, the value should be the same as a call to get_pose_in_world().

Parameters
frame_idThe identifier of the queried frame.
Returns
The pose in the parent frame (X_PF) of the identified frame.
Exceptions
std::logic_errorif the frame id is not valid.

Here is the call graph for this function:

Here is the caller graph for this function:

const Isometry3< T > & get_pose_in_world ( FrameId  frame_id) const

Reports the pose of the frame with the given id.

Parameters
frame_idThe identifier of the queried frame.
Returns
The pose in the world (X_WF) of the identified frame.
Exceptions
std::logic_errorif the frame id is not valid.

Here is the call graph for this function:

Here is the caller graph for this function:

const Isometry3< T > & get_pose_in_world ( GeometryId  geometry_id) const

Reports the pose of the geometry with the given id.

Parameters
geometry_idThe identifier of the queried geometry.
Returns
The pose in the world (X_WG) of the identified geometry.
Exceptions
std::logic_errorif the geometry id is not valid.

Here is the call graph for this function:

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

Reports the source name for the given source id.

Parameters
idThe identifier of the source.
Returns
The name of the source.
Exceptions
std::logic_errorif the id does not map to a registered source.

Here is the call graph for this function:

Here is the caller graph for this function:

FrameId GetFrameId ( GeometryId  geometry_id) const

Retrieves the frame id on which the given geometry id is registered.

Parameters
geometry_idThe query geometry id.
Returns
An optional FrameId based on a successful lookup.
Exceptions
std::logic_errorIf the geometry_id does not map to a geometry which belongs to an existing frame.

Here is the call graph for this function:

Here is the caller graph for this function:

const FrameIdSet & GetFramesForSource ( SourceId  source_id) const

Returns the set of frames registered to the given source.

Parameters
source_idThe identifier of the source to query.
Returns
The set of frames associated with the id.
Exceptions
std::logic_errorIf the source_id does not map to a registered source.

Here is the call graph for this function:

Here is the caller graph for this function:

const Isometry3< double > & GetPoseInFrame ( GeometryId  geometry_id) const

Reports the pose, relative to the registered frame, for the geometry the given identifier refers to.

Parameters
geometry_idThe id of the queried geometry.
Returns
The geometry's pose relative to its frame.
Exceptions
std::logic_errorIf the geometry_id does not map to a valid GeometryInstance.

Here is the call graph for this function:

Here is the caller graph for this function:

const Isometry3< double > & GetPoseInParent ( GeometryId  geometry_id) const

Reports the pose of identified dynamic geometry, relative to its registered parent.

If the geometry was registered directly to a frame, this must produce the same pose as GetPoseInFrame().

Parameters
geometry_idThe id of the queried geometry.
Returns
The geometry's pose relative to its registered parent.
Exceptions
std::logic_errorIf the geometry_id does not map to a valid GeometryInstance.

Here is the call graph for this function:

Here is the caller graph for this function:

GeometryState& operator= ( GeometryState< T > &&  )
default
GeometryState& operator= ( const GeometryState< T > &  )
default
std::enable_if<!std::is_same<T1, double>::value, GeometryState<T>&>::type operator= ( const GeometryState< double > &  other)
inline

Allow assignment from a GeometryState<double> to a GeometryState<T>.

GeometryId RegisterAnchoredGeometry ( SourceId  source_id,
std::unique_ptr< GeometryInstance geometry 
)

Registers a GeometryInstance with the state as anchored geometry.

This registers geometry which "hangs" from the world frame and never moves. The geometry's pose value is relative to the world frame. The state takes ownership of the geometry and associates it with the given source. Returns the new identifier for the GeometryInstance.

Parameters
source_idThe id of the source on which the geometry is being declared.
geometryThe geometry to get the id for. The state takes ownership of the geometry.
Returns
A newly allocated geometry id.
Exceptions
std::logic_errorIf the source_id does not map to a registered source, or geometry has a previously registered id.

Here is the call graph for this function:

Here is the caller graph for this function:

FrameId RegisterFrame ( SourceId  source_id,
const GeometryFrame frame 
)

Registers a new frame for the given source, the id of the new frame is returned.

Parameters
source_idThe id of the source for which this frame is allocated.
frameThe frame to register.
Returns
A newly allocated frame id.
Exceptions
std::logic_errorIf the source_id does not map to a registered source, or frame has an id that has already been registered.

Here is the caller graph for this function:

FrameId RegisterFrame ( SourceId  source_id,
FrameId  parent_id,
const GeometryFrame frame 
)

Registers a new frame for the given source as a child of a previously registered frame.

The id of the new frame is returned.

Parameters
source_idThe id of the source for which this frame is allocated.
parent_idThe id of the parent frame.
frameThe frame to register.
Returns
A newly allocated frame id.
Exceptions
std::logic_error1. If the source_id does not map to a registered source,
  1. If the parent_id does not map to a known frame or does not belong to the source, or
  2. frame has an id that has already been registered

Here is the call graph for this function:

GeometryId RegisterGeometry ( SourceId  source_id,
FrameId  frame_id,
std::unique_ptr< GeometryInstance geometry 
)

Registers a GeometryInstance with the state.

The state takes ownership of the geometry and associates it with the given frame and source. Returns the new identifier for the successfully registered GeometryInstance.

Parameters
source_idThe id of the source to which the frame and geometry belongs.
frame_idThe id of the frame on which the geometry is to hang.
geometryThe geometry to get the id for. The state takes ownership of the geometry.
Returns
A newly allocated geometry id.
Exceptions
std::logic_error1. the source_id does not map to a registered source, or
  1. the frame_id doesn't belong to the source,
  2. The geometry is equal to nullptr, or
  3. geometry has a previously registered id.

Here is the call graph for this function:

Here is the caller graph for this function:

GeometryId RegisterGeometryWithParent ( SourceId  source_id,
GeometryId  geometry_id,
std::unique_ptr< GeometryInstance geometry 
)

Registers a GeometryInstance with the state.

Rather than hanging directly from a frame, the instance hangs on another geometry instance. The input geometry instance's pose is assumed to be relative to that parent geometry instance. The state takes ownership of the geometry and associates it with the given geometry parent (and, ultimately, the parent geometry's frame) and source. Returns the new identifier for the successfully registered GeometryInstance.

Parameters
source_idThe id of the source on which the geometry is being declared.
geometry_idThe parent geometry for this geometry.
geometryThe geometry to get the id for. The state takes ownership of the geometry.
Returns
A newly allocated geometry id.
Exceptions
std::logic_error1. the source_id does not map to a registered source, or
  1. the geometry_id doesn't belong to the source,
  2. the geometry is equal to nullptr, or
  3. geometry has a previously registered id.

Here is the call graph for this function:

Here is the caller graph for this function:

SourceId RegisterNewSource ( const std::string &  name = "")

Registers a new, named source into the state.

Parameters
nameThe optional name of the source. If none or the empty string is provided it will be named "Source_##" where the number is the value of the returned SourceId.
Exceptions
std::logic_erroris thrown if the name is not unique.

Here is the call graph for this function:

Here is the caller graph for this function:

void RemoveFrame ( SourceId  source_id,
FrameId  frame_id 
)

Removes the given frame from the the indicated source's frames.

All registered geometries connected to this frame will also be removed from the world.

Parameters
source_idThe identifier for the owner geometry source.
frame_idThe identifier of the frame to remove.
Exceptions
std::logic_error1. If the source_id does not map to a registered source, or
  1. the frame_id does not map to a valid frame, or
  2. the frame_id maps to a frame that does not belong to the indicated source.

Here is the call graph for this function:

Here is the caller graph for this function:

void RemoveGeometry ( SourceId  source_id,
GeometryId  geometry_id 
)

Removes the given geometry from the the indicated source's geometries.

Any geometry that was hung from the indicated geometry will also be removed.

Parameters
source_idThe identifier for the owner geometry source.
geometry_idThe identifier of the geometry to remove (can be dynamic or anchored).
Exceptions
std::logic_error1. If the source_id does not map to a registered source, or
  1. the geometry_id does not map to a valid geometry, or
  2. the geometry_id maps to a geometry that does not belong to the indicated source.

Here is the call graph for this function:

Here is the caller graph for this function:

bool source_is_registered ( SourceId  source_id) const

Reports true if the given source_id references a registered source.

Here is the caller graph for this function:

std::unique_ptr< GeometryState< AutoDiffXd > > ToAutoDiffXd ( ) const

Scalar conversion.

Returns a deep copy of this state using the AutoDiffXd scalar with all scalar values initialized from the current values. If this is invoked on an instance already instantiated on AutoDiffXd, it is equivalent to cloning the instance.

Here is the call graph for this function:

Here is the caller graph for this function:

Friends And Related Function Documentation

void DispatchLoadMessage ( const GeometryState< double > &  state)
friend
friend class GeometryState
friend
friend class GeometryStateTester
friend
friend class GeometrySystem< T >
friend

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