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 <optional>
22 #include <string>
23 #include <ignition/math/SphericalCoordinates.hh>
24 #include <ignition/math/Vector3.hh>
25 #include <ignition/utils/ImplPtr.hh>
26 
27 #include "sdf/Atmosphere.hh"
28 #include "sdf/Element.hh"
29 #include "sdf/Gui.hh"
30 #include "sdf/Scene.hh"
31 #include "sdf/Types.hh"
32 #include "sdf/sdf_config.h"
33 #include "sdf/system_util.hh"
34 
35 namespace sdf
36 {
37  // Inline bracket to help doxygen filtering.
38  inline namespace SDF_VERSION_NAMESPACE {
39  //
40 
41  // Forward declare private data class.
42  class Actor;
43  class Frame;
44  class InterfaceModel;
45  class Light;
46  class Model;
47  class ParserConfig;
48  class Physics;
49  class NestedInclude;
50  struct PoseRelativeToGraph;
51  struct FrameAttachedToGraph;
52  template <typename T> class ScopedGraph;
53 
55  {
57  public: World();
58 
65  public: Errors Load(ElementPtr _sdf);
66 
74  public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
75 
80  public: Errors ValidateGraphs() const;
81 
84  public: std::string Name() const;
85 
88  public: void SetName(const std::string &_name);
89 
94  public: std::string AudioDevice() const;
95 
100  public: void SetAudioDevice(const std::string &_device);
101 
106  public: ignition::math::Vector3d WindLinearVelocity() const;
107 
112  public: void SetWindLinearVelocity(const ignition::math::Vector3d &_wind);
113 
119  public: ignition::math::Vector3d Gravity() const;
120 
124  public: void SetGravity(const ignition::math::Vector3d &_gravity);
125 
132  public: ignition::math::Vector3d MagneticField() const;
133 
140  public: void SetMagneticField(const ignition::math::Vector3d &_mag);
141 
144  public: const ignition::math::SphericalCoordinates *
145  SphericalCoordinates() const;
146 
149  public: void SetSphericalCoordinates(
150  const ignition::math::SphericalCoordinates &_coord);
151 
157  public: uint64_t ModelCount() const;
158 
165  public: const Model *ModelByIndex(const uint64_t _index) const;
166 
174  public: const Model *ModelByName(const std::string &_name) const;
175 
181  public: bool ModelNameExists(const std::string &_name) const;
182 
185  public: uint64_t ActorCount() const;
186 
192  public: const Actor *ActorByIndex(const uint64_t _index) const;
193 
197  public: bool ActorNameExists(const std::string &_name) const;
198 
204  public: uint64_t FrameCount() const;
205 
213  public: const Frame *FrameByIndex(const uint64_t _index) const;
214 
221  public: const Frame *FrameByName(const std::string &_name) const;
222 
228  public: bool FrameNameExists(const std::string &_name) const;
229 
232  public: uint64_t LightCount() const;
233 
239  public: const Light *LightByIndex(const uint64_t _index) const;
240 
244  public: bool LightNameExists(const std::string &_name) const;
245 
250  public: const sdf::Atmosphere *Atmosphere() const;
251 
254  public: void SetAtmosphere(const sdf::Atmosphere &_atmosphere);
255 
260  public: const sdf::Gui *Gui() const;
261 
264  public: void SetGui(const sdf::Gui &_gui);
265 
270  public: const sdf::Scene *Scene() const;
271 
274  public: void SetScene(const sdf::Scene &_scene);
275 
280  public: sdf::ElementPtr Element() const;
281 
284  public: uint64_t PhysicsCount() const;
285 
292  public: const Physics *PhysicsByIndex(const uint64_t _index) const;
293 
296  public: const Physics *PhysicsDefault() const;
297 
301  public: bool PhysicsNameExists(const std::string &_name) const;
302 
307  public: uint64_t InterfaceModelCount() const;
308 
315  public: std::shared_ptr<const InterfaceModel> InterfaceModelByIndex(
316  const uint64_t _index) const;
317 
325  public: const NestedInclude* InterfaceModelNestedIncludeByIndex(
326  const uint64_t _index) const;
327 
332  private: void SetPoseRelativeToGraph(
334 
339  private: void SetFrameAttachedToGraph(
341 
344  friend class Root;
345 
347  IGN_UTILS_IMPL_PTR(dataPtr)
348  };
349  }
350 }
351 #endif
sdf::v12::Scene
Definition: Scene.hh:33
sdf::v12::World
Definition: World.hh:54
Gui.hh
sdf::v12::ScopedGraph
Definition: Collision.hh:39
sdf::v12::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
sdf::v12::Actor
Provides a description of an actor.
Definition: Actor.hh:190
Scene.hh
sdf::v12::NestedInclude
Contains the necessary information about an included model file for custom model parsers to be able t...
Definition: InterfaceElements.hh:44
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:33
sdf::v12::Light
Provides a description of a light source.
Definition: Light.hh:63
sdf::v12::Model
Definition: Model.hh:48
sdf::v12::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
Types.hh
sdf::v12::Frame
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition: Frame.hh:42
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:41
sdf::v12::Element
SDF Element class.
Definition: Element.hh:73
sdf::v12::Gui
Definition: Gui.hh:30
sdf::v12::Atmosphere
The Atmosphere class contains information about an atmospheric model and related parameters such as t...
Definition: Atmosphere.hh:45
sdf::v12::Root
Root class that acts as an entry point to the SDF document model.
Definition: Root.hh:54
sdf::v12::Physics
The physics element specifies the type and properties of a dynamics engine.
Definition: Physics.hh:36
system_util.hh
sdf::v12::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
Atmosphere.hh
Element.hh