29 #include <boost/enable_shared_from_this.hpp>
30 #include <boost/shared_ptr.hpp>
48 class recursive_mutex;
66 class World :
public boost::enable_shared_from_this<World>
72 public:
explicit World(
const std::string &_name =
"");
87 public:
void Save(
const std::string &_filename);
110 public:
void Clear();
114 public: std::string
GetName()
const;
149 public:
void Reset();
262 public: std::string
StripWorldName(
const std::string &_name)
const;
284 public:
void LoadPlugin(
const std::string &_filename,
285 const std::string &_name,
295 {
return this->setWorldPoseMutex;}
300 {
return this->enablePhysicsEngine;}
305 {this->enablePhysicsEngine = _enable;}
316 private:
ModelPtr GetModelById(
unsigned int _id);
321 private:
void LoadPlugins();
347 private:
void RunLoop();
350 private:
void Step();
353 private:
void LogStep();
356 private:
void Update();
360 private:
void OnPause(
bool _p);
363 private:
void OnStep();
367 private:
void OnControl(ConstWorldControlPtr &_data);
371 private:
void OnRequest(ConstRequestPtr &_msg);
375 private:
void SetSelectedEntityCB(
const std::string &_name);
381 private:
void BuildSceneMsg(msgs::Scene &_scene,
BasePtr _entity);
385 private:
void JointLog(ConstJointPtr &_msg);
389 private:
void OnFactoryMsg(ConstFactoryPtr &_data);
393 private:
void OnModelMsg(ConstModelPtr &_msg);
396 private:
void ModelUpdateTBB();
399 private:
void ModelUpdateSingleLoop();
408 private:
void FillModelMsg(msgs::Model &_msg,
ModelPtr _model);
411 private:
void ProcessEntityMsgs();
414 private:
void ProcessRequestMsgs();
417 private:
void ProcessFactoryMsgs();
420 private:
void ProcessModelMsgs();
423 private:
bool OnLog(std::ostringstream &_stream);
426 private:
void ProcessMessages();
429 private:
void PublishWorldStats();
441 private: boost::thread *thread;
450 private: std::vector<google::protobuf::Message> messages;
453 private: std::string name;
468 private:
int stepInc;
510 private: msgs::WorldStatistics worldStatsMsg;
513 private: msgs::Scene sceneMsg;
516 private: void (
World::*modelUpdateFunc)();
531 private: boost::mutex *receiveMutex;
534 private: boost::mutex *loadModelMutex;
540 private: boost::mutex *setWorldPoseMutex;
548 private: boost::recursive_mutex *worldUpdateMutex;
554 private: std::vector<WorldPluginPtr> plugins;
557 private: std::list<std::string> deleteEntity;
565 private: std::list<msgs::Request> requestMsgs;
568 private: std::list<msgs::Factory> factoryMsgs;
571 private: std::list<msgs::Model> modelMsgs;
574 private:
bool needsReset;
577 private:
bool resetAll;
580 private:
bool resetTimeOnly;
583 private:
bool resetModelOnly;
586 private:
bool initialized;
589 private:
bool enablePhysicsEngine;
595 private:
bool pluginsLoaded;
607 private: std::deque<WorldState> states;
609 private:
int stateToggle;