Gazebo

StereoCameraSensor.hh

00001 /*
00002  *  Gazebo - Outdoor Multi-Robot Simulator
00003  *  Copyright (C) 2003  
00004  *     Nate Koenig & Andrew Howard
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; either version 2 of the License, or
00009  *  (at your option) any later version.
00010  *
00011  *  This program is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *  GNU General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU General Public License
00017  *  along with this program; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 /* Desc: Stereo Camera Sensor
00022  * Author: Nate Koenig
00023  * Date: 25 March 2008
00024  * SVN: $Id:$
00025  */
00026 
00027 #ifndef STEREOCAMERASENSOR_HH
00028 #define STEREOCAMERASENSOR_HH
00029 
00030 #include <OgrePrerequisites.h>
00031 #include <OgreTexture.h>
00032 #include <OgreMaterial.h>
00033 
00034 #include "CameraSensor.hh"
00035 
00036 // Forward Declarations
00037 namespace Ogre
00038 {
00039   class RenderTarget;
00040   class Camera;
00041   class Viewport;
00042   class SceneNode;
00043 }
00044 
00045 namespace gazebo
00046 {
00052 // \{
00053 
00054 
00058 class StereoCameraSensor : public CameraSensor
00059 {
00060 
00061   enum Sides {LEFT, RIGHT, D_LEFT, D_RIGHT};
00062 
00064   public: StereoCameraSensor(Body *body);
00065 
00067   public: virtual ~StereoCameraSensor();
00068 
00071   protected: virtual void LoadChild( XMLConfigNode *node );
00072 
00074   protected: virtual void InitChild();
00075 
00077   protected: virtual void UpdateChild(UpdateParams &params);
00078 
00080   protected: virtual void FiniChild();
00081 
00083   public: virtual std::string GetMaterialName() const;
00084 
00087   public: virtual const unsigned char *GetImageData(unsigned int i=0);
00088 
00091   public: const float *GetDisparityData(unsigned int i=0);
00092 
00094   public: double GetBaseline() const;
00095 
00096   // Save the camera frame
00097   protected: virtual void SaveFrame();
00098 
00100   private: void FillBuffers();
00101 
00102   private: Ogre::TexturePtr CreateRTT( const std::string &name, bool depth);
00103 
00104   //private: void UpdateAllDependentRenderTargets();
00105 
00106   private: Ogre::TexturePtr renderTexture[4];
00107   private: Ogre::RenderTarget *renderTarget[4];
00108   private: Ogre::MaterialPtr depthMaterial;
00109 
00110   private: std::string textureName[4];
00111   private: std::string materialName[4];
00112 
00113   private: unsigned int depthBufferSize;
00114   private: unsigned int rgbBufferSize;
00115   private: float *depthBuffer[2];
00116   private: unsigned char *rgbBuffer[2];
00117   private: double baseline;
00118 
00119   private: Ogre::Camera *depthCamera;
00120 
00121   /*private: 
00122            class StereoCameraListener : public Ogre::RenderTargetListener
00123            {
00124              public: StereoCameraListener() : Ogre::RenderTargetListener() {}
00125 
00126              public: void Init(StereoCameraSensor *sensor, Ogre::RenderTarget *target, bool isLeft);
00127              public: void preViewportUpdate(const Ogre::RenderTargetViewportEvent &evt);
00128              public: void postViewportUpdate(const Ogre::RenderTargetViewportEvent &evt);
00129 
00130              private: Ogre::Vector3 pos;
00131              private: StereoCameraSensor *sensor;
00132              private: Ogre::Camera *camera;
00133              private: Ogre::RenderTarget *renderTarget;
00134              private: bool isLeftCamera;
00135            };
00136 
00137 
00138   private: StereoCameraListener leftCameraListener;
00139   private: StereoCameraListener rightCameraListener;
00140   */
00141 };
00142 
00145 }
00146 #endif
00147 

Last updated Aug 04 2007