Revision: 8891
http://playerstage.svn.sourceforge.net/playerstage/?rev=8891&view=rev
Author: hsujohnhsu
Date: 2010-09-10 19:36:35 +0000 (Fri, 10 Sep 2010)
Log Message:
-----------
fix udpate rate for Controller Sensor OgreCamera (renderRate)
Modified Paths:
--------------
code/gazebo/branches/wg/server/Simulator.cc
code/gazebo/branches/wg/server/controllers/Controller.cc
code/gazebo/branches/wg/server/controllers/Controller.hh
code/gazebo/branches/wg/server/rendering/OgreCamera.cc
code/gazebo/branches/wg/server/rendering/UserCamera.cc
code/gazebo/branches/wg/server/sensors/Sensor.cc
Modified: code/gazebo/branches/wg/server/Simulator.cc
===================================================================
--- code/gazebo/branches/wg/server/Simulator.cc 2010-09-10 16:57:23 UTC (rev
8890)
+++ code/gazebo/branches/wg/server/Simulator.cc 2010-09-10 19:36:35 UTC (rev
8891)
@@ -704,15 +704,9 @@
{
{
- DIAGNOSTICTIMER(timer("PhysicsLoop Get Rendering Mutex ",6));
+ DIAGNOSTICTIMER(timer("PhysicsLoop MR MD Mutex and world->Update()
",6));
boost::recursive_mutex::scoped_lock lock(*this->GetMRMutex());
- }
- {
- DIAGNOSTICTIMER(timer("PhysicsLoop Get Model Mutex ",6));
boost::recursive_mutex::scoped_lock
model_delete_lock(*this->GetMDMutex());
- }
- {
- DIAGNOSTICTIMER(timer("PhysicsLoop world->Update() ",6));
world->Update();
}
}
Modified: code/gazebo/branches/wg/server/controllers/Controller.cc
===================================================================
--- code/gazebo/branches/wg/server/controllers/Controller.cc 2010-09-10
16:57:23 UTC (rev 8890)
+++ code/gazebo/branches/wg/server/controllers/Controller.cc 2010-09-10
19:36:35 UTC (rev 8891)
@@ -47,7 +47,7 @@
this->nameP = new ParamT<std::string>("name","",1);
this->alwaysOnP = new ParamT<bool>("alwaysOn", false, 0);
this->updateRateP = new ParamT<double>("updateRate", 10, 0);
- this->updateRateP->Callback(&Controller::SetUpdateRate, (Controller*)this);
+ this->updateRateP->Callback(&Controller::SetUpdateRate, this);
Param::End();
if (!dynamic_cast<Model*>(entity) && !dynamic_cast<Sensor*>(entity))
@@ -83,9 +83,9 @@
this->alwaysOnP->Load(node);
this->updateRateP->Load(node);
+ this->SetUpdateRate(this->updateRateP->GetValue());
+ //printf("updatePeriod loaded %f Rate:
%f\n",this->updatePeriod.Double(),**this->updateRateP);
- this->lastUpdate = Simulator::Instance()->GetSimTime();
-
childNode = node->GetChildByNSPrefix("interface");
// Create the interfaces
@@ -144,11 +144,11 @@
void Controller::SetUpdateRate(const double &rate)
{
- this->updateRateP->SetValue(rate);
if (rate == 0)
this->updatePeriod = 0.0;
else
this->updatePeriod = 1.0 / rate;
+ this->updateRateP->SetValue(rate); // need this when called externally
}
@@ -157,6 +157,8 @@
/// Initialize the controller. Called once on startup.
void Controller::Init()
{
+ this->lastUpdate = Simulator::Instance()->GetSimTime();
+
this->InitChild();
}
@@ -204,10 +206,10 @@
//timer.Start();
Time simTime = Simulator::Instance()->GetSimTime();
- if ((simTime-lastUpdate-updatePeriod)/physics_dt >= 0)
+ if ((simTime-this->lastUpdate-this->updatePeriod)/physics_dt >= 0)
{
this->UpdateChild();
- lastUpdate = Simulator::Instance()->GetSimTime();
+ this->lastUpdate = Simulator::Instance()->GetSimTime();
//timer.Report("Update() dt");
}
}
Modified: code/gazebo/branches/wg/server/controllers/Controller.hh
===================================================================
--- code/gazebo/branches/wg/server/controllers/Controller.hh 2010-09-10
16:57:23 UTC (rev 8890)
+++ code/gazebo/branches/wg/server/controllers/Controller.hh 2010-09-10
19:36:35 UTC (rev 8891)
@@ -125,7 +125,7 @@
protected: ParamT<bool> *alwaysOnP;
/// \brief Update period
- protected: double updatePeriod;
+ protected: Time updatePeriod;
protected: ParamT<double> *updateRateP;
private: std::string typeName;
Modified: code/gazebo/branches/wg/server/rendering/OgreCamera.cc
===================================================================
--- code/gazebo/branches/wg/server/rendering/OgreCamera.cc 2010-09-10
16:57:23 UTC (rev 8890)
+++ code/gazebo/branches/wg/server/rendering/OgreCamera.cc 2010-09-10
19:36:35 UTC (rev 8891)
@@ -101,19 +101,7 @@
this->viewController = new FPSViewController(this);
}
-
//////////////////////////////////////////////////////////////////////////////
-// Set update rate for the camera rendering
-void OgreCamera::SetUpdateRate(const double &rate)
-{
- this->updateRateP->SetValue(rate);
- if (**this->updateRateP == 0)
- this->renderPeriod = Time(0.0);
- else
- this->renderPeriod = Time(1.0/(**this->updateRateP));
-}
-
-//////////////////////////////////////////////////////////////////////////////
// Destructor
OgreCamera::~OgreCamera()
{
@@ -123,6 +111,7 @@
if (this->bayerFrameBuffer)
delete [] this->bayerFrameBuffer;
+ delete this->updateRateP;
delete this->nearClipP;
delete this->farClipP;
delete this->saveFramesP;
@@ -156,6 +145,10 @@
if (!Simulator::Instance()->GetRenderEngineEnabled())
return;
+ this->updateRateP->Load(node);
+ SetUpdateRate(this->updateRateP->GetValue());
+ //printf("renderPeriod loaded %f Rate:
%f\n",this->renderPeriod.Double(),**this->updateRateP);
+
this->visibilityMask = GZ_ALL_CAMERA;
if (node)
@@ -255,6 +248,8 @@
OgreAdaptor::Instance()->RegisterCamera(this);
this->origParentNode = (Ogre::SceneNode*)this->sceneNode->getParent();
+
+ this->lastUpdate = Simulator::Instance()->GetSimTime();
}
//////////////////////////////////////////////////////////////////////////////
@@ -318,6 +313,17 @@
return this->renderingEnabled;
}
+//////////////////////////////////////////////////////////////////////////////
+// Set update rate for the camera rendering
+void OgreCamera::SetUpdateRate(const double &rate)
+{
+ if (rate == 0)
+ this->renderPeriod = 0.0;
+ else
+ this->renderPeriod = 1.0/rate;
+ this->updateRateP->SetValue(rate); // need this when called externally
+}
+
////////////////////////////////////////////////////////////////////////////////
// Render the camera
void OgreCamera::Render()
Modified: code/gazebo/branches/wg/server/rendering/UserCamera.cc
===================================================================
--- code/gazebo/branches/wg/server/rendering/UserCamera.cc 2010-09-10
16:57:23 UTC (rev 8890)
+++ code/gazebo/branches/wg/server/rendering/UserCamera.cc 2010-09-10
19:36:35 UTC (rev 8891)
@@ -188,8 +188,8 @@
{
boost::recursive_mutex::scoped_lock
md_lock(*Simulator::Instance()->GetMDMutex());
OgreCamera::UpdateCam();
- this->window->update();
}
+ this->window->update();
if (this->saveFramesP->GetValue())
{
Modified: code/gazebo/branches/wg/server/sensors/Sensor.cc
===================================================================
--- code/gazebo/branches/wg/server/sensors/Sensor.cc 2010-09-10 16:57:23 UTC
(rev 8890)
+++ code/gazebo/branches/wg/server/sensors/Sensor.cc 2010-09-10 19:36:35 UTC
(rev 8891)
@@ -53,7 +53,7 @@
Param::Begin(&this->parameters);
this->updateRateP = new ParamT<double>("updateRate", 0, 0);
- this->updateRateP->Callback(&Sensor::SetUpdateRate, (Sensor*)this);
+ this->updateRateP->Callback(&Sensor::SetUpdateRate, this);
this->alwaysActiveP = new ParamT<bool>("alwaysActive", false, 0);
Param::End();
}
@@ -72,6 +72,9 @@
{
this->nameP->Load(node);
this->updateRateP->Load(node);
+ this->SetUpdateRate(this->updateRateP->GetValue());
+ //printf("updatePeriod loaded %f Rate:
%f\n",this->updatePeriod.Double(),**this->updateRateP);
+
this->alwaysActiveP->Load(node);
this->LoadController( node->GetChildByNSPrefix("controller") );
@@ -81,20 +84,9 @@
}
-////////////////////////////////////////////////////////////////////////////////
-/// Save the sensor info in XML format
-void Sensor::SetUpdateRate(const double &rate)
-{
- this->updateRateP->SetValue(rate);
- if (rate == 0)
- this->updatePeriod = 0.0;
- else
- this->updatePeriod = 1.0 / rate;
-}
-
////////////////////////////////////////////////////////////////////////////////
/// Save the sensor info in XML format
void Sensor::Save(std::string &prefix, std::ostream &stream)
@@ -126,6 +118,19 @@
}
////////////////////////////////////////////////////////////////////////////////
+/// Save the sensor info in XML format
+void Sensor::SetUpdateRate(const double &rate)
+{
+
+ if (rate == 0)
+ this->updatePeriod = 0.0;
+ else
+ this->updatePeriod = 1.0 / rate;
+ this->updateRateP->SetValue(rate); // need this when called externally
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
/// Update the sensor
void Sensor::Update()
{
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit