Revision: 8661
          http://playerstage.svn.sourceforge.net/playerstage/?rev=8661&view=rev
Author:   natepak
Date:     2010-05-06 17:49:44 +0000 (Thu, 06 May 2010)

Log Message:
-----------
Added signals to the World update, and show physics display coord axes

Modified Paths:
--------------
    code/gazebo/trunk/server/Mesh.hh
    code/gazebo/trunk/server/MeshManager.cc
    code/gazebo/trunk/server/Model.cc
    code/gazebo/trunk/server/Model.hh
    code/gazebo/trunk/server/World.cc
    code/gazebo/trunk/server/World.hh
    code/gazebo/trunk/server/physics/Body.cc
    code/gazebo/trunk/server/rendering/OgreVisual.cc
    code/gazebo/trunk/server/rendering/OgreVisual.hh
    code/gazebo/trunk/worlds/simpleshapes.world

Modified: code/gazebo/trunk/server/Mesh.hh
===================================================================
--- code/gazebo/trunk/server/Mesh.hh    2010-05-06 15:26:25 UTC (rev 8660)
+++ code/gazebo/trunk/server/Mesh.hh    2010-05-06 17:49:44 UTC (rev 8661)
@@ -163,6 +163,7 @@
     private: std::vector< Vector2<double> > texCoords;
     private: std::vector<unsigned int> indices;
 
+
     private: int materialIndex;
   };
 }

Modified: code/gazebo/trunk/server/MeshManager.cc
===================================================================
--- code/gazebo/trunk/server/MeshManager.cc     2010-05-06 15:26:25 UTC (rev 
8660)
+++ code/gazebo/trunk/server/MeshManager.cc     2010-05-06 17:49:44 UTC (rev 
8661)
@@ -32,6 +32,7 @@
   this->CreateCylinder("unit_cylinder", 0.5, 1.0, 1, 32);
   this->CreateCone("unit_cone", 0.5, 1.0, 5, 32);
   this->CreateCamera("unit_camera", 0.5);
+  this->CreateCylinder("axis_cylinder",0.005,0.5,1,32);
 
   this->CreateTube("selection_tube", 1.0, 1.2, 0.01, 1, 64);
 }

Modified: code/gazebo/trunk/server/Model.cc
===================================================================
--- code/gazebo/trunk/server/Model.cc   2010-05-06 15:26:25 UTC (rev 8660)
+++ code/gazebo/trunk/server/Model.cc   2010-05-06 17:49:44 UTC (rev 8661)
@@ -378,10 +378,12 @@
 
   for (biter = this->children.begin(); biter!=this->children.end(); biter++)
   {
-    if (*biter && (*biter)->GetType() == Entity::BODY)
+    if (*biter)
     {
-      Body *body = (Body*)*biter;
-      body->Init();
+      if ((*biter)->GetType() == Entity::BODY)
+        ((Body*)*biter)->Init();
+      else if ((*biter)->GetType() == Entity::MODEL)
+        ((Model*)*biter)->Init();
     }
   }
 
@@ -399,7 +401,6 @@
   Body* cb = this->GetCanonicalBody();
   if (cb != NULL)
     cb->SetCanonicalModel(this);
-
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -415,7 +416,7 @@
   std::map<std::string, Controller* >::iterator contIter;
   JointContainer::iterator jointIter;
 
-  //this->updateSignal();
+  this->updateSignal();
 
   {
     //DiagnosticTimer timer("Model[" + this->GetName() + "] Bodies Update ");

Modified: code/gazebo/trunk/server/Model.hh
===================================================================
--- code/gazebo/trunk/server/Model.hh   2010-05-06 15:26:25 UTC (rev 8660)
+++ code/gazebo/trunk/server/Model.hh   2010-05-06 17:49:44 UTC (rev 8661)
@@ -247,9 +247,6 @@
     /// \brief Initial pose of the model
     private: Pose3d initPose;
  
-    /// \brief Map of the bodies. std::string == body_name
-    protected: std::map<std::string, Body* > bodies;
-  
     /// \brief Map of the joints
     //protected: std::map<std::string, Joint* > joints;
     protected: std::vector<Joint* > joints;

Modified: code/gazebo/trunk/server/World.cc
===================================================================
--- code/gazebo/trunk/server/World.cc   2010-05-06 15:26:25 UTC (rev 8660)
+++ code/gazebo/trunk/server/World.cc   2010-05-06 17:49:44 UTC (rev 8661)
@@ -311,6 +311,8 @@
 // Update the world
 void World::Update()
 {
+  this->worldUpdateStartSignal();
+
   if (this->simPauseTime > 0)
   {
     if (Simulator::Instance()->GetSimTime() >= this->simPauseTime)
@@ -366,6 +368,8 @@
   }
 
   this->factory->Update();
+
+  this->worldUpdateEndSignal();
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/World.hh
===================================================================
--- code/gazebo/trunk/server/World.hh   2010-05-06 15:26:25 UTC (rev 8660)
+++ code/gazebo/trunk/server/World.hh   2010-05-06 17:49:44 UTC (rev 8661)
@@ -328,7 +328,26 @@
           void DisconnectShowBoundingBoxesSignal( T subscriber )
           { showBoundingBoxesSignal.disconnect(subscriber); }
 
+  /// \brief Connect a boost::slot the the world update start signal
+  public: template<typename T>
+          boost::signals::connection ConnectWorldUpdateStartSignal(T 
subscriber)
+          { return worldUpdateStartSignal.connect(subscriber); }
+  /// \brief Disconnect a boost::slot the the world update start signal
+  public: template<typename T>
+          void DisconnectWorldUpdateStartSignal( T subscriber )
+          { worldUpdateStartSignal.disconnect(subscriber); }
 
+  /// \brief Connect a boost::slot the the world update end signal
+  public: template<typename T>
+          boost::signals::connection ConnectWorldUpdateEndSignal(T subscriber)
+          { return worldUpdateEndSignal.connect(subscriber); }
+  /// \brief Disconnect a boost::slot the the world update end signal
+  public: template<typename T>
+          void DisconnectWorldUpdateEndSignal( T subscriber )
+          { worldUpdateEndSignal.disconnect(subscriber); }
+
+
+
   /// \brief Get the names of interfaces defined in the tree of a model
   private: void GetInterfaceNames(Entity* m, std::vector<std::string>& list);
 
@@ -379,6 +398,9 @@
   private: boost::signal<void (bool)> showJointsSignal;
   private: boost::signal<void (bool)> showBoundingBoxesSignal;
 
+  private: boost::signal<void ()> worldUpdateStartSignal;
+  private: boost::signal<void ()> worldUpdateEndSignal;
+
   private: std::deque<WorldState> worldStates;
   private: std::deque<WorldState>::iterator worldStatesInsertIter;
   private: std::deque<WorldState>::iterator worldStatesEndIter;

Modified: code/gazebo/trunk/server/physics/Body.cc
===================================================================
--- code/gazebo/trunk/server/physics/Body.cc    2010-05-06 15:26:25 UTC (rev 
8660)
+++ code/gazebo/trunk/server/physics/Body.cc    2010-05-06 17:49:44 UTC (rev 
8661)
@@ -368,6 +368,8 @@
   this->linearAccel.Set(0,0,0);
   this->angularAccel.Set(0,0,0);
 
+  std::cout << this->GetName() << "Mass[" << this->mass.GetAsDouble() << "]\n";
+
   /// Attach mesh for CG visualization
   /// Add a renderable visual for CG, make visible in Update()
   if (this->mass.GetAsDouble() > 0.0)
@@ -375,9 +377,12 @@
     std::ostringstream visname;
     visname << this->GetCompleteScopedName() + ":" + this->GetName() << 
"_CGVISUAL" ;
 
+      std::cout << "CG Visual Name[" << visname.str() << "]\n";
     if (this->cgVisual == NULL)
+    {
       this->cgVisual = OgreCreator::Instance()->CreateVisual(visname.str(),
           this->comEntity->GetVisualNode());
+    }
     else
       this->cgVisual->DetachObjects();
 
@@ -386,6 +391,7 @@
       this->cgVisual->AttachMesh("body_cg");
       this->cgVisual->SetMaterial("Gazebo/Red");
       this->cgVisual->SetCastShadows(false);
+      this->cgVisual->AttachAxes();
 
       std::map< std::string, Geom* >::iterator giter;
 

Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.cc    2010-05-06 15:26:25 UTC 
(rev 8660)
+++ code/gazebo/trunk/server/rendering/OgreVisual.cc    2010-05-06 17:49:44 UTC 
(rev 8661)
@@ -522,8 +522,52 @@
 }
 
 
+void OgreVisual::AttachAxes()
+{
+  std::ostringstream nodeName;
 
+  nodeName << this->sceneNode->getName()<<"_AXES_NODE";
+ 
+  if (!this->sceneNode->getCreator()->hasEntity("axis_cylinder"))
+    OgreCreator::InsertMesh(MeshManager::Instance()->GetMesh("axis_cylinder"));
 
+  Ogre::SceneNode *node = 
this->sceneNode->createChildSceneNode(nodeName.str());
+  Ogre::SceneNode *x, *y, *z;
+
+  x = node->createChildSceneNode(nodeName.str() + "_axisX");
+  x->setInheritScale(true);
+  x->translate(.25,0,0);
+  x->yaw(Ogre::Radian(M_PI/2.0));
+
+  y = node->createChildSceneNode(nodeName.str() + "_axisY");
+  y->setInheritScale(true);
+  y->translate(0,.25,0);
+  y->pitch(Ogre::Radian(M_PI/2.0));
+
+  z = node->createChildSceneNode(nodeName.str() + "_axisZ");
+  z->translate(0,0,.25);
+  z->setInheritScale(true);
+  
+  Ogre::MovableObject *xobj, *yobj, *zobj;
+
+  xobj = 
(Ogre::MovableObject*)(node->getCreator()->createEntity(nodeName.str()+"X_AXIS",
 "axis_cylinder"));
+  xobj->setCastShadows(false);
+  ((Ogre::Entity*)xobj)->setMaterialName("Gazebo/Red");
+
+  yobj = 
(Ogre::MovableObject*)(node->getCreator()->createEntity(nodeName.str()+"Y_AXIS",
 "axis_cylinder"));
+  yobj->setCastShadows(false);
+  ((Ogre::Entity*)yobj)->setMaterialName("Gazebo/Green");
+
+  zobj = 
(Ogre::MovableObject*)(node->getCreator()->createEntity(nodeName.str()+"Z_AXIS",
 "axis_cylinder"));
+  zobj->setCastShadows(false);
+  ((Ogre::Entity*)zobj)->setMaterialName("Gazebo/Blue");
+
+  x->attachObject(xobj);
+  y->attachObject(yobj);
+  z->attachObject(zobj);
+}
+
+
 
////////////////////////////////////////////////////////////////////////////////
 /// Set the transparency
 void OgreVisual::SetTransparency( float trans )

Modified: code/gazebo/trunk/server/rendering/OgreVisual.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.hh    2010-05-06 15:26:25 UTC 
(rev 8660)
+++ code/gazebo/trunk/server/rendering/OgreVisual.hh    2010-05-06 17:49:44 UTC 
(rev 8661)
@@ -96,6 +96,8 @@
     /// \brief Set the material
     public: void SetMaterial(const std::string &materialName);
 
+    public: void AttachAxes();
+
     /// \brief Set the transparency
     public: void SetTransparency( float trans );
 

Modified: code/gazebo/trunk/worlds/simpleshapes.world
===================================================================
--- code/gazebo/trunk/worlds/simpleshapes.world 2010-05-06 15:26:25 UTC (rev 
8660)
+++ code/gazebo/trunk/worlds/simpleshapes.world 2010-05-06 17:49:44 UTC (rev 
8661)
@@ -48,7 +48,7 @@
 
   <model:physical name="sphere1_model">
     <xyz>0 0 0.2</xyz>
-    <rpy>45 0.0 0.0</rpy>
+    <rpy>0 0.0 0.0</rpy>
     <static>false</static>
 
     <body:sphere name="sphere1_body">


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

------------------------------------------------------------------------------
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to