Revision: 8532
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8532&view=rev
Author:   natepak
Date:     2010-01-27 16:37:21 +0000 (Wed, 27 Jan 2010)

Log Message:
-----------
Added more callback functions

Modified Paths:
--------------
    code/gazebo/trunk/server/World.cc
    code/gazebo/trunk/server/World.hh
    code/gazebo/trunk/server/physics/Geom.cc
    code/gazebo/trunk/server/physics/Joint.cc
    code/gazebo/trunk/server/physics/Joint.hh
    code/gazebo/trunk/server/physics/PhysicsEngine.cc
    code/gazebo/trunk/server/physics/ode/ODEPhysics.cc
    code/gazebo/trunk/server/rendering/OgreVisual.cc
    code/gazebo/trunk/server/rendering/OgreVisual.hh
    code/gazebo/trunk/worlds/pioneer2dx.world

Modified: code/gazebo/trunk/server/World.cc
===================================================================
--- code/gazebo/trunk/server/World.cc   2010-01-27 01:47:07 UTC (rev 8531)
+++ code/gazebo/trunk/server/World.cc   2010-01-27 16:37:21 UTC (rev 8532)
@@ -327,7 +327,6 @@
     }
   }
 
-
   {
     //DiagnosticTimer timer("World::Update Models");
 
@@ -685,14 +684,7 @@
 void World::SetShowBoundingBoxes(bool show)
 {
   this->showBoundingBoxes = show;
-
-  std::vector< Geom *>::iterator iter;
-
-  for (iter = this->geometries.begin(); iter != this->geometries.end(); iter++)
-  {
-    (*iter)->ShowBoundingBox(this->showBoundingBoxes);
-  }
-
+  this->showBoundingBoxesSignal(this->showBoundingBoxes);
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -707,13 +699,7 @@
 void World::SetShowJoints(bool show)
 {
   this->showJoints = show;
-
-  std::vector< Geom *>::iterator iter;
-
-  for (iter = this->geometries.begin(); iter != this->geometries.end(); iter++)
-  {
-    (*iter)->ShowJoints(this->showJoints);
-  }
+  this->showJointsSignal(show);
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -791,13 +777,6 @@
 {
   this->showPhysics = show;
   this->showPhysicsSignal(this->showPhysics);
-
-  /*std::vector< Geom*>::iterator iter;
-
-  for (iter = this->geometries.begin(); iter != this->geometries.end(); iter++)
-  {
-    (*iter)->ShowPhysics(this->showPhysics);
-  }*/
 }
 
 

Modified: code/gazebo/trunk/server/World.hh
===================================================================
--- code/gazebo/trunk/server/World.hh   2010-01-27 01:47:07 UTC (rev 8531)
+++ code/gazebo/trunk/server/World.hh   2010-01-27 16:37:21 UTC (rev 8532)
@@ -304,7 +304,21 @@
             showPhysicsSignal.connect(subscriber);
           }
 
+  /// \brief Connect a boost::slot the the show joints signal
+  public: template<typename T>
+          void ConnectShowJointsSignal( T subscriber )
+          {
+            showJointsSignal.connect(subscriber);
+          }
 
+  /// \brief Connect a boost::slot the the show bounding boxes signal
+  public: template<typename T>
+          void ConnectShowBoundingBoxesSignal( T subscriber )
+          {
+            showBoundingBoxesSignal.connect(subscriber);
+          }
+
+
   /// \brief Get the names of interfaces defined in the tree of a model
   private: void GetInterfaceNames(Entity* m, std::vector<std::string>& list);
 
@@ -358,6 +372,8 @@
   private: boost::signal<void (bool)> showContactsSignal;
   private: boost::signal<void (bool)> wireframeSignal;
   private: boost::signal<void (bool)> showPhysicsSignal;
+  private: boost::signal<void (bool)> showJointsSignal;
+  private: boost::signal<void (bool)> showBoundingBoxesSignal;
 
   private: std::deque<WorldState> worldStates;
   private: std::deque<WorldState>::iterator worldStatesInsertIter;

Modified: code/gazebo/trunk/server/physics/Geom.cc
===================================================================
--- code/gazebo/trunk/server/physics/Geom.cc    2010-01-27 01:47:07 UTC (rev 
8531)
+++ code/gazebo/trunk/server/physics/Geom.cc    2010-01-27 16:37:21 UTC (rev 
8532)
@@ -78,6 +78,8 @@
   Param::End();
 
   World::Instance()->ConnectShowPhysicsSignal( boost::bind(&Geom::ShowPhysics, 
this, _1) );
+  World::Instance()->ConnectShowJointsSignal( boost::bind(&Geom::ShowJoints, 
this, _1) );
+  World::Instance()->ConnectShowBoundingBoxesSignal( 
boost::bind(&Geom::ShowBoundingBox, this, _1) );
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/physics/Joint.cc
===================================================================
--- code/gazebo/trunk/server/physics/Joint.cc   2010-01-27 01:47:07 UTC (rev 
8531)
+++ code/gazebo/trunk/server/physics/Joint.cc   2010-01-27 16:37:21 UTC (rev 
8532)
@@ -63,6 +63,9 @@
   this->body2 = NULL;
 
   this->physics = World::Instance()->GetPhysicsEngine();
+
+  World::Instance()->ConnectShowJointsSignal( 
+      boost::bind(&Joint::ShowJoints, this, _1) );
 }
 
 
@@ -216,15 +219,14 @@
 /// Update the joint
 void Joint::Update()
 {
-  this->anchorPos = (Pose3d(**(this->anchorOffsetP),Quatern()) + 
-                     this->anchorBody->GetAbsPose()).pos;
-
   //TODO: Evaluate impact of this code on performance
-  if (this->visual)
+  if (this->visual && this->visual->GetVisible())
   {
-    this->visual->SetVisible(World::Instance()->GetShowJoints());
+    this->anchorPos = (Pose3d(**(this->anchorOffsetP),Quatern()) + 
+        this->anchorBody->GetAbsPose()).pos;
 
     this->visual->SetPosition(this->anchorPos);
+
     if (this->body1) 
       this->line1->SetPoint(1, this->body1->GetAbsPose().pos - 
this->anchorPos);
 
@@ -234,6 +236,14 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
+// Set the joint to show visuals
+void Joint::ShowJoints(bool s)
+{
+  if (this->visual)
+    this->visual->SetVisible(s);
+}
+
+//////////////////////////////////////////////////////////////////////////////
 /// Reset the joint
 void Joint::Reset()
 {

Modified: code/gazebo/trunk/server/physics/Joint.hh
===================================================================
--- code/gazebo/trunk/server/physics/Joint.hh   2010-01-27 01:47:07 UTC (rev 
8531)
+++ code/gazebo/trunk/server/physics/Joint.hh   2010-01-27 16:37:21 UTC (rev 
8532)
@@ -70,6 +70,9 @@
     /// \brief Update the joint
     public: void Update();
 
+    /// \brief Set the joint to show visuals
+    public: void ShowJoints(bool s);
+
     /// \brief Reset the joint
     public: virtual void Reset();
 

Modified: code/gazebo/trunk/server/physics/PhysicsEngine.cc
===================================================================
--- code/gazebo/trunk/server/physics/PhysicsEngine.cc   2010-01-27 01:47:07 UTC 
(rev 8531)
+++ code/gazebo/trunk/server/physics/PhysicsEngine.cc   2010-01-27 16:37:21 UTC 
(rev 8532)
@@ -102,8 +102,6 @@
 {
 }
 
-
-
 
////////////////////////////////////////////////////////////////////////////////
 /// Return the gavity vector
 Vector3 PhysicsEngine::GetGravity() const

Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc
===================================================================
--- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc  2010-01-27 01:47:07 UTC 
(rev 8531)
+++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc  2010-01-27 16:37:21 UTC 
(rev 8532)
@@ -254,19 +254,14 @@
 
   // Update the dynamical model
   if (**this->quickStepP)
-  {
     dWorldQuickStep(this->worldId, (**this->stepTimeP).Double());
-  }
   else
-  {
     dWorldStep( this->worldId, (**this->stepTimeP).Double() );
-  }
 
   // Very important to clear out the contact group
   dJointGroupEmpty( this->contactGroup );
 
   this->UnlockMutex(); 
-
 }
 
 

Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.cc    2010-01-27 01:47:07 UTC 
(rev 8531)
+++ code/gazebo/trunk/server/rendering/OgreVisual.cc    2010-01-27 16:37:21 UTC 
(rev 8532)
@@ -64,6 +64,7 @@
     isStatic = this->owner->IsStatic();
   }
 
+  this->visible = true;
   this->ConstructorHelper(pnode, isStatic);
 }
 
@@ -655,8 +656,15 @@
     return;
 
   this->sceneNode->setVisible( visible, cascade );
+  this->visible = visible;
 }
 
+////////////////////////////////////////////////////////////////////////////////
+/// Get whether the visual is visible
+bool OgreVisual::GetVisible() const
+{
+  return this->visible;
+}
 
 
////////////////////////////////////////////////////////////////////////////////
 // Set the position of the visual

Modified: code/gazebo/trunk/server/rendering/OgreVisual.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.hh    2010-01-27 01:47:07 UTC 
(rev 8531)
+++ code/gazebo/trunk/server/rendering/OgreVisual.hh    2010-01-27 16:37:21 UTC 
(rev 8532)
@@ -106,6 +106,9 @@
     /// \param cascade setting this parameter in children too
     public: void SetVisible(bool visible, bool cascade=true);
 
+    /// \brief Get whether the visual is visible
+    public: bool GetVisible() const;
+
     /// \brief Set the position of the visual
     public: void SetPosition( const Vector3 &pos);
 
@@ -191,6 +194,7 @@
 
     private: bool isStatic;
     private: Ogre::StaticGeometry *staticGeom;
+    private: bool visible;
   };
 }
 

Modified: code/gazebo/trunk/worlds/pioneer2dx.world
===================================================================
--- code/gazebo/trunk/worlds/pioneer2dx.world   2010-01-27 01:47:07 UTC (rev 
8531)
+++ code/gazebo/trunk/worlds/pioneer2dx.world   2010-01-27 16:37:21 UTC (rev 
8532)
@@ -19,14 +19,14 @@
   <verbosity>4</verbosity>
 
   <physics:ode>
-    <stepTime>0.0005</stepTime>
+    <stepTime>0.001</stepTime>
     <gravity>0 0 -9.8</gravity>
     <cfm>10e-5</cfm>
     <erp>0.3</erp>
     <!-- updateRate: <0 == throttle simTime to match realTime.
                       0 == No throttling
                      >0 == Frequency at which to throttle the sim --> 
-    <updateRate>-1</updateRate>
+    <updateRate>0</updateRate>
   </physics:ode>
 
   <rendering:gui>
@@ -145,7 +145,6 @@
     </include>
   </model:physical>
 
-
   <model:physical name="ramp_model">
     <xyz>0 2 0.0725</xyz>
     <rpy>-20 0 0</rpy>
@@ -215,5 +214,4 @@
     </light>
   </model:renderable>
 
-
 </gazebo:world>


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

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to