Gazebo Gazebo

API Reference

3.15.1
gz/sim/World.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 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 GZ_GAZEBO_WORLD_HH_
18 #define GZ_GAZEBO_WORLD_HH_
19 
20 #include <memory>
21 #include <string>
22 #include <vector>
23 
24 #include <sdf/Atmosphere.hh>
25 #include <gz/math/Vector3.hh>
26 
27 #include "gz/sim/config.hh"
29 #include "gz/sim/Export.hh"
30 #include "gz/sim/Types.hh"
31 
32 namespace ignition
33 {
34  namespace gazebo
35  {
36  // Inline bracket to help doxygen filtering.
37  inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
38  // Forward declarations.
39  class IGNITION_GAZEBO_HIDDEN WorldPrivate;
40  //
59  class IGNITION_GAZEBO_VISIBLE World {
62  public: explicit World(gz::sim::Entity _entity = kNullEntity);
63 
66  public: World(const World &_world);
67 
70  public: World(World &&_world) noexcept;
71 
75  public: World &operator=(World &&_world) noexcept;
76 
80  public: World &operator=(const World &_world);
81 
83  public: virtual ~World();
84 
87  public: gz::sim::Entity Entity() const;
88 
93  public: bool Valid(const EntityComponentManager &_ecm) const;
94 
99  public: std::optional<std::string> Name(
100  const EntityComponentManager &_ecm) const;
101 
106  public: std::optional<math::Vector3d> Gravity(
107  const EntityComponentManager &_ecm) const;
108 
113  public: std::optional<math::Vector3d> MagneticField(
114  const EntityComponentManager &_ecm) const;
115 
120  public: std::optional<sdf::Atmosphere> Atmosphere(
121  const EntityComponentManager &_ecm) const;
122 
128  public: gz::sim::Entity LightByName(const EntityComponentManager &_ecm,
129  const std::string &_name) const;
130 
136  public: gz::sim::Entity ActorByName(const EntityComponentManager &_ecm,
137  const std::string &_name) const;
138 
144  public: gz::sim::Entity ModelByName(const EntityComponentManager &_ecm,
145  const std::string &_name) const;
146 
150  public: std::vector<gz::sim::Entity> Lights(
151  const EntityComponentManager &_ecm) const;
152 
156  public: std::vector<gz::sim::Entity> Actors(
157  const EntityComponentManager &_ecm) const;
158 
162  public: std::vector<gz::sim::Entity> Models(
163  const EntityComponentManager &_ecm) const;
164 
169  public: uint64_t LightCount(const EntityComponentManager &_ecm) const;
170 
175  public: uint64_t ActorCount(const EntityComponentManager &_ecm) const;
176 
181  public: uint64_t ModelCount(const EntityComponentManager &_ecm) const;
182 
184  private: std::unique_ptr<WorldPrivate> dataPtr;
185  };
186  }
187  }
188 }
189 #endif
virtual ~World()
Destructor.
World & operator=(World &&_world) noexcept
Move assignment operator.
uint64_t Entity
An Entity identifies a single object in simulation such as a model, link, or light....
Definition: gz/sim/Entity.hh:59
This library is part of the Ignition Robotics project.
STL class.
The EntityComponentManager constructs, deletes, and returns components and entities....
Definition: gz/sim/EntityComponentManager.hh:65
gz::sim::Entity LightByName(const EntityComponentManager &_ecm, const std::string &_name) const
Get the ID of a light entity which is an immediate child of this world.
bool Valid(const EntityComponentManager &_ecm) const
Check whether this world correctly refers to an entity that has a components::World.
std::optional< std::string > Name(const EntityComponentManager &_ecm) const
Get the world's unscoped name.
uint64_t ActorCount(const EntityComponentManager &_ecm) const
Get the number of actors which are immediate children of this world.
STL class.
Component< NoData, class WorldTag > World
A component that identifies an entity as being a world.
Definition: gz/sim/components/World.hh:35
gz::sim::Entity ActorByName(const EntityComponentManager &_ecm, const std::string &_name) const
Get the ID of a actor entity which is an immediate child of this world.
uint64_t ModelCount(const EntityComponentManager &_ecm) const
Get the number of models which are immediate children of this world.
std::vector< gz::sim::Entity > Actors(const EntityComponentManager &_ecm) const
Get all actors which are immediate children of this world.
std::optional< math::Vector3d > MagneticField(const EntityComponentManager &_ecm) const
Get the magnetic field in Tesla.
Component< math::Vector3d, class MagneticFieldTag > MagneticField
Stores the 3D magnetic field in teslas.
Definition: gz/sim/components/MagneticField.hh:37
Component< std::string, class NameTag > Name
This component holds an entity's name. The component has no concept of scoped names nor does it care ...
Definition: gz/sim/components/Name.hh:35
class IGNITION_GAZEBO_HIDDEN WorldPrivate
Definition: gz/sim/World.hh:39
gz::sim::Entity ModelByName(const EntityComponentManager &_ecm, const std::string &_name) const
Get the ID of a model entity which is an immediate child of this world.
std::vector< gz::sim::Entity > Models(const EntityComponentManager &_ecm) const
Get all models which are immediate children of this world.
const Entity kNullEntity
Indicates a non-existant or invalid Entity.
Definition: gz/sim/Entity.hh:62
Component< sdf::Atmosphere, class AtmosphereTag, serializers::AtmosphereSerializer > Atmosphere
This component holds atmosphere properties of the world.
Definition: gz/sim/components/Atmosphere.hh:44
uint64_t LightCount(const EntityComponentManager &_ecm) const
Get the number of lights which are immediate children of this world.
Component< math::Vector3d, class GravityTag > Gravity
Store the gravity acceleration.
Definition: gz/sim/components/Gravity.hh:37
This class provides wrappers around entities and components which are more convenient and straight-fo...
Definition: gz/sim/World.hh:59
std::optional< sdf::Atmosphere > Atmosphere(const EntityComponentManager &_ecm) const
Get atmosphere information.
World(gz::sim::Entity _entity=kNullEntity)
Constructor.
gz::sim::Entity Entity() const
Get the entity which this World is related to.
std::vector< gz::sim::Entity > Lights(const EntityComponentManager &_ecm) const
Get all lights which are immediate children of this world.
std::optional< math::Vector3d > Gravity(const EntityComponentManager &_ecm) const
Get the gravity in m/s^2.