From: <na...@us...> - 2009-03-17 00:18:33
|
Revision: 7491 http://playerstage.svn.sourceforge.net/playerstage/?rev=7491&view=rev Author: natepak Date: 2009-03-17 00:18:30 +0000 (Tue, 17 Mar 2009) Log Message: ----------- Throttle the gui update to 30hz Modified Paths: -------------- code/branches/federation/gazebo/SConstruct code/branches/federation/gazebo/server/Simulator.cc code/branches/federation/gazebo/worlds/bandit.world Modified: code/branches/federation/gazebo/SConstruct =================================================================== --- code/branches/federation/gazebo/SConstruct 2009-03-17 00:01:48 UTC (rev 7490) +++ code/branches/federation/gazebo/SConstruct 2009-03-17 00:18:30 UTC (rev 7491) @@ -173,11 +173,13 @@ CXXCOMSTR = 'Compiling $TARGET', CCCOMSTR = 'Compiling $TARGET', LINKCOMSTR = 'Linking $TARGET', + ARCOMSTR = 'Linking $TARGET', # Shared object compile strings SHCXXCOMSTR = 'Compiling $TARGET', SHCCCOMSTR = 'Compiling $TARGET', SHLINKCOMSTR = 'Linking $TARGET', + SHARCOMSTR = 'Linking $TARGET', HAS_ERROR = False, ) Modified: code/branches/federation/gazebo/server/Simulator.cc =================================================================== --- code/branches/federation/gazebo/server/Simulator.cc 2009-03-17 00:01:48 UTC (rev 7490) +++ code/branches/federation/gazebo/server/Simulator.cc 2009-03-17 00:18:30 UTC (rev 7491) @@ -286,6 +286,9 @@ /// Main simulation loop, when this loop ends the simulation finish void Simulator::MainLoop() { + double currTime, lastTime; + double freq = 30.0; + this->physicsThread = new boost::thread( boost::bind(&Simulator::PhysicsLoop, this)); if (this->gui) @@ -293,8 +296,24 @@ // Update the gui while (!this->userQuit) { - this->gui->Update(); - usleep(1000); + currTime = this->GetWallTime(); + if ( currTime - lastTime > 1/freq) + { + lastTime = this->GetWallTime(); + this->gui->Update(); + currTime = this->GetWallTime(); + + //printf("Curr Time[%f] LastTime[%f] Period[%f] %f]\n",currTime, lastTime, 1/freq, currTime-lastTime); + if (currTime - lastTime < 1/freq) + { + usleep((1/freq - (currTime - lastTime)) * 1e6); + } + } + else + { + //printf("Now Here[%f]\n",1/freq - (currTime - lastTime)); + usleep((1/freq - currTime - lastTime) * 1e6); + } } } @@ -545,8 +564,7 @@ boost::recursive_mutex::scoped_lock lock(*this->mutex); world->Update(); } - - usleep(100); + usleep(1); } // Process all incoming messages from simiface Modified: code/branches/federation/gazebo/worlds/bandit.world =================================================================== --- code/branches/federation/gazebo/worlds/bandit.world 2009-03-17 00:01:48 UTC (rev 7490) +++ code/branches/federation/gazebo/worlds/bandit.world 2009-03-17 00:18:30 UTC (rev 7491) @@ -16,7 +16,7 @@ <verbosity>5</verbosity> <physics:ode> - <stepTime>0.003</stepTime> + <stepTime>0.03</stepTime> <gravity>0 0 -9.8</gravity> <cfm>10e-5</cfm> <erp>0.3</erp> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |