Gazebo

CameraSensor.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: A persepective X11 OpenGL Camera Sensor
00022  * Author: Nate Koenig
00023  * Date: 15 July 2003
00024  * CVS: $Id: CameraSensor.hh 152 2007-11-01 23:45:07Z natepak $
00025  */
00026 
00027 #ifndef CAMERASENSOR_HH
00028 #define CAMERASENSOR_HH
00029 
00030 #include <Ogre.h>
00031 #include "Pose3d.hh"
00032 #include "Sensor.hh"
00033 
00034 // Forward Declarations
00035 namespace Ogre
00036 {
00037   class TexturePtr;
00038   class RenderTarget;
00039   class Camera;
00040   class Viewport;
00041 }
00042 
00043 namespace gazebo
00044 {
00050 // \{
00051 
00052 
00058 class CameraSensor : public Sensor
00059 {
00061   public: CameraSensor(Body *body);
00062 
00064   public: virtual ~CameraSensor();
00065 
00068   protected: virtual void LoadChild( XMLConfigNode *node );
00069 
00071   protected: virtual void InitChild();
00072 
00074   protected: virtual void UpdateChild(UpdateParams &params);
00075 
00077   protected: virtual void FiniChild();
00078 
00080   public: Pose3d GetWorldPose() const;
00081 
00083   public: std::string GetMaterialName() const;
00084 
00086   public: void Translate( const Vector3 &direction );
00087 
00089   public: void RotateYaw( float angle );
00090 
00092   public: void RotatePitch( float angle );
00093 
00095   public: void SetFOV(double fov);
00096 
00098   public: double GetFOV() const;
00099 
00101   public: unsigned int GetImageWidth() const;
00102 
00104   public: unsigned int GetTextureWidth() const;
00105 
00107   public: unsigned int GetImageHeight() const;
00108 
00110   public: unsigned int GetTextureHeight() const;
00111 
00113   public: const unsigned char *GetImageData();
00114 
00116   public: size_t GetImageByteSize() const;
00117 
00123   public: double GetZValue(int x, int y);
00124 
00126   public: void EnableSaveFrame(bool enable);
00127 
00129   public: void ToggleSaveFrame();
00130 
00132   public: Ogre::Camera *GetOgreCamera() const;
00133 
00134   // Save the camera frame
00135   private: void SaveFrame();
00136 
00137   private: double hfov;
00138   private: double nearClip, farClip;
00139   private: unsigned int imageWidth, imageHeight;
00140 
00141   private: Ogre::TexturePtr renderTexture;
00142   private: Ogre::RenderTarget *renderTarget;
00143   private: Ogre::Viewport *viewport;
00144 
00145   private: Ogre::Camera *camera;
00146   private: Ogre::SceneNode *translateYawNode;
00147   private: Ogre::SceneNode *pitchNode;
00148 
00149   private: std::string ogreTextureName;
00150   private: std::string ogreMaterialName;
00151 
00152   private: Pose3d pose;
00153 
00154   // Info for saving images
00155   private: unsigned char *saveFrameBuffer;
00156   private: unsigned int saveCount;
00157   private: bool saveFrames;
00158   private: std::string savePathname;
00159 };
00160 
00163 }
00164 #endif
00165 

Last updated Aug 04 2007