The world provides access to all other object within a simulated environment. More...
#include <physics/physics.hh>
Public Member Functions | |
World (const std::string &_name="") | |
Constructor. More... | |
~World () | |
Destructor. More... | |
void | _AddDirty (Entity *_entity) |
void | _SetSensorsInitialized (const bool _init) |
void | Clear () |
Remove all entities from the world. More... | |
void | ClearModels () |
Remove all entities from the world. More... | |
void | DisableAllModels () |
Disable all links in all the models. More... | |
void | EnableAllModels () |
Enable all links in all the models. More... | |
void | EnablePhysicsEngine (bool _enable) |
enable/disable physics engine during World::Update. More... | |
void | Fini () |
Finalize the world. More... | |
BasePtr | GetByName (const std::string &_name) |
Get an element by name. More... | |
bool | GetEnablePhysicsEngine () |
check if physics engine is enabled/disabled. More... | |
EntityPtr | GetEntity (const std::string &_name) |
Get a pointer to an Entity based on a name. More... | |
EntityPtr | GetEntityBelowPoint (const math::Vector3 &_pt) |
Get the nearest entity below a point. More... | |
uint32_t | GetIterations () const |
Get the total number of iterations. More... | |
ModelPtr | GetModel (unsigned int _index) const |
Get a model based on an index. More... | |
ModelPtr | GetModel (const std::string &_name) |
Get a model by name. More... | |
ModelPtr | GetModelBelowPoint (const math::Vector3 &_pt) |
Get the nearest model below and not encapsulating a point. More... | |
unsigned int | GetModelCount () const |
Get the number of models. More... | |
Model_V | GetModels () const |
Get a list of all the models. More... | |
std::string | GetName () const |
Get the name of the world. More... | |
common::Time | GetPauseTime () const |
Get the amount of time simulation has been paused. More... | |
PhysicsEnginePtr | GetPhysicsEngine () const |
Return the physics engine. More... | |
PresetManagerPtr | GetPresetManager () const |
Return the preset manager. More... | |
common::Time | GetRealTime () const |
Get the real time (elapsed time). More... | |
bool | GetRunning () const |
Return the running state of the world. More... | |
msgs::Scene | GetSceneMsg () const |
Get the current scene in message form. More... | |
boost::mutex * | GetSetWorldPoseMutex () const |
Get the set world pose mutex. More... | |
common::Time | GetSimTime () const |
Get the world simulation time, note if you want the PC wall clock call common::Time::GetWallTime. More... | |
common::SphericalCoordinatesPtr | GetSphericalCoordinates () const |
Return the spherical coordinates converter. More... | |
common::Time | GetStartTime () const |
Get the wall time simulation was started. More... | |
ignition::math::Vector3d | Gravity () const |
Return the gravity vector. More... | |
void | Init () |
Initialize the world. More... | |
void | InsertModelFile (const std::string &_sdfFilename) |
Insert a model from an SDF file. More... | |
void | InsertModelSDF (const sdf::SDF &_sdf) |
Insert a model using SDF. More... | |
void | InsertModelString (const std::string &_sdfString) |
Insert a model from an SDF string. More... | |
bool | IsLoaded () const |
Return true if the world has been loaded. More... | |
bool | IsPaused () const |
Returns the state of the simulation true if paused. More... | |
LightPtr | Light (const std::string &_name) |
Get a light by name. More... | |
Light_V | Lights () const |
Get a list of all the lights. More... | |
void | Load (sdf::ElementPtr _sdf) |
Load the world using SDF parameters. More... | |
void | LoadPlugin (const std::string &_filename, const std::string &_name, sdf::ElementPtr _sdf) |
Load a plugin. More... | |
virtual ignition::math::Vector3d | MagneticField () const |
Return the magnetic field vector. More... | |
void | PrintEntityTree () |
Print Entity tree. More... | |
void | PublishLightPose (const physics::LightPtr _light) |
Publish pose updates for a light. More... | |
void | PublishModelPose (physics::ModelPtr _model) |
Publish pose updates for a model. More... | |
void | PublishModelScale (physics::ModelPtr _model) |
Publish scale updates for a model. More... | |
void | RemoveModel (ModelPtr _model) |
Remove a model. More... | |
void | RemoveModel (const std::string &_name) |
Remove a model by name. More... | |
void | RemovePlugin (const std::string &_name) |
Remove a running plugin. More... | |
void | Reset () |
Reset time and model poses, configurations in simulation. More... | |
void | ResetEntities (Base::EntityType _type=Base::BASE) |
Reset with options. More... | |
void | ResetPhysicsStates () |
Reset the velocity, acceleration, force and torque of all child models. More... | |
void | ResetTime () |
Reset simulation time back to zero. More... | |
void | Run (unsigned int _iterations=0) |
Run the world in a thread. More... | |
void | RunBlocking (unsigned int _iterations=0) |
Run the world. More... | |
void | Save (const std::string &_filename) |
Save a world to a file. More... | |
bool | SensorsInitialized () const |
Get whether sensors have been initialized. More... | |
void | SetGravity (const ignition::math::Vector3d &_gravity) |
Set the gravity vector. More... | |
void | SetGravitySDF (const ignition::math::Vector3d &_gravity) |
Set the gravity sdf value. More... | |
void | SetMagneticField (const ignition::math::Vector3d &_mag) |
Set the magnetic field vector. More... | |
void | SetPaused (bool _p) |
Set whether the simulation is paused. More... | |
void | SetSimTime (const common::Time &_t) |
Set the sim time. More... | |
void | SetState (const WorldState &_state) |
Set the current world state. More... | |
void | Step (unsigned int _steps) |
Step the world forward in time. More... | |
void | Stop () |
Stop the world. More... | |
std::string | StripWorldName (const std::string &_name) const |
Return a version of the name with "<world_name>::" removed. More... | |
void | UpdateStateSDF () |
Update the state SDF value from the current state. More... | |
The world provides access to all other object within a simulated environment.
The World is the container for all models and their components (links, joints, sensors, plugins, etc), and WorldPlugin instances. Many core function are also handled in the World, including physics update, model updates, and message processing.
|
explicit |
Constructor.
Constructor for the World. Must specify a unique name.
[in] | _name | Name of the world. |
gazebo::physics::World::~World | ( | ) |
Destructor.
void gazebo::physics::World::_AddDirty | ( | Entity * | _entity | ) |
void gazebo::physics::World::_SetSensorsInitialized | ( | const bool | _init | ) |
void gazebo::physics::World::Clear | ( | ) |
Remove all entities from the world.
This function has delayed effect. Models are cleared at the end of the current update iteration.
void gazebo::physics::World::ClearModels | ( | ) |
Remove all entities from the world.
Implementation of World::Clear
void gazebo::physics::World::DisableAllModels | ( | ) |
Disable all links in all the models.
Disable is a physics concept. Disabling means that the physics engine should not update an entity.
void gazebo::physics::World::EnableAllModels | ( | ) |
Enable all links in all the models.
Enable is a physics concept. Enabling means that the physics engine should update an entity.
void gazebo::physics::World::EnablePhysicsEngine | ( | bool | _enable | ) |
enable/disable physics engine during World::Update.
[in] | _enable | True to enable the physics engine. |
void gazebo::physics::World::Fini | ( | ) |
Finalize the world.
Call this function to tear-down the world.
BasePtr gazebo::physics::World::GetByName | ( | const std::string & | _name | ) |
Get an element by name.
Searches the list of entities, and return a pointer to the model with a matching _name.
[in] | _name | The name of the Model to find. |
bool gazebo::physics::World::GetEnablePhysicsEngine | ( | ) |
check if physics engine is enabled/disabled.
True | if the physics engine is enabled. |
EntityPtr gazebo::physics::World::GetEntity | ( | const std::string & | _name | ) |
EntityPtr gazebo::physics::World::GetEntityBelowPoint | ( | const math::Vector3 & | _pt | ) |
Get the nearest entity below a point.
Projects a Ray down (-Z axis) starting at the given point. The first entity hit by the Ray is returned.
[in] | _pt | The 3D point to search below |
uint32_t gazebo::physics::World::GetIterations | ( | ) | const |
Get the total number of iterations.
ModelPtr gazebo::physics::World::GetModel | ( | unsigned int | _index | ) | const |
Get a model based on an index.
Get a Model using an index, where index must be greater than zero and less than World::GetModelCount()
[in] | _index | The index of the model [0..GetModelCount) |
ModelPtr gazebo::physics::World::GetModel | ( | const std::string & | _name | ) |
ModelPtr gazebo::physics::World::GetModelBelowPoint | ( | const math::Vector3 & | _pt | ) |
Get the nearest model below and not encapsulating a point.
Only objects below the start point can be returned. Any object that encapsulates the start point can not be returned from this function. This function makes use of World::GetEntityBelowPoint.
[in] | _pt | The 3D point to search below. |
unsigned int gazebo::physics::World::GetModelCount | ( | ) | const |
Get the number of models.
Model_V gazebo::physics::World::GetModels | ( | ) | const |
Get a list of all the models.
std::string gazebo::physics::World::GetName | ( | ) | const |
Get the name of the world.
common::Time gazebo::physics::World::GetPauseTime | ( | ) | const |
Get the amount of time simulation has been paused.
PhysicsEnginePtr gazebo::physics::World::GetPhysicsEngine | ( | ) | const |
Return the physics engine.
Get a pointer to the physics engine used by the world.
PresetManagerPtr gazebo::physics::World::GetPresetManager | ( | ) | const |
Return the preset manager.
common::Time gazebo::physics::World::GetRealTime | ( | ) | const |
Get the real time (elapsed time).
bool gazebo::physics::World::GetRunning | ( | ) | const |
Return the running state of the world.
msgs::Scene gazebo::physics::World::GetSceneMsg | ( | ) | const |
Get the current scene in message form.
boost::mutex* gazebo::physics::World::GetSetWorldPoseMutex | ( | ) | const |
Get the set world pose mutex.
common::Time gazebo::physics::World::GetSimTime | ( | ) | const |
Get the world simulation time, note if you want the PC wall clock call common::Time::GetWallTime.
common::SphericalCoordinatesPtr gazebo::physics::World::GetSphericalCoordinates | ( | ) | const |
Return the spherical coordinates converter.
common::Time gazebo::physics::World::GetStartTime | ( | ) | const |
Get the wall time simulation was started.
ignition::math::Vector3d gazebo::physics::World::Gravity | ( | ) | const |
Return the gravity vector.
void gazebo::physics::World::Init | ( | ) |
Initialize the world.
This is called after Load.
void gazebo::physics::World::InsertModelFile | ( | const std::string & | _sdfFilename | ) |
Insert a model from an SDF file.
Spawns a model into the world base on and SDF file.
[in] | _sdfFilename | The name of the SDF file (including path). |
void gazebo::physics::World::InsertModelSDF | ( | const sdf::SDF & | _sdf | ) |
Insert a model using SDF.
Spawns a model into the world base on and SDF object.
[in] | _sdf | A reference to an SDF object. |
void gazebo::physics::World::InsertModelString | ( | const std::string & | _sdfString | ) |
Insert a model from an SDF string.
Spawns a model into the world base on and SDF string.
[in] | _sdfString | A string containing valid SDF markup. |
bool gazebo::physics::World::IsLoaded | ( | ) | const |
Return true if the world has been loaded.
bool gazebo::physics::World::IsPaused | ( | ) | const |
Returns the state of the simulation true if paused.
LightPtr gazebo::physics::World::Light | ( | const std::string & | _name | ) |
Light_V gazebo::physics::World::Lights | ( | ) | const |
Get a list of all the lights.
void gazebo::physics::World::Load | ( | sdf::ElementPtr | _sdf | ) |
Load the world using SDF parameters.
Load a world from and SDF pointer.
[in] | _sdf | SDF parameters. |
void gazebo::physics::World::LoadPlugin | ( | const std::string & | _filename, |
const std::string & | _name, | ||
sdf::ElementPtr | _sdf | ||
) |
Load a plugin.
[in] | _filename | The filename of the plugin. |
[in] | _name | A unique name for the plugin. |
[in] | _sdf | The SDF to pass into the plugin. |
|
virtual |
Return the magnetic field vector.
void gazebo::physics::World::PrintEntityTree | ( | ) |
Print Entity tree.
Prints alls the entities to stdout.
void gazebo::physics::World::PublishLightPose | ( | const physics::LightPtr | _light | ) |
Publish pose updates for a light.
Adds light to a list of lights to publish, which is processed and cleared once every iteration.
[in] | _light | Pointer to the light to publish. |
void gazebo::physics::World::PublishModelPose | ( | physics::ModelPtr | _model | ) |
Publish pose updates for a model.
This list of models to publish is processed and cleared once every iteration.
[in] | _model | Pointer to the model to publish. |
void gazebo::physics::World::PublishModelScale | ( | physics::ModelPtr | _model | ) |
Publish scale updates for a model.
This list of models to publish is processed and cleared once every iteration.
[in] | _model | Pointer to the model to publish. |
void gazebo::physics::World::RemoveModel | ( | ModelPtr | _model | ) |
Remove a model.
This function will block until the physics engine is not locked. The duration of the block is less than the time to complete a simulation iteration.
[in] | _model | Pointer to a model to remove. |
void gazebo::physics::World::RemoveModel | ( | const std::string & | _name | ) |
Remove a model by name.
This function will block until the physics engine is not locked. The duration of the block is less than the time to complete a simulation iteration.
[in] | _name | Name of the model to remove. |
void gazebo::physics::World::RemovePlugin | ( | const std::string & | _name | ) |
Remove a running plugin.
[in] | _name | The unique name of the plugin to remove. |
void gazebo::physics::World::Reset | ( | ) |
Reset time and model poses, configurations in simulation.
void gazebo::physics::World::ResetEntities | ( | Base::EntityType | _type = Base::BASE | ) |
Reset with options.
The _type parameter specifies which type of eneities to reset. See Base::EntityType.
[in] | _type | The type of reset. |
void gazebo::physics::World::ResetPhysicsStates | ( | ) |
Reset the velocity, acceleration, force and torque of all child models.
void gazebo::physics::World::ResetTime | ( | ) |
Reset simulation time back to zero.
void gazebo::physics::World::Run | ( | unsigned int | _iterations = 0 | ) |
Run the world in a thread.
Run the update loop.
[in] | _iterations | Run for this many iterations, then stop. A value of zero disables run stop. |
void gazebo::physics::World::RunBlocking | ( | unsigned int | _iterations = 0 | ) |
Run the world.
This call blocks. Run the update loop.
[in] | _iterations | Run for this many iterations, then stop. A value of zero disables run stop. |
void gazebo::physics::World::Save | ( | const std::string & | _filename | ) |
Save a world to a file.
Save the current world and its state to a file.
[in] | _filename | Name of the file to save into. |
bool gazebo::physics::World::SensorsInitialized | ( | ) | const |
Get whether sensors have been initialized.
void gazebo::physics::World::SetGravity | ( | const ignition::math::Vector3d & | _gravity | ) |
Set the gravity vector.
[in] | _gravity | New gravity vector. |
void gazebo::physics::World::SetGravitySDF | ( | const ignition::math::Vector3d & | _gravity | ) |
Set the gravity sdf value.
[in] | _gravity | New gravity vector. |
void gazebo::physics::World::SetMagneticField | ( | const ignition::math::Vector3d & | _mag | ) |
Set the magnetic field vector.
[in] | _mag | New magnetic field vector. |
void gazebo::physics::World::SetPaused | ( | bool | _p | ) |
Set whether the simulation is paused.
[in] | _p | True pauses the simulation. False runs the simulation. |
void gazebo::physics::World::SetSimTime | ( | const common::Time & | _t | ) |
Set the sim time.
[in] | _t | The new simulation time |
void gazebo::physics::World::SetState | ( | const WorldState & | _state | ) |
Set the current world state.
_state | The state to set the World to. |
void gazebo::physics::World::Step | ( | unsigned int | _steps | ) |
Step the world forward in time.
[in] | _steps | The number of steps the World should take. |
void gazebo::physics::World::Stop | ( | ) |
Stop the world.
Stop the update loop.
std::string gazebo::physics::World::StripWorldName | ( | const std::string & | _name | ) | const |
Return a version of the name with "<world_name>::" removed.
[in] | _name | Usually the name of an entity. |
void gazebo::physics::World::UpdateStateSDF | ( | ) |
Update the state SDF value from the current state.