Revision: 6848
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6848&view=rev
Author:   natepak
Date:     2008-07-11 13:04:18 -0700 (Fri, 11 Jul 2008)

Log Message:
-----------
Gui can be configured via xml

Modified Paths:
--------------
    code/gazebo/trunk/doc/xmltags.html
    code/gazebo/trunk/server/Simulator.cc
    code/gazebo/trunk/server/gui/GLFrame.cc
    code/gazebo/trunk/server/gui/GLFrame.hh
    code/gazebo/trunk/server/gui/GLFrameManager.cc
    code/gazebo/trunk/server/gui/GLFrameManager.hh
    code/gazebo/trunk/server/gui/GLWindow.cc
    code/gazebo/trunk/server/gui/GLWindow.hh
    code/gazebo/trunk/server/gui/Gui.cc
    code/gazebo/trunk/server/gui/Gui.hh
    code/gazebo/trunk/worlds/pioneer2dx.world
    code/gazebo/trunk/worlds/stereocamera.world
    code/gazebo/trunk/worlds/test.world

Modified: code/gazebo/trunk/doc/xmltags.html
===================================================================
--- code/gazebo/trunk/doc/xmltags.html  2008-07-11 19:51:49 UTC (rev 6847)
+++ code/gazebo/trunk/doc/xmltags.html  2008-07-11 20:04:18 UTC (rev 6848)
@@ -35,6 +35,8 @@
         <linearStart>#</linearStart> <!-- Distance at which the fog starts -->
         <linearEnd>#</linearEnd> <!-- Distance at which the fog reaches full 
density-->
     </fog>
+
+    <grid>true|false</grid> <!-- Enable / disable the ground plane grid -->
   </rendering:ogre>
 
   <!-- A model. There is no limit to the number of models in a world-->

Modified: code/gazebo/trunk/server/Simulator.cc
===================================================================
--- code/gazebo/trunk/server/Simulator.cc       2008-07-11 19:51:49 UTC (rev 
6847)
+++ code/gazebo/trunk/server/Simulator.cc       2008-07-11 20:04:18 UTC (rev 
6848)
@@ -146,14 +146,12 @@
         int height = childNode->GetTupleInt("size",1,480);
         int x = childNode->GetTupleInt("pos",0,0);
         int y = childNode->GetTupleInt("pos",1,0);
-        std::string type = childNode->GetString("type","fltk",1);
 
-        gzmsg(1) << "Creating GUI:\n\tType[" << type 
-          << "] Pos[" << x << " " << y 
-          << "] Size[" << width << " " << height << "]\n";
+        //gzmsg(1) << "Creating GUI: Pos[" << x << " " << y << "] Size[" << 
width << " " << height << "]\n";
 
         // Create the GUI
-        this->gui = new Gui(x, y, width, height, type+"::Gazebo");
+        this->gui = new Gui(x, y, width, height, "Gazebo");
+        this->gui->Load(childNode);
       }
     }
     catch (GazeboError e)

Modified: code/gazebo/trunk/server/gui/GLFrame.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLFrame.cc     2008-07-11 19:51:49 UTC (rev 
6847)
+++ code/gazebo/trunk/server/gui/GLFrame.cc     2008-07-11 20:04:18 UTC (rev 
6848)
@@ -26,6 +26,7 @@
 
 #include <boost/bind.hpp>
 
+#include "XMLConfig.hh"
 #include "CameraManager.hh"
 #include "Global.hh"
 #include "Pose3d.hh"
@@ -90,6 +91,10 @@
 
   this->resizable(NULL);
   this->resizable(this->glWindow);
+
+  // Set default starting pose of the camera
+  this->startPose.pos.Set(-2, 0, 2);
+  this->startPose.rot.SetFromEuler( Vector3(0, DTOR(30), 0) );
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -99,10 +104,24 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+// Load the frame
+void GLFrame::Load( XMLConfigNode *node )
+{
+
+  if (node)
+  {
+    this->startPose.pos = node->GetVector3("xyz", Vector3(0,0,0));
+    this->startPose.rot = node->GetRotation("rpy", Quatern());
+  }
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
 // Initialize the frame
 void GLFrame::Init()
 {
   this->glWindow->Init();
+  this->glWindow->GetCamera()->SetWorldPose(this->startPose);
 
   CameraManager::Instance()->ConnectAddCameraSignal( 
boost::bind(&GLFrame::CameraAddedSlot, this, _1) );
 }
@@ -163,13 +182,12 @@
 // Switch view callback
 void GLFrame::ViewCB(Fl_Widget *widget, void *data)
 {
-  /*GLFrame *frame = reinterpret_cast<GLFrame *>(data);
+  GLFrame *frame = reinterpret_cast<GLFrame *>(data);
   Fl_Choice *choice = dynamic_cast<Fl_Choice *>(widget);
   CameraManager *manager = CameraManager::Instance();
   OgreCamera *cam = manager->GetCamera(choice->text());
 
-  frame->glWindow->SetActiveCamera( cam );
-  */
+  frame->glWindow->SetViewStyle(choice->text());
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/gui/GLFrame.hh
===================================================================
--- code/gazebo/trunk/server/gui/GLFrame.hh     2008-07-11 19:51:49 UTC (rev 
6847)
+++ code/gazebo/trunk/server/gui/GLFrame.hh     2008-07-11 20:04:18 UTC (rev 
6848)
@@ -39,6 +39,7 @@
 {
   class GLWindow;
   class OgreCamera;
+  class XMLConfigNode;
 
   class GLFrame : public Fl_Group
   {
@@ -48,6 +49,9 @@
     /// \brief Destructor
     public: virtual ~GLFrame();
 
+    /// \brief Load the frame
+    public: void Load( XMLConfigNode *node );
+
     /// \brief Initialize 
     public: void Init();
 
@@ -89,6 +93,9 @@
 
     private: Fl_Output *outputXYZ;
     private: Fl_Output *outputRPY;
+
+    /// Starting pose of the camera
+    private: Pose3d startPose;
   };
 }
 

Modified: code/gazebo/trunk/server/gui/GLFrameManager.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLFrameManager.cc      2008-07-11 19:51:49 UTC 
(rev 6847)
+++ code/gazebo/trunk/server/gui/GLFrameManager.cc      2008-07-11 20:04:18 UTC 
(rev 6848)
@@ -24,6 +24,8 @@
  * SVN: $Id:$
  */
 
+#include "XMLConfig.hh"
+
 #include "GLFrame.hh"
 #include "GLWindow.hh"
 #include "GLFrameManager.hh"
@@ -34,12 +36,13 @@
 // Constructor
 GLFrameManager::GLFrameManager(int x, int y, int w, int h, const std::string 
&name) : Fl_Tile(x,y,w,h, name.c_str())
 {
-  GLFrame *frame = NULL;
+  //GLFrame *frame = NULL;
 
   // Create a deafult view
-  frame = new GLFrame(x, y, w, h,"");
+  /*frame = new GLFrame(x, y, w, h,"");
   this->frames.push_back(frame);
   this->add(frame);
+  */
 
   this->end();
 
@@ -59,11 +62,77 @@
 
 }
 
+void GLFrameManager::Load( XMLConfigNode *node )
+{
+  GLFrame *frame = NULL;
+  int windowCount = 0;
+  XMLConfigNode *rowNode = NULL;
+  XMLConfigNode *camNode = NULL;
+
+  if (node)
+  {
+    rowNode = node->GetChild("row");
+
+    float frameHeight, frameWidth;
+    int width = this->w();
+    int height = this->h();
+    int x = this->x();
+    int y = this->y();
+
+    // Process each row
+    while (rowNode)
+    {
+      camNode = rowNode->GetChild("camera");
+
+      std::string heightStr = rowNode->GetString("height","",1);
+
+      frameHeight = atof( heightStr.substr(0, heightStr.find( "%", 0 ) 
).c_str() );
+
+      frameHeight = frameHeight/100.0 * height;
+
+      // Process each camera
+      while (camNode)
+      {
+        std::string widthStr = camNode->GetString("width","",1);
+        frameWidth = atof( widthStr.substr(0, widthStr.find( "%", 0 ) 
).c_str() );
+
+        frameWidth = frameWidth/100.0 * width;
+
+        windowCount = this->children();
+
+        // Create the frame
+        frame = new GLFrame( x, y, (int)frameWidth, (int)frameHeight, "" );
+        frame->Load(camNode);
+
+        this->frames.push_back( frame );
+        this->insert(*frame, windowCount);
+
+        x += (int)frameWidth;
+
+        camNode = camNode->GetNext();
+      }
+
+      y += (int)frameHeight;
+      x = this->x();
+
+      rowNode = rowNode->GetNext();
+    }
+  }
+
+  // Create a big default window if no frames have been defined
+  if (this->frames.size() == 0)
+  {
+    frame = new GLFrame( this->x(), this->y(), this->w(), this->h(), "" );
+    this->frames.push_back( frame );
+    this->insert(*frame, windowCount);
+  }
+  
+}
+
 
////////////////////////////////////////////////////////////////////////////////
 /// Initalize the window manager
 void GLFrameManager::Init()
 {
-
   std::vector<GLFrame *>::iterator iter;
   for (iter = this->frames.begin(); iter != this->frames.end(); iter++)
   {
@@ -83,6 +152,7 @@
   }
 }
 
+
 
////////////////////////////////////////////////////////////////////////////////
 // Split a frame
 void GLFrameManager::Split(GLFrame *parent, const std::string &type)

Modified: code/gazebo/trunk/server/gui/GLFrameManager.hh
===================================================================
--- code/gazebo/trunk/server/gui/GLFrameManager.hh      2008-07-11 19:51:49 UTC 
(rev 6847)
+++ code/gazebo/trunk/server/gui/GLFrameManager.hh      2008-07-11 20:04:18 UTC 
(rev 6848)
@@ -34,6 +34,7 @@
 {
   class GLFrame;
   class GLWindow;
+  class XMLConfigNode;
 
   /// \brief Class to manage all the GL frames
   class GLFrameManager : public Fl_Tile
@@ -44,6 +45,9 @@
     /// \brief Destructor
     public: virtual ~GLFrameManager();
 
+    /// \brief Load the frame manager
+    public: void Load( XMLConfigNode *node );
+
     /// \brief Initalize the window manager
     public: void Init();
 

Modified: code/gazebo/trunk/server/gui/GLWindow.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLWindow.cc    2008-07-11 19:51:49 UTC (rev 
6847)
+++ code/gazebo/trunk/server/gui/GLWindow.cc    2008-07-11 20:04:18 UTC (rev 
6848)
@@ -445,3 +445,26 @@
 {
    this->activeCamera = camera;
 }
+
+////////////////////////////////////////////////////////////////////////////////
+/// Set the style of the view = "front, left, top, user"
+void GLWindow::SetViewStyle(std::string view)
+{
+  UserCamera *cam =  this->GetCamera();
+  Pose3d pose = cam->GetWorldPose();
+
+  if (view == "Top")
+  {
+    pose.rot.SetFromEuler( Vector3(0, DTOR(90), 0) );
+  }
+  else if (view == "Left")
+  {
+    pose.rot.SetFromEuler( Vector3(0, 0, DTOR(90) ) );
+  }
+  else if (view == "Front")
+  {
+    pose.rot.SetFromEuler( Vector3(0, 0,0) );
+  }
+
+  cam->SetWorldPose( pose );
+}

Modified: code/gazebo/trunk/server/gui/GLWindow.hh
===================================================================
--- code/gazebo/trunk/server/gui/GLWindow.hh    2008-07-11 19:51:49 UTC (rev 
6847)
+++ code/gazebo/trunk/server/gui/GLWindow.hh    2008-07-11 20:04:18 UTC (rev 
6848)
@@ -95,6 +95,9 @@
     /// \brief Set the active camera
     public: void SetActiveCamera( OgreCamera *camera );
 
+    /// \brief Set the style of the view = "front, left, top, user"
+    public: void SetViewStyle(std::string view);
+
     /// \brief Handle a mouse button push
     private: void HandleMousePush();
 

Modified: code/gazebo/trunk/server/gui/Gui.cc
===================================================================
--- code/gazebo/trunk/server/gui/Gui.cc 2008-07-11 19:51:49 UTC (rev 6847)
+++ code/gazebo/trunk/server/gui/Gui.cc 2008-07-11 20:04:18 UTC (rev 6848)
@@ -31,6 +31,7 @@
 #include <FL/Fl_Choice.H>
 
 #include "Global.hh"
+#include "XMLConfig.hh"
 #include "GLFrameManager.hh"
 #include "OgreAdaptor.hh"
 #include "OgreCreator.hh"
@@ -64,7 +65,6 @@
     this->statusbar->gui = this;
   }
 
-
   // Create the toolbar
   //this->toolbar = new Toolbar(this->w()-200, 30, 200, this->h()-60);
 
@@ -92,6 +92,13 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Load the gui
+void Gui::Load( XMLConfigNode *node )
+{
+  this->frameMgr->Load( node->GetChild("frames") );
+}
+
+////////////////////////////////////////////////////////////////////////////////
 /// Initalize the gui
 void Gui::Init()
 {

Modified: code/gazebo/trunk/server/gui/Gui.hh
===================================================================
--- code/gazebo/trunk/server/gui/Gui.hh 2008-07-11 19:51:49 UTC (rev 6847)
+++ code/gazebo/trunk/server/gui/Gui.hh 2008-07-11 20:04:18 UTC (rev 6848)
@@ -42,6 +42,7 @@
   class Toolbar;
   class StatusBar;
   class GLFrameManager;
+  class XMLConfigNode;
 
   /// \brief FLTK Main Window
   class Gui : public Fl_Window
@@ -52,6 +53,9 @@
     /// \brief Destructor
     public: virtual ~Gui();
 
+    /// \brief Load the gui
+    public: virtual void Load(XMLConfigNode *node);
+
     /// \brief Initalize the gui
     public: virtual void Init();
 

Modified: code/gazebo/trunk/worlds/pioneer2dx.world
===================================================================
--- code/gazebo/trunk/worlds/pioneer2dx.world   2008-07-11 19:51:49 UTC (rev 
6847)
+++ code/gazebo/trunk/worlds/pioneer2dx.world   2008-07-11 20:04:18 UTC (rev 
6848)
@@ -30,6 +30,8 @@
     <type>fltk</type>
     <size>800 600</size>
     <pos>0 0</pos>
+    <xyz>0 0 0</xyz>
+    <rpy>0 0 0</rpy>
   </rendering:gui>
 
   <rendering:ogre>

Modified: code/gazebo/trunk/worlds/stereocamera.world
===================================================================
--- code/gazebo/trunk/worlds/stereocamera.world 2008-07-11 19:51:49 UTC (rev 
6847)
+++ code/gazebo/trunk/worlds/stereocamera.world 2008-07-11 20:04:18 UTC (rev 
6848)
@@ -105,10 +105,10 @@
         <saveFramePath>frames</saveFramePath>
         <baseline>0.2</baseline>
 
-        <controller:stereo_camera name="stereo_camera_controller">
+        <controller:stereocamera name="stereo_camera_controller">
           <interface:stereocamera name="stereo_iface_0" />
           <interface:camera name="camera_iface_0" />
-        </controller:stereo_camera>
+        </controller:stereocamera>
       </sensor:stereocamera>
     </body:empty>
   </model:physical>

Modified: code/gazebo/trunk/worlds/test.world
===================================================================
--- code/gazebo/trunk/worlds/test.world 2008-07-11 19:51:49 UTC (rev 6847)
+++ code/gazebo/trunk/worlds/test.world 2008-07-11 20:04:18 UTC (rev 6848)
@@ -27,9 +27,30 @@
   </physics:ode>
 
   <rendering:gui>
-    <type>fltk</type>
     <size>800 600</size>
-    <pos>0 0</pos>
+    <pos>100 100</pos>
+    <frames>
+      <row height="50%">
+        <camera width="50%">
+          <xyz>-1 0 4</xyz>
+          <rpy>0 34 0</rpy>
+        </camera>
+        <camera width="50%">
+          <xyz>0 0 10</xyz>
+          <rpy>0 90 0</rpy>
+        </camera>
+      </row>
+      <row height="50%">
+        <camera width="50%">
+          <xyz>0 0 0</xyz>
+          <rpy>0 0 0</rpy>
+        </camera>
+        <camera width="50%">
+          <xyz>10 0 1</xyz>
+          <rpy>0 0 90</rpy>
+        </camera>
+      </row>
+    </frames>
   </rendering:gui>
 
   <rendering:ogre>
@@ -62,22 +83,22 @@
     </body:plane>
   </model:physical>
 
-  <model:physical name="cylinder1_model">
-    <xyz>1 -1.5 0.5</xyz>
+  <model:physical name="sphere1_model">
+    <xyz>2.15 -1.68 .7</xyz>
     <rpy>0.0 0.0 0.0</rpy>
+    <static>true</static>
 
-    <body:cylinder name="cylinder1_body">
-      <geom:cylinder name="cylinder1_geom">
-        <size>0.5 1</size>
-        <mass>1.0</mass>
-        <laserFiducialId>1</laserFiducialId>
-        
+    <body:sphere name="sphere1_body">
+      <geom:sphere name="sphere1_geom">
+        <size>0.1</size>
+
         <visual>
-          <mesh>unit_cylinder</mesh>
-          <material>Gazebo/RustyBarrel</material>
+          <scale>0.1 0.1 0.1</scale>
+          <mesh>unit_sphere</mesh>
+          <material>Gazebo/Rocky</material>
         </visual>
-      </geom:cylinder>
-    </body:cylinder>
+      </geom:sphere>
+    </body:sphere>
   </model:physical>
 
 
@@ -97,7 +118,7 @@
     <controller:differential_position2d name="controller1">
       <leftJoint>left_wheel_hinge</leftJoint>
       <rightJoint>right_wheel_hinge</rightJoint>
-      <wheelSeparation>0.34</wheelSeparation>
+      <wheelSeparation>0.39</wheelSeparation>
       <wheelDiameter>0.15</wheelDiameter>
       <torque>5</torque>
       <interface:position name="position_iface_0"/>


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

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to