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 6338 2008-04-16 17:24:32Z natepak $
00025  */
00026 
00027 #ifndef CAMERASENSOR_HH
00028 #define CAMERASENSOR_HH
00029 
00030 #include <OgrePrerequisites.h>
00031 #include <OgreTexture.h>
00032 
00033 #include "Pose3d.hh"
00034 #include "Sensor.hh"
00035 
00036 // Forward Declarations
00037 namespace Ogre
00038 {
00039   class TexturePtr;
00040   class RenderTarget;
00041   class Camera;
00042   class Viewport;
00043   class SceneNode;
00044 }
00045 
00046 namespace gazebo
00047 {
00053 // \{
00054 
00055 
00061 class CameraSensor : public Sensor
00062 {
00064   public: CameraSensor(Body *body);
00065 
00067   public: virtual ~CameraSensor();
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: Pose3d GetWorldPose() const;
00084 
00086   public: virtual std::string GetMaterialName() const = 0;
00087 
00089   public: void Translate( const Vector3 &direction );
00090 
00092   public: void RotateYaw( float angle );
00093 
00095   public: void RotatePitch( float angle );
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: size_t GetImageByteSize() const;
00114 
00115   public: virtual const unsigned char *GetImageData(unsigned int i=0) = 0;
00116 
00122   public: double GetZValue(int x, int y);
00123 
00125   public: double GetNearClip();
00126 
00128   public: double GetFarClip();
00129 
00131   public: void EnableSaveFrame(bool enable);
00132 
00134   public: void ToggleSaveFrame();
00135 
00137   public: Ogre::Camera *GetOgreCamera() const;
00138 
00139   // Save the camera frame
00140   protected: virtual void SaveFrame() = 0;
00141 
00142   protected: double hfov;
00143   protected: double nearClip, farClip;
00144   protected: unsigned int imageWidth, imageHeight;
00145   protected: unsigned int textureWidth, textureHeight;
00146 
00147   protected: Ogre::Camera *camera;
00148   protected: Ogre::SceneNode *pitchNode;
00149 
00150   protected: Pose3d pose;
00151 
00152   //access to our visual node (convenience member)
00153   protected: Ogre::SceneNode *sceneNode;
00154 
00155   // Info for saving images
00156   protected: unsigned char *saveFrameBuffer;
00157   protected: unsigned int saveCount;
00158   protected: bool saveFrames;
00159   protected: std::string savePathname;
00160 
00161   protected: unsigned int visibilityMask;
00162 };
00163 
00166 }
00167 #endif
00168 

Last updated Aug 04 2007