Gazebo Physics

API Reference

2.6.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 GetLinkFromModel : public virtual Feature
220  {
221  public: template <typename PolicyT, typename FeaturesT>
222  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
223  {
224  // typedefs for the type of Link that this Model can return
225  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
226  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
227 
229  public: std::size_t GetLinkCount() const;
230 
236  public: LinkPtrType GetLink(std::size_t _index);
237 
239  public: ConstLinkPtrType GetLink(std::size_t _index) const;
240 
246  public: LinkPtrType GetLink(const std::string &_name);
247 
249  public: ConstLinkPtrType GetLink(const std::string &_name) const;
250  };
251 
252  public: template <typename PolicyT, typename FeaturesT>
253  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
254  {
255  // typedefs for the type of Model that this Link can return
256  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
257  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
258 
260  public: const std::string &GetName() const;
261 
263  public: std::size_t GetIndex() const;
264 
267  public: ModelPtrType GetModel();
268 
270  public: ConstModelPtrType GetModel() const;
271  };
272 
273  public: template <typename PolicyT>
274  class Implementation : public virtual Feature::Implementation<PolicyT>
275  {
276  public: virtual std::size_t GetLinkCount(
277  const Identity &_modelID) const = 0;
278 
279  public: virtual Identity GetLink(
280  const Identity &_modelID, std::size_t _linkIndex) const = 0;
281 
282  public: virtual Identity GetLink(
283  const Identity &_modelID, const std::string &_linkName) const = 0;
284 
285  public: virtual const std::string &GetLinkName(
286  const Identity &_linkID) const = 0;
287 
288  public: virtual std::size_t GetLinkIndex(
289  const Identity &_linkID) const = 0;
290 
291  public: virtual Identity GetModelOfLink(
292  const Identity &_linkID) const = 0;
293  };
294  };
295 
299  class IGNITION_PHYSICS_VISIBLE GetJointFromModel : public virtual Feature
300  {
301  public: template <typename PolicyT, typename FeaturesT>
302  class Model : public virtual Feature::Model<PolicyT, FeaturesT>
303  {
304  // typedefs for the type of Joint that this Model can return
305  public: using JointPtrType = JointPtr<PolicyT, FeaturesT>;
306  public: using ConstJointPtrType = ConstJointPtr<PolicyT, FeaturesT>;
307 
309  public: std::size_t GetJointCount() const;
310 
316  public: JointPtrType GetJoint(std::size_t _index);
317 
319  public: ConstJointPtrType GetJoint(std::size_t _index) const;
320 
326  public: JointPtrType GetJoint(const std::string &_name);
327 
329  public: ConstJointPtrType GetJoint(const std::string &_name) const;
330  };
331 
332  public: template <typename PolicyT, typename FeaturesT>
333  class Joint : public virtual Feature::Joint<PolicyT, FeaturesT>
334  {
335  // typedefs for the type of Model that this Link can return
336  public: using ModelPtrType = ModelPtr<PolicyT, FeaturesT>;
337  public: using ConstModelPtrType = ConstModelPtr<PolicyT, FeaturesT>;
338 
340  public: const std::string &GetName() const;
341 
343  public: std::size_t GetIndex() const;
344 
347  public: ModelPtrType GetModel();
348 
350  public: ConstModelPtrType GetModel() const;
351  };
352 
353  public: template <typename PolicyT>
354  class Implementation : public virtual Feature::Implementation<PolicyT>
355  {
356  public: virtual std::size_t GetJointCount(
357  const Identity &_modelID) const = 0;
358 
359  public: virtual Identity GetJoint(
360  const Identity &_modelID, std::size_t _jointIndex) const = 0;
361 
362  public: virtual Identity GetJoint(
363  const Identity &_modelID, const std::string &_jointName) const = 0;
364 
365  public: virtual const std::string &GetJointName(
366  const Identity &_jointID) const = 0;
367 
368  public: virtual std::size_t GetJointIndex(
369  const Identity &_jointID) const = 0;
370 
371  public: virtual Identity GetModelOfJoint(
372  const Identity &_jointID) const = 0;
373  };
374  };
375 
379  class IGNITION_PHYSICS_VISIBLE GetShapeFromLink : public virtual Feature
380  {
381  public: template <typename PolicyT, typename FeaturesT>
382  class Link : public virtual Feature::Link<PolicyT, FeaturesT>
383  {
384  // typedefs for the type of Shape that this Link can return
385  public: using ShapePtrType = ShapePtr<PolicyT, FeaturesT>;
386  public: using ConstShapePtrType = ConstShapePtr<PolicyT, FeaturesT>;
387 
389  public: std::size_t GetShapeCount() const;
390 
396  public: ShapePtrType GetShape(std::size_t _index);
397 
399  public: ConstShapePtrType GetShape(std::size_t _index) const;
400 
406  public: ShapePtrType GetShape(const std::string &_name);
407 
409  public: ConstShapePtrType GetShape(const std::string &_name) const;
410  };
411 
412  public: template <typename PolicyT, typename FeaturesT>
413  class Shape : public virtual Feature::Shape<PolicyT, FeaturesT>
414  {
415  // typedefs for the type of Link that this Shape can return
416  public: using LinkPtrType = LinkPtr<PolicyT, FeaturesT>;
417  public: using ConstLinkPtrType = ConstLinkPtr<PolicyT, FeaturesT>;
418 
420  public: const std::string &GetName() const;
421 
423  public: std::size_t GetIndex() const;
424 
427  public: LinkPtrType GetLink();
428 
430  public: ConstLinkPtrType GetLink() const;
431  };
432 
433  public: template <typename PolicyT>
434  class Implementation : public virtual Feature::Implementation<PolicyT>
435  {
436  public: virtual std::size_t GetShapeCount(
437  const Identity &_linkID) const = 0;
438 
439  public: virtual Identity GetShape(
440  const Identity &_linkID, std::size_t _shapeIndex) const = 0;
441 
442  public: virtual Identity GetShape(
443  const Identity &_linkID, const std::string &_shapeName) const = 0;
444 
445  public: virtual const std::string &GetShapeName(
446  const Identity &_shapeID) const = 0;
447 
448  public: virtual std::size_t GetShapeIndex(
449  const Identity &_shapeID) const = 0;
450 
451  public: virtual Identity GetLinkOfShape(
452  const Identity &_shapeID) const = 0;
453  };
454  };
455 
457  GetEngineInfo,
458  GetWorldFromEngine,
459  GetModelFromWorld,
460  GetLinkFromModel,
461  GetJointFromModel,
462  GetShapeFromLink
463  > { };
464  }
465 }
466 
467 #include <gz/physics/detail/GetEntities.hh>
468 
469 #endif
virtual std::size_t GetLinkCount(const Identity &_modelID) const =0
ConstJointPtr< PolicyT, FeaturesT > ConstJointPtrType
Definition: gz/physics/GetEntities.hh:306
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
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
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:299
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
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:51
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:274
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:222
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:225
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
ConstModelPtr< PolicyT, FeaturesT > ConstModelPtrType
Definition: gz/physics/GetEntities.hh:337
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:336
virtual const std::string & GetJointName(const Identity &_jointID) const =0
Definition: gz/physics/GetEntities.hh:456
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:302
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:333
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
Definition: gz/physics/GetEntities.hh:62
JointPtr< PolicyT, FeaturesT > JointPtrType
Definition: gz/physics/GetEntities.hh:305
Definition: gz/physics/GetEntities.hh:34
Definition: gz/physics/GetEntities.hh:354
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.
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:219
const std::string & GetName() const
Get the name of this World.
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:226
Definition: gz/physics/GetEntities.hh:46