Drake
QueryObject< T > Class Template Reference

The QueryObject serves as a mechanism to perform geometry queries on the world's geometry. More...

#include <geometry/geometry_system.h>

Public Member Functions

 QueryObject (const QueryObject &other)
 
QueryObjectoperator= (const QueryObject &)
 
State queries
const std::string & GetSourceName (SourceId id) const
 Reports the name for the given source id. More...
 
FrameId GetFrameId (GeometryId geometry_id) const
 Reports the id of the frame to which the given geometry id is registered. More...
 

Friends

class GeometrySystem< T >
 
class QueryObjectTester
 

Detailed Description

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

The QueryObject serves as a mechanism to perform geometry queries on the world's geometry.

The GeometrySystem has an abstract-valued port that contains a QueryObject (i.e., a QueryObject-valued output port).

To perform geometry queries on GeometrySystem:

  • a LeafSystem must have a QueryObject-valued input port and connect it to the corresponding query output port on GeometrySystem,
  • the querying LeafSystem can evaluate the input port, retrieving a const QueryObject& in return, and, finally,
  • invoke the appropriate method on the QueryObject.

The const reference returned by the input port is considered "live" - it is linked to the context, system, and cache (making full use of all of those mechanisms). This const reference should never be persisted; doing so can lead to erroneous query results. It is simpler and more advisable to acquire it for evaluation in a limited scope (e.g., CalcTimeDerivatives()) and then discard it. If a QueryObject is needed for many separate functions in a LeafSystem, each should re-evaluate the input port. The underlying caching mechanism should make the cost of this negligible.

In addition to not persisting the reference from the output port, the QueryObject shouldn't be copied. Strictly speaking, it is an allowed operation, but the result is not live, and any geometry query performed on the copy will throw an exception.

A QueryObject cannot be converted to a different scalar type. A QueryObject of scalar type S can only be acquired from the output port of a GeometrySystem of type S evaluated on a corresponding GeometryContext, also of type S.

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.

Constructor & Destructor Documentation

QueryObject ( const QueryObject< T > &  other)

Member Function Documentation

FrameId GetFrameId ( GeometryId  geometry_id) const

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

Exceptions
std::runtime_errorif the QueryObject is in default configuration.
std::logic_errorif the geometry id is invalid.
const std::string & GetSourceName ( SourceId  id) const

Reports the name for the given source id.

Exceptions
std::runtime_errorif the QueryObject is in default configuration.
std::logic_errorif the identifier is invalid.
QueryObject< T > & operator= ( const QueryObject< T > &  )

Friends And Related Function Documentation

friend class GeometrySystem< T >
friend
friend class QueryObjectTester
friend

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