Gazebo Gazebo

API Reference

3.15.2

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::EntityActors (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::Vector3dGravity (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::EntityLights (const EntityComponentManager &_ecm) const
 Get all lights which are immediate children of this world. More...
 
std::optional< math::Vector3dMagneticField (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::EntityModels (const EntityComponentManager &_ecm) const
 Get all models which are immediate children of this world. More...
 
std::optional< std::stringName (const EntityComponentManager &_ecm) const
 Get the world's unscoped name. More...
 
Worldoperator= (const World &_world)
 Copy assignment operator. More...
 
Worldoperator= (World &&_world) noexcept
 Move assignment operator. 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]

World ( gz::sim::Entity  _entity = kNullEntity)
explicit

Constructor.

Parameters
[in]_entityWorld entity

◆ World() [2/3]

World ( const World _world)

Copy constructor.

Parameters
[in]_worldWorld to copy.

◆ World() [3/3]

World ( World &&  _world)
noexcept

Move constructor.

Parameters
[in]_worldWorld to move.

◆ ~World()

virtual ~World ( )
virtual

Destructor.

Member Function Documentation

◆ ActorByName()

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.

Parameters
[in]_ecmEntity-component manager.
[in]_nameActor name.
Returns
Actor entity.

◆ ActorCount()

uint64_t ActorCount ( const EntityComponentManager _ecm) const

Get the number of actors which are immediate children of this world.

Parameters
[in]_ecmEntity-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]_ecmEntity-component manager.
Returns
All actors in this world.

◆ Atmosphere()

std::optional<sdf::Atmosphere> Atmosphere ( const EntityComponentManager _ecm) const

Get atmosphere information.

Parameters
[in]_ecmEntity-component manager.
Returns
Magnetic field vector or nullopt if the entity does not have a components::Atmosphere component.

◆ Entity()

Get the entity which this World is related to.

Returns
World entity.

◆ Gravity()

std::optional<math::Vector3d> Gravity ( const EntityComponentManager _ecm) const

Get the gravity in m/s^2.

Parameters
[in]_ecmEntity-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

Get the ID of a light entity which is an immediate child of this world.

Parameters
[in]_ecmEntity-component manager.
[in]_nameLight name.
Returns
Light entity.

◆ LightCount()

uint64_t LightCount ( const EntityComponentManager _ecm) const

Get the number of lights which are immediate children of this world.

Parameters
[in]_ecmEntity-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]_ecmEntity-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]_ecmEntity-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

Get the ID of a model entity which is an immediate child of this world.

Parameters
[in]_ecmEntity-component manager.
[in]_nameModel name.
Returns
Model entity.

◆ ModelCount()

uint64_t ModelCount ( const EntityComponentManager _ecm) const

Get the number of models which are immediate children of this world.

Parameters
[in]_ecmEntity-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]_ecmEntity-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]_ecmEntity-component manager.
Returns
World's name or nullopt if the entity does not have a components::Name component

◆ operator=() [1/2]

World& operator= ( const World _world)

Copy assignment operator.

Parameters
[in]_worldWorld to copy.
Returns
Reference to this.

◆ operator=() [2/2]

World& operator= ( World &&  _world)
noexcept

Move assignment operator.

Parameters
[in]_worldWorld component to move.
Returns
Reference to this.

◆ Valid()

bool Valid ( const EntityComponentManager _ecm) const

Check whether this world correctly refers to an entity that has a components::World.

Parameters
[in]_ecmEntity-component manager.
Returns
True if it's a valid world in the manager.

The documentation for this class was generated from the following file: