Revision: 8441 http://playerstage.svn.sourceforge.net/playerstage/?rev=8441&view=rev Author: natepak Date: 2009-11-24 01:14:03 +0000 (Tue, 24 Nov 2009)
Log Message: ----------- Added parameters for save buffer Modified Paths: -------------- code/gazebo/trunk/server/Timer.hh code/gazebo/trunk/server/World.cc code/gazebo/trunk/server/World.hh Modified: code/gazebo/trunk/server/Timer.hh =================================================================== --- code/gazebo/trunk/server/Timer.hh 2009-11-23 23:59:22 UTC (rev 8440) +++ code/gazebo/trunk/server/Timer.hh 2009-11-24 01:14:03 UTC (rev 8441) @@ -38,7 +38,7 @@ /// \brief Constructor /// \param t The type of timer (based on either the simulation or real /// time) - public: Timer(Type t); + public: Timer(Type t=Timer::REAL_TIMER); /// \brief Destructor public: virtual ~Timer(); Modified: code/gazebo/trunk/server/World.cc =================================================================== --- code/gazebo/trunk/server/World.cc 2009-11-23 23:59:22 UTC (rev 8440) +++ code/gazebo/trunk/server/World.cc 2009-11-24 01:14:03 UTC (rev 8441) @@ -68,16 +68,12 @@ PhysicsFactory::RegisterAll(); this->factory = NULL; -#ifdef USE_THREADPOOL Param::Begin(&this->parameters); this->threadsP = new ParamT<int>("threads",2,0); + this->saveStateTimeoutP = new ParamT<Time>("saveStateResolution",0.1,0); + this->saveStateBufferSizeP = new ParamT<unsigned int>("saveStateBufferSize",1000,0); Param::End(); -#endif - this->worldStates.resize(10000); - this->worldStatesInsertIter = this->worldStates.begin(); - this->worldStatesEndIter = this->worldStates.begin(); - this->worldStatesCurrentIter = this->worldStatesInsertIter; } //////////////////////////////////////////////////////////////////////////////// @@ -134,8 +130,12 @@ this->factory = NULL; } + delete this->saveStateTimeoutP; + delete this->saveStateBufferSizeP; + + delete this->threadsP; + #ifdef USE_THREADPOOL - delete this->threadsP; delete this->threadPool; #endif @@ -206,9 +206,18 @@ this->physicsEngine->Load(rootNode); + this->threadsP->Load(rootNode); + this->saveStateTimeoutP->Load(rootNode); + this->saveStateBufferSizeP->Load(rootNode); + + this->worldStates.resize(**this->saveStateBufferSizeP); + this->worldStatesInsertIter = this->worldStates.begin(); + this->worldStatesEndIter = this->worldStates.begin(); + this->worldStatesCurrentIter = this->worldStatesInsertIter; + + #ifdef USE_THREADPOOL // start a thread pool with X threads - this->threadsP->Load(rootNode); this->threadPool = new boost::threadpool::pool(this->threadsP->GetValue()); #endif } @@ -219,6 +228,10 @@ { std::vector< Model* >::iterator miter; + std::cout << prefix << " " << *(this->threadsP); + std::cout << prefix << " " << *(this->saveStateTimeoutP); + std::cout << prefix << " " << *(this->saveStateBufferSizeP); + // Save all the models for (miter=this->models.begin(); miter!=this->models.end(); miter++) { @@ -260,6 +273,7 @@ this->graphics->Init(); this->factory->Init(); + this->saveStateTimer.Start(); } //////////////////////////////////////////////////////////////////////////////// @@ -333,7 +347,12 @@ Simulator::Instance()->GetPhysicsEnabled()) { this->physicsEngine->UpdatePhysics(); - this->SaveState(); + + if (this->saveStateTimer.GetElapsed() > **this->saveStateTimeoutP) + { + this->SaveState(); + this->saveStateTimer.Start(); + } } this->factory->Update(); Modified: code/gazebo/trunk/server/World.hh =================================================================== --- code/gazebo/trunk/server/World.hh 2009-11-23 23:59:22 UTC (rev 8440) +++ code/gazebo/trunk/server/World.hh 2009-11-24 01:14:03 UTC (rev 8441) @@ -46,6 +46,7 @@ #include "Pose3d.hh" #include "Entity.hh" #include "Global.hh" +#include "Timer.hh" namespace gazebo { @@ -64,6 +65,8 @@ class OpenAL; class Factory; class WorldState; + class Timer; + class Time; /// \brief The World /* @@ -271,10 +274,12 @@ private: OpenAL *openAL; -#ifdef USE_THREADPOOL - private: ParamT<int>* threadsP; /// List of all the parameters protected: std::vector<Param*> parameters; + + private: ParamT<int>* threadsP; + +#ifdef USE_THREADPOOL public: boost::threadpool::pool* threadPool; #endif @@ -287,6 +292,10 @@ private: std::deque<WorldState>::iterator worldStatesInsertIter; private: std::deque<WorldState>::iterator worldStatesEndIter; private: std::deque<WorldState>::iterator worldStatesCurrentIter; + + private: Timer saveStateTimer; + private: ParamT<Time> *saveStateTimeoutP; + private: ParamT<unsigned int> *saveStateBufferSizeP; }; class WorldState This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Playerstage-commit mailing list Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit