forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene_graph_inspector.cc
318 lines (271 loc) · 9.71 KB
/
scene_graph_inspector.cc
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#include "drake/geometry/scene_graph_inspector.h"
#include <algorithm>
#include <memory>
#include "drake/geometry/geometry_state.h"
namespace drake {
namespace geometry {
template <typename T>
int SceneGraphInspector<T>::num_sources() const {
DRAKE_DEMAND(state_ != nullptr);
return state_->get_num_sources();
}
template <typename T>
int SceneGraphInspector<T>::num_frames() const {
DRAKE_DEMAND(state_ != nullptr);
return state_->get_num_frames();
}
template <typename T>
std::vector<FrameId> SceneGraphInspector<T>::GetAllFrameIds() const {
DRAKE_DEMAND(state_ != nullptr);
typename GeometryState<T>::FrameIdRange range = state_->get_frame_ids();
std::vector<FrameId> frame_ids(range.begin(), range.end());
std::sort(frame_ids.begin(), frame_ids.end());
return frame_ids;
}
template <typename T>
int SceneGraphInspector<T>::num_geometries() const {
DRAKE_DEMAND(state_ != nullptr);
return state_->get_num_geometries();
}
template <typename T>
std::vector<GeometryId> SceneGraphInspector<T>::GetAllGeometryIds() const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetAllGeometryIds();
}
template <typename T>
std::unordered_set<GeometryId> SceneGraphInspector<T>::GetGeometryIds(
const GeometrySet& geometry_set, const std::optional<Role>& role) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetGeometryIds(geometry_set, role);
}
template <typename T>
int SceneGraphInspector<T>::NumGeometriesWithRole(Role role) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->NumGeometriesWithRole(role);
}
template <typename T>
int SceneGraphInspector<T>::NumDynamicGeometries() const {
DRAKE_DEMAND(state_ != nullptr);
return state_->NumDynamicGeometries();
}
template <typename T>
int SceneGraphInspector<T>::NumAnchoredGeometries() const {
DRAKE_DEMAND(state_ != nullptr);
return state_->NumAnchoredGeometries();
}
template <typename T>
std::set<std::pair<GeometryId, GeometryId>>
SceneGraphInspector<T>::GetCollisionCandidates() const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetCollisionCandidates();
}
template <typename T>
const GeometryVersion& SceneGraphInspector<T>::geometry_version() const {
return state_->geometry_version();
}
template <typename T>
bool SceneGraphInspector<T>::SourceIsRegistered(SourceId source_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->SourceIsRegistered(source_id);
}
template <typename T>
const std::string& SceneGraphInspector<T>::GetName(SourceId source_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetName(source_id);
}
template <typename T>
int SceneGraphInspector<T>::NumFramesForSource(SourceId source_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->NumFramesForSource(source_id);
}
template <typename T>
const std::unordered_set<FrameId>& SceneGraphInspector<T>::FramesForSource(
SourceId source_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->FramesForSource(source_id);
}
template <typename T>
bool SceneGraphInspector<T>::BelongsToSource(FrameId frame_id,
SourceId source_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->BelongsToSource(frame_id, source_id);
}
template <typename T>
const std::string& SceneGraphInspector<T>::GetOwningSourceName(
FrameId frame_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetOwningSourceName(frame_id);
}
template <typename T>
const std::string& SceneGraphInspector<T>::GetName(FrameId frame_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetName(frame_id);
}
template <typename T>
FrameId SceneGraphInspector<T>::GetParentFrame(FrameId frame_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetParentFrame(frame_id);
}
template <typename T>
int SceneGraphInspector<T>::GetFrameGroup(FrameId frame_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetFrameGroup(frame_id);
}
template <typename T>
int SceneGraphInspector<T>::NumGeometriesForFrame(FrameId frame_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->NumGeometriesForFrame(frame_id);
}
template <typename T>
int SceneGraphInspector<T>::NumGeometriesForFrameWithRole(FrameId frame_id,
Role role) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->NumGeometriesForFrameWithRole(frame_id, role);
}
template <typename T>
std::vector<GeometryId> SceneGraphInspector<T>::GetGeometries(
FrameId frame_id, const std::optional<Role>& role) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetGeometries(frame_id, role);
}
template <typename T>
GeometryId SceneGraphInspector<T>::GetGeometryIdByName(
FrameId frame_id, Role role, const std::string& name) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetGeometryIdByName(frame_id, role, name);
}
template <typename T>
bool SceneGraphInspector<T>::BelongsToSource(GeometryId geometry_id,
SourceId source_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->BelongsToSource(geometry_id, source_id);
}
template <typename T>
const std::string& SceneGraphInspector<T>::GetOwningSourceName(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetOwningSourceName(geometry_id);
}
template <typename T>
FrameId SceneGraphInspector<T>::GetFrameId(GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetFrameId(geometry_id);
}
template <typename T>
const std::string& SceneGraphInspector<T>::GetName(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetName(geometry_id);
}
template <typename T>
const Shape& SceneGraphInspector<T>::GetShape(GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetShape(geometry_id);
}
template <typename T>
const math::RigidTransform<double>& SceneGraphInspector<T>::GetPoseInParent(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
return state_->GetPoseInParent(geometry_id);
#pragma GCC diagnostic pop
}
template <typename T>
const math::RigidTransform<double>& SceneGraphInspector<T>::GetPoseInFrame(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetPoseInFrame(geometry_id);
}
template <typename T>
std::variant<std::monostate, const TriangleSurfaceMesh<double>*,
const VolumeMesh<double>*>
SceneGraphInspector<T>::maybe_get_hydroelastic_mesh(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->maybe_get_hydroelastic_mesh(geometry_id);
}
template <typename T>
const GeometryProperties* SceneGraphInspector<T>::GetProperties(
GeometryId geometry_id, Role role) const {
DRAKE_DEMAND(state_ != nullptr);
switch (role) {
case Role::kProximity:
return state_->GetProximityProperties(geometry_id);
case Role::kIllustration:
return state_->GetIllustrationProperties(geometry_id);
case Role::kPerception:
return state_->GetPerceptionProperties(geometry_id);
case Role::kUnassigned:
return nullptr;
}
return nullptr;
}
template <typename T>
const ProximityProperties* SceneGraphInspector<T>::GetProximityProperties(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetProximityProperties(geometry_id);
}
template <typename T>
const IllustrationProperties* SceneGraphInspector<T>::GetIllustrationProperties(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetIllustrationProperties(geometry_id);
}
template <typename T>
const PerceptionProperties* SceneGraphInspector<T>::GetPerceptionProperties(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetPerceptionProperties(geometry_id);
}
template <typename T>
const VolumeMesh<double>* SceneGraphInspector<T>::GetReferenceMesh(
GeometryId geometry_id) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->GetReferenceMesh(geometry_id);
}
template <typename T>
bool SceneGraphInspector<T>::IsDeformableGeometry(GeometryId id) const {
return state_->IsDeformableGeometry(id);
}
template <typename T>
std::vector<GeometryId> SceneGraphInspector<T>::GetAllDeformableGeometryIds()
const {
return state_->GetAllDeformableGeometryIds();
}
template <typename T>
bool SceneGraphInspector<T>::CollisionFiltered(GeometryId geometry_id1,
GeometryId geometry_id2) const {
DRAKE_DEMAND(state_ != nullptr);
return state_->CollisionFiltered(geometry_id1, geometry_id2);
}
template <typename T>
void SceneGraphInspector<T>::Reify(GeometryId geometry_id,
ShapeReifier* reifier) const {
DRAKE_DEMAND(state_ != nullptr);
state_->GetShape(geometry_id).Reify(reifier);
}
template <typename T>
std::unique_ptr<GeometryInstance> SceneGraphInspector<T>::CloneGeometryInstance(
GeometryId id) const {
const std::string name = GetName(id);
const math::RigidTransformd X_PG = GetPoseInFrame(id);
std::unique_ptr<Shape> shape = GetShape(id).Clone();
auto geometry_instance =
std::make_unique<GeometryInstance>(X_PG, std::move(shape), name);
if (const auto* props = GetProximityProperties(id)) {
geometry_instance->set_proximity_properties(*props);
}
if (const auto* props = GetIllustrationProperties(id)) {
geometry_instance->set_illustration_properties(*props);
}
if (const auto* props = GetPerceptionProperties(id)) {
geometry_instance->set_perception_properties(*props);
}
return geometry_instance;
}
} // namespace geometry
} // namespace drake
DRAKE_DEFINE_CLASS_TEMPLATE_INSTANTIATIONS_ON_DEFAULT_SCALARS(
class ::drake::geometry::SceneGraphInspector)