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 
89 
92 
95 
98 
101 
104 
107 
110 
113 
116 
119 
122 
125 
127  public: msgs::WorldStatistics worldStatsMsg;
128 
130  public: msgs::Scene sceneMsg;
131 
133  public: void (World::*modelUpdateFunc)();
134 
137 
140 
143 
145  public: boost::recursive_mutex *receiveMutex;
146 
148  public: boost::mutex *loadModelMutex;
149 
154  public: boost::mutex *setWorldPoseMutex;
155 
162  public: boost::recursive_mutex *worldUpdateMutex;
163 
165  public: sdf::ElementPtr sdf;
166 
168  public: std::vector<WorldPluginPtr> plugins;
169 
171  public: std::list<std::string> deleteEntity;
172 
174  public: std::list<msgs::Request> requestMsgs;
175 
177  public: std::list<msgs::Factory> factoryMsgs;
178 
180  public: std::list<msgs::Model> modelMsgs;
181 
183  public: bool needsReset;
184 
186  public: bool resetAll;
187 
189  public: bool resetTimeOnly;
190 
192  public: bool resetModelOnly;
193 
195  public: bool initialized;
196 
198  public: bool loaded;
199 
201  public: bool enablePhysicsEngine;
202 
205 
207  public: bool pluginsLoaded;
208 
211 
214 
217 
219  public: std::deque<WorldState> states[2];
220 
222  public: int currentStateBuffer;
223 
225  public: WorldState prevStates[2];
226 
228  public: int stateToggle;
229 
231  public: sdf::ElementPtr logPlayStateSDF;
232 
235 
238  public: sdf::SDFPtr factorySDF;
239 
241  public: std::set<ModelPtr> publishModelPoses;
242 
245 
247  public: uint64_t iterations;
248 
250  public: uint64_t stopIterations;
251 
253  public: boost::condition_variable logCondition;
254 
257  public: boost::condition_variable logContinueCondition;
258 
260  public: uint64_t logPrevIteration;
261 
264 
266  public: boost::mutex logMutex;
267 
269  public: boost::mutex logBufferMutex;
270 
272  public: boost::mutex entityDeleteMutex;
273 
275  public: boost::thread *logThread;
276 
278  public: Model_V models;
279 
282  public: boost::mutex factoryDeleteMutex;
283 
287  public: std::list<Entity*> dirtyPoses;
288  };
289  }
290 }
291 
292 #endif
msgs::Scene sceneMsg
Outgoing scene message.
Definition: WorldPrivate.hh:130
boost::shared_ptr< Base > BasePtr
Definition: PhysicsTypes.hh:66
sdf::SDFPtr factorySDF
Store a factory SDF object to improve speed at which objects are inserted via the factory...
Definition: WorldPrivate.hh:238
bool resetModelOnly
True to reset only model poses.
Definition: WorldPrivate.hh:192
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:121
std::list< std::string > deleteEntity
List of entities to delete.
Definition: WorldPrivate.hh:171
uint64_t iterations
The number of simulation iterations.
Definition: WorldPrivate.hh:247
boost::recursive_mutex * worldUpdateMutex
Used by World classs in following calls: World::Step for then entire function World::StepWorld for ch...
Definition: WorldPrivate.hh:162
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:287
common::Time pauseStartTime
Time at which pause started.
Definition: WorldPrivate.hh:139
common::Time prevProcessMsgsTime
Last time incoming messages were processed.
Definition: WorldPrivate.hh:213
bool loaded
True if the world has been loaded.
Definition: WorldPrivate.hh:198
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:241
transport::SubscriberPtr controlSub
Subscriber to world control messages.
Definition: WorldPrivate.hh:109
boost::shared_ptr< Subscriber > SubscriberPtr
Definition: TransportTypes.hh:53
bool initialized
True if the world has been initialized.
Definition: WorldPrivate.hh:195
transport::PublisherPtr responsePub
Publisher for request response messages.
Definition: WorldPrivate.hh:91
Forward declarations for transport.
Model_V models
A cached list of models. This is here for performance.
Definition: WorldPrivate.hh:278
boost::thread * logThread
Worker thread for logging.
Definition: WorldPrivate.hh:275
uint64_t stopIterations
The number of simulation iterations to take before stopping.
Definition: WorldPrivate.hh:250
transport::NodePtr node
Transportation node.
Definition: WorldPrivate.hh:85
transport::PublisherPtr guiPub
Publisher for gui messages.
Definition: WorldPrivate.hh:97
std::vector< WorldPluginPtr > plugins
All the plugins.
Definition: WorldPrivate.hh:168
event::Connection_V connections
All the event connections.
Definition: WorldPrivate.hh:82
transport::SubscriberPtr requestSub
Subscriber to request messages.
Definition: WorldPrivate.hh:124
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:282
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:136
boost::mutex entityDeleteMutex
Mutex to protect the deleteEntity list.
Definition: WorldPrivate.hh:272
boost::mutex * loadModelMutex
Mutex to protext loading of models.
Definition: WorldPrivate.hh:148
transport::PublisherPtr poseLocalPub
Publisher for local pose messages.
Definition: WorldPrivate.hh:106
Private data class for World.
Definition: WorldPrivate.hh:43
bool enablePhysicsEngine
True to enable the physics engine.
Definition: WorldPrivate.hh:201
std::list< msgs::Factory > factoryMsgs
Factory message buffer.
Definition: WorldPrivate.hh:177
boost::shared_ptr< PhysicsEngine > PhysicsEnginePtr
Definition: PhysicsTypes.hh:106
sdf::ElementPtr sdf
THe world's SDF values.
Definition: WorldPrivate.hh:165
transport::SubscriberPtr jointSub
Subscriber to joint messages.
Definition: WorldPrivate.hh:115
msgs::WorldStatistics worldStatsMsg
Outgoing world statistics message.
Definition: WorldPrivate.hh:127
PhysicsEnginePtr physicsEngine
Pointer the physics engine.
Definition: WorldPrivate.hh:49
void(World::* modelUpdateFunc)()
Function pointer to the model update function.
Definition: WorldPrivate.hh:133
The world provides access to all other object within a simulated environment.
Definition: World.hh:62
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:142
transport::PublisherPtr modelPub
Publisher for model messages.
Definition: WorldPrivate.hh:94
transport::PublisherPtr lightPub
Publisher for light messages.
Definition: WorldPrivate.hh:100
bool resetAll
True to reset everything.
Definition: WorldPrivate.hh:186
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:154
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:210
WorldState prevStates[2]
Buffer of prev states.
Definition: WorldPrivate.hh:225
boost::recursive_mutex * receiveMutex
Mutex to protect incoming message buffers.
Definition: WorldPrivate.hh:145
boost::condition_variable logContinueCondition
Condition used to guarantee the log worker thread doesn't skip an interation.
Definition: WorldPrivate.hh:257
std::vector< ConnectionPtr > Connection_V
Definition: CommonTypes.hh:148
int stateToggle
Int used to toggle between prevStates.
Definition: WorldPrivate.hh:228
WorldState logPlayState
Current state when playing from a log file.
Definition: WorldPrivate.hh:234
boost::shared_ptr< Node > NodePtr
Definition: TransportTypes.hh:57
bool needsReset
True to reset the world on next update.
Definition: WorldPrivate.hh:183
bool pluginsLoaded
True if the plugins have been loaded.
Definition: WorldPrivate.hh:207
boost::condition_variable logCondition
Condition used for log worker.
Definition: WorldPrivate.hh:253
bool stop
True to stop the world from running.
Definition: WorldPrivate.hh:61
transport::PublisherPtr posePub
Publisher for pose messages.
Definition: WorldPrivate.hh:103
boost::mutex logBufferMutex
Mutex to protect the log state buffers.
Definition: WorldPrivate.hh:269
common::Time processMsgsPeriod
Period over which messages should be processed.
Definition: WorldPrivate.hh:216
std::deque< WorldState > states[2]
Alternating buffer of states.
Definition: WorldPrivate.hh:219
transport::PublisherPtr statPub
Publisher for world statistics messages.
Definition: WorldPrivate.hh:88
std::vector< ModelPtr > Model_V
Definition: PhysicsTypes.hh:170
common::UpdateInfo updateInfo
Info passed through the WorldUpdateBegin event.
Definition: WorldPrivate.hh:244
common::Time startTime
Clock time when simulation was started.
Definition: WorldPrivate.hh:73
transport::SubscriberPtr factorySub
Subscriber to factory messages.
Definition: WorldPrivate.hh:112
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:174
std::list< msgs::Model > modelMsgs
Model message buffer.
Definition: WorldPrivate.hh:180
boost::shared_ptr< SphericalCoordinates > SphericalCoordinatesPtr
Definition: CommonTypes.hh:135
uint64_t logPrevIteration
Last iteration recorded by the log worker thread.
Definition: WorldPrivate.hh:260
transport::SubscriberPtr lightSub
Subscriber to light messages.
Definition: WorldPrivate.hh:118
RayShapePtr testRay
Ray used to test for collisions when placing entities.
Definition: WorldPrivate.hh:204
bool resetTimeOnly
True to reset only the time.
Definition: WorldPrivate.hh:189
int currentStateBuffer
Keep track of current state buffer being updated.
Definition: WorldPrivate.hh:222
sdf::ElementPtr logPlayStateSDF
State from from log file.
Definition: WorldPrivate.hh:231
common::Time logRealTime
Real time value set from a log file.
Definition: WorldPrivate.hh:263
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:266
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43
boost::shared_ptr< RayShape > RayShapePtr
Definition: PhysicsTypes.hh:114