17 #ifndef _GAZEBO_WORLD_HH_
18 #define _GAZEBO_WORLD_HH_
31 #include <boost/thread.hpp>
32 #include <boost/enable_shared_from_this.hpp>
33 #include <boost/shared_ptr.hpp>
68 class GZ_PHYSICS_VISIBLE
World :
69 public boost::enable_shared_from_this<World>
74 public:
explicit World(
const std::string &_name =
"");
82 public:
void Load(sdf::ElementPtr _sdf);
87 public:
void Save(
const std::string &_filename);
97 public:
void Run(
unsigned int _iterations = 0);
101 public:
bool GetRunning()
const;
114 public:
void Clear();
118 public: std::string GetName()
const;
143 public: ignition::math::Vector3d Gravity()
const;
147 public:
void SetGravity(
const ignition::math::Vector3d &_gravity);
151 public:
void SetGravitySDF(
const ignition::math::Vector3d &_gravity);
155 public:
virtual ignition::math::Vector3d MagneticField()
const;
159 public:
void SetMagneticField(
const ignition::math::Vector3d &_mag);
163 public:
unsigned int GetModelCount()
const;
170 public:
ModelPtr GetModel(
unsigned int _index)
const;
174 public:
Model_V GetModels()
const;
178 public:
unsigned int LightCount()
const;
182 public:
Light_V Lights()
const;
191 public:
void ResetTime();
194 public:
void Reset();
198 public:
void PrintEntityTree();
223 public:
bool IsPaused()
const;
227 public:
void SetPaused(
bool _p);
234 public:
BasePtr GetByName(
const std::string &_name);
241 public:
ModelPtr GetModel(
const std::string &_name);
255 public:
EntityPtr GetEntity(
const std::string &_name);
275 public:
void SetState(
const WorldState &_state);
280 public:
void InsertModelFile(
const std::string &_sdfFilename);
285 public:
void InsertModelString(
const std::string &_sdfString);
290 public:
void InsertModelSDF(
const sdf::SDF &_sdf);
295 public: std::string StripWorldName(
const std::string &_name)
const;
300 public:
void EnableAllModels();
305 public:
void DisableAllModels();
309 public:
void Step(
unsigned int _steps);
315 public:
void LoadPlugin(
const std::string &_filename,
316 const std::string &_name,
317 sdf::ElementPtr _sdf);
321 public:
void RemovePlugin(
const std::string &_name);
325 public: boost::mutex *GetSetWorldPoseMutex()
const;
329 public:
bool GetEnablePhysicsEngine();
333 public:
void EnablePhysicsEngine(
bool _enable);
337 public:
bool WindEnabled()
const;
341 public:
void SetWindEnabled(
const bool _enable);
345 public:
bool AtmosphereEnabled()
const;
349 public:
void SetAtmosphereEnabled(
const bool _enable);
352 public:
void UpdateStateSDF();
356 public:
bool IsLoaded()
const;
360 public:
void ClearModels();
382 public: uint32_t GetIterations()
const;
386 public: msgs::Scene GetSceneMsg()
const;
392 public:
void RunBlocking(
unsigned int _iterations = 0);
398 public:
void RemoveModel(
ModelPtr _model);
404 public:
void RemoveModel(
const std::string &_name);
408 public:
void ResetPhysicsStates();
416 public:
void _AddDirty(
Entity *_entity);
420 public:
bool SensorsInitialized()
const;
426 public:
void _SetSensorsInitialized(
const bool _init);
435 private:
ModelPtr GetModelById(
unsigned int _id);
441 private:
void LoadPlugins();
446 private:
void LoadEntities(sdf::ElementPtr _sdf,
BasePtr _parent);
458 private:
LightPtr LoadLight(
const sdf::ElementPtr &_sdf,
474 private:
void RunLoop();
477 private:
void Step();
480 private:
void LogStep();
483 private:
void Update();
487 private:
void OnPause(
bool _p);
490 private:
void OnStep();
494 private:
void OnControl(ConstWorldControlPtr &_data);
498 private:
void OnPlaybackControl(ConstLogPlaybackControlPtr &_data);
502 private:
void OnRequest(ConstRequestPtr &_msg);
508 private:
void BuildSceneMsg(msgs::Scene &_scene,
BasePtr _entity);
512 private:
void JointLog(ConstJointPtr &_msg);
516 private:
void OnFactoryMsg(ConstFactoryPtr &_data);
520 private:
void OnModelMsg(ConstModelPtr &_msg);
523 private:
void ModelUpdateTBB();
526 private:
void ModelUpdateSingleLoop();
530 private:
void LoadPlugin(sdf::ElementPtr _sdf);
535 private:
void FillModelMsg(msgs::Model &_msg,
ModelPtr _model);
539 private:
void ProcessEntityMsgs();
543 private:
void ProcessRequestMsgs();
547 private:
void ProcessFactoryMsgs();
551 private:
void ProcessModelMsgs();
555 private:
void ProcessLightFactoryMsgs();
559 private:
void ProcessLightModifyMsgs();
562 private:
bool OnLog(std::ostringstream &_stream);
565 private:
void ProcessMessages();
568 private:
void PublishWorldStats();
571 private:
void LogWorker();
578 private:
void OnLightMsg(ConstLightPtr &_msg);
583 private:
void OnLightFactoryMsg(ConstLightPtr &_msg);
588 private:
void OnLightModifyMsg(ConstLightPtr &_msg);
592 private: WorldPrivate *dataPtr;
boost::shared_ptr< Actor > ActorPtr
Definition: PhysicsTypes.hh:97
boost::shared_ptr< PresetManager > PresetManagerPtr
Definition: PhysicsTypes.hh:129
A light entity.
Definition: physics/Light.hh:33
std::vector< ModelPtr > Model_V
Definition: PhysicsTypes.hh:205
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
std::vector< LightPtr > Light_V
Definition: PhysicsTypes.hh:221
Forward declarations for transport.
default namespace for gazebo
Base type.
Definition: Base.hh:83
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:125
The world provides access to all other object within a simulated environment.
Definition: World.hh:68
Simbody physics engine.
Definition: SimbodyPhysics.hh:42
boost::shared_ptr< SphericalCoordinates > SphericalCoordinatesPtr
Definition: CommonTypes.hh:140
Base class for wind.
Definition: Wind.hh:41
Base class for all physics objects in Gazebo.
Definition: Entity.hh:58
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:85
boost::shared_ptr< Road > RoadPtr
Definition: PhysicsTypes.hh:161
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:93
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
EntityType
Unique identifiers for all entity types.
Definition: Base.hh:81
boost::shared_ptr< Light > LightPtr
Definition: PhysicsTypes.hh:105
Store state information of a physics::World object.
Definition: WorldState.hh:47
This models a base atmosphere class to serve as a common interface to any derived atmosphere models...
Definition: Atmosphere.hh:42
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:77
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44
DART Link class.
Definition: DARTLink.hh:40