World.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2017 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 #ifndef SDF_WORLD_HH_
18 #define SDF_WORLD_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <ignition/math/Vector3.hh>
23 #include <ignition/utils/ImplPtr.hh>
24 
25 #include "sdf/Atmosphere.hh"
26 #include "sdf/Element.hh"
27 #include "sdf/Gui.hh"
28 #include "sdf/Scene.hh"
29 #include "sdf/Types.hh"
30 #include "sdf/sdf_config.h"
31 #include "sdf/system_util.hh"
32 
33 namespace sdf
34 {
35  // Inline bracket to help doxygen filtering.
36  inline namespace SDF_VERSION_NAMESPACE {
37  //
38 
39  // Forward declare private data class.
40  class Actor;
41  class Frame;
42  class InterfaceModel;
43  class Light;
44  class Model;
45  class ParserConfig;
46  class Physics;
47  struct NestedInclude;
48  struct PoseRelativeToGraph;
49  struct FrameAttachedToGraph;
50  template <typename T> class ScopedGraph;
51 
53  {
55  public: World();
56 
63  public: Errors Load(ElementPtr _sdf);
64 
72  public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
73 
78  public: Errors ValidateGraphs() const;
79 
82  public: std::string Name() const;
83 
86  public: void SetName(const std::string &_name);
87 
92  public: std::string AudioDevice() const;
93 
98  public: void SetAudioDevice(const std::string &_device);
99 
104  public: ignition::math::Vector3d WindLinearVelocity() const;
105 
110  public: void SetWindLinearVelocity(const ignition::math::Vector3d &_wind);
111 
117  public: ignition::math::Vector3d Gravity() const;
118 
122  public: void SetGravity(const ignition::math::Vector3d &_gravity);
123 
130  public: ignition::math::Vector3d MagneticField() const;
131 
138  public: void SetMagneticField(const ignition::math::Vector3d &_mag);
139 
145  public: uint64_t ModelCount() const;
146 
153  public: const Model *ModelByIndex(const uint64_t _index) const;
154 
162  public: const Model *ModelByName(const std::string &_name) const;
163 
169  public: bool ModelNameExists(const std::string &_name) const;
170 
173  public: uint64_t ActorCount() const;
174 
180  public: const Actor *ActorByIndex(const uint64_t _index) const;
181 
185  public: bool ActorNameExists(const std::string &_name) const;
186 
192  public: uint64_t FrameCount() const;
193 
201  public: const Frame *FrameByIndex(const uint64_t _index) const;
202 
209  public: const Frame *FrameByName(const std::string &_name) const;
210 
216  public: bool FrameNameExists(const std::string &_name) const;
217 
220  public: uint64_t LightCount() const;
221 
227  public: const Light *LightByIndex(const uint64_t _index) const;
228 
232  public: bool LightNameExists(const std::string &_name) const;
233 
238  public: const sdf::Atmosphere *Atmosphere() const;
239 
242  public: void SetAtmosphere(const sdf::Atmosphere &_atmosphere);
243 
248  public: const sdf::Gui *Gui() const;
249 
252  public: void SetGui(const sdf::Gui &_gui);
253 
258  public: const sdf::Scene *Scene() const;
259 
262  public: void SetScene(const sdf::Scene &_scene);
263 
268  public: sdf::ElementPtr Element() const;
269 
272  public: uint64_t PhysicsCount() const;
273 
280  public: const Physics *PhysicsByIndex(const uint64_t _index) const;
281 
284  public: const Physics *PhysicsDefault() const;
285 
289  public: bool PhysicsNameExists(const std::string &_name) const;
290 
295  public: uint64_t InterfaceModelCount() const;
296 
303  public: std::shared_ptr<const InterfaceModel> InterfaceModelByIndex(
304  const uint64_t _index) const;
305 
313  public: const NestedInclude* InterfaceModelNestedIncludeByIndex(
314  const uint64_t _index) const;
315 
320  private: void SetPoseRelativeToGraph(
321  sdf::ScopedGraph<PoseRelativeToGraph> _graph);
322 
327  private: void SetFrameAttachedToGraph(
328  sdf::ScopedGraph<FrameAttachedToGraph> _graph);
329 
332  friend class Root;
333 
335  IGN_UTILS_IMPL_PTR(dataPtr)
336  };
337  }
338 }
339 #endif
Provides a description of a light source.
Definition: Light.hh:63
Provides a description of an actor.
Definition: Actor.hh:190
The physics element specifies the type and properties of a dynamics engine.
Definition: Physics.hh:36
Definition: World.hh:52
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:42
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
The Atmosphere class contains information about an atmospheric model and related parameters such as t...
Definition: Atmosphere.hh:45
Definition: Model.hh:48
Contains the necessary information about an included model file for custom model parsers to be able t...
Definition: InterfaceElements.hh:43
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:41
Definition: Gui.hh:30
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
Definition: Scene.hh:33
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:54
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
namespace for Simulation Description Format parser
Definition: Actor.hh:33