18 #ifndef _GAZEBO_RENDERING_CAMERA_HH_
19 #define _GAZEBO_RENDERING_CAMERA_HH_
21 #include <boost/enable_shared_from_this.hpp>
44 #include "gazebo/msgs/MessageTypes.hh"
79 public boost::enable_shared_from_this<Camera>
86 bool _autoRender =
true);
93 public:
virtual void Load(sdf::ElementPtr _sdf);
96 public:
virtual void Load();
99 public:
virtual void Init();
103 public:
void SetRenderRate(
double _hz);
107 public:
double GetRenderRate()
const;
114 public:
void Render(
bool _force =
false);
119 public:
virtual void PostRender();
126 public:
virtual void Update();
131 public:
virtual void Fini();
135 public:
bool GetInitialized()
const;
140 public:
void SetWindowId(
unsigned int _windowId);
144 public:
unsigned int GetWindowId()
const;
148 public:
void SetScene(
ScenePtr _scene);
160 public:
virtual void SetWorldPose(
const math::Pose &_pose);
184 Ogre::Node::TransformSpace _relativeTo =
185 Ogre::Node::TS_LOCAL);
193 Ogre::Node::TransformSpace _relativeTo =
194 Ogre::Node::TS_LOCAL);
202 Ogre::Node::TransformSpace _relativeTo =
203 Ogre::Node::TS_WORLD);
216 public:
virtual void SetClipDist(
float _near,
float _far);
233 public:
void SetImageSize(
unsigned int _w,
unsigned int _h);
237 public:
void SetImageWidth(
unsigned int _w);
241 public:
void SetImageHeight(
unsigned int _h);
245 public:
virtual unsigned int GetImageWidth()
const;
249 public:
unsigned int GetTextureWidth()
const;
253 public:
virtual unsigned int GetImageHeight()
const;
257 public:
unsigned int GetImageDepth()
const;
261 public: std::string GetImageFormat()
const;
265 public:
unsigned int GetTextureHeight()
const;
269 public:
size_t GetImageByteSize()
const;
276 public:
static size_t GetImageByteSize(
unsigned int _width,
277 unsigned int _height,
278 const std::string &_format);
285 public:
double GetZValue(
int _x,
int _y);
289 public:
double GetNearClip();
293 public:
double GetFarClip();
297 public:
void EnableSaveFrame(
bool _enable);
301 public:
bool GetCaptureData()
const;
305 public:
void SetSaveFramePathname(
const std::string &_pathname);
310 public:
bool SaveFrame(
const std::string &_filename);
314 public: Ogre::Camera *GetOgreCamera()
const;
318 public: Ogre::Viewport *GetViewport()
const;
322 public:
unsigned int GetViewportWidth()
const;
326 public:
unsigned int GetViewportHeight()
const;
338 public:
virtual float GetAvgFPS()
const;
342 public:
virtual unsigned int GetTriangleCount()
const;
346 public:
void SetAspectRatio(
float _ratio);
350 public:
float GetAspectRatio()
const;
354 public:
void SetSceneNode(Ogre::SceneNode *_node);
358 public: Ogre::SceneNode *GetSceneNode()
const;
365 public:
virtual const unsigned char *GetImageData(
unsigned int i = 0);
369 public: std::string GetName()
const;
373 public: std::string GetScopedName()
const;
377 public:
void SetName(
const std::string &_name);
380 public:
void ToggleShowWireframe();
384 public:
void ShowWireframe(
bool _s);
393 public:
void GetCameraToViewportRay(
int _screenx,
int _screeny,
399 public:
void SetCaptureData(
bool _value);
402 public:
void SetCaptureDataOnce();
406 public:
void CreateRenderTexture(
const std::string &_textureName);
418 public:
bool GetWorldPointOnPlane(
int _x,
int _y,
423 public:
virtual void SetRenderTarget(Ogre::RenderTarget *_target);
433 public:
void AttachToVisual(
const std::string &_visualName,
434 bool _inheritOrientation,
435 double _minDist = 0.0,
double _maxDist = 0.0);
445 public:
void AttachToVisual(uint32_t _id,
446 bool _inheritOrientation,
447 double _minDist = 0.0,
double _maxDist = 0.0);
451 public:
void TrackVisual(
const std::string &_visualName);
455 public: Ogre::Texture *GetRenderTexture()
const;
465 public:
template<
typename T>
467 {
return newImageFrame.Connect(_subscriber);}
472 {newImageFrame.Disconnect(_c);}
482 public:
static bool SaveFrame(
const unsigned char *_image,
483 unsigned int _width,
unsigned int _height,
int _depth,
484 const std::string &_format,
485 const std::string &_filename);
496 public:
bool IsVisible(
VisualPtr _visual);
502 public:
bool IsVisible(
const std::string &_visualName);
505 public:
bool IsAnimating()
const;
511 public:
virtual bool MoveToPosition(
const math::Pose &_pose,
521 public:
bool MoveToPositions(
const std::vector<math::Pose> &_pts,
523 boost::function<
void()> _onComplete =
NULL);
527 public: std::string GetScreenshotPath()
const;
538 public:
virtual bool SetProjectionType(
const std::string &_type);
543 public: std::string GetProjectionType()
const;
546 protected:
virtual void RenderImpl();
549 protected:
void ReadPixelBuffer();
554 protected:
bool TrackVisualImpl(
const std::string &_visualName);
559 protected:
virtual bool TrackVisualImpl(
VisualPtr _visual);
570 protected:
virtual bool AttachToVisualImpl(
const std::string &_name,
571 bool _inheritOrientation,
572 double _minDist = 0,
double _maxDist = 0);
583 protected:
virtual bool AttachToVisualImpl(uint32_t _id,
584 bool _inheritOrientation,
585 double _minDist = 0,
double _maxDist = 0);
596 protected:
virtual bool AttachToVisualImpl(
VisualPtr _visual,
597 bool _inheritOrientation,
598 double _minDist = 0,
double _maxDist = 0);
602 protected: std::string GetFrameFilename();
606 protected:
virtual void AnimationComplete();
609 protected:
virtual void UpdateFOV();
618 private:
void ConvertRGBToBAYER(
unsigned char *_dst,
unsigned char *_src,
619 std::string _format,
int _width,
int _height);
622 private:
void SetClipDist();
627 private:
static int GetOgrePixelFormat(
const std::string &_format);
631 private:
void OnCmdMsg(ConstCameraCmdPtr &_msg);
634 private:
void CreateCamera();
646 protected: sdf::ElementPtr
sdf;
710 unsigned int,
unsigned int,
unsigned int,
int imageHeight
Save image height.
Definition: Camera.hh:685
Basic camera sensor.
Definition: Camera.hh:78
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:147
Ogre::Viewport * viewport
Viewport the ogre camera uses.
Definition: Camera.hh:661
unsigned int saveCount
Number of saved frames.
Definition: Camera.hh:673
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
event::EventT< void(const unsigned char *, unsigned int, unsigned int, unsigned int, const std::string &)> newImageFrame
Event triggered when a new frame is generated.
Definition: Camera.hh:711
bool captureData
True to capture frames into an image buffer.
Definition: Camera.hh:694
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:47
void DisconnectNewImageFrame(event::ConnectionPtr &_c)
Disconnect from an image frame.
Definition: Camera.hh:471
boost::shared_ptr< Distortion > DistortionPtr
Definition: RenderTypes.hh:187
Ogre::Texture * renderTexture
Texture that receives results from rendering.
Definition: Camera.hh:691
unsigned char * bayerFrameBuffer
Buffer for a bayer image frame.
Definition: Camera.hh:670
bool initialized
True if initialized.
Definition: Camera.hh:720
Ogre::Camera * camera
The OGRE camera.
Definition: Camera.hh:658
Private data for the Camera class.
Definition: CameraPrivate.hh:37
event::ConnectionPtr ConnectNewImageFrame(T _subscriber)
Connect to the new image signal.
Definition: Camera.hh:466
Ogre::SceneNode * sceneNode
Scene node that controls camera position and orientation.
Definition: Camera.hh:664
std::list< msgs::Request > requests
List of requests.
Definition: Camera.hh:717
ScenePtr scene
Pointer to the scene.
Definition: Camera.hh:706
Ogre::RenderTarget * renderTarget
Target that renders frames.
Definition: Camera.hh:688
boost::function< void()> onAnimationComplete
User callback for when an animation completes.
Definition: Camera.hh:729
common::Time lastRenderWallTime
Time the last frame was rendered.
Definition: Camera.hh:703
#define GZ_RENDERING_VISIBLE
Definition: system.hh:241
unsigned int textureHeight
Height of the render texture.
Definition: Camera.hh:655
unsigned char * saveFrameBuffer
Buffer for a single image frame.
Definition: Camera.hh:667
bool captureDataOnce
True to capture a frame once and save to disk.
Definition: Camera.hh:697
A plane and related functions.
Definition: Plane.hh:35
A quaternion class.
Definition: Quaternion.hh:42
bool newData
True if new data is available.
Definition: Camera.hh:700
std::string screenshotPath
Path to saved screenshots.
Definition: Camera.hh:676
unsigned int windowId
ID of the window that the camera is attached to.
Definition: Camera.hh:649
unsigned int textureWidth
Width of the render texture.
Definition: Camera.hh:652
sdf::ElementPtr sdf
Camera's SDF values.
Definition: Camera.hh:646
#define NULL
Definition: CommonTypes.hh:30
int imageFormat
Format for saving images.
Definition: Camera.hh:679
std::string name
Name of the camera.
Definition: Camera.hh:637
std::string scopedName
Scene scoped name of the camera.
Definition: Camera.hh:640
std::vector< event::ConnectionPtr > connections
The camera's event connections.
Definition: Camera.hh:714
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:79
common::Time prevAnimTime
Previous time the camera animation was updated.
Definition: Camera.hh:726
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
A class for event processing.
Definition: Event.hh:178
boost::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:107
Ogre::AnimationState * animState
Animation state, used to animate the camera.
Definition: Camera.hh:723
An angle and related functions.
Definition: Angle.hh:53
int imageWidth
Save image width.
Definition: Camera.hh:682
std::string scopedUniqueName
Scene scoped name of the camera with a unique ID.
Definition: Camera.hh:643
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:39