17 #ifndef GAZEBO_PHYSICS_WORLD_HH_
18 #define GAZEBO_PHYSICS_WORLD_HH_
33 #include <boost/enable_shared_from_this.hpp>
81 class GZ_PHYSICS_VISIBLE
World :
82 public boost::enable_shared_from_this<World>
87 public:
explicit World(
const std::string &_name =
"");
95 public:
void Load(sdf::ElementPtr _sdf);
100 public:
void Save(
const std::string &_filename);
110 public:
void Run(
const unsigned int _iterations = 0);
119 public:
bool Running()
const;
132 public:
void Clear();
141 public: std::string Name()
const;
183 public: ignition::math::Vector3d Gravity()
const;
187 public:
void SetGravity(
const ignition::math::Vector3d &_gravity);
191 public:
void SetGravitySDF(
const ignition::math::Vector3d &_gravity);
195 public:
virtual ignition::math::Vector3d MagneticField()
const;
199 public:
void SetMagneticField(
const ignition::math::Vector3d &_mag);
208 public:
unsigned int ModelCount()
const;
216 public:
ModelPtr GetModel(
unsigned int _index)
const
224 public:
ModelPtr ModelByIndex(
const unsigned int _index)
const;
233 public:
Model_V Models()
const;
237 public:
unsigned int LightCount()
const;
241 public:
Light_V Lights()
const;
250 public:
void ResetTime();
253 public:
void Reset();
257 public:
void PrintEntityTree();
303 public:
bool IsPaused()
const;
307 public:
void SetPaused(
const bool _p);
315 public:
BasePtr GetByName(
const std::string &_name)
323 public:
BasePtr BaseByName(
const std::string &_name)
const;
331 public:
ModelPtr GetModel(
const std::string &_name)
339 public:
ModelPtr ModelByName(
const std::string &_name)
const;
355 public:
LightPtr LightByName(
const std::string &_name)
const;
363 public:
EntityPtr GetEntity(
const std::string &_name)
371 public:
EntityPtr EntityByName(
const std::string &_name)
const;
393 const ignition::math::Vector3d &_pt)
const;
411 const ignition::math::Vector3d &_pt)
const;
415 public:
void SetState(
const WorldState &_state);
420 public:
void InsertModelFile(
const std::string &_sdfFilename);
425 public:
void InsertModelString(
const std::string &_sdfString);
430 public:
void InsertModelSDF(
const sdf::SDF &_sdf);
435 public: std::string StripWorldName(
const std::string &_name)
const;
440 public:
void EnableAllModels();
445 public:
void DisableAllModels();
449 public:
void Step(
const unsigned int _steps);
455 public:
void LoadPlugin(
const std::string &_filename,
456 const std::string &_name,
457 sdf::ElementPtr _sdf);
461 public:
void RemovePlugin(
const std::string &_name);
470 public: std::mutex &WorldPoseMutex()
const;
479 public:
bool PhysicsEnabled()
const;
484 public:
void EnablePhysicsEngine(
const bool _enable)
489 public:
void SetPhysicsEnabled(
const bool _enable);
493 public:
bool WindEnabled()
const;
497 public:
void SetWindEnabled(
const bool _enable);
501 public:
bool AtmosphereEnabled()
const;
505 public:
void SetAtmosphereEnabled(
const bool _enable);
508 public:
void UpdateStateSDF();
512 public:
bool IsLoaded()
const;
516 public:
void ClearModels();
543 public: uint32_t Iterations()
const;
552 public: msgs::Scene SceneMsg()
const;
558 public:
void RunBlocking(
const unsigned int _iterations = 0);
564 public:
void RemoveModel(
ModelPtr _model);
570 public:
void RemoveModel(
const std::string &_name);
574 public:
void ResetPhysicsStates();
582 public:
void _AddDirty(
Entity *_entity);
586 public:
bool SensorsInitialized()
const;
592 public:
void _SetSensorsInitialized(
const bool _init);
603 public: std::string UniqueModelName(
const std::string &_name);
612 private:
ModelPtr ModelById(
const unsigned int _id)
const;
618 private:
void LoadPlugins();
623 private:
void LoadEntities(sdf::ElementPtr _sdf,
BasePtr _parent);
635 private:
LightPtr LoadLight(
const sdf::ElementPtr &_sdf,
651 private:
void RunLoop();
654 private:
void Step();
657 private:
void LogStep();
660 private:
void Update();
664 private:
void OnPause(
bool _p);
667 private:
void OnStep();
671 private:
void OnControl(ConstWorldControlPtr &_data);
675 private:
void OnPlaybackControl(ConstLogPlaybackControlPtr &_data);
679 private:
void OnRequest(ConstRequestPtr &_msg);
685 private:
void BuildSceneMsg(msgs::Scene &_scene,
BasePtr _entity);
689 private:
void JointLog(ConstJointPtr &_msg);
693 private:
void OnFactoryMsg(ConstFactoryPtr &_data);
697 private:
void OnModelMsg(ConstModelPtr &_msg);
700 private:
void ModelUpdateTBB();
703 private:
void ModelUpdateSingleLoop();
707 private:
void LoadPlugin(sdf::ElementPtr _sdf);
712 private:
void FillModelMsg(msgs::Model &_msg,
ModelPtr _model);
716 private:
void ProcessEntityMsgs();
720 private:
void ProcessRequestMsgs();
724 private:
void ProcessFactoryMsgs();
728 private:
void ProcessModelMsgs();
732 private:
void ProcessLightFactoryMsgs();
736 private:
void ProcessLightModifyMsgs();
739 private:
bool OnLog(std::ostringstream &_stream);
742 private:
void ProcessMessages();
745 private:
void PublishWorldStats();
748 private:
void LogWorker();
751 private:
void RegisterIntrospectionItems();
754 private:
void UnregisterIntrospectionItems();
761 private:
void OnLightMsg(ConstLightPtr &_msg);
766 private:
void OnLightFactoryMsg(ConstLightPtr &_msg);
771 private:
void OnLightModifyMsg(ConstLightPtr &_msg);
789 private:
void PluginInfoService(
const ignition::msgs::StringMsg &_request,
790 ignition::msgs::Plugin_V &_plugins,
bool &_success);
794 private: std::unique_ptr<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:44
std::vector< LightPtr > Light_V
Definition: PhysicsTypes.hh:221
Forward declarations for transport.
default namespace for gazebo
A complete URI.
Definition: URI.hh:176
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:81
Simbody physics engine.
Definition: SimbodyPhysics.hh:42
boost::shared_ptr< SphericalCoordinates > SphericalCoordinatesPtr
Definition: CommonTypes.hh:121
Base class for wind.
Definition: Wind.hh:41
Base class for all physics objects in Gazebo.
Definition: Entity.hh:56
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:302
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:39