WorldPrivate.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef _GAZEBO_WORLD_PRIVATE_HH_
18 #define _GAZEBO_WORLD_PRIVATE_HH_
19 
20 #include <deque>
21 #include <vector>
22 #include <list>
23 #include <set>
24 #include <boost/thread.hpp>
25 #include <sdf/sdf.hh>
26 #include <string>
27 
28 #include "gazebo/common/Event.hh"
29 #include "gazebo/common/Time.hh"
30 
31 #include "gazebo/msgs/msgs.hh"
32 
34 
37 
38 namespace gazebo
39 {
40  namespace physics
41  {
44  {
47 
50 
53 
56 
58  public: boost::thread *thread;
59 
61  public: bool stop;
62 
64  public: std::string name;
65 
68 
71 
74 
76  public: bool pause;
77 
79  public: int stepInc;
80 
83 
86  public: bool seekPending;
87 
90 
93 
96 
99 
102 
105 
108 
111 
114 
117 
120 
123 
126 
129 
132 
135 
137  public: msgs::WorldStatistics worldStatsMsg;
138 
140  public: msgs::Scene sceneMsg;
141 
143  public: void (World::*modelUpdateFunc)();
144 
147 
150 
153 
155  public: boost::recursive_mutex *receiveMutex;
156 
158  public: boost::mutex *loadModelMutex;
159 
164  public: boost::mutex *setWorldPoseMutex;
165 
172  public: boost::recursive_mutex *worldUpdateMutex;
173 
175  public: sdf::ElementPtr sdf;
176 
178  public: std::vector<WorldPluginPtr> plugins;
179 
181  public: std::list<std::string> deleteEntity;
182 
184  public: std::list<msgs::Request> requestMsgs;
185 
187  public: std::list<msgs::Factory> factoryMsgs;
188 
190  public: std::list<msgs::Model> modelMsgs;
191 
193  public: bool needsReset;
194 
196  public: bool resetAll;
197 
199  public: bool resetTimeOnly;
200 
202  public: bool resetModelOnly;
203 
205  public: bool initialized;
206 
208  public: bool loaded;
209 
211  public: bool enablePhysicsEngine;
212 
215 
217  public: bool pluginsLoaded;
218 
221 
224 
227 
229  public: std::deque<WorldState> states[2];
230 
232  public: int currentStateBuffer;
233 
235  public: WorldState prevStates[2];
236 
238  public: int stateToggle;
239 
241  public: sdf::ElementPtr logPlayStateSDF;
242 
245 
248  public: sdf::SDFPtr factorySDF;
249 
251  public: std::set<ModelPtr> publishModelPoses;
252 
255 
257  public: uint64_t iterations;
258 
260  public: uint64_t stopIterations;
261 
263  public: boost::condition_variable logCondition;
264 
267  public: boost::condition_variable logContinueCondition;
268 
270  public: uint64_t logPrevIteration;
271 
274 
276  public: boost::mutex logMutex;
277 
279  public: boost::mutex logBufferMutex;
280 
282  public: boost::mutex entityDeleteMutex;
283 
285  public: boost::thread *logThread;
286 
288  public: Model_V models;
289 
292  public: boost::mutex factoryDeleteMutex;
293 
297  public: std::list<Entity*> dirtyPoses;
298 
301  };
302  }
303 }
304 
305 #endif
msgs::Scene sceneMsg
Outgoing scene message.
Definition: WorldPrivate.hh:140
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:68
sdf::SDFPtr factorySDF
Store a factory SDF object to improve speed at which objects are inserted via the factory...
Definition: WorldPrivate.hh:248
bool resetModelOnly
True to reset only model poses.
Definition: WorldPrivate.hh:202
common::Time prevStepWallTime
For keeping track of time step throttling.
Definition: WorldPrivate.hh:46
std::string name
Name of the world.
Definition: WorldPrivate.hh:64
transport::SubscriberPtr modelSub
Subscriber to model messages.
Definition: WorldPrivate.hh:131
std::list< std::string > deleteEntity
List of entities to delete.
Definition: WorldPrivate.hh:181
uint64_t iterations
The number of simulation iterations.
Definition: WorldPrivate.hh:257
boost::recursive_mutex * worldUpdateMutex
Used by World classs in following calls: World::Step for then entire function World::StepWorld for ch...
Definition: WorldPrivate.hh:172
std::list< Entity * > dirtyPoses
when physics engine makes an update and changes a link pose, this flag is set to trigger Entity::SetW...
Definition: WorldPrivate.hh:297
common::Time pauseStartTime
Time at which pause started.
Definition: WorldPrivate.hh:149
common::Time prevProcessMsgsTime
Last time incoming messages were processed.
Definition: WorldPrivate.hh:223
bool loaded
True if the world has been loaded.
Definition: WorldPrivate.hh:208
boost::thread * thread
thread in which the world is updated.
Definition: WorldPrivate.hh:58
std::set< ModelPtr > publishModelPoses
The list of models that need to publish their pose.
Definition: WorldPrivate.hh:251
transport::SubscriberPtr controlSub
Subscriber to world control messages.
Definition: WorldPrivate.hh:116
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
bool initialized
True if the world has been initialized.
Definition: WorldPrivate.hh:205
transport::PublisherPtr responsePub
Publisher for request response messages.
Definition: WorldPrivate.hh:98
PresetManagerPtr presetManager
Class to manage preset simulation parameter profiles.
Definition: WorldPrivate.hh:300
Forward declarations for transport.
Model_V models
A cached list of models. This is here for performance.
Definition: WorldPrivate.hh:288
boost::thread * logThread
Worker thread for logging.
Definition: WorldPrivate.hh:285
uint64_t stopIterations
The number of simulation iterations to take before stopping.
Definition: WorldPrivate.hh:260
transport::NodePtr node
Transportation node.
Definition: WorldPrivate.hh:92
transport::PublisherPtr guiPub
Publisher for gui messages.
Definition: WorldPrivate.hh:104
std::vector< WorldPluginPtr > plugins
All the plugins.
Definition: WorldPrivate.hh:178
event::Connection_V connections
All the event connections.
Definition: WorldPrivate.hh:89
transport::SubscriberPtr requestSub
Subscriber to request messages.
Definition: WorldPrivate.hh:134
Information for use in an update event.
Definition: UpdateInfo.hh:30
boost::mutex factoryDeleteMutex
This mutex is used to by the ::RemoveModel and ::ProcessFactoryMsgs functions.
Definition: WorldPrivate.hh:292
int stepInc
Number of steps in increment by.
Definition: WorldPrivate.hh:79
default namespace for gazebo
common::Time prevStatTime
Last time a world statistics message was sent.
Definition: WorldPrivate.hh:146
boost::mutex entityDeleteMutex
Mutex to protect the deleteEntity list.
Definition: WorldPrivate.hh:282
bool seekPending
When there is a 'seek' command pending during a log file playback this member variable should be true...
Definition: WorldPrivate.hh:86
boost::mutex * loadModelMutex
Mutex to protext loading of models.
Definition: WorldPrivate.hh:158
transport::PublisherPtr poseLocalPub
Publisher for local pose messages.
Definition: WorldPrivate.hh:113
Private data class for World.
Definition: WorldPrivate.hh:43
bool enablePhysicsEngine
True to enable the physics engine.
Definition: WorldPrivate.hh:211
std::list< msgs::Factory > factoryMsgs
Factory message buffer.
Definition: WorldPrivate.hh:187
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:108
sdf::ElementPtr sdf
THe world's SDF values.
Definition: WorldPrivate.hh:175
transport::SubscriberPtr jointSub
Subscriber to joint messages.
Definition: WorldPrivate.hh:125
msgs::WorldStatistics worldStatsMsg
Outgoing world statistics message.
Definition: WorldPrivate.hh:137
PhysicsEnginePtr physicsEngine
Pointer the physics engine.
Definition: WorldPrivate.hh:49
void(World::* modelUpdateFunc)()
Function pointer to the model update function.
Definition: WorldPrivate.hh:143
The world provides access to all other object within a simulated environment.
Definition: World.hh:68
BasePtr rootElement
The root of all entities in the world.
Definition: WorldPrivate.hh:55
common::Time realTimeOffset
Used to compute a more accurate real time value.
Definition: WorldPrivate.hh:152
transport::PublisherPtr modelPub
Publisher for model messages.
Definition: WorldPrivate.hh:101
transport::PublisherPtr lightPub
Publisher for light messages.
Definition: WorldPrivate.hh:107
bool resetAll
True to reset everything.
Definition: WorldPrivate.hh:196
common::Time pauseTime
Amount of time simulation has been paused.
Definition: WorldPrivate.hh:70
boost::mutex * setWorldPoseMutex
: Add an accessor for this, and make it private Used in Entity.cc.
Definition: WorldPrivate.hh:164
common::SphericalCoordinatesPtr sphericalCoordinates
Pointer the spherical coordinates data.
Definition: WorldPrivate.hh:52
common::Time sleepOffset
sleep timing error offset due to clock wake up latency
Definition: WorldPrivate.hh:220
WorldState prevStates[2]
Buffer of prev states.
Definition: WorldPrivate.hh:235
boost::recursive_mutex * receiveMutex
Mutex to protect incoming message buffers.
Definition: WorldPrivate.hh:155
boost::condition_variable logContinueCondition
Condition used to guarantee the log worker thread doesn't skip an interation.
Definition: WorldPrivate.hh:267
std::vector< ConnectionPtr > Connection_V
Definition: CommonTypes.hh:151
int stateToggle
Int used to toggle between prevStates.
Definition: WorldPrivate.hh:238
WorldState logPlayState
Current state when playing from a log file.
Definition: WorldPrivate.hh:244
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
bool needsReset
True to reset the world on next update.
Definition: WorldPrivate.hh:193
bool pluginsLoaded
True if the plugins have been loaded.
Definition: WorldPrivate.hh:217
boost::condition_variable logCondition
Condition used for log worker.
Definition: WorldPrivate.hh:263
bool stop
True to stop the world from running.
Definition: WorldPrivate.hh:61
transport::SubscriberPtr playbackControlSub
Subscriber to log playback control messages.
Definition: WorldPrivate.hh:119
transport::PublisherPtr posePub
Publisher for pose messages.
Definition: WorldPrivate.hh:110
boost::mutex logBufferMutex
Mutex to protect the log state buffers.
Definition: WorldPrivate.hh:279
common::Time processMsgsPeriod
Period over which messages should be processed.
Definition: WorldPrivate.hh:226
std::deque< WorldState > states[2]
Alternating buffer of states.
Definition: WorldPrivate.hh:229
transport::PublisherPtr statPub
Publisher for world statistics messages.
Definition: WorldPrivate.hh:95
std::vector< ModelPtr > Model_V
Definition: PhysicsTypes.hh:180
common::UpdateInfo updateInfo
Info passed through the WorldUpdateBegin event.
Definition: WorldPrivate.hh:254
common::Time startTime
Clock time when simulation was started.
Definition: WorldPrivate.hh:73
transport::SubscriberPtr factorySub
Subscriber to factory messages.
Definition: WorldPrivate.hh:122
boost::shared_ptr< Publisher > PublisherPtr
Definition: TransportTypes.hh:49
Store state information of a physics::World object.
Definition: WorldState.hh:46
std::list< msgs::Request > requestMsgs
Request message buffer.
Definition: WorldPrivate.hh:184
std::list< msgs::Model > modelMsgs
Model message buffer.
Definition: WorldPrivate.hh:190
boost::shared_ptr< SphericalCoordinates > SphericalCoordinatesPtr
Definition: CommonTypes.hh:138
common::Time targetSimTime
Stores the simulation time target during a 'seek' operation.
Definition: WorldPrivate.hh:82
uint64_t logPrevIteration
Last iteration recorded by the log worker thread.
Definition: WorldPrivate.hh:270
transport::SubscriberPtr lightSub
Subscriber to light messages.
Definition: WorldPrivate.hh:128
RayShapePtr testRay
Ray used to test for collisions when placing entities.
Definition: WorldPrivate.hh:214
bool resetTimeOnly
True to reset only the time.
Definition: WorldPrivate.hh:199
int currentStateBuffer
Keep track of current state buffer being updated.
Definition: WorldPrivate.hh:232
sdf::ElementPtr logPlayStateSDF
State from from log file.
Definition: WorldPrivate.hh:241
common::Time logRealTime
Real time value set from a log file.
Definition: WorldPrivate.hh:273
common::Time simTime
Current simulation time.
Definition: WorldPrivate.hh:67
bool pause
True if simulation is paused.
Definition: WorldPrivate.hh:76
boost::mutex logMutex
Mutex to protect the log worker thread.
Definition: WorldPrivate.hh:276
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:39
boost::shared_ptr< RayShape > RayShapePtr
Definition: PhysicsTypes.hh:120
boost::shared_ptr< PresetManager > PresetManagerPtr
Definition: PhysicsTypes.hh:112