Revision: 6891
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6891&view=rev
Author:   natepak
Date:     2008-07-21 05:27:12 +0000 (Mon, 21 Jul 2008)

Log Message:
-----------
Fixed seg fault when closing. Removed stringvalue class. Stereocamera 
controller now outputs two images.

Modified Paths:
--------------
    code/gazebo/trunk/libgazebo/Iface.cc
    code/gazebo/trunk/libgazebo/gazebo.h
    code/gazebo/trunk/server/GazeboMessage.cc
    code/gazebo/trunk/server/Model.cc
    code/gazebo/trunk/server/SConscript
    code/gazebo/trunk/server/Simulator.cc
    code/gazebo/trunk/server/XMLConfig.cc
    code/gazebo/trunk/server/XMLConfig.hh
    code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.cc
    code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.hh
    
code/gazebo/trunk/server/controllers/position2d/differential/Differential_Position2d.cc
    code/gazebo/trunk/server/gui/GLWindow.cc
    code/gazebo/trunk/server/gui/Gui.cc
    code/gazebo/trunk/server/gui/Gui.hh
    code/gazebo/trunk/server/main.cc
    code/gazebo/trunk/server/physics/Body.cc
    code/gazebo/trunk/server/physics/Geom.cc
    code/gazebo/trunk/server/physics/MapGeom.cc
    code/gazebo/trunk/server/physics/ode/ODEPhysics.cc
    code/gazebo/trunk/server/rendering/OgreAdaptor.cc
    code/gazebo/trunk/server/rendering/OgreAdaptor.hh
    code/gazebo/trunk/server/rendering/OgreCreator.cc
    code/gazebo/trunk/server/rendering/OgreVisual.cc
    code/gazebo/trunk/worlds/models/bandit.model

Removed Paths:
-------------
    code/gazebo/trunk/server/StringValue.cc
    code/gazebo/trunk/server/StringValue.hh

Modified: code/gazebo/trunk/libgazebo/Iface.cc
===================================================================
--- code/gazebo/trunk/libgazebo/Iface.cc        2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/libgazebo/Iface.cc        2008-07-21 05:27:12 UTC (rev 
6891)
@@ -113,22 +113,24 @@
 
   this->server = server;
 
+  this->id = id;
+
   // Went cant have null id's
-  if (id.empty())
+  if (this->id.empty())
   {
     stream << "interface [" << this->type << "] id is NULL";
     throw(stream.str());
   }
 
   // We cannot have id with '.'
-  if (strchr(id.c_str(), '.'))
+  if (strchr(this->id.c_str(), '.'))
   {
-    stream << "invalid id [" << id << "] (must not contain '.')";
+    stream << "invalid id [" << this->id << "] (must not contain '.')";
     throw(stream.str());
   }
 
   // Work out the filename
-  this->Filename(id);
+  this->Filename(this->id);
 
   // Create and open the file
   this->mmapFd = open(this->filename.c_str(), O_RDWR | O_CREAT | O_TRUNC, 
S_IREAD | S_IWRITE);
@@ -364,6 +366,13 @@
 }
 
 //////////////////////////////////////////////////////////////////////////////
+/// Get the ID of the inteface
+std::string Iface::GetId() const
+{
+  return this->id;
+}
+
+//////////////////////////////////////////////////////////////////////////////
 /// Get the number of connections
 int Iface::GetOpenCount()
 {

Modified: code/gazebo/trunk/libgazebo/gazebo.h
===================================================================
--- code/gazebo/trunk/libgazebo/gazebo.h        2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/libgazebo/gazebo.h        2008-07-21 05:27:12 UTC (rev 
6891)
@@ -297,6 +297,9 @@
   /// \return The type of interface
   public: std::string GetType() const;
 
+  /// \brief Get the ID of the inteface
+  public: std::string GetId() const;
+
   private: std::string Filename(std::string id);
 
   /// The server we are associated with
@@ -317,6 +320,8 @@
   /// type of interface
   protected: std::string type;
 
+  protected: std::string id;
+
   private: bool creator;
 
   private: size_t size;

Modified: code/gazebo/trunk/server/GazeboMessage.cc
===================================================================
--- code/gazebo/trunk/server/GazeboMessage.cc   2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/GazeboMessage.cc   2008-07-21 05:27:12 UTC (rev 
6891)
@@ -97,18 +97,17 @@
 
 void GazeboMessage::Save(XMLConfigNode *node)
 {
-  node->SetValue("verbosity", this->level);
+  /*node->SetValue("verbosity", this->level);
   node->SetValue("logData", this->logData);
 
-  /*
-    node->NewElement("verbosity", String(this->level)); //std::ostringstream 
<< this->level);
+    //node->NewElement("verbosity", String(this->level)); //std::ostringstream 
<< this->level);
 
-    node->NewElement("logData", gazebo::String(this->logData));
+    //node->NewElement("logData", gazebo::String(this->logData));
 
-    if (this->logData)
-      node->NewElement("logData", std::ostringstream << "true");
-    else
-      node->NewElement("logData", std::ostringstream << "true");
+    //if (this->logData)
+    //  node->NewElement("logData", std::ostringstream << "true");
+    //else
+    //  node->NewElement("logData", std::ostringstream << "true");
     */
 }
 

Modified: code/gazebo/trunk/server/Model.cc
===================================================================
--- code/gazebo/trunk/server/Model.cc   2008-07-18 23:57:33 UTC (rev 6890)
+++ code/gazebo/trunk/server/Model.cc   2008-07-21 05:27:12 UTC (rev 6891)
@@ -181,7 +181,7 @@
 
 void Model::Save()
 {
-  std::map<std::string, Body* >::iterator bodyIter;
+  /*std::map<std::string, Body* >::iterator bodyIter;
   std::map<std::string, Controller* >::iterator contIter;
   std::map<std::string, Joint* >::iterator jointIter;
 
@@ -225,6 +225,7 @@
       contIter->second->Save();
   }
 
+  */
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/SConscript
===================================================================
--- code/gazebo/trunk/server/SConscript 2008-07-18 23:57:33 UTC (rev 6890)
+++ code/gazebo/trunk/server/SConscript 2008-07-21 05:27:12 UTC (rev 6891)
@@ -19,7 +19,6 @@
            'GazeboMessage.cc',
            'Model.cc',
            'Simulator.cc',
-           'StringValue.cc'
            ]
 
 headers.append( 
@@ -33,7 +32,6 @@
            '#/server/Simulator.hh',
            '#/server/SingletonT.hh',
            '#/server/StaticPluginRegister.hh',
-           '#/server/StringValue.hh',
            '#/server/Time.hh',
            '#/server/Vector2.hh', 
            '#/server/Vector3.hh',

Modified: code/gazebo/trunk/server/Simulator.cc
===================================================================
--- code/gazebo/trunk/server/Simulator.cc       2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/Simulator.cc       2008-07-21 05:27:12 UTC (rev 
6891)
@@ -419,16 +419,16 @@
 
 void Simulator::SaveGui(XMLConfigNode *node)
 {
-  Vector2<int> size;
+  /*Vector2<int> size;
   XMLConfigNode* childNode = node->GetChild("gui");
 
   if (childNode && this->gui)
   {
     size.x = this->gui->GetWidth();
     size.y = this->gui->GetHeight();
-    childNode->SetValue("size", size);
+    //childNode->SetValue("size", size);
     //TODO: node->SetValue("pos", Vector2<int>(x,y));
-  }
+  }*/
 
 }
 

Deleted: code/gazebo/trunk/server/StringValue.cc
===================================================================
--- code/gazebo/trunk/server/StringValue.cc     2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/StringValue.cc     2008-07-21 05:27:12 UTC (rev 
6891)
@@ -1,150 +0,0 @@
-/*
- *  Gazebo - Outdoor Multi-Robot Simulator
- *  Copyright (C) 2003
- *     Nate Koenig & Andrew Howard
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-/* Desc: A helpfull StringValue class, mostly a converter
- * Author: Jordi Polo
- * Date: 3 Jan 2008
- * SVN: $Id:$
- */
-
-#include "Vector3.hh"
-#include "Vector2.hh"
-#include "Quatern.hh"
-#include <OgreColourValue.h>
-
-#include "StringValue.hh"
-
-using namespace gazebo;
-
-////////////////////////////////////////////////////////////////////////////////
-/// Copy Constructor
-StringValue::StringValue(const StringValue& data)
-{
-  stream << data.GetStr();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert Vector3 to string
-StringValue::StringValue(Vector3 data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert Vector2<int> to string
-StringValue::StringValue(Vector2<int> data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert Vector2<double> to string
-StringValue::StringValue(Vector2<double> data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert Quatern to string
-StringValue::StringValue(Quatern data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert bool to string
-StringValue::StringValue(bool data)
-{
-  if (data)
-    stream << "true";
-  else
-    stream << "false";
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert int to string
-StringValue::StringValue(int data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert double to string
-StringValue::StringValue(double data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert float to string
-StringValue::StringValue(float data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Convert float to string
-StringValue::StringValue(const char* data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Ogre colour value to string
-StringValue::StringValue(std::string data)
-{
-  stream << data;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// A std string
-StringValue::StringValue(Ogre::ColourValue* data)
-{
-  stream << data->r << " " <<data->g <<" " << data->b << " " << data->a;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// destructor
-StringValue::~StringValue()
-{}
-
-////////////////////////////////////////////////////////////////////////////////
-/// True if the string is null
-bool StringValue::IsNull() const
-{
-  bool null=false;
-  if (stream.str()==std::string())
-    null=true;
-  return null;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Get the value as a std string
-std::string StringValue::GetStr() const
-{
-  return stream.str();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-/// Get the value as a char string
-const char* StringValue::GetCharStr() const
-{
-  return stream.str().c_str();
-}

Deleted: code/gazebo/trunk/server/StringValue.hh
===================================================================
--- code/gazebo/trunk/server/StringValue.hh     2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/StringValue.hh     2008-07-21 05:27:12 UTC (rev 
6891)
@@ -1,106 +0,0 @@
-/*
- *  Gazebo - Outdoor Multi-Robot Simulator
- *  Copyright (C) 2003  
- *     Nate Koenig & Andrew Howard
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-/* Desc: A helpfull StringValue class, mostly a converter
- * Author: Jordi Polo
- * Date: 3 Jan 2008
- * SVN: $Id:$
- */
-
-#ifndef STRING_HH
-#define STRING_HH
-
-#include <iostream>
-#include <sstream>
-#include <string>
-
-#include "Vector3.hh"
-#include "Vector2.hh"
-#include "Quatern.hh"
-
-namespace Ogre
-{
- class ColourValue;
-}
-
-namespace gazebo
-{
-/// \addtogroup gazebo_server
-/// \brief StringValue conversions and tools
-/// \{
-
-  class StringValue
-  {
-    /// \brief Copy Constructor
-    public: StringValue(const StringValue& data);
-
-    /// \brief Convert Vector3 to string
-    public: StringValue(Vector3 data);
-
-    /// \brief Convert Vector2<int> to string
-    public: StringValue(Vector2<int> data);
-
-    /// \brief Convert Vector2<double> to string
-    public: StringValue(Vector2<double> data);
-
-    /// \brief Convert Quatern to string
-    public: StringValue(Quatern data);
-
-    /// \brief Convert bool to string
-    public: StringValue(bool data);
-
-    /// \brief Convert int to string
-    public: StringValue(int data);
-
-    /// \brief Convert double to string
-    public: StringValue(double data);
-
-    /// \brief Convert float to string
-    public: StringValue(float data);
-
-    /// \brief Convert float to string
-    public: StringValue(const char* data);
-
-    /// \brief Ogre colour value to string
-    public: StringValue(Ogre::ColourValue* data);
-
-    /// \brief A std string
-    public: StringValue(std::string data);
-    
-    /// \brief destructor
-    public: ~StringValue();
-
-    /// \brief True if the string is null
-    public: bool IsNull() const;
-
-    /// \brief Get the value as a std string
-    public: std::string GetStr() const;
-
-    /// \brief Get the value as a char string
-    public: const char* GetCharStr() const;
-  
-    //private: std::string str;
-    private: std::ostringstream stream;
-  };
-
-
-/// \}
-}
-
-#endif

Modified: code/gazebo/trunk/server/XMLConfig.cc
===================================================================
--- code/gazebo/trunk/server/XMLConfig.cc       2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/XMLConfig.cc       2008-07-21 05:27:12 UTC (rev 
6891)
@@ -836,7 +836,7 @@
 
 ////////////////////////////////////////////////////////////////////////////
 // Set the value associated with a node.
-void XMLConfigNode::SetValue(const std::string &key, const StringValue &data, 
int require, int type) 
+/*void XMLConfigNode::SetValue(const std::string &key, const StringValue 
&data, int require, int type) 
 {
   bool success;
 
@@ -847,7 +847,7 @@
     this->NewNode(key.c_str(), data.GetCharStr(), type);
   }
 
-}
+}*/
 
 
 ////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/XMLConfig.hh
===================================================================
--- code/gazebo/trunk/server/XMLConfig.hh       2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/XMLConfig.hh       2008-07-21 05:27:12 UTC (rev 
6891)
@@ -35,7 +35,6 @@
 #include "Vector2.hh"
 #include "Quatern.hh"
 #include "Time.hh"
-#include "StringValue.hh"
 
 namespace gazebo
 {
@@ -195,7 +194,7 @@
     /// \param value : the name of the element or attribute to write
     /// \param require : Require=1 means that if not found a new node will be 
created
     /// \param type : Only if a new node is created, the type must be specified
-    public: void SetValue(const std::string &key, const StringValue &data, int 
require =0, int type=0);
+    //public: void SetValue(const std::string &key, const StringValue &data, 
int require =0, int type=0);
 
     /// \brief Get a node's value, which is either a attribute or child node 
value.
     protected: xmlChar* GetNodeValue( const std::string &key ) const;

Modified: code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.cc
===================================================================
--- code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.cc 
2008-07-18 23:57:33 UTC (rev 6890)
+++ code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.cc 
2008-07-21 05:27:12 UTC (rev 6891)
@@ -70,9 +70,15 @@
     if ((*iter)->GetType() == "stereo")
       this->stereoIface = dynamic_cast<StereoCameraIface*>(*iter);
     else if ((*iter)->GetType() == "camera")
-      this->cameraIface = dynamic_cast<CameraIface*>(*iter);
+    {
+      CameraIface *ciface = dynamic_cast<CameraIface*>(*iter);
+      this->cameraIfaces[ciface->GetId()] = ciface;
+    }
   }
 
+  this->leftCameraName = node->GetString("leftcamera","", 1);
+  this->rightCameraName = node->GetString("rightcamera","", 1);
+
   if (!this->stereoIface)
     gzthrow("Stereo_Camera controller requires a StereoCameraIface");
 }
@@ -87,15 +93,23 @@
 // Update the controller
 void Stereo_Camera::UpdateChild()
 {
-  if (this->cameraIface)
+  std::map< std::string, CameraIface*>::iterator iter;
+
+  for (iter = this->cameraIfaces.begin(); 
+       iter != this->cameraIfaces.end(); iter++)
   {
-    this->cameraIface->Lock(1);
-    if (this->cameraIface->data->head.openCount > 0)
-      this->PutCameraData();
-    this->cameraIface->Unlock();
+    iter->second->Lock(1);
 
-    // New data is available
-    this->cameraIface->Post();
+    if (iter->second->data->head.openCount > 0)
+    {
+      if (this->leftCameraName == iter->first)
+        this->PutCameraData( iter->second->data, 0 );
+      else
+        this->PutCameraData( iter->second->data, 1 );
+    }
+
+    iter->second->Unlock();
+    iter->second->Post();
   }
 
   if (this->stereoIface)
@@ -175,9 +189,9 @@
 
 
////////////////////////////////////////////////////////////////////////////////
 // Put camera data to the interface
-void Stereo_Camera::PutCameraData()
+void Stereo_Camera::PutCameraData(CameraData *camera_data, unsigned int camera)
 {
-  CameraData *camera_data = this->cameraIface->data;
+  //CameraData *camera_data = this->cameraIface->data;
   const unsigned char *rgb_src = NULL;
   unsigned char *rgb_dst = NULL;
   Pose3d cameraPose;
@@ -202,10 +216,9 @@
   camera_data->camera_pose.yaw = cameraPose.rot.GetYaw();
 
   // Copy the pixel data to the interface
-  rgb_src = this->myParent->GetImageData(0);
+  rgb_src = this->myParent->GetImageData(camera);
   rgb_dst = camera_data->image;
 
   memcpy(rgb_dst, rgb_src, camera_data->image_size);
-
 }
 

Modified: code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.hh
===================================================================
--- code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.hh 
2008-07-18 23:57:33 UTC (rev 6890)
+++ code/gazebo/trunk/server/controllers/camera/stereo/Stereo_Camera.hh 
2008-07-21 05:27:12 UTC (rev 6891)
@@ -28,6 +28,8 @@
 #ifndef STEREO_CAMERA_HH
 #define STEREO_CAMERA_HH
 
+#include <map>
+
 #include "Controller.hh"
 
 namespace gazebo
@@ -93,12 +95,15 @@
   private: void PutStereoData();
 
   /// \brief Put camera data to the iface
-  private: void PutCameraData();
+  private: void PutCameraData(CameraData *camera_data, unsigned int camera);
 
   /// The camera interface
   private: StereoCameraIface *stereoIface;
-  private: CameraIface *cameraIface;
+  private: std::map< std::string, CameraIface*> cameraIfaces;
 
+  private: std::string leftCameraName;
+  private: std::string rightCameraName;
+
   /// The parent sensor
   private: StereoCameraSensor *myParent;
 

Modified: 
code/gazebo/trunk/server/controllers/position2d/differential/Differential_Position2d.cc
===================================================================
--- 
code/gazebo/trunk/server/controllers/position2d/differential/Differential_Position2d.cc
     2008-07-18 23:57:33 UTC (rev 6890)
+++ 
code/gazebo/trunk/server/controllers/position2d/differential/Differential_Position2d.cc
     2008-07-21 05:27:12 UTC (rev 6891)
@@ -113,11 +113,12 @@
 // Load the controller
 void Differential_Position2d::SaveChild(XMLConfigNode *node)
 {
-  node->SetValue("wheelSeparation",this->wheelSep);
+  /*node->SetValue("wheelSeparation",this->wheelSep);
   node->SetValue("wheelDiameter",this->wheelDiam);
   node->SetValue("torque",this->torque);
 //  node->SetValue("leftJoint",this->XMLData["leftJointName"]);
 //  node->SetValue("rightJoint",this->XMLData["rightJointName"]);
+*/
 }
 
 

Modified: code/gazebo/trunk/server/gui/GLWindow.cc
===================================================================
--- code/gazebo/trunk/server/gui/GLWindow.cc    2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/gui/GLWindow.cc    2008-07-21 05:27:12 UTC (rev 
6891)
@@ -122,17 +122,6 @@
 // Update function
 void GLWindow::Update()
 {
-  /*if (this->userCamera && this->userCamera->GetUserMovable())
-  {
-    this->userCamera->Translate( 
-        this->directionVec * (Simulator::Instance()->GetRealTime() - 
this->lastUpdateTime) );
-    this->directionVec.Set(0,0,0);
-  }
-
-  this->lastUpdateTime = Simulator::Instance()->GetRealTime();
-
-  this->userCamera->Update();
-  */
   if (this->activeCamera && this->activeCamera->GetUserMovable())
   {
     this->activeCamera->Translate( 
@@ -216,17 +205,6 @@
 /// Handle a mouse drag
 void GLWindow::HandleMouseDrag()
 {
-  /*if (this->userCamera && this->userCamera->GetUserMovable())
-  {
-    if (this->leftMousePressed)
-    {
-      Vector2<int> d = this->mousePos - this->prevMousePos;
-      this->userCamera->RotateYaw(DTOR(-d.x * this->rotateAmount));
-      this->userCamera->RotatePitch(DTOR(d.y * this->rotateAmount));
-    }
-  }
-  */
-
   if (this->activeCamera && this->activeCamera->GetUserMovable())
   {
     if (this->leftMousePressed)

Modified: code/gazebo/trunk/server/gui/Gui.cc
===================================================================
--- code/gazebo/trunk/server/gui/Gui.cc 2008-07-18 23:57:33 UTC (rev 6890)
+++ code/gazebo/trunk/server/gui/Gui.cc 2008-07-21 05:27:12 UTC (rev 6891)
@@ -79,6 +79,8 @@
   // Create a dummy rendering window. This creates a context, and allows Ogre
   // to initialize properly
   OgreCreator::CreateWindow(this, 1, 1);
+
+  this->hasFocus = true;
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -133,12 +135,18 @@
 /// Handle an event
 int Gui::handle(int event)
 {
-
-  switch (event)
+  switch(event)
   {
+    case FL_FOCUS:
+      this->hasFocus = true;
+      break;
+    case FL_UNFOCUS:
+      this->hasFocus = false;
+      break;
     case FL_HIDE:
-      Simulator::Instance()->SetUserQuit();
-      return 1;
+      if (this->hasFocus)
+        Simulator::Instance()->SetUserQuit();
+      break;
   }
 
   return Fl_Window::handle(event);

Modified: code/gazebo/trunk/server/gui/Gui.hh
===================================================================
--- code/gazebo/trunk/server/gui/Gui.hh 2008-07-18 23:57:33 UTC (rev 6890)
+++ code/gazebo/trunk/server/gui/Gui.hh 2008-07-21 05:27:12 UTC (rev 6891)
@@ -76,6 +76,8 @@
     private: Toolbar *toolbar;
     private: StatusBar *statusbar;
     private: GLFrameManager *frameMgr;
+
+    private: bool hasFocus;
   };
 }
 

Modified: code/gazebo/trunk/server/main.cc
===================================================================
--- code/gazebo/trunk/server/main.cc    2008-07-18 23:57:33 UTC (rev 6890)
+++ code/gazebo/trunk/server/main.cc    2008-07-21 05:27:12 UTC (rev 6891)
@@ -311,5 +311,6 @@
     return -1;
   }
 
+  printf("Done.\n");
   return 0;
 }

Modified: code/gazebo/trunk/server/physics/Body.cc
===================================================================
--- code/gazebo/trunk/server/physics/Body.cc    2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/physics/Body.cc    2008-07-21 05:27:12 UTC (rev 
6891)
@@ -127,7 +127,7 @@
 // Save the body based on our XMLConfig node
 void Body::Save()
 {
-  std::vector< Geom* >::iterator giter;
+  /*std::vector< Geom* >::iterator giter;
   std::vector< Sensor* >::iterator siter;
 
   this->xmlNode->SetValue("name", this->GetName());
@@ -143,7 +143,7 @@
   {
     //(*siter)->Save();
   }
-
+  */
 }
 
 

Modified: code/gazebo/trunk/server/physics/Geom.cc
===================================================================
--- code/gazebo/trunk/server/physics/Geom.cc    2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/physics/Geom.cc    2008-07-21 05:27:12 UTC (rev 
6891)
@@ -128,10 +128,10 @@
     childNode = childNode->GetNext("visual");
   }
 
-  if (this->IsStatic())
+  /*if (this->IsStatic())
   {
     this->visualNode->MakeStatic();
-  }
+  }*/
 
   // Create the bounding box
   if (this->geomId && dGeomGetClass(this->geomId) != dPlaneClass)
@@ -161,7 +161,7 @@
 // Save the body based on our XMLConfig node
 void Geom::Save()
 {
-  std::vector<OgreVisual*>::iterator iter;
+  /*std::vector<OgreVisual*>::iterator iter;
   Pose3d pose= this->GetPose();
 
   this->xmlNode->SetValue("name", this->GetName());
@@ -176,8 +176,7 @@
   {
     (*iter)->Save();
   }
-
-
+  */
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/physics/MapGeom.cc
===================================================================
--- code/gazebo/trunk/server/physics/MapGeom.cc 2008-07-18 23:57:33 UTC (rev 
6890)
+++ code/gazebo/trunk/server/physics/MapGeom.cc 2008-07-21 05:27:12 UTC (rev 
6891)
@@ -35,6 +35,7 @@
 #include "OgreAdaptor.hh"
 #include "Simulator.hh"
 #include "OgreAdaptor.hh"
+#include "OgreVisual.hh"
 #include "Global.hh"
 #include "Body.hh"
 #include "MapGeom.hh"
@@ -110,6 +111,8 @@
   }
 
   this->CreateBoxes(this->root);
+
+  this->visualNode->MakeStatic();
 }
 
 void MapGeom::CreateBoxes(QuadNode *node)

Modified: code/gazebo/trunk/server/physics/ode/ODEPhysics.cc
===================================================================
--- code/gazebo/trunk/server/physics/ode/ODEPhysics.cc  2008-07-18 23:57:33 UTC 
(rev 6890)
+++ code/gazebo/trunk/server/physics/ode/ODEPhysics.cc  2008-07-21 05:27:12 UTC 
(rev 6891)
@@ -108,7 +108,7 @@
 // Save the ODE engine
 void ODEPhysics::Save(XMLConfigNode *node)
 {
-  XMLConfigNode *cnode = node->GetChild("ode");
+  /*XMLConfigNode *cnode = node->GetChild("ode");
   if (cnode == NULL)
     gzthrow("No <physics:ode> node in the XML, can't write back the data");
 
@@ -116,6 +116,7 @@
   cnode->SetValue("stepTime", this->stepTime);
   cnode->SetValue("cfm", this->globalCFM);
   cnode->SetValue("erp", this->globalERP);
+  */
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreAdaptor.cc   2008-07-18 23:57:33 UTC 
(rev 6890)
+++ code/gazebo/trunk/server/rendering/OgreAdaptor.cc   2008-07-21 05:27:12 UTC 
(rev 6891)
@@ -67,6 +67,8 @@
   this->root=NULL;
 
   this->updateRate = 0;
+
+  this->dummyDisplay = false;
 }
 
 
////////////////////////////////////////////////////////////////////////////////
@@ -269,12 +271,15 @@
   this->root->addFrameListener(this->frameListener);
 
   this->updateRate = node->GetDouble("maxUpdateRate",0,0);
+
+  this->raySceneQuery = this->sceneMgr->createRayQuery( Ogre::Ray() );
 }
 
 
////////////////////////////////////////////////////////////////////////////////
 // Save
 void OgreAdaptor::Save(XMLConfigNode *node)
 {
+  /*
   //Video information is not modified so we don't need to rewrite it.
   //Sky is not modified, not rewritten
   XMLConfigNode *rnode;
@@ -290,7 +295,7 @@
   cnode = rnode->GetChild("fog");
   if (cnode)
     OgreCreator::SaveFog(cnode);
-
+    */
 }
 
 
@@ -460,6 +465,32 @@
 }
 
 
////////////////////////////////////////////////////////////////////////////////
+/// Get an entity at a pixel location using a camera. Used for mouse picking. 
+Entity *OgreAdaptor::GetEntityAt(OgreCamera *camera, int x, int y)
+{
+  /*
+  Ogre::Vector3 camPos = camera->getPosition();
+
+  Ogre::Ray mouseRay = camera->getCameraToViewportRay(
+      x/camera->GetViewportWidth(), y/camera->GetViewportHeight());
+
+  this->raySceneQuery->setRay( mouseRay );
+
+  // Perform the scene query
+  Ogre::RaySceneQueryResult &result = this->raySceneQuery->execute();
+  Ogre::RaySceneQueryResult::iterator iter = result.begin();
+   
+  // Get the results, set the camera height
+  if (iter != result.end() && iter->worldFragment)
+  {
+    Ogre::Real terrainHeight = iter->worldFragment->singleIntersection.y;
+    if ((terrainHeight + 10.0f) > camPos.y)
+        camera->setPosition( camPos.x, terrainHeight + 10.0f, camPos.z);
+  }
+  */
+}
+
+////////////////////////////////////////////////////////////////////////////////
 /// Get the desired update rate
 double OgreAdaptor::GetUpdateRate()
 {

Modified: code/gazebo/trunk/server/rendering/OgreAdaptor.hh
===================================================================
--- code/gazebo/trunk/server/rendering/OgreAdaptor.hh   2008-07-18 23:57:33 UTC 
(rev 6890)
+++ code/gazebo/trunk/server/rendering/OgreAdaptor.hh   2008-07-21 05:27:12 UTC 
(rev 6891)
@@ -51,6 +51,7 @@
   class RenderTarget;
   class ColourValue;
   class RenderSystem;
+  class RaySceneQuery; 
 }
 
 
@@ -94,6 +95,10 @@
     /// \brief Update a window
     public: void UpdateWindow(Ogre::RenderWindow *window, OgreCamera *camera);
 
+    /// \brief Get an entity at a pixel location using a camera. Used for
+    ///        mouse picking. 
+    public: Entity *GetEntityAt(OgreCamera *camera, int x, int y);
+
     private: void LoadPlugins();
     private: void SetupResources();
     private: void SetupRenderSystem(bool create);
@@ -116,6 +121,7 @@
   
     private: std::string videoMode;
   
+    private: Ogre::RaySceneQuery *raySceneQuery;
 
     //bsp attributes saved to write XML file back
     private: int sceneType;
@@ -145,6 +151,7 @@
     
     /// GLX context used to render the scenes.Used for gui-less operation
     protected: GLXContext dummyContext;
+
   };
   
  

Modified: code/gazebo/trunk/server/rendering/OgreCreator.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreCreator.cc   2008-07-18 23:57:33 UTC 
(rev 6890)
+++ code/gazebo/trunk/server/rendering/OgreCreator.cc   2008-07-21 05:27:12 UTC 
(rev 6891)
@@ -258,7 +258,7 @@
 
////////////////////////////////////////////////////////////////////////////////
 void OgreCreator::SaveFog(XMLConfigNode *node)
 {
-  Ogre::ColourValue color=OgreAdaptor::Instance()->sceneMgr->getFogColour();
+  /*Ogre::ColourValue color=OgreAdaptor::Instance()->sceneMgr->getFogColour();
   Ogre::Real start = OgreAdaptor::Instance()->sceneMgr->getFogStart();
   Ogre::Real end = OgreAdaptor::Instance()->sceneMgr->getFogEnd();
   //Ogre::Real density = OgreAdaptor::Instance()->sceneMgr->getFogDensity();
@@ -286,6 +286,7 @@
   node->SetValue("linearEnd", end);
   //node->SetValue("density", density);
 
+  */
 }
 
 
////////////////////////////////////////////////////////////////////////////////

Modified: code/gazebo/trunk/server/rendering/OgreVisual.cc
===================================================================
--- code/gazebo/trunk/server/rendering/OgreVisual.cc    2008-07-18 23:57:33 UTC 
(rev 6890)
+++ code/gazebo/trunk/server/rendering/OgreVisual.cc    2008-07-21 05:27:12 UTC 
(rev 6891)
@@ -151,9 +151,10 @@
 
 void OgreVisual::Save()
 {
-  this->xmlNode->SetValue("xyz", this->GetPosition());
+  /*this->xmlNode->SetValue("xyz", this->GetPosition());
   this->xmlNode->SetValue("rpy", this->GetRotation());
   //TODO: A lot of information!
+  */
 }
 
 

Modified: code/gazebo/trunk/worlds/models/bandit.model
===================================================================
--- code/gazebo/trunk/worlds/models/bandit.model        2008-07-18 23:57:33 UTC 
(rev 6890)
+++ code/gazebo/trunk/worlds/models/bandit.model        2008-07-21 05:27:12 UTC 
(rev 6891)
@@ -67,7 +67,11 @@
 
       <controller:stereocamera name="stereo_camera_controller">
         <interface:stereocamera name="bandit_stereo_iface" />
-        <interface:camera name="bandit_stereo_camera_iface" />
+        <interface:camera name="bandit_stereo_camera_left_iface" />
+        <interface:camera name="bandit_stereo_camera_right_iface" />
+
+        <leftcamera>bandit_stereo_camera_left_iface</leftcamera>
+        <rightcamera>bandit_stereo_camera_right_iface</rightcamera>
       </controller:stereocamera>
     </sensor:stereocamera>
   </body:box>


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

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to