Gazebo Physics

API Reference

5.3.2
gz/physics/GetEntities.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_PHYSICS_GETENTITIES_HH_
19 #define GZ_PHYSICS_GETENTITIES_HH_
20 
21 #include <string>
22 
24 
25 namespace ignition
26 {
27  namespace physics
28  {
31  class IGNITION_PHYSICS_VISIBLE GetEngineInfo : public virtual Feature
32  {
33  public: template <typename PolicyT, typename FeaturesT>
34  class Engine : public virtual Feature::Engine<PolicyT, FeaturesT>
35  {
38  public: const std::string &GetName() const;
39 
42  public: std::size_t GetIndex() const;
43  };
44 
45  public: template <typename PolicyT>
46  class Implementation : public virtual Feature::Implementation<PolicyT>
47  {
48  public: virtual const std::string &GetEngineName(
49  const Identity &_engineID) const = 0;
50 
51  public: virtual std::size_t GetEngineIndex(
52  const Identity &_engineID) const = 0;
53  };
54  };
55 
59  class IGNITION_PHYSICS_VISIBLE GetWorldFromEngine : public virtual Feature
60  {
61  public: template <typename PolicyT, typename FeaturesT>
62  class Engine : public virtual Feature::Engine<PolicyT, FeaturesT>
63  {
64  // typedefs for the type of World that this engine can return.
65  public: using WorldPtrType = WorldPtr<PolicyT, FeaturesT>;
66  public: using ConstWorldPtrType = ConstWorldPtr<PolicyT, FeaturesT>;
67 
69  public: std::size_t GetWorldCount() const;
70 
76  public: WorldPtrType GetWorld(std::size_t _index);
77 
79  public: ConstWorldPtrType GetWorld(std::size_t _index) const;
80 
86  public: WorldPtrType GetWorld(const std::string &_name);
87 
89  public: ConstWorldPtrType GetWorld(const std::string &_name) const;
90  };
91 
92  public: template <typename PolicyT, typename FeaturesT>
93  class World : public virtual Feature::World<PolicyT, FeaturesT>
94  {
95  // typedefs for the type of Engine that this World can return
96  public: using EnginePtrType = EnginePtr<PolicyT, FeaturesT>;
97  public: using ConstEnginePtrType = ConstEnginePtr<PolicyT, FeaturesT>;
98 
100  public: const std::string &GetName() const;
101 
103  public: std::size_t GetIndex() const;
104 
107  public: EnginePtrType GetEngine();
108 
110  public: ConstEnginePtrType GetEngine() const;
111  };
112 
113  public: template <typename PolicyT>
114  class Implementation : public virtual Feature::Implementation<PolicyT>
115  {
116  public: virtual std::size_t GetWorldCount(
117  const Identity &_engineID) const = 0;
118 
119  public: virtual Identity GetWorld(
120  const Identity &_engineID, std::size_t _worldIndex) const = 0;
121 
122  public: virtual Identity GetWorld(
123  const Identity &_engineID, const std::string &_worldName) const = 0;
124 
125  public: virtual const std::string &GetWorldName(
126  const Identity &_worldID) const = 0;
127 
128  public: virtual std::size_t GetWorldIndex(
129  const Identity &_worldID) const = 0;
130 
131  public: virtual Identity GetEngineOfWorld(
132  const Identity &_worldID) const = 0;
133  };
134  };
135 
139  class IGNITION_PHYSICS_VISIBLE GetModelFromWorld : public virtual Feature
140  {
141  public: template <typename PolicyT, typename FeaturesT>
142  class World : public virtual Feature::World<PolicyT, FeaturesT>
143  {
144  // typedefs for the type of Model that this World can return
145  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
146  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
147 
149  public: std::size_t GetModelCount() const;
150 
156  public: ModelPtrType GetModel(std::size_t _index);
157 
159  public: ConstModelPtrType GetModel(std::size_t _index) const;
160 
166  public: ModelPtrType GetModel(const std::string &_name);
167 
169  public: ConstModelPtrType GetModel(const std::string &_name) const;
170  };
171 
172  public: template <typename PolicyT, typename FeaturesT>
173  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
174  {
175  // typedefs for the type of World that this Model can return
176  public: using WorldPtrType = WorldPtr<PolicyT, FeaturesT>;
177  public: using ConstWorldPtrType = ConstWorldPtr<PolicyT, FeaturesT>;
178 
180  public: const std::string &GetName() const;
181 
183  public: std::size_t GetIndex() const;
184 
187  public: WorldPtrType GetWorld();
188 
190  public: ConstWorldPtrType GetWorld() const;
191  };
192 
193  public: template <typename PolicyT>
194  class Implementation : public virtual Feature::Implementation<PolicyT>
195  {
196  public: virtual std::size_t GetModelCount(
197  const Identity &_worldID) const = 0;
198 
199  public: virtual Identity GetModel(
200  const Identity &_worldID, std::size_t _modelIndex) const = 0;
201 
202  public: virtual Identity GetModel(
203  const Identity &_worldID, const std::string &_modelName) const = 0;
204 
205  public: virtual const std::string &GetModelName(
206  const Identity &_modelID) const = 0;
207 
208  public: virtual std::size_t GetModelIndex(
209  const Identity &_modelID) const = 0;
210 
211  public: virtual Identity GetWorldOfModel(
212  const Identity &_modelID) const = 0;
213  };
214  };
215 
219  class IGNITION_PHYSICS_VISIBLE GetNestedModelFromModel
220  : public virtual FeatureWithRequirements<GetModelFromWorld>
221  {
222  public: template <typename PolicyT, typename FeaturesT>
223  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
224  {
225  // typedefs for the type of Model that this Model can return
226  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
227  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
228 
230  public: std::size_t GetNestedModelCount() const;
231 
237  public: ModelPtrType GetNestedModel(std::size_t _index);
238 
240  public: ConstModelPtrType GetNestedModel(std::size_t _index) const;
241 
247  public: ModelPtrType GetNestedModel(const std::string &_name);
248 
250  public: ConstModelPtrType GetNestedModel(
251  const std::string &_name) const;
252  };
253 
254  public: template <typename PolicyT>
255  class Implementation : public virtual Feature::Implementation<PolicyT>
256  {
257  public: virtual std::size_t GetNestedModelCount(
258  const Identity &_modelID) const = 0;
259 
260  public: virtual Identity GetNestedModel(
261  const Identity &_modelID, std::size_t _modelIndex) const = 0;
262 
263  public: virtual Identity GetNestedModel(
264  const Identity &_modelID, const std::string &_modelName) const = 0;
265  };
266  };
267 
271  class IGNITION_PHYSICS_VISIBLE GetLinkFromModel : public virtual Feature
272  {
273  public: template <typename PolicyT, typename FeaturesT>
274  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
275  {
276  // typedefs for the type of Link that this Model can return
277  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
278  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
279 
281  public: std::size_t GetLinkCount() const;
282 
288  public: LinkPtrType GetLink(std::size_t _index);
289 
291  public: ConstLinkPtrType GetLink(std::size_t _index) const;
292 
298  public: LinkPtrType GetLink(const std::string &_name);
299 
301  public: ConstLinkPtrType GetLink(const std::string &_name) const;
302  };
303 
304  public: template <typename PolicyT, typename FeaturesT>
305  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
306  {
307  // typedefs for the type of Model that this Link can return
308  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
309  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
310 
312  public: const std::string &GetName() const;
313 
315  public: std::size_t GetIndex() const;
316 
319  public: ModelPtrType GetModel();
320 
322  public: ConstModelPtrType GetModel() const;
323  };
324 
325  public: template <typename PolicyT>
326  class Implementation : public virtual Feature::Implementation<PolicyT>
327  {
328  public: virtual std::size_t GetLinkCount(
329  const Identity &_modelID) const = 0;
330 
331  public: virtual Identity GetLink(
332  const Identity &_modelID, std::size_t _linkIndex) const = 0;
333 
334  public: virtual Identity GetLink(
335  const Identity &_modelID, const std::string &_linkName) const = 0;
336 
337  public: virtual const std::string &GetLinkName(
338  const Identity &_linkID) const = 0;
339 
340  public: virtual std::size_t GetLinkIndex(
341  const Identity &_linkID) const = 0;
342 
343  public: virtual Identity GetModelOfLink(
344  const Identity &_linkID) const = 0;
345  };
346  };
347 
351  class IGNITION_PHYSICS_VISIBLE GetJointFromModel : public virtual Feature
352  {
353  public: template <typename PolicyT, typename FeaturesT>
354  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
355  {
356  // typedefs for the type of Joint that this Model can return
357  public: using JointPtrType = JointPtr<PolicyT, FeaturesT>;
358  public: using ConstJointPtrType = ConstJointPtr<PolicyT, FeaturesT>;
359 
361  public: std::size_t GetJointCount() const;
362 
368  public: JointPtrType GetJoint(std::size_t _index);
369 
371  public: ConstJointPtrType GetJoint(std::size_t _index) const;
372 
378  public: JointPtrType GetJoint(const std::string &_name);
379 
381  public: ConstJointPtrType GetJoint(const std::string &_name) const;
382  };
383 
384  public: template <typename PolicyT, typename FeaturesT>
385  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
386  {
387  // typedefs for the type of Model that this Link can return
388  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
389  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
390 
392  public: const std::string &GetName() const;
393 
395  public: std::size_t GetIndex() const;
396 
399  public: ModelPtrType GetModel();
400 
402  public: ConstModelPtrType GetModel() const;
403  };
404 
405  public: template <typename PolicyT>
406  class Implementation : public virtual Feature::Implementation<PolicyT>
407  {
408  public: virtual std::size_t GetJointCount(
409  const Identity &_modelID) const = 0;
410 
411  public: virtual Identity GetJoint(
412  const Identity &_modelID, std::size_t _jointIndex) const = 0;
413 
414  public: virtual Identity GetJoint(
415  const Identity &_modelID, const std::string &_jointName) const = 0;
416 
417  public: virtual const std::string &GetJointName(
418  const Identity &_jointID) const = 0;
419 
420  public: virtual std::size_t GetJointIndex(
421  const Identity &_jointID) const = 0;
422 
423  public: virtual Identity GetModelOfJoint(
424  const Identity &_jointID) const = 0;
425  };
426  };
427 
431  class IGNITION_PHYSICS_VISIBLE GetShapeFromLink : public virtual Feature
432  {
433  public: template <typename PolicyT, typename FeaturesT>
434  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
435  {
436  // typedefs for the type of Shape that this Link can return
437  public: using ShapePtrType = ShapePtr<PolicyT, FeaturesT>;
438  public: using ConstShapePtrType = ConstShapePtr<PolicyT, FeaturesT>;
439 
441  public: std::size_t GetShapeCount() const;
442 
448  public: ShapePtrType GetShape(std::size_t _index);
449 
451  public: ConstShapePtrType GetShape(std::size_t _index) const;
452 
458  public: ShapePtrType GetShape(const std::string &_name);
459 
461  public: ConstShapePtrType GetShape(const std::string &_name) const;
462  };
463 
464  public: template <typename PolicyT, typename FeaturesT>
465  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
466  {
467  // typedefs for the type of Link that this Shape can return
468  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
469  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
470 
472  public: const std::string &GetName() const;
473 
475  public: std::size_t GetIndex() const;
476 
479  public: LinkPtrType GetLink();
480 
482  public: ConstLinkPtrType GetLink() const;
483  };
484 
485  public: template <typename PolicyT>
486  class Implementation : public virtual Feature::Implementation<PolicyT>
487  {
488  public: virtual std::size_t GetShapeCount(
489  const Identity &_linkID) const = 0;
490 
491  public: virtual Identity GetShape(
492  const Identity &_linkID, std::size_t _shapeIndex) const = 0;
493 
494  public: virtual Identity GetShape(
495  const Identity &_linkID, const std::string &_shapeName) const = 0;
496 
497  public: virtual const std::string &GetShapeName(
498  const Identity &_shapeID) const = 0;
499 
500  public: virtual std::size_t GetShapeIndex(
501  const Identity &_shapeID) const = 0;
502 
503  public: virtual Identity GetLinkOfShape(
504  const Identity &_shapeID) const = 0;
505  };
506  };
507 
509  GetEngineInfo,
510  GetWorldFromEngine,
511  GetModelFromWorld,
512  GetNestedModelFromModel,
513  GetLinkFromModel,
514  GetJointFromModel,
515  GetShapeFromLink
516  > { };
517  }
518 }
519 
520 #include <gz/physics/detail/GetEntities.hh>
521 
522 #endif
virtual std::size_t GetLinkCount(const Identity &_modelID) const =0
ConstJointPtr< PolicyT, FeaturesT > ConstJointPtrType
Definition: gz/physics/GetEntities.hh:358
virtual Identity GetModelOfJoint(const Identity &_jointID) const =0
std::size_t GetWorldCount() const
Get the number of worlds inside this engine.
virtual std::size_t GetLinkIndex(const Identity &_linkID) const =0
If your feature is known to require any other features, then you should have your feature class inher...
Definition: gz/physics/FeatureList.hh:118
std::size_t GetNestedModelCount() const
Get the number of nested Models inside this Model.
Placeholder class in case a Feature does not define its own Shape API.
Definition: gz/physics/Feature.hh:85
STL class.
virtual std::size_t GetJointCount(const Identity &_modelID) const =0
virtual std::size_t GetNestedModelCount(const Identity &_modelID) const =0
This feature retrieves the physics engine name in use.
Definition: gz/physics/GetEntities.hh:31
JointPtrType GetJoint(std::size_t _index)
Get a Joint that exists within this Model.
Definition: gz/physics/GetEntities.hh:142
const std::string & GetName() const
Get the name of this Joint.
WorldPtr< PolicyT, FeaturesT > WorldPtrType
Definition: gz/physics/GetEntities.hh:65
EnginePtrType GetEngine()
Get the Engine that is managing this World.
This feature retrieves the joint pointer from the model by specifying model index and joint index/nam...
Definition: gz/physics/GetEntities.hh:351
ModelPtr< PolicyT, FeaturesT > ModelPtrType
Definition: gz/physics/GetEntities.hh:145
virtual Identity GetJoint(const Identity &_modelID, std::size_t _jointIndex) const =0
WorldPtrType GetWorld()
Get the World that contains this Model.
This feature retrieves the world pointer using index or name from the physics engine in use.
Definition: gz/physics/GetEntities.hh:59
virtual const std::string & GetModelName(const Identity &_modelID) const =0
This feature retrieves the nested model pointer from the parent model by specifying the name or index...
Definition: gz/physics/GetEntities.hh:219
virtual Identity GetNestedModel(const Identity &_modelID, std::size_t _modelIndex) const =0
virtual Identity GetLink(const Identity &_modelID, std::size_t _linkIndex) const =0
ConstWorldPtr< PolicyT, FeaturesT > ConstWorldPtrType
Definition: gz/physics/GetEntities.hh:66
std::size_t GetModelCount() const
Get the number of Models inside this World.
virtual std::size_t GetWorldIndex(const Identity &_worldID) const =0
ModelPtrType GetModel(std::size_t _index)
Get a Model that exists within this World.
std::size_t GetIndex() const
Get the index of this engine. The meaning of an engine index is plugin-defined.
Use a FeatureList to aggregate a list of Features.
Definition: gz/physics/FeatureList.hh:61
EnginePtr< PolicyT, FeaturesT > EnginePtrType
Definition: gz/physics/GetEntities.hh:96
ConstWorldPtr< PolicyT, FeaturesT > ConstWorldPtrType
Definition: gz/physics/GetEntities.hh:177
Definition: gz/physics/GetEntities.hh:326
std::size_t GetIndex() const
Get the index of this Joint within its Model.
virtual const std::string & GetLinkName(const Identity &_linkID) const =0
LinkPtrType GetLink(std::size_t _index)
Get a Link that exists within this Model.
virtual Identity GetWorld(const Identity &_engineID, std::size_t _worldIndex) const =0
ModelPtrType GetModel()
Get the model that contains this Link.
Definition: gz/physics/GetEntities.hh:274
Definition: gz/physics/GetEntities.hh:194
virtual std::size_t GetJointIndex(const Identity &_jointID) const =0
Definition: gz/physics/Feature.hh:92
This class defines the concept of a Feature. It should be inherited by classes that define some plugi...
Definition: gz/physics/Feature.hh:35
ConstModelPtr< PolicyT, FeaturesT > ConstModelPtrType
Definition: gz/physics/GetEntities.hh:146
std::size_t GetIndex() const
Get the index of this Model within its World.
LinkPtr< PolicyT, FeaturesT > LinkPtrType
Definition: gz/physics/GetEntities.hh:277
virtual Identity GetWorldOfModel(const Identity &_modelID) const =0
virtual Identity GetModelOfLink(const Identity &_linkID) const =0
Placeholder class in case a Feature does not define its own Joint API.
Definition: gz/physics/Feature.hh:76
virtual Identity GetModel(const Identity &_worldID, std::size_t _modelIndex) const =0
Definition: gz/physics/GetEntities.hh:255
ConstModelPtr< PolicyT, FeaturesT > ConstModelPtrType
Definition: gz/physics/GetEntities.hh:389
WorldPtr< PolicyT, FeaturesT > WorldPtrType
Definition: gz/physics/GetEntities.hh:176
virtual std::size_t GetWorldCount(const Identity &_engineID) const =0
Definition: gz/physics/GetEntities.hh:93
virtual std::size_t GetModelCount(const Identity &_worldID) const =0
Placeholder class in case a Feature does not define its own Model API.
Definition: gz/physics/Feature.hh:58
ModelPtr< PolicyT, FeaturesT > ModelPtrType
Definition: gz/physics/GetEntities.hh:388
virtual const std::string & GetJointName(const Identity &_jointID) const =0
Definition: gz/physics/GetEntities.hh:508
Definition: gz/physics/GetEntities.hh:223
virtual std::size_t GetModelIndex(const Identity &_modelID) const =0
Placeholder class in case a Feature does not define its own World API.
Definition: gz/physics/Feature.hh:49
ConstEnginePtr< PolicyT, FeaturesT > ConstEnginePtrType
Definition: gz/physics/GetEntities.hh:97
Definition: gz/physics/GetEntities.hh:354
virtual Identity GetEngineOfWorld(const Identity &_worldID) const =0
virtual const std::string & GetWorldName(const Identity &_worldID) const =0
std::size_t GetIndex() const
Get the index of this World within its engine.
Definition: gz/physics/GetEntities.hh:385
Definition: gz/physics/GetEntities.hh:114
std::size_t GetLinkCount() const
Get the number of Links within this Model.
virtual std::size_t GetEngineIndex(const Identity &_engineID) const =0
ModelPtr< PolicyT, FeaturesT > ModelPtrType
Definition: gz/physics/GetEntities.hh:226
Definition: gz/physics/GetEntities.hh:62
JointPtr< PolicyT, FeaturesT > JointPtrType
Definition: gz/physics/GetEntities.hh:357
Definition: gz/physics/GetEntities.hh:34
Definition: gz/physics/GetEntities.hh:406
This feature retrieves the model pointer from the simulation world by specifying world index and mode...
Definition: gz/physics/GetEntities.hh:139
Placeholder class for the Engine API. Every Engine feature MUST inherit this class.
Definition: gz/physics/Feature.hh:40
const std::string & GetName() const
Get the name of this Model.
ConstModelPtr< PolicyT, FeaturesT > ConstModelPtrType
Definition: gz/physics/GetEntities.hh:227
Definition: gz/physics/GetEntities.hh:173
virtual const std::string & GetEngineName(const Identity &_engineID) const =0
This feature retrieves the link pointer from the model by specifying model index and link index/name.
Definition: gz/physics/GetEntities.hh:271
const std::string & GetName() const
Get the name of this World.
ModelPtrType GetNestedModel(std::size_t _index)
Get a nested Model that exists within this Model.
const std::string & GetName() const
Get the name of this engine. The meaning of an engine name is plugin-defined.
WorldPtrType GetWorld(std::size_t _index)
Get a world that is being managed by this engine.
std::size_t GetJointCount() const
Get the number of Joints within this Model.
ConstLinkPtr< PolicyT, FeaturesT > ConstLinkPtrType
Definition: gz/physics/GetEntities.hh:278
Definition: gz/physics/GetEntities.hh:46