This class provides wrappers around entities and components which are more convenient and straight-forward to use than dealing with the EntityComponentManager
directly. All the functions provided here are meant to be used with a world entity.
More...
#include <ignition/gazebo/World.hh>
Public Member Functions | |
World (const World &_world) | |
Copy constructor. More... | |
World (gz::sim::Entity _entity=kNullEntity) | |
Constructor. More... | |
World (World &&_world) noexcept | |
Move constructor. More... | |
virtual | ~World () |
Destructor. More... | |
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. More... | |
uint64_t | ActorCount (const EntityComponentManager &_ecm) const |
Get the number of actors which are immediate children of this world. More... | |
std::vector< gz::sim::Entity > | Actors (const EntityComponentManager &_ecm) const |
Get all actors which are immediate children of this world. More... | |
std::optional< sdf::Atmosphere > | Atmosphere (const EntityComponentManager &_ecm) const |
Get atmosphere information. More... | |
gz::sim::Entity | Entity () const |
Get the entity which this World is related to. More... | |
std::optional< math::Vector3d > | Gravity (const EntityComponentManager &_ecm) const |
Get the gravity in m/s^2. More... | |
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. More... | |
uint64_t | LightCount (const EntityComponentManager &_ecm) const |
Get the number of lights which are immediate children of this world. More... | |
std::vector< gz::sim::Entity > | Lights (const EntityComponentManager &_ecm) const |
Get all lights which are immediate children of this world. More... | |
std::optional< math::Vector3d > | MagneticField (const EntityComponentManager &_ecm) const |
Get the magnetic field in Tesla. More... | |
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. More... | |
uint64_t | ModelCount (const EntityComponentManager &_ecm) const |
Get the number of models which are immediate children of this world. More... | |
std::vector< gz::sim::Entity > | Models (const EntityComponentManager &_ecm) const |
Get all models which are immediate children of this world. More... | |
std::optional< std::string > | Name (const EntityComponentManager &_ecm) const |
Get the world's unscoped name. More... | |
World & | operator= (const World &_world) |
Copy assignment operator. More... | |
World & | operator= (World &&_world) noexcept |
Move assignment operator. More... | |
void | SetSphericalCoordinates (EntityComponentManager &_ecm, const math::SphericalCoordinates &_sphericalCoordinates) |
Set spherical coordinates for the world origin. More... | |
std::optional< math::SphericalCoordinates > | SphericalCoordinates (const EntityComponentManager &_ecm) const |
Get spherical coordinates for the world origin. More... | |
bool | Valid (const EntityComponentManager &_ecm) const |
Check whether this world correctly refers to an entity that has a components::World. More... | |
Detailed Description
This class provides wrappers around entities and components which are more convenient and straight-forward to use than dealing with the EntityComponentManager
directly. All the functions provided here are meant to be used with a world entity.
For example, given a world's entity, to find the value of its name component, one could use the entity-component manager (ecm
) directly as follows:
std::string name = ecm.Component<components::Name>(entity)->Data();
Using this class however, the same information can be obtained with a simpler function call:
World world(entity); std::string name = world.Name(ecm);
Constructor & Destructor Documentation
◆ World() [1/3]
|
explicit |
Constructor.
- Parameters
-
[in] _entity World entity
◆ World() [2/3]
◆ World() [3/3]
◆ ~World()
|
virtual |
Destructor.
Member Function Documentation
◆ ActorByName()
gz::sim::Entity ActorByName | ( | const EntityComponentManager & | _ecm, |
const std::string & | _name | ||
) | const |
◆ ActorCount()
uint64_t ActorCount | ( | const EntityComponentManager & | _ecm | ) | const |
Get the number of actors which are immediate children of this world.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Number of actors in this world.
◆ Actors()
std::vector<gz::sim::Entity> Actors | ( | const EntityComponentManager & | _ecm | ) | const |
Get all actors which are immediate children of this world.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- All actors in this world.
◆ Atmosphere()
std::optional<sdf::Atmosphere> Atmosphere | ( | const EntityComponentManager & | _ecm | ) | const |
Get atmosphere information.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Atmosphere or nullopt if the entity does not have a components::Atmosphere component.
◆ Entity()
gz::sim::Entity Entity | ( | ) | const |
◆ Gravity()
std::optional<math::Vector3d> Gravity | ( | const EntityComponentManager & | _ecm | ) | const |
Get the gravity in m/s^2.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Gravity vector or nullopt if the entity does not have a components::Gravity component.
◆ LightByName()
gz::sim::Entity LightByName | ( | const EntityComponentManager & | _ecm, |
const std::string & | _name | ||
) | const |
◆ LightCount()
uint64_t LightCount | ( | const EntityComponentManager & | _ecm | ) | const |
Get the number of lights which are immediate children of this world.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Number of lights in this world.
◆ Lights()
std::vector<gz::sim::Entity> Lights | ( | const EntityComponentManager & | _ecm | ) | const |
Get all lights which are immediate children of this world.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- All lights in this world.
◆ MagneticField()
std::optional<math::Vector3d> MagneticField | ( | const EntityComponentManager & | _ecm | ) | const |
Get the magnetic field in Tesla.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Magnetic field vector or nullopt if the entity does not have a components::MagneticField component.
◆ ModelByName()
gz::sim::Entity ModelByName | ( | const EntityComponentManager & | _ecm, |
const std::string & | _name | ||
) | const |
◆ ModelCount()
uint64_t ModelCount | ( | const EntityComponentManager & | _ecm | ) | const |
Get the number of models which are immediate children of this world.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Number of models in this world.
◆ Models()
std::vector<gz::sim::Entity> Models | ( | const EntityComponentManager & | _ecm | ) | const |
Get all models which are immediate children of this world.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- All models in this world.
◆ Name()
std::optional<std::string> Name | ( | const EntityComponentManager & | _ecm | ) | const |
Get the world's unscoped name.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- World's name or nullopt if the entity does not have a components::Name component
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ SetSphericalCoordinates()
void SetSphericalCoordinates | ( | EntityComponentManager & | _ecm, |
const math::SphericalCoordinates & | _sphericalCoordinates | ||
) |
Set spherical coordinates for the world origin.
- Parameters
-
[in] _ecm Entity-component manager. [in] _sphericalCoordinates New spherical coordinates.
◆ SphericalCoordinates()
std::optional<math::SphericalCoordinates> SphericalCoordinates | ( | const EntityComponentManager & | _ecm | ) | const |
Get spherical coordinates for the world origin.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- Spherical coordinates or nullopt if the entity does not have a components::SphericalCoordinates component.
◆ Valid()
bool Valid | ( | const EntityComponentManager & | _ecm | ) | const |
Check whether this world correctly refers to an entity that has a components::World.
- Parameters
-
[in] _ecm Entity-component manager.
- Returns
- True if it's a valid world in the manager.
The documentation for this class was generated from the following file: