17 #ifndef GAZEBO_PHYSICS_WORLD_HH_ 18 #define GAZEBO_PHYSICS_WORLD_HH_ 27 #include <boost/enable_shared_from_this.hpp> 74 class GZ_PHYSICS_VISIBLE
World :
75 public boost::enable_shared_from_this<World>
80 public:
explicit World(
const std::string &_name =
"");
88 public:
void Load(sdf::ElementPtr _sdf);
92 public:
const sdf::ElementPtr SDF();
96 public:
const sdf::World *GetSDFDom()
const;
101 public:
void Save(
const std::string &_filename);
117 public:
void Run(
const unsigned int _iterations = 0);
121 public:
bool Running()
const;
135 public:
void Clear();
139 public: std::string Name()
const;
164 public: ignition::math::Vector3d Gravity()
const;
168 public:
void SetGravity(
const ignition::math::Vector3d &_gravity);
172 public:
void SetGravitySDF(
const ignition::math::Vector3d &_gravity);
176 public: ignition::math::Vector3d MagneticField()
const;
180 public:
void SetMagneticField(
const ignition::math::Vector3d &_mag);
184 public:
unsigned int ModelCount()
const;
191 public:
ModelPtr ModelByIndex(
const unsigned int _index)
const;
195 public:
Model_V Models()
const;
199 public:
unsigned int LightCount()
const;
203 public:
Light_V Lights()
const;
212 public:
void ResetTime();
215 public:
void Reset();
219 public:
void PrintEntityTree();
244 public:
bool IsPaused()
const;
248 public:
void SetPaused(
const bool _p);
255 public:
BasePtr BaseByName(
const std::string &_name)
const;
262 public:
ModelPtr ModelByName(
const std::string &_name)
const;
269 public:
LightPtr LightByName(
const std::string &_name)
const;
276 public:
EntityPtr EntityByName(
const std::string &_name)
const;
286 const ignition::math::Vector3d &_pt)
const;
294 const ignition::math::Vector3d &_pt)
const;
298 public:
void SetState(
const WorldState &_state);
303 public:
void InsertModelFile(
const std::string &_sdfFilename);
308 public:
void InsertModelString(
const std::string &_sdfString);
313 public:
void InsertModelSDF(
const sdf::SDF &_sdf);
318 public: std::string StripWorldName(
const std::string &_name)
const;
323 public:
void EnableAllModels();
328 public:
void DisableAllModels();
332 public:
void Step(
const unsigned int _steps);
338 public:
void LoadPlugin(
const std::string &_filename,
339 const std::string &_name,
340 sdf::ElementPtr _sdf);
344 public:
void RemovePlugin(
const std::string &_name);
348 public: std::mutex &WorldPoseMutex()
const;
352 public:
bool PhysicsEnabled()
const;
356 public:
void SetPhysicsEnabled(
const bool _enable);
360 public:
bool WindEnabled()
const;
364 public:
void SetWindEnabled(
const bool _enable);
368 public:
bool AtmosphereEnabled()
const;
372 public:
void SetAtmosphereEnabled(
const bool _enable);
375 public:
void UpdateStateSDF();
379 public:
bool IsLoaded()
const;
383 public:
void ClearModels();
405 public: uint32_t Iterations()
const;
409 public: msgs::Scene SceneMsg()
const;
415 public:
void RunBlocking(
const unsigned int _iterations = 0);
421 public:
void RemoveModel(
ModelPtr _model);
427 public:
void RemoveModel(
const std::string &_name);
431 public:
void ResetPhysicsStates();
439 public:
void _AddDirty(
Entity *_entity);
443 public:
bool SensorsInitialized()
const;
449 public:
void _SetSensorsInitialized(
const bool _init);
460 public: std::string UniqueModelName(
const std::string &_name);
469 private:
ModelPtr ModelById(
const unsigned int _id)
const;
475 private:
void LoadPlugins();
480 private:
void LoadEntities(sdf::ElementPtr _sdf,
BasePtr _parent);
492 public:
LightPtr LoadLight(
const sdf::ElementPtr &_sdf,
508 private:
void RunLoop();
511 private:
void Step();
514 private:
void LogStep();
517 private:
void Update();
521 private:
void OnPause(
bool _p);
524 private:
void OnStep();
528 private:
void OnControl(ConstWorldControlPtr &_data);
532 private:
void OnPlaybackControl(ConstLogPlaybackControlPtr &_data);
536 private:
void OnRequest(ConstRequestPtr &_msg);
542 private:
void BuildSceneMsg(msgs::Scene &_scene,
BasePtr _entity);
546 private:
void JointLog(ConstJointPtr &_msg);
550 private:
void OnFactoryMsg(ConstFactoryPtr &_data);
554 private:
void OnModelMsg(ConstModelPtr &_msg);
557 private:
void ModelUpdateTBB();
560 private:
void ModelUpdateSingleLoop();
564 private:
void LoadPlugin(sdf::ElementPtr _sdf);
569 private:
void FillModelMsg(msgs::Model &_msg,
ModelPtr _model);
573 private:
void ProcessEntityMsgs();
577 private:
void ProcessRequestMsgs();
581 private:
void ProcessFactoryMsgs();
585 private:
void ProcessModelMsgs();
589 private:
void ProcessLightFactoryMsgs();
593 private:
void ProcessLightModifyMsgs();
597 private:
void ProcessPlaybackControlMsgs();
600 private:
bool OnLog(std::ostringstream &_stream);
604 private:
void LogModelResources();
607 private:
void ProcessMessages();
610 private:
void PublishWorldStats();
613 private:
void LogWorker();
616 private:
void RegisterIntrospectionItems();
619 private:
void UnregisterIntrospectionItems();
624 private:
void OnLightFactoryMsg(ConstLightPtr &_msg);
629 private:
void OnLightModifyMsg(ConstLightPtr &_msg);
647 private:
bool PluginInfoService(
const ignition::msgs::StringMsg &_request,
648 ignition::msgs::Plugin_V &_plugins);
652 private: std::unique_ptr<WorldPrivate> dataPtr;
boost::shared_ptr< Actor > ActorPtr
Definition: PhysicsTypes.hh:98
boost::shared_ptr< PresetManager > PresetManagerPtr
Definition: PhysicsTypes.hh:130
Forward declarations for the common classes.
Definition: Animation.hh:26
std::vector< ModelPtr > Model_V
Definition: PhysicsTypes.hh:206
std::function< void(const std::string &, const msgs::PosesStamped &)> UpdateScenePosesFunc
Function signature for API that updates scene poses.
Definition: PhysicsTypes.hh:252
std::vector< LightPtr > Light_V
Definition: PhysicsTypes.hh:222
Forward declarations for transport.
default namespace for gazebo
A complete URI.
Definition: URI.hh:176
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:126
The world provides access to all other object within a simulated environment.
Definition: World.hh:74
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:52
#define GAZEBO_DEPRECATED(version)
Definition: system.hh:328
boost::shared_ptr< Entity > EntityPtr
Definition: PhysicsTypes.hh:86
boost::shared_ptr< Road > RoadPtr
Definition: PhysicsTypes.hh:162
boost::shared_ptr< Model > ModelPtr
Definition: PhysicsTypes.hh:94
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:76
boost::shared_ptr< Light > LightPtr
Definition: PhysicsTypes.hh:106
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:78
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:47
DART Link class.
Definition: DARTLink.hh:39