ModelState Class Reference

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

#include <physics/physics.hh>

Inherits State.

Public Member Functions

 ModelState ()
 Default constructor. More...
 
 ModelState (const ModelPtr _model, const common::Time &_realTime, const common::Time &_simTime, const uint64_t _iterations)
 Constructor. More...
 
 ModelState (const ModelPtr _model)
 Constructor. More...
 
 ModelState (const sdf::ElementPtr _sdf)
 Constructor. More...
 
virtual ~ModelState ()
 Destructor. 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...
 
JointState GetJointState (unsigned int _index) const
 Get a Joint state. More...
 
JointState GetJointState (const std::string &_jointName) const
 Get a Joint state by Joint name. More...
 
unsigned int GetJointStateCount () const
 Get the number of joint states. More...
 
JointState_M GetJointStates (const boost::regex &_regex) const
 Get joint states based on a regular expression. More...
 
const JointState_MGetJointStates () const
 Get the joint states. More...
 
LinkState GetLinkState (const std::string &_linkName) const
 Get a link state by Link name. More...
 
unsigned int GetLinkStateCount () const
 Get the number of link states. More...
 
LinkState_M GetLinkStates (const boost::regex &_regex) const
 Get link states based on a regular expression. More...
 
const LinkState_MGetLinkStates () const
 Get the link states. More...
 
std::string GetName () const
 Get the name associated with this State. More...
 
const math::Pose GetPose () const GAZEBO_DEPRECATED(8.0)
 Get the stored model pose. 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 HasJointState (const std::string &_jointName) const
 Return true if there is a joint with the specified name. More...
 
bool HasLinkState (const std::string &_linkName) const
 Return true if there is a link with the specified name. More...
 
bool HasNestedModelState (const std::string &_modelName) const
 Return true if there is a nested model with the specified name. More...
 
bool IsZero () const
 Return true if the values in the state are zero. More...
 
void Load (const ModelPtr _model, const common::Time &_realTime, const common::Time &_simTime, const uint64_t _iterations)
 Load state from Model pointer. More...
 
virtual void Load (const sdf::ElementPtr _elem)
 Load state from SDF element. More...
 
ModelState NestedModelState (const std::string &_modelName) const
 Get a model state by model name. More...
 
unsigned int NestedModelStateCount () const
 Get the number of model states. More...
 
const ModelState_MNestedModelStates () const
 Get the nested model states. More...
 
ModelState operator+ (const ModelState &_state) const
 Addition operator. More...
 
State operator- (const State &_state) const
 Subtraction operator. More...
 
ModelState operator- (const ModelState &_state) const
 Subtraction operator. More...
 
ModelStateoperator= (const ModelState &_state)
 Assignment operator. More...
 
const ignition::math::Pose3d & Pose () const
 Get the stored model pose. More...
 
const ignition::math::Vector3d & Scale () const
 Get the stored model scale. More...
 
virtual void SetIterations (const uint64_t _iterations)
 Set the simulation iterations 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...
 

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::ModelState &_state)
 Stream insertion operator. More...
 

Detailed Description

Store state information of a physics::Model object.

This class captures the entire state of a Model at one specific time during a simulation run.

State of a Model includes the state of all its child Links and Joints.

Constructor & Destructor Documentation

Default constructor.

ModelState ( const ModelPtr  _model,
const common::Time _realTime,
const common::Time _simTime,
const uint64_t  _iterations 
)

Constructor.

Build a ModelState from an existing Model.

Parameters
[in]_modelPointer to the model from which to gather state info.
[in]_realTimeReal time stamp.
[in]_simTimeSim time stamp.
[in]_iterationsSimulation iterations.
ModelState ( const ModelPtr  _model)
explicit

Constructor.

Build a ModelState from an existing Model.

Parameters
[in]_modelPointer to the model from which to gather state info.
ModelState ( const sdf::ElementPtr  _sdf)
explicit

Constructor.

Build a ModelState from SDF data

Parameters
[in]_sdfSDF data to load a model state from.
virtual ~ModelState ( )
virtual

Destructor.

Member Function Documentation

void FillSDF ( sdf::ElementPtr  _sdf)

Populate a state SDF element with data from the object.

Parameters
[out]_sdfSDF element to populate.
uint64_t GetIterations ( ) const
inherited

Get the iterations when this state was generated.

Returns
Iterations when the data was recorded
JointState GetJointState ( unsigned int  _index) const

Get a Joint state.

Return a JointState based on a index, where index is between 0...ModelState::GetJointStateCount().

Parameters
[in]_indexIndex of a JointState.
Returns
State of a Joint.
Exceptions
common::ExceptionWhen _index is out of range.
JointState GetJointState ( const std::string &  _jointName) const

Get a Joint state by Joint name.

Searches through all JointStates. Returns the JointState with the matching name, if any.

Parameters
[in]_jointNameName of the JointState.
Returns
State of the Joint.
Exceptions
common::ExceptionWhen _jointName is invalid.
unsigned int GetJointStateCount ( ) const

Get the number of joint states.

Returns the number of JointStates recorded.

Returns
Number of JointStates.
JointState_M GetJointStates ( const boost::regex &  _regex) const

Get joint states based on a regular expression.

Parameters
[in]_regexThe regular expression.
Returns
List of joint states whose names match the regular expression.
const JointState_M& GetJointStates ( ) const

Get the joint states.

Returns
A map of joint states.
LinkState GetLinkState ( const std::string &  _linkName) const

Get a link state by Link name.

Searches through all LinkStates. Returns the LinkState with the matching name, if any.

Parameters
[in]_linkNameName of the LinkState
Returns
State of the Link.
Exceptions
common::ExceptionWhen _linkName is invalid.
unsigned int GetLinkStateCount ( ) const

Get the number of link states.

This returns the number of Links recorded.

Returns
Number of LinkState recorded.
LinkState_M GetLinkStates ( const boost::regex &  _regex) const

Get link states based on a regular expression.

Parameters
[in]_regexThe regular expression.
Returns
List of link states whose names match the regular expression.
const LinkState_M& GetLinkStates ( ) const

Get the link states.

Returns
A map of link states.
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.
const math::Pose GetPose ( ) const

Get the stored model pose.

Returns
The gazebo::math::Pose of the Model.
Deprecated:
See function that returns ign-math.
common::Time GetRealTime ( ) const
inherited

Get the real time when this state was generated.

Returns
Clock time since simulation was stated.
common::Time GetSimTime ( ) const
inherited

Get the sim time when this state was generated.

Returns
Simulation time when the data was recorded.
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.
bool HasJointState ( const std::string &  _jointName) const

Return true if there is a joint with the specified name.

Parameters
[in]_jointNameName of the Jointtate.
Returns
True if the joint exists in the model.
bool HasLinkState ( const std::string &  _linkName) const

Return true if there is a link with the specified name.

Parameters
[in]_linkNameName of the LinkState.
Returns
True if the link exists in the model.
bool HasNestedModelState ( const std::string &  _modelName) const

Return true if there is a nested model with the specified name.

Parameters
[in]_modelNameName of the model state.
Returns
True if the model exists in this model state.
bool IsZero ( ) const

Return true if the values in the state are zero.

Returns
True if the values in the state are zero.
void Load ( const ModelPtr  _model,
const common::Time _realTime,
const common::Time _simTime,
const uint64_t  _iterations 
)

Load state from Model pointer.

Build a ModelState from an existing Model.

Parameters
[in]_modelPointer to the model from which to gather state info.
[in]_realTimeReal time stamp.
[in]_simTimeSim time stamp.
[in]_iterationsSimulation iterations.
virtual void Load ( const sdf::ElementPtr  _elem)
virtual

Load state from SDF element.

Load ModelState information from stored data in and SDF::Element

Parameters
[in]_elemPointer to the SDF::Element containing state info.

Reimplemented from State.

ModelState NestedModelState ( const std::string &  _modelName) const

Get a model state by model name.

Searches through all nested model states. Returns the model state with the matching name, if any.

Parameters
[in]_modelNameName of the model state
Returns
State of the Model.
Exceptions
common::ExceptionWhen _modelName is invalid.
unsigned int NestedModelStateCount ( ) const

Get the number of model states.

This returns the number of nested model states recorded.

Returns
Number of nested ModelState recorded.
const ModelState_M& NestedModelStates ( ) const

Get the nested model states.

Returns
A map of model names to model states.
ModelState operator+ ( const ModelState _state) const

Addition operator.

Parameters
[in]_ptA state to substract.
Returns
The resulting state.
State operator- ( const State _state) const
inherited

Subtraction operator.

Parameters
[in]_ptA state to substract.
Returns
The resulting state.
ModelState operator- ( const ModelState _state) const

Subtraction operator.

Parameters
[in]_ptA state to substract.
Returns
The resulting state.
ModelState& operator= ( const ModelState _state)

Assignment operator.

Parameters
[in]_stateState value
Returns
this
const ignition::math::Pose3d& Pose ( ) const

Get the stored model pose.

Returns
The ignition::math::Pose3d of the Model.
const ignition::math::Vector3d& Scale ( ) const

Get the stored model scale.

Returns
The scale of the Model.
virtual void SetIterations ( const uint64_t  _iterations)
virtual

Set the simulation iterations when this state was generated.

Parameters
[in]_iterationsSimulation iterations when the data was recorded.

Reimplemented from State.

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

Set the name associated with this State.

Parameters
[in]_nameName associated with this state information. Typically the name of an Entity.
virtual void SetRealTime ( const common::Time _time)
virtual

Set the real time when this state was generated.

Parameters
[in]_timeClock time since simulation was stated.

Reimplemented from State.

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

Set the sim time when this state was generated.

Parameters
[in]_timeSimulation time when the data was recorded.

Reimplemented from State.

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

Set the wall time when this state was generated.

Parameters
[in]_timeThe absolute clock time when the State data was recorded.

Reimplemented from State.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  _out,
const gazebo::physics::ModelState _state 
)
friend

Stream insertion operator.

Parameters
[in]_outoutput stream.
[in]_stateModel state to output.
Returns
The stream.

Member Data Documentation

uint64_t iterations = 0
protectedinherited

The number of simulation iterations when this state was generated.

std::string name
protectedinherited

Name associated with this State.

common::Time realTime
protectedinherited
common::Time simTime
protectedinherited
common::Time wallTime
protectedinherited

Times for the state data.


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