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();
255 public: std::string
StripWorldName(
const std::string &_name)
const;
277 public:
void LoadPlugin(
const std::string &_filename,
278 const std::string &_name,
288 {
return this->setWorldPoseMutex;}
293 {
return this->enablePhysicsEngine;}
298 {this->enablePhysicsEngine = _enable;}
318 private:
ModelPtr GetModelById(
unsigned int _id);
323 private:
void LoadPlugins();
349 private:
void RunLoop();
352 private:
void Step();
355 private:
void LogStep();
358 private:
void Update();
362 private:
void OnPause(
bool _p);
365 private:
void OnStep();
369 private:
void OnControl(ConstWorldControlPtr &_data);
373 private:
void OnRequest(ConstRequestPtr &_msg);
377 private:
void SetSelectedEntityCB(
const std::string &_name);
383 private:
void BuildSceneMsg(msgs::Scene &_scene,
BasePtr _entity);
387 private:
void JointLog(ConstJointPtr &_msg);
391 private:
void OnFactoryMsg(ConstFactoryPtr &_data);
395 private:
void OnModelMsg(ConstModelPtr &_msg);
398 private:
void ModelUpdateTBB();
401 private:
void ModelUpdateSingleLoop();
410 private:
void FillModelMsg(msgs::Model &_msg,
ModelPtr _model);
414 private:
void ProcessEntityMsgs();
418 private:
void ProcessRequestMsgs();
422 private:
void ProcessFactoryMsgs();
426 private:
void ProcessModelMsgs();
429 private:
bool OnLog(std::ostringstream &_stream);
432 private:
void ProcessMessages();
435 private:
void PublishWorldStats();
447 private: boost::thread *thread;
456 private: std::vector<google::protobuf::Message> messages;
459 private: std::string name;
474 private:
int stepInc;
519 private: msgs::WorldStatistics worldStatsMsg;
522 private: msgs::Scene sceneMsg;
525 private: void (
World::*modelUpdateFunc)();
540 private: boost::recursive_mutex *receiveMutex;
543 private: boost::mutex *loadModelMutex;
549 private: boost::mutex *setWorldPoseMutex;
557 private: boost::recursive_mutex *worldUpdateMutex;
563 private: std::vector<WorldPluginPtr> plugins;
566 private: std::list<std::string> deleteEntity;
574 private: std::list<msgs::Request> requestMsgs;
577 private: std::list<msgs::Factory> factoryMsgs;
580 private: std::list<msgs::Model> modelMsgs;
583 private:
bool needsReset;
586 private:
bool resetAll;
589 private:
bool resetTimeOnly;
592 private:
bool resetModelOnly;
595 private:
bool initialized;
598 private:
bool loaded;
601 private:
bool enablePhysicsEngine;
607 private:
bool pluginsLoaded;
619 private: std::deque<WorldState> states;
621 private:
int stateToggle;
631 private: msgs::Pose_V poseMsgs;