Loading...
Searching...
No Matches
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 <string>
21#include <ignition/math/Vector3.hh>
22
23#include "sdf/Atmosphere.hh"
24#include "sdf/Element.hh"
25#include "sdf/Gui.hh"
26#include "sdf/Scene.hh"
27#include "sdf/Types.hh"
28#include "sdf/sdf_config.h"
29#include "sdf/system_util.hh"
30
31namespace sdf
32{
33 // Inline bracket to help doxygen filtering.
34 inline namespace SDF_VERSION_NAMESPACE {
35 //
36
37 // Forward declare private data class.
38 class Actor;
39 class Frame;
40 class Light;
41 class Model;
42 class Physics;
43 class WorldPrivate;
44
46 {
48 public: World();
49
52 public: World(const World &_world);
53
56 public: World(World &&_world) noexcept;
57
61 public: World &operator=(World &&_world);
62
66 public: World &operator=(const World &_world);
67
69 public: ~World();
70
77 public: Errors Load(ElementPtr _sdf);
78
83 public: Errors ValidateGraphs() const;
84
87 public: std::string Name() const;
88
91 public: void SetName(const std::string &_name) const;
92
97 public: std::string AudioDevice() const;
98
103 public: void SetAudioDevice(const std::string &_device);
104
109 public: ignition::math::Vector3d WindLinearVelocity() const;
110
115 public: void SetWindLinearVelocity(const ignition::math::Vector3d &_wind);
116
122 public: ignition::math::Vector3d Gravity() const;
123
127 public: void SetGravity(const ignition::math::Vector3d &_gravity);
128
135 public: ignition::math::Vector3d MagneticField() const;
136
143 public: void SetMagneticField(const ignition::math::Vector3d &_mag);
144
147 public: uint64_t ModelCount() const;
148
154 public: const Model *ModelByIndex(const uint64_t _index) const;
155
159 public: const Model *ModelByName(const std::string &_name) const;
160
164 public: bool ModelNameExists(const std::string &_name) const;
165
168 public: uint64_t ActorCount() const;
169
175 public: const Actor *ActorByIndex(const uint64_t _index) const;
176
180 public: bool ActorNameExists(const std::string &_name) const;
181
184 public: uint64_t FrameCount() const;
185
192 public: const Frame *FrameByIndex(const uint64_t _index) const;
193
198 public: const Frame *FrameByName(const std::string &_name) const;
199
203 public: bool FrameNameExists(const std::string &_name) const;
204
207 public: uint64_t LightCount() const;
208
214 public: const Light *LightByIndex(const uint64_t _index) const;
215
219 public: bool LightNameExists(const std::string &_name) const;
220
225 public: const sdf::Atmosphere *Atmosphere() const;
226
229 public: void SetAtmosphere(const sdf::Atmosphere &_atmosphere) const;
230
235 public: sdf::Gui *Gui() const;
236
239 public: void SetGui(const sdf::Gui &_gui);
240
245 public: const sdf::Scene *Scene() const;
246
249 public: void SetScene(const sdf::Scene &_scene);
250
255 public: sdf::ElementPtr Element() const;
256
259 public: uint64_t PhysicsCount() const;
260
267 public: const Physics *PhysicsByIndex(const uint64_t _index) const;
268
271 public: const Physics *PhysicsDefault() const;
272
276 public: bool PhysicsNameExists(const std::string &_name) const;
277
279 private: WorldPrivate *dataPtr = nullptr;
280 };
281 }
282}
283#endif
Provides a description of an actor.
Definition Actor.hh:278
The Atmosphere class contains information about an atmospheric model and related parameters such as t...
Definition Atmosphere.hh:47
A Frame element descibes the properties associated with an explicit frame defined in a Model or World...
Definition Frame.hh:42
Definition Gui.hh:35
Provides a description of a light source.
Definition Light.hh:63
Definition Model.hh:44
The physics element specifies the type and properties of a dynamics engine.
Definition Physics.hh:39
Definition Scene.hh:38
Definition World.hh:46
~World()
Destructor.
void SetScene(const sdf::Scene &_scene)
Set the Scene parameters associated with this world.
const Frame * FrameByName(const std::string &_name) const
Get an explicit frame based on a name.
Errors ValidateGraphs() const
Check that the FrameAttachedToGraph and PoseRelativeToGraph are valid.
const Actor * ActorByIndex(const uint64_t _index) const
Get an actor based on an index.
const Light * LightByIndex(const uint64_t _index) const
Get a light based on an index.
bool ModelNameExists(const std::string &_name) const
Get whether a model name exists.
const Frame * FrameByIndex(const uint64_t _index) const
Get an explicit frame based on an index.
const sdf::Atmosphere * Atmosphere() const
Get a pointer to the atmosphere model associated with this world.
ignition::math::Vector3d WindLinearVelocity() const
Get the wind linear velocity in the global/world coordinate frame.
const Model * ModelByName(const std::string &_name) const
Get a model based on a name.
World()
Default constructor.
void SetGravity(const ignition::math::Vector3d &_gravity)
Set the acceleration due to gravity.
bool ActorNameExists(const std::string &_name) const
Get whether an actor name exists.
uint64_t ModelCount() const
Get the number of models.
bool FrameNameExists(const std::string &_name) const
Get whether an explicit frame name exists.
uint64_t FrameCount() const
Get the number of explicit frames.
const Model * ModelByIndex(const uint64_t _index) const
Get a model based on an index.
std::string AudioDevice() const
Get the audio device name.
World(World &&_world) noexcept
Move constructor.
uint64_t LightCount() const
Get the number of lights.
const Physics * PhysicsByIndex(const uint64_t _index) const
Get a physics profile based on an index.
World & operator=(World &&_world)
Move assignment operator.
void SetName(const std::string &_name) const
Set the name of the world.
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
void SetWindLinearVelocity(const ignition::math::Vector3d &_wind)
Set the wind linear velocity in the global/world coordinate frame.
bool PhysicsNameExists(const std::string &_name) const
Get whether a physics profile name exists.
ignition::math::Vector3d MagneticField() const
Get the magnetic vector in Tesla, expressed in a coordinate frame defined by the SphericalCoordinates...
Errors Load(ElementPtr _sdf)
Load the world based on a element pointer.
bool LightNameExists(const std::string &_name) const
Get whether a light name exists.
uint64_t ActorCount() const
Get the number of actors.
const Physics * PhysicsDefault() const
Get the default physics profile.
ignition::math::Vector3d Gravity() const
Get the acceleration due to gravity.
void SetGui(const sdf::Gui &_gui)
Set the Gui parameters associated with this world.
void SetAtmosphere(const sdf::Atmosphere &_atmosphere) const
Set the atmosphere model associated with this world.
sdf::Gui * Gui() const
Get a pointer to the Gui associated with this world.
uint64_t PhysicsCount() const
Get the number of physics profiles.
World(const World &_world)
Copy constructor.
void SetAudioDevice(const std::string &_device)
Set the audio device name.
World & operator=(const World &_world)
Copy assignment operator.
std::string Name() const
Get the name of the world.
void SetMagneticField(const ignition::math::Vector3d &_mag)
Set the magnetic vector in Tesla, expressed in a coordinate frame defined by the SphericalCoordinate.
const sdf::Scene * Scene() const
Get a pointer to the Scene associated with this world.
std::vector< Error > Errors
A vector of Error.
Definition Types.hh:89
std::shared_ptr< Element > ElementPtr
Definition Element.hh:53
namespace for Simulation Description Format parser
Definition Actor.hh:33
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition system_util.hh:48