##

WorldState Class Reference
Physics

Store state information of a physics::World object. More...

`#include <physics/physics.hh>`

Inherits State.

## Public Member Functions

| WorldState ()
| Default constructor. More...
| WorldState (const sdf::ElementPtr _sdf)
| Constructor. More...
| WorldState (const WorldPtr _world)
| Constructor. More...
virtual | ~WorldState ()
| Destructor. More...
const std::vector< std::string > & | Deletions () const
| Get the vector of SDF deletions. More...
void | FillSDF (sdf::ElementPtr _sdf)
| Populate a state SDF element with data from the object. More...
uint64_t | GetIterations () const
| Get the iterations when this state was generated. More...
LightState | GetLightState (const std::string &_lightName) const
| Get a light state by light name. More...
ModelState | GetModelState (const std::string &_modelName) const
| Get a model state by model name. More...
unsigned int | GetModelStateCount () const
| Get the number of model states. More...
const ModelState_M & | GetModelStates () const
| Get the model states. More...
ModelState_M | GetModelStates (const boost::regex &_regex) const
| Get model states based on a regular expression. More...
std::string | GetName () const
| Get the name associated with this State. More...
common::Time | GetRealTime () const
| Get the real time when this state was generated. More...
common::Time | GetSimTime () const
| Get the sim time when this state was generated. More...
common::Time | GetWallTime () const
| Get the wall time when this state was generated. More...
bool | HasLightState (const std::string &_lightName) const
| Return true if WorldState has a LightState with the given name. More...
bool | HasModelState (const std::string &_modelName) const
| Return true if WorldState has a ModelState with the given name. More...
const std::vector< std::string > & | Insertions () const
| Get the vector of SDF insertions. More...
bool | IsZero () const
| Return true if the values in the state are zero. More...
unsigned int | LightStateCount () const
| Get the number of light states. More...
const LightState_M & | LightStates () const
| Get the light states. More...
virtual void | Load (const sdf::ElementPtr _elem)
| Load state from SDF element. More...
void | Load (const WorldPtr _world)
| Load from a World pointer. More...
void | LoadWithFilter (const WorldPtr _world, const std::string &_filter)
| Load from a World pointer. More...
WorldState | operator+ (const WorldState &_state) const
| Addition operator. More...
State | operator- (const State &_state) const
| Subtraction operator. More...
WorldState | operator- (const WorldState &_state) const
| Subtraction operator. More...
WorldState & | operator= (const WorldState &_state)
| Assignment operator. More...
void | SetDeletions (const std::vector< std::string > &_deletions)
| Set a new vector of SDF deletions. More...
void | SetInsertions (const std::vector< std::string > &_insertions)
| Set a new vector of SDF insertions. More...
virtual void | SetIterations (const uint64_t _iterations)
| Set the simulation interations when this state was generated. More...
void | SetName (const std::string &_name)
| Set the name associated with this State. More...
virtual void | SetRealTime (const common::Time &_time)
| Set the real time when this state was generated. More...
virtual void | SetSimTime (const common::Time &_time)
| Set the sim time when this state was generated. More...
virtual void | SetWallTime (const common::Time &_time)
| Set the wall time when this state was generated. More...
void | SetWorld (const WorldPtr _world)
| Set the world. More...

## Protected Attributes

uint64_t | iterations = 0
| The number of simulation iterations when this state was generated. More...
std::string | name
| Name associated with this State. More...
common::Time | realTime
common::Time | simTime
common::Time | wallTime
| Times for the state data. More...

## Friends

std::ostream & | operator<< (std::ostream &_out, const gazebo::physics::WorldState &_state)
| Stream insertion operator. More...

## Detailed Description

Store state information of a physics::World object.

Instances of this class contain the state of a World at a specific time. World state includes the state of all models, and their children.

## Constructor & Destructor Documentation

## WorldState() [1/3]

WorldState | ( |  | ) |

Default constructor.

## WorldState() [2/3]

WorldState | ( | const WorldPtr | _world | ) |

explicit

Constructor.

Generate a WorldState from an instance of a World.

Parameters

  [in] | _world | Pointer to a world

## WorldState() [3/3]

WorldState | ( | const sdf::ElementPtr | _sdf | ) |

explicit

Constructor.

Build a WorldState from SDF data

Parameters

  [in] | _sdf | SDF data to load a world state from.

## ~WorldState()

virtual ~WorldState | ( |  | ) |

virtual

Destructor.

## Member Function Documentation

## Deletions()

const std::vector<std::string>& Deletions | ( |  | ) | const

Get the vector of SDF deletions.

Returns
  A vector containing the names of entities deleted in the current state.

## FillSDF()

void FillSDF | ( | sdf::ElementPtr | _sdf | ) |

Populate a state SDF element with data from the object.

Parameters

  [out] | _sdf | SDF element to populate.

## GetIterations()

uint64_t GetIterations | ( |  | ) | const

inherited

Get the iterations when this state was generated.

Returns
  Iterations when the data was recorded

## GetLightState()

LightState GetLightState | ( | const std::string & | _lightName | ) | const

Get a light state by light name.

Parameters

  [in] | _lightName | Name of the light state to get.

Returns
  The light state.

Exceptions

  common::Exception | When the _lightName doesn't exist.

## GetModelState()

ModelState GetModelState | ( | const std::string & | _modelName | ) | const

Get a model state by model name.

Parameters

  [in] | _modelName | Name of the model state to get.

Returns
  The model state.

Exceptions

  common::Exception | When the _modelName doesn't exist.

## GetModelStateCount()

unsigned int GetModelStateCount | ( |  | ) | const

Get the number of model states.

Returns the number of models in this instance.

Returns
  Number of models.

## GetModelStates() [1/2]

const ModelState_M& GetModelStates | ( |  | ) | const

Get the model states.

Returns
  A vector of model states.

## GetModelStates() [2/2]

ModelState_M GetModelStates | ( | const boost::regex & | _regex | ) | const

Get model states based on a regular expression.

Parameters

  [in] | _regex | The regular expression.

Returns
  List of model states whose names match the regular expression.

## GetName()

std::string GetName | ( |  | ) | const

inherited

Get the name associated with this State.

Returns
  Name associated with this state information. Typically a name of an Entity.

## GetRealTime()

common::Time GetRealTime | ( |  | ) | const

inherited

Get the real time when this state was generated.

Returns
  Clock time since simulation was stated.

## GetSimTime()

common::Time GetSimTime | ( |  | ) | const

inherited

Get the sim time when this state was generated.

Returns
  Simulation time when the data was recorded.

## GetWallTime()

common::Time GetWallTime | ( |  | ) | const

inherited

Get the wall time when this state was generated.

Returns
  The absolute clock time when the State data was recorded.

## HasLightState()

bool HasLightState | ( | const std::string & | _lightName | ) | const

Return true if WorldState has a LightState with the given name.

Parameters

  [in] | _lightName | Name of the light to search for.

Returns
  True if the LightState exists.

## HasModelState()

bool HasModelState | ( | const std::string & | _modelName | ) | const

Return true if WorldState has a ModelState with the given name.

Parameters

  [in] | _modelName | Name of the model to search for.

Returns
  True if the ModelState exists.

## Insertions()

const std::vector<std::string>& Insertions | ( |  | ) | const

Get the vector of SDF insertions.

Returns
  A vector of SDF blocks. Each block contains the SDF of the model to be spawned in the simulation, without the <sdf> tag wrapping it.

## IsZero()

bool IsZero | ( |  | ) | const

Return true if the values in the state are zero.

This will check to see if the all model states are zero.

Returns
  True if the values in the state are zero.

## LightStateCount()

unsigned int LightStateCount | ( |  | ) | const

Get the number of light states.

Returns the number of lights in this instance.

Returns
  Number of lights.

## LightStates()

const LightState_M& LightStates | ( |  | ) | const

Get the light states.

Returns
  A vector of light states.

## Load() [1/2]

virtual void Load | ( | const sdf::ElementPtr | _elem | ) |

virtual

Load state from SDF element.

Set a WorldState from an SDF element containing WorldState info.

Parameters

  [in] | _elem | Pointer to the WorldState SDF element.

Reimplemented from State.

## Load() [2/2]

void Load | ( | const WorldPtr | _world | ) |

Load from a World pointer.

Generate a WorldState from an instance of a World.

Parameters

  [in] | _world | Pointer to a world

## LoadWithFilter()

void LoadWithFilter | ( | const WorldPtr | _world,
|  | const std::string & | _filter
| ) |  |

Load from a World pointer.

Generate a WorldState from an instance of a World.

Parameters

  [in] | _world | Pointer to a world
  [in] | _filter | String for filtering models states

## operator+()

WorldState operator+ | ( | const WorldState & | _state | ) | const

Addition operator.

Parameters

  [in] | _pt | A state to add.

Returns
  The resulting state.

## operator-() [1/2]

State operator- | ( | const State & | _state | ) | const

inherited

Subtraction operator.

Parameters

  [in] | _pt | A state to substract.

Returns
  The resulting state.

## operator-() [2/2]

WorldState operator- | ( | const WorldState & | _state | ) | const

Subtraction operator.

Parameters

  [in] | _pt | A state to substract.

Returns
  The resulting state.

## operator=()

WorldState& operator= | ( | const WorldState & | _state | ) |

Assignment operator.

Parameters

  [in] | _state | State value

Returns
  Reference to this

## SetDeletions()

void SetDeletions | ( | const std::vector< std::string > & | _deletions | ) |

Set a new vector of SDF deletions.

Parameters

  [in] | _deletions | Vector containing names of entities removed in the current simulation frame.

## SetInsertions()

void SetInsertions | ( | const std::vector< std::string > & | _insertions | ) |

Set a new vector of SDF insertions.

Parameters

  [in] | _insertions | Vector containing SDF blocks. Each block should contain the SDF of the new model, light or actor spawned in the current simulation frame. The block could either come wrapped in an <sdf> tag or not.

## SetIterations()

virtual void SetIterations | ( | const uint64_t | _iterations | ) |

virtual

Set the simulation interations when this state was generated.

Parameters

  [in] | _iterations | Simulation iterations when the data was recorded.

Reimplemented from State.

## SetName()

void SetName | ( | const std::string & | _name | ) |

inherited

Set the name associated with this State.

Parameters

  [in] | _name | Name associated with this state information. Typically the name of an Entity.

## SetRealTime()

virtual void SetRealTime | ( | const common::Time & | _time | ) |

virtual

Set the real time when this state was generated.

Parameters

  [in] | _time | Clock time since simulation was stated.

Reimplemented from State.

## SetSimTime()

virtual void SetSimTime | ( | const common::Time & | _time | ) |

virtual

Set the sim time when this state was generated.

Parameters

  [in] | _time | Simulation time when the data was recorded.

Reimplemented from State.

## SetWallTime()

virtual void SetWallTime | ( | const common::Time & | _time | ) |

virtual

Set the wall time when this state was generated.

Parameters

  [in] | _time | The absolute clock time when the State data was recorded.

Reimplemented from State.

## SetWorld()

void SetWorld | ( | const WorldPtr | _world | ) |

Set the world.

Parameters

  [in] | _world | Pointer to the world.

## Friends And Related Function Documentation

## operator<<

std::ostream& operator<< | ( | std::ostream & | _out,
|  | const gazebo::physics::WorldState & | _state
| ) |  |

friend

Stream insertion operator.

Parameters

  [in] | _out | output stream
  [in] | _state | World state to output

Returns
  the stream

## Member Data Documentation

## iterations

uint64_t iterations = 0

protected inherited

The number of simulation iterations when this state was generated.

## name

std::string name

protected inherited

Name associated with this State.

## realTime

common::Time realTime

protected inherited

## simTime

common::Time simTime

protected inherited

## wallTime

common::Time wallTime

protected inherited

Times for the state data.

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

- WorldState.hh