forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geometry_instance.h
73 lines (58 loc) · 2.72 KB
/
geometry_instance.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#include <memory>
#include <utility>
#include "drake/common/copyable_unique_ptr.h"
#include "drake/common/drake_copyable.h"
#include "drake/common/eigen_types.h"
#include "drake/geometry/geometry_ids.h"
#include "drake/geometry/shape_specification.h"
#include "drake/geometry/visual_material.h"
namespace drake {
namespace geometry {
/** 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. */
class GeometryInstance {
public:
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(GeometryInstance)
/** Constructor with default visual material (see VisualMaterial default
constructor for details on what that color is).
@param X_PG The pose of this geometry (`G`) in its parent's frame (`P`).
@param shape The underlying shape for this geometry instance. */
GeometryInstance(const Isometry3<double>& X_PG, std::unique_ptr<Shape> shape);
/** Constructor.
@param X_PG The pose of this geometry (`G`) in its parent's frame (`P`).
@param shape The underlying shape for this geometry instance.
@param vis_material The visual material to apply to this geometry. */
GeometryInstance(const Isometry3<double>& X_PG, std::unique_ptr<Shape> shape,
const VisualMaterial& vis_material);
/** 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. */
GeometryId id() const { return id_; }
const Isometry3<double>& pose() const { return X_PG_; }
void set_pose(const Isometry3<double>& X_PG) { X_PG_ = X_PG; }
const Shape& shape() const {
DRAKE_DEMAND(shape_ != nullptr);
return *shape_;
}
/** Releases the shape from the instance. */
std::unique_ptr<Shape> release_shape() { return std::move(shape_); }
const VisualMaterial& visual_material() const { return visual_material_; }
private:
// The *globally* unique identifier for this instance. It is functionally
// const (i.e. defined in construction) but not marked const to allow for
// default copying/assigning.
GeometryId id_{};
// The pose of the geometry relative to the parent frame it hangs on.
Isometry3<double> X_PG_;
// The shape associated with this instance.
copyable_unique_ptr<Shape> shape_;
// The "rendering" material -- e.g., OpenGl contexts and the like.
VisualMaterial visual_material_;
};
} // namespace geometry
} // namespace drake