Revision: 7386
          http://playerstage.svn.sourceforge.net/playerstage/?rev=7386&view=rev
Author:   natepak
Date:     2009-03-08 05:05:57 +0000 (Sun, 08 Mar 2009)

Log Message:
-----------
Run for a specified time

Modified Paths:
--------------
    code/branches/federation/gazebo/server/Global.hh
    code/branches/federation/gazebo/server/Model.cc
    code/branches/federation/gazebo/server/Model.hh
    code/branches/federation/gazebo/server/Simulator.cc
    code/branches/federation/gazebo/server/Simulator.hh
    code/branches/federation/gazebo/server/World.cc
    code/branches/federation/gazebo/server/World.hh
    code/branches/federation/gazebo/server/sensors/ir/IRSensor.cc
    code/branches/federation/gazebo/server/sensors/ray/RaySensor.cc
    code/branches/federation/gazebo/worlds/pioneer2dx.world

Modified: code/branches/federation/gazebo/server/Global.hh
===================================================================
--- code/branches/federation/gazebo/server/Global.hh    2009-03-08 04:55:48 UTC 
(rev 7385)
+++ code/branches/federation/gazebo/server/Global.hh    2009-03-08 05:05:57 UTC 
(rev 7386)
@@ -52,7 +52,7 @@
 #define GZ_ALL_COLLIDE 0xFFFFFFFF
 #define GZ_NONE_COLLIDE 0x00000000
 #define GZ_FIXED_COLLIDE 0x00000001
-#define GZ_LASER_COLLIDE 0x00000002
+#define GZ_SENSOR_COLLIDE 0x00000002
 
 #endif
 

Modified: code/branches/federation/gazebo/server/Model.cc
===================================================================
--- code/branches/federation/gazebo/server/Model.cc     2009-03-08 04:55:48 UTC 
(rev 7385)
+++ code/branches/federation/gazebo/server/Model.cc     2009-03-08 05:05:57 UTC 
(rev 7386)
@@ -75,6 +75,9 @@
   this->enableFrictionP = new ParamT<bool>("enableFriction", true, 0);
   this->enableFrictionP->Callback( &Model::SetFrictionMode, this );
 
+  this->collideP = new ParamT<std::string>("collide", "all", 0);
+  this->collideP->Callback( &Model::SetCollideMode, this );
+
   Param::End();
 
   this->parentBodyNameP = NULL;
@@ -127,6 +130,7 @@
   this->rpyP->Load(node);
   this->enableGravityP->Load(node);
   this->enableFrictionP->Load(node);
+  this->collideP->Load(node);
 
   this->xmlNode = node;
   this->type=node->GetName();
@@ -188,6 +192,8 @@
 
   this->SetFrictionMode( **this->enableFrictionP );
 
+  this->SetCollideMode( **this->collideP );
+
   return 0;
 
   // Get the name of the python module
@@ -242,6 +248,7 @@
   stream << prefix << "  " << *(this->rpyP) << "\n";
   stream << prefix << "  " << *(this->enableGravityP) << "\n";
   stream << prefix << "  " << *(this->enableFrictionP) << "\n";
+  stream << prefix << "  " << *(this->collideP) << "\n";
 
   if (this->type == "physical")
   {
@@ -822,6 +829,22 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Set the collide mode of the model
+void Model::SetCollideMode( const std::string &m )
+{
+  /*Body *body;
+
+  std::map<std::string, Body* >::iterator iter;
+
+  for (iter=this->bodies.begin(); iter!=this->bodies.end(); iter++)
+  {
+    body = iter->second;
+
+    body->SetFrictionMode( v );
+  }
+  */
+}
+////////////////////////////////////////////////////////////////////////////////
 // Load a renderable model (like a light source).
 void Model::LoadRenderable(XMLConfigNode *node)
 {

Modified: code/branches/federation/gazebo/server/Model.hh
===================================================================
--- code/branches/federation/gazebo/server/Model.hh     2009-03-08 04:55:48 UTC 
(rev 7385)
+++ code/branches/federation/gazebo/server/Model.hh     2009-03-08 05:05:57 UTC 
(rev 7386)
@@ -161,6 +161,9 @@
     /// \brief Set the friction mode of the model
     public: void SetFrictionMode( const bool &v );
 
+    /// \brief Set the collide mode of the model
+    public: void SetCollideMode( const std::string &m );
+
     /// \brief Load a body helper function
     /// \param node XML Configuration node
     private: void LoadBody(XMLConfigNode *node);
@@ -213,6 +216,7 @@
     private: ParamT<std::string> *myBodyNameP;
     private: ParamT<bool> *enableGravityP;
     private: ParamT<bool> *enableFrictionP;
+    private: ParamT<std::string> *collideP;
 
     // Name of a light (if the model is renderable:light)
     private: std::string lightName;

Modified: code/branches/federation/gazebo/server/Simulator.cc
===================================================================
--- code/branches/federation/gazebo/server/Simulator.cc 2009-03-08 04:55:48 UTC 
(rev 7385)
+++ code/branches/federation/gazebo/server/Simulator.cc 2009-03-08 05:05:57 UTC 
(rev 7386)
@@ -290,11 +290,21 @@
 
   this->prevPhysicsTime = this->GetRealTime();
   this->prevRenderTime = this->GetRealTime();
- 
+
+  this->runLength = 1.0;
+
+  this->lastUpdateTime = this->GetRealTime();
+
   while (!this->userQuit)
   {
     currTime = this->GetRealTime();
 
+    if (currTime - this->lastUpdateTime > this->runLength)
+    {
+      World::Instance()->ProcessMessages();
+      continue;
+    }
+
     if (physicsUpdateRate == 0 || 
         currTime - this->prevPhysicsTime >= physicsUpdatePeriod) 
     {
@@ -316,6 +326,7 @@
 
       this->prevPhysicsTime = this->GetRealTime();
 
+      std::cout << "Updating at[" << this->GetRealTime() << "]\n";
       World::Instance()->Update();
     }
 
@@ -343,6 +354,7 @@
 
     if (this->timeout > 0 && this->GetRealTime() > this->timeout)
       break;
+
   }
 }
 
@@ -536,3 +548,9 @@
 
   return model;
 }
+
+void Simulator::Go()
+{
+  this->lastUpdateTime = this->GetRealTime();
+}
+

Modified: code/branches/federation/gazebo/server/Simulator.hh
===================================================================
--- code/branches/federation/gazebo/server/Simulator.hh 2009-03-08 04:55:48 UTC 
(rev 7385)
+++ code/branches/federation/gazebo/server/Simulator.hh 2009-03-08 05:05:57 UTC 
(rev 7386)
@@ -159,6 +159,8 @@
     /// \brief Get the model that currently selected
     public: Model *GetSelectedModel() const;
 
+    public: void Go();
+
     ///pointer to the XML Data
     private: XMLConfig *xmlFile;
 
@@ -213,9 +215,16 @@
     /// Length of time the simulation should run
     private: double timeout;
 
+    /// Length of time the simulator is allowed to run
+    private: double updateTime;
+
     /// The entity currently selected by the user
     private: Entity *selectedEntity;
 
+    /// Length of time to run before receiving a "go" command
+    private: double runLength;
+    private: double lastUpdateTime;
+
     //Singleton implementation
     private: friend class DestroyerT<Simulator>;
     private: friend class SingletonT<Simulator>;

Modified: code/branches/federation/gazebo/server/World.cc
===================================================================
--- code/branches/federation/gazebo/server/World.cc     2009-03-08 04:55:48 UTC 
(rev 7385)
+++ code/branches/federation/gazebo/server/World.cc     2009-03-08 05:05:57 UTC 
(rev 7386)
@@ -214,28 +214,15 @@
     this->physicsEngine->Update();
   }
 
+  return 0;
+}
+
+void World::ProcessMessages()
+{
   this->UpdateSimulationIface();
+}
 
-  // Copy the newly created models into the main model vector
-  std::copy(this->toAddModels.begin(), this->toAddModels.end(),
-            std::back_inserter(this->models));
-  this->toAddModels.clear();
 
-
-  // Remove and delete all models that are marked for deletion
-  for (miter=this->toDeleteModels.begin();
-       miter!=this->toDeleteModels.end(); miter++)
-  {
-    this->models.erase(
-      std::remove(this->models.begin(), this->models.end(), *miter) );
-    delete *miter;
-  }
-
-  this->toDeleteModels.clear();
-
-  return 0;
-}
-
 
////////////////////////////////////////////////////////////////////////////////
 // Finilize the world
 int World::Fini()
@@ -630,6 +617,8 @@
             // Set the model's linear and angular acceleration
             model->SetLinearAccel(linearAccel);
             model->SetAngularAccel(angularAccel);
+
+            Simulator::Instance()->Go();
           }
           else
           {
@@ -724,5 +713,26 @@
   }
 
   this->simIface->Unlock();
+
+
+  std::vector< Model* >::iterator miter;
+
+  // Copy the newly created models into the main model vector
+  std::copy(this->toAddModels.begin(), this->toAddModels.end(),
+      std::back_inserter(this->models));
+  this->toAddModels.clear();
+
+
+  // Remove and delete all models that are marked for deletion
+  for (miter=this->toDeleteModels.begin();
+      miter!=this->toDeleteModels.end(); miter++)
+  {
+    this->models.erase(
+        std::remove(this->models.begin(), this->models.end(), *miter) );
+    delete *miter;
+  }
+
+  this->toDeleteModels.clear();
+
 }
 

Modified: code/branches/federation/gazebo/server/World.hh
===================================================================
--- code/branches/federation/gazebo/server/World.hh     2009-03-08 04:55:48 UTC 
(rev 7385)
+++ code/branches/federation/gazebo/server/World.hh     2009-03-08 05:05:57 UTC 
(rev 7386)
@@ -140,6 +140,8 @@
   /// \brief Get whether to view as wireframe
   public: bool GetShowPhysics();
 
+  public: void ProcessMessages();
+
   /// Set to true to show bounding boxes
   private: bool showBoundingBoxes;
 

Modified: code/branches/federation/gazebo/server/sensors/ir/IRSensor.cc
===================================================================
--- code/branches/federation/gazebo/server/sensors/ir/IRSensor.cc       
2009-03-08 04:55:48 UTC (rev 7385)
+++ code/branches/federation/gazebo/server/sensors/ir/IRSensor.cc       
2009-03-08 05:05:57 UTC (rev 7386)
@@ -126,8 +126,8 @@
   this->raySpaceId = dSimpleSpaceCreate( this->superSpaceId );
 
   // Set collision bits
-  dGeomSetCategoryBits((dGeomID) this->raySpaceId, GZ_LASER_COLLIDE);
-  dGeomSetCollideBits((dGeomID) this->raySpaceId, ~GZ_LASER_COLLIDE);
+  dGeomSetCategoryBits((dGeomID) this->raySpaceId, GZ_SENSOR_COLLIDE);
+  dGeomSetCollideBits((dGeomID) this->raySpaceId, ~GZ_SENSOR_COLLIDE);
 
   //this->body->spaceId = this->superSpaceId;
   this->body->spaceId = this->raySpaceId;

Modified: code/branches/federation/gazebo/server/sensors/ray/RaySensor.cc
===================================================================
--- code/branches/federation/gazebo/server/sensors/ray/RaySensor.cc     
2009-03-08 04:55:48 UTC (rev 7385)
+++ code/branches/federation/gazebo/server/sensors/ray/RaySensor.cc     
2009-03-08 05:05:57 UTC (rev 7386)
@@ -108,8 +108,8 @@
   this->raySpaceId = dSimpleSpaceCreate( this->superSpaceId );
 
   // Set collision bits
-  dGeomSetCategoryBits((dGeomID) this->raySpaceId, GZ_LASER_COLLIDE);
-  dGeomSetCollideBits((dGeomID) this->raySpaceId, ~GZ_LASER_COLLIDE);
+  dGeomSetCategoryBits((dGeomID) this->raySpaceId, GZ_SENSOR_COLLIDE);
+  dGeomSetCollideBits((dGeomID) this->raySpaceId, ~GZ_SENSOR_COLLIDE);
 
   //this->body->spaceId = this->superSpaceId;
   this->body->spaceId = this->raySpaceId;
@@ -158,8 +158,6 @@
     ray = new RayGeom(this->body, displayRaysP->GetValue());
 
     ray->SetPoints(start, end);
-//    ray->SetCategoryBits( GZ_LASER_COLLIDE );
-    //ray->SetCollideBits( ~GZ_LASER_COLLIDE );
 
     this->rays.push_back(ray);
 

Modified: code/branches/federation/gazebo/worlds/pioneer2dx.world
===================================================================
--- code/branches/federation/gazebo/worlds/pioneer2dx.world     2009-03-08 
04:55:48 UTC (rev 7385)
+++ code/branches/federation/gazebo/worlds/pioneer2dx.world     2009-03-08 
05:05:57 UTC (rev 7386)
@@ -98,6 +98,7 @@
     <rpy>0.0 0.0 90.0</rpy>
     <enableGravity>false</enableGravity>
     <enableFriction>false</enableFriction>
+    <collide>sensors</collide>
 
     <controller:differential_position2d name="controller1">
       <leftJoint>left_wheel_hinge</leftJoint>


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to