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;
135 public: ignition::math::Vector3d Gravity()
const;
139 public:
void SetGravity(
const ignition::math::Vector3d &_gravity);
143 public:
void SetGravitySDF(
const ignition::math::Vector3d &_gravity);
147 public:
virtual ignition::math::Vector3d MagneticField()
const;
151 public:
void SetMagneticField(
const ignition::math::Vector3d &_mag);
155 public:
unsigned int GetModelCount()
const;
162 public:
ModelPtr GetModel(
unsigned int _index)
const;
166 public:
Model_V GetModels()
const;
170 public:
unsigned int LightCount()
const;
174 public:
Light_V Lights()
const;
183 public:
void ResetTime();
186 public:
void Reset();
190 public:
void PrintEntityTree();
215 public:
bool IsPaused()
const;
219 public:
void SetPaused(
bool _p);
226 public:
BasePtr GetByName(
const std::string &_name);
233 public:
ModelPtr GetModel(
const std::string &_name);
247 public:
EntityPtr GetEntity(
const std::string &_name);
267 public:
void SetState(
const WorldState &_state);
272 public:
void InsertModelFile(
const std::string &_sdfFilename);
277 public:
void InsertModelString(
const std::string &_sdfString);
282 public:
void InsertModelSDF(
const sdf::SDF &_sdf);
287 public: std::string StripWorldName(
const std::string &_name)
const;
292 public:
void EnableAllModels();
297 public:
void DisableAllModels();
301 public:
void Step(
unsigned int _steps);
307 public:
void LoadPlugin(
const std::string &_filename,
308 const std::string &_name,
309 sdf::ElementPtr _sdf);
313 public:
void RemovePlugin(
const std::string &_name);
317 public: boost::mutex *GetSetWorldPoseMutex()
const;
321 public:
bool GetEnablePhysicsEngine();
325 public:
void EnablePhysicsEngine(
bool _enable);
328 public:
void UpdateStateSDF();
332 public:
bool IsLoaded()
const;
336 public:
void ClearModels();
358 public: uint32_t GetIterations()
const;
362 public: msgs::Scene GetSceneMsg()
const;
368 public:
void RunBlocking(
unsigned int _iterations = 0);
374 public:
void RemoveModel(
ModelPtr _model);
380 public:
void RemoveModel(
const std::string &_name);
384 public:
void ResetPhysicsStates();
392 public:
void _AddDirty(
Entity *_entity);
396 public:
bool SensorsInitialized()
const;
402 public:
void _SetSensorsInitialized(
const bool _init);
409 public: std::string UniqueModelName(
const std::string &_name);
418 private:
ModelPtr GetModelById(
unsigned int _id);
424 private:
void LoadPlugins();
429 private:
void LoadEntities(sdf::ElementPtr _sdf,
BasePtr _parent);
441 private:
LightPtr LoadLight(
const sdf::ElementPtr &_sdf,
457 private:
void RunLoop();
460 private:
void Step();
463 private:
void LogStep();
466 private:
void Update();
470 private:
void OnPause(
bool _p);
473 private:
void OnStep();
477 private:
void OnControl(ConstWorldControlPtr &_data);
481 private:
void OnPlaybackControl(ConstLogPlaybackControlPtr &_data);
485 private:
void OnRequest(ConstRequestPtr &_msg);
491 private:
void BuildSceneMsg(msgs::Scene &_scene,
BasePtr _entity);
495 private:
void JointLog(ConstJointPtr &_msg);
499 private:
void OnFactoryMsg(ConstFactoryPtr &_data);
503 private:
void OnModelMsg(ConstModelPtr &_msg);
506 private:
void ModelUpdateTBB();
509 private:
void ModelUpdateSingleLoop();
513 private:
void LoadPlugin(sdf::ElementPtr _sdf);
518 private:
void FillModelMsg(msgs::Model &_msg,
ModelPtr _model);
522 private:
void ProcessEntityMsgs();
526 private:
void ProcessRequestMsgs();
530 private:
void ProcessFactoryMsgs();
534 private:
void ProcessModelMsgs();
538 private:
void ProcessLightFactoryMsgs();
542 private:
void ProcessLightModifyMsgs();
545 private:
bool OnLog(std::ostringstream &_stream);
548 private:
void ProcessMessages();
551 private:
void PublishWorldStats();
554 private:
void LogWorker();
561 private:
void OnLightMsg(ConstLightPtr &_msg);
566 private:
void OnLightFactoryMsg(ConstLightPtr &_msg);
571 private:
void OnLightModifyMsg(ConstLightPtr &_msg);
575 private: WorldPrivate *dataPtr;
boost::shared_ptr< Actor > ActorPtr
Definition: PhysicsTypes.hh:92
boost::shared_ptr< PresetManager > PresetManagerPtr
Definition: PhysicsTypes.hh:120
A light entity.
Definition: physics/Light.hh:33
Forward declarations for the common classes.
Definition: Animation.hh:33
std::vector< ModelPtr > Model_V
Definition: PhysicsTypes.hh:196
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
std::vector< LightPtr > Light_V
Definition: PhysicsTypes.hh:212
Forward declarations for transport.
default namespace for gazebo
Base type.
Definition: Base.hh:87
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:116
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 all physics objects in Gazebo.
Definition: Entity.hh:58
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:80
boost::shared_ptr< Road > RoadPtr
Definition: PhysicsTypes.hh:152
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:88
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:85
boost::shared_ptr< Light > LightPtr
Definition: PhysicsTypes.hh:96
Store state information of a physics::World object.
Definition: WorldState.hh:47
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:72
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44
DART Link class.
Definition: DARTLink.hh:40