CameraSensor.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
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 ¶ms);
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
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
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