18 #ifndef _GAZEBO_RENDERING_CAMERA_HH_
19 #define _GAZEBO_RENDERING_CAMERA_HH_
21 #include <boost/enable_shared_from_this.hpp>
43 #include "gazebo/msgs/MessageTypes.hh"
84 bool _autoRender =
true);
91 public:
virtual void Load(sdf::ElementPtr _sdf);
94 public:
virtual void Load();
97 public:
virtual void Init();
101 public:
void SetRenderRate(
double _hz);
105 public:
double GetRenderRate()
const;
112 public:
void Render();
119 public:
void Render(
bool _force);
124 public:
virtual void PostRender();
131 public:
virtual void Update();
136 public:
virtual void Fini();
140 public:
bool GetInitialized()
const;
145 public:
void SetWindowId(
unsigned int _windowId);
149 public:
unsigned int GetWindowId()
const;
153 public:
void SetScene(
ScenePtr _scene);
165 public:
virtual void SetWorldPose(
const math::Pose &_pose);
194 public:
void SetClipDist(
float _near,
float _far);
211 public:
void SetImageSize(
unsigned int _w,
unsigned int _h);
215 public:
void SetImageWidth(
unsigned int _w);
219 public:
void SetImageHeight(
unsigned int _h);
223 public:
virtual unsigned int GetImageWidth()
const;
227 public:
unsigned int GetTextureWidth()
const;
231 public:
virtual unsigned int GetImageHeight()
const;
235 public:
unsigned int GetImageDepth()
const;
239 public: std::string GetImageFormat()
const;
243 public:
unsigned int GetTextureHeight()
const;
247 public:
size_t GetImageByteSize()
const;
254 public:
static size_t GetImageByteSize(
unsigned int _width,
255 unsigned int _height,
256 const std::string &_format);
263 public:
double GetZValue(
int _x,
int _y);
267 public:
double GetNearClip();
271 public:
double GetFarClip();
275 public:
void EnableSaveFrame(
bool _enable);
279 public:
bool GetCaptureData()
const;
283 public:
void SetSaveFramePathname(
const std::string &_pathname);
288 public:
bool SaveFrame(
const std::string &_filename);
292 public: Ogre::Camera *GetOgreCamera()
const;
296 public: Ogre::Viewport *GetViewport()
const;
300 public:
unsigned int GetViewportWidth()
const;
304 public:
unsigned int GetViewportHeight()
const;
324 public:
void SetAspectRatio(
float _ratio);
328 public:
float GetAspectRatio()
const;
332 public:
void SetSceneNode(Ogre::SceneNode *_node);
336 public: Ogre::SceneNode *GetSceneNode()
const;
347 public: virtual const
unsigned char *GetImageData(
unsigned int i = 0);
351 public:
std::
string GetName() const;
355 public:
std::
string GetScopedName() const;
359 public:
void SetName(const
std::
string &_name);
362 public:
void ToggleShowWireframe();
366 public:
void ShowWireframe(
bool _s);
375 public:
void GetCameraToViewportRay(
int _screenx,
int _screeny,
376 math::Vector3 &_origin,
377 math::Vector3 &_dir);
381 public:
void SetCaptureData(
bool _value);
384 public:
void SetCaptureDataOnce();
388 public:
void CreateRenderTexture(const
std::
string &_textureName);
400 public:
bool GetWorldPointOnPlane(
int _x,
int _y,
401 const math::Plane &_plane, math::Vector3 &_result);
405 public: virtual
void SetRenderTarget(
Ogre::RenderTarget *_target);
415 public:
void AttachToVisual(const
std::
string &_visualName,
416 bool _inheritOrientation,
417 double _minDist = 0.0,
double _maxDist = 0.0);
427 public:
void AttachToVisual(uint32_t _id,
428 bool _inheritOrientation,
429 double _minDist = 0.0,
double _maxDist = 0.0);
433 public:
void TrackVisual(const
std::
string &_visualName);
437 public:
Ogre::Texture *GetRenderTexture() const;
441 public: math::Vector3 GetDirection() const;
447 public: template<typename T>
449 {
return newImageFrame.Connect(_subscriber);}
454 {newImageFrame.Disconnect(_c);}
464 public:
static bool SaveFrame(
const unsigned char *_image,
465 unsigned int _width,
unsigned int _height,
int _depth,
466 const std::string &_format,
467 const std::string &_filename);
478 public:
bool IsVisible(
VisualPtr _visual);
484 public:
bool IsVisible(
const std::string &_visualName);
487 public:
bool IsAnimating()
const;
493 public:
virtual bool MoveToPosition(
const math::Pose &_pose,
503 public:
bool MoveToPositions(
const std::vector<math::Pose> &_pts,
505 boost::function<
void()> _onComplete =
NULL);
509 public: std::string GetScreenshotPath()
const;
512 protected:
virtual void RenderImpl();
515 protected:
void ReadPixelBuffer();
520 protected:
bool TrackVisualImpl(
const std::string &_visualName);
525 protected:
virtual bool TrackVisualImpl(
VisualPtr _visual);
536 protected:
virtual bool AttachToVisualImpl(
const std::string &_name,
537 bool _inheritOrientation,
538 double _minDist = 0,
double _maxDist = 0);
549 protected:
virtual bool AttachToVisualImpl(uint32_t _id,
550 bool _inheritOrientation,
551 double _minDist = 0,
double _maxDist = 0);
562 protected:
virtual bool AttachToVisualImpl(
VisualPtr _visual,
563 bool _inheritOrientation,
564 double _minDist = 0,
double _maxDist = 0);
568 protected: std::string GetFrameFilename();
572 protected:
virtual void AnimationComplete();
581 private:
void ConvertRGBToBAYER(
unsigned char *_dst,
unsigned char *_src,
582 std::string _format,
int _width,
int _height);
585 private:
void SetClipDist();
590 private:
static int GetOgrePixelFormat(
const std::string &_format);
594 private:
void OnCmdMsg(ConstCameraCmdPtr &_msg);
597 private:
void CreateCamera();
609 protected: sdf::ElementPtr
sdf;
673 unsigned int,
unsigned int,
unsigned int,
int imageHeight
Save image height.
Definition: Camera.hh:648
Basic camera sensor.
Definition: Camera.hh:77
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:144
Ogre::Viewport * viewport
Viewport the ogre camera uses.
Definition: Camera.hh:624
unsigned int saveCount
Number of saved frames.
Definition: Camera.hh:636
Forward declarations for the common classes.
Definition: Animation.hh:24
Encapsulates a position and rotation in three space.
Definition: Pose.hh:40
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:43
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:674
virtual float GetAvgFPS() const
Get the average FPS.
Definition: Camera.hh:316
bool captureData
True to capture frames into an image buffer.
Definition: Camera.hh:657
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:44
void DisconnectNewImageFrame(event::ConnectionPtr &_c)
Disconnect from an image frame.
Definition: Camera.hh:453
Ogre::Texture * renderTexture
Texture that receives results from rendering.
Definition: Camera.hh:654
unsigned char * bayerFrameBuffer
Buffer for a bayer image frame.
Definition: Camera.hh:633
bool initialized
True if initialized.
Definition: Camera.hh:683
Ogre::Camera * camera
The OGRE camera.
Definition: Camera.hh:621
Private data for the Camera class.
Definition: CameraPrivate.hh:37
Ogre::SceneNode * sceneNode
Scene node that controls camera position and orientation.
Definition: Camera.hh:627
std::list< msgs::Request > requests
List of requests.
Definition: Camera.hh:680
ScenePtr scene
Pointer to the scene.
Definition: Camera.hh:669
Ogre::RenderTarget * renderTarget
Target that renders frames.
Definition: Camera.hh:651
boost::function< void()> onAnimationComplete
User callback for when an animation completes.
Definition: Camera.hh:692
common::Time lastRenderWallTime
Time the last frame was rendered.
Definition: Camera.hh:666
unsigned int textureHeight
Height of the render texture.
Definition: Camera.hh:618
unsigned char * saveFrameBuffer
Definition: Camera.hh:630
bool captureDataOnce
True to capture a frame once and save to disk.
Definition: Camera.hh:660
A quaternion class.
Definition: Quaternion.hh:45
bool newData
True if new data is available.
Definition: Camera.hh:663
std::string screenshotPath
Path to saved screenshots.
Definition: Camera.hh:639
unsigned int windowId
ID of the window that the camera is attached to.
Definition: Camera.hh:612
unsigned int textureWidth
Width of the render texture.
Definition: Camera.hh:615
sdf::ElementPtr sdf
Camera's SDF values.
Definition: Camera.hh:609
#define NULL
Definition: CommonTypes.hh:30
int imageFormat
Format for saving images.
Definition: Camera.hh:642
std::string name
Name of the camera.
Definition: Camera.hh:600
std::string scopedName
Scene scoped name of the camera.
Definition: Camera.hh:603
std::vector< event::ConnectionPtr > connections
The camera's event connections.
Definition: Camera.hh:677
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:67
common::Time prevAnimTime
Previous time the camera animation was updated.
Definition: Camera.hh:689
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
A class for event processing.
Definition: Event.hh:156
boost::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:95
Ogre::AnimationState * animState
Animation state, used to animate the camera.
Definition: Camera.hh:686
An angle and related functions.
Definition: Angle.hh:52
int imageWidth
Save image width.
Definition: Camera.hh:645
#define GAZEBO_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system.hh:48
std::string scopedUniqueName
Scene scoped name of the camera with a unique ID.
Definition: Camera.hh:606
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:43
virtual unsigned int GetTriangleCount() const
Get the triangle count.
Definition: Camera.hh:320