A geometry instance combines a geometry definition (i.e., a shape of some sort), a pose (relative to a parent "frame" P), material information, and an opaque collection of metadata.
The parent frame can be a registered frame or another registered geometry.
Every GeometryInstance must be named. The naming convention mirrors that of valid names in SDF files. Specifically, any user-specified name will have all leading and trailing space and tab characters trimmed off. The trimmed name will have to satisfy the following requirements:
If valid, the trimmed name will be assigned to the instance.
Names can have internal whitespace (e.g., "my geometry name").
The silent transformation of a user-defined name to canonical name mirrors that of specifying geometry names in an SDF file. Consider the following SDF snippet:
The name has two leading whitespace characters. The parsing process will consider this name as equivalent to "visual" and tests for uniqueness and non-emptiness will be applied to that trimmed result. The following code has an analogous effect:
The specified name includes leading whitespace. That name will be trimmed and the result will be stored in the GeometryInstance (to be later validated by SceneGraph as part of geometry registration). Querying the instance of its name will return this canonicalized name.
#include <drake/geometry/geometry_instance.h>
Public Member Functions | |
GeometryInstance (const math::RigidTransform< double > &X_PG, const Shape &shape, const std::string &name) | |
Constructs a geometry instance specification. More... | |
GeometryInstance (const math::RigidTransform< double > &X_PG, std::unique_ptr< Shape > shape, const std::string &name) | |
(Advanced) Overload that transfers ownership of shape (for performance). More... | |
GeometryId | id () const |
Returns the globally unique id for this geometry specification. More... | |
const math::RigidTransformd & | pose () const |
Returns the instance geometry's pose in its parent frame. More... | |
void | set_pose (const math::RigidTransformd &X_PG) |
Sets the pose of this instance in its parent's frame. More... | |
const Shape & | shape () const |
Returns the underlying shape specification for this geometry instance. More... | |
std::unique_ptr< Shape > | release_shape () |
(Advanced) Transfers ownership of this geometry instance's underlying shape specification to the caller. More... | |
const std::string & | name () const |
Returns the canonicalized name for the instance. More... | |
void | set_name (const std::string &name) |
Sets the canonicalized name for the instance. More... | |
void | set_proximity_properties (ProximityProperties properties) |
Sets the proximity properties for the given instance. More... | |
void | set_illustration_properties (IllustrationProperties properties) |
Sets the illustration properties for the given instance. More... | |
void | set_perception_properties (PerceptionProperties properties) |
Sets the perception properties for the given instance. More... | |
ProximityProperties * | mutable_proximity_properties () |
Returns a pointer to the geometry's mutable proximity properties (if they are defined). More... | |
const ProximityProperties * | proximity_properties () const |
Returns a pointer to the geometry's const proximity properties (if they are defined). More... | |
IllustrationProperties * | mutable_illustration_properties () |
Returns a pointer to the geometry's mutable illustration properties (if they are defined). More... | |
const IllustrationProperties * | illustration_properties () const |
Returns a pointer to the geometry's const illustration properties (if they are defined). More... | |
PerceptionProperties * | mutable_perception_properties () |
Returns a pointer to the geometry's mutable perception properties (if they are defined). More... | |
const PerceptionProperties * | perception_properties () const |
Returns a pointer to the geometry's const perception properties (if they are defined). More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
GeometryInstance (const GeometryInstance &)=default | |
GeometryInstance & | operator= (const GeometryInstance &)=default |
GeometryInstance (GeometryInstance &&)=default | |
GeometryInstance & | operator= (GeometryInstance &&)=default |
|
default |
|
default |
GeometryInstance | ( | const math::RigidTransform< double > & | X_PG, |
const Shape & | shape, | ||
const std::string & | name | ||
) |
Constructs a geometry instance specification.
X_PG | The pose of this geometry (G ) in its parent's frame (P ). |
shape | The underlying shape for this geometry instance. |
name | The name of the geometry (must satisfy the name requirements). |
std::exception | if the canonicalized version of name is empty. |
GeometryInstance | ( | const math::RigidTransform< double > & | X_PG, |
std::unique_ptr< Shape > | shape, | ||
const std::string & | name | ||
) |
(Advanced) Overload that transfers ownership of shape
(for performance).
GeometryId id | ( | ) | const |
Returns the globally unique id for this geometry specification.
Every instantiation of GeometryInstance will contain a unique id value. The id value is preserved across copies. After successfully registering this GeometryInstance, this id will serve as the identifier for the registered representation as well.
const IllustrationProperties* illustration_properties | ( | ) | const |
Returns a pointer to the geometry's const illustration properties (if they are defined).
Nullptr otherwise.
IllustrationProperties* mutable_illustration_properties | ( | ) |
Returns a pointer to the geometry's mutable illustration properties (if they are defined).
Nullptr otherwise.
PerceptionProperties* mutable_perception_properties | ( | ) |
Returns a pointer to the geometry's mutable perception properties (if they are defined).
Nullptr otherwise.
ProximityProperties* mutable_proximity_properties | ( | ) |
Returns a pointer to the geometry's mutable proximity properties (if they are defined).
Nullptr otherwise.
const std::string& name | ( | ) | const |
Returns the canonicalized name for the instance.
|
default |
|
default |
const PerceptionProperties* perception_properties | ( | ) | const |
Returns a pointer to the geometry's const perception properties (if they are defined).
Nullptr otherwise.
const math::RigidTransformd& pose | ( | ) | const |
Returns the instance geometry's pose in its parent frame.
const ProximityProperties* proximity_properties | ( | ) | const |
Returns a pointer to the geometry's const proximity properties (if they are defined).
Nullptr otherwise.
std::unique_ptr<Shape> release_shape | ( | ) |
(Advanced) Transfers ownership of this geometry instance's underlying shape specification to the caller.
void set_illustration_properties | ( | IllustrationProperties | properties | ) |
Sets the illustration properties for the given instance.
void set_name | ( | const std::string & | name | ) |
Sets the canonicalized name for the instance.
void set_perception_properties | ( | PerceptionProperties | properties | ) |
Sets the perception properties for the given instance.
void set_pose | ( | const math::RigidTransformd & | X_PG | ) |
Sets the pose of this instance in its parent's frame.
void set_proximity_properties | ( | ProximityProperties | properties | ) |
Sets the proximity properties for the given instance.
const Shape& shape | ( | ) | const |
Returns the underlying shape specification for this geometry instance.