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(
bool _force =
false);
117 public:
virtual void PostRender();
124 public:
virtual void Update();
129 public:
virtual void Fini();
133 public:
bool GetInitialized()
const;
138 public:
void SetWindowId(
unsigned int _windowId);
142 public:
unsigned int GetWindowId()
const;
146 public:
void SetScene(
ScenePtr _scene);
158 public:
virtual void SetWorldPose(
const math::Pose &_pose);
187 public:
void SetClipDist(
float _near,
float _far);
204 public:
void SetImageSize(
unsigned int _w,
unsigned int _h);
208 public:
void SetImageWidth(
unsigned int _w);
212 public:
void SetImageHeight(
unsigned int _h);
216 public:
virtual unsigned int GetImageWidth()
const;
220 public:
unsigned int GetTextureWidth()
const;
224 public:
virtual unsigned int GetImageHeight()
const;
228 public:
unsigned int GetImageDepth()
const;
232 public: std::string GetImageFormat()
const;
236 public:
unsigned int GetTextureHeight()
const;
240 public:
size_t GetImageByteSize()
const;
247 public:
static size_t GetImageByteSize(
unsigned int _width,
248 unsigned int _height,
249 const std::string &_format);
256 public:
double GetZValue(
int _x,
int _y);
260 public:
double GetNearClip();
264 public:
double GetFarClip();
268 public:
void EnableSaveFrame(
bool _enable);
272 public:
bool GetCaptureData()
const;
276 public:
void SetSaveFramePathname(
const std::string &_pathname);
281 public:
bool SaveFrame(
const std::string &_filename);
285 public: Ogre::Camera *GetOgreCamera()
const;
289 public: Ogre::Viewport *GetViewport()
const;
293 public:
unsigned int GetViewportWidth()
const;
297 public:
unsigned int GetViewportHeight()
const;
317 public:
void SetAspectRatio(
float _ratio);
321 public:
float GetAspectRatio()
const;
325 public:
void SetSceneNode(Ogre::SceneNode *_node);
329 public: Ogre::SceneNode *GetSceneNode()
const;
336 public:
virtual const unsigned char *GetImageData(
unsigned int i = 0);
340 public: std::string GetName()
const;
344 public: std::string GetScopedName()
const;
348 public:
void SetName(
const std::string &_name);
351 public:
void ToggleShowWireframe();
355 public:
void ShowWireframe(
bool _s);
364 public:
void GetCameraToViewportRay(
int _screenx,
int _screeny,
370 public:
void SetCaptureData(
bool _value);
373 public:
void SetCaptureDataOnce();
377 public:
void CreateRenderTexture(
const std::string &_textureName);
389 public:
bool GetWorldPointOnPlane(
int _x,
int _y,
394 public:
virtual void SetRenderTarget(Ogre::RenderTarget *_target);
404 public:
void AttachToVisual(
const std::string &_visualName,
405 bool _inheritOrientation,
406 double _minDist = 0.0,
double _maxDist = 0.0);
416 public:
void AttachToVisual(uint32_t _id,
417 bool _inheritOrientation,
418 double _minDist = 0.0,
double _maxDist = 0.0);
422 public:
void TrackVisual(
const std::string &_visualName);
426 public: Ogre::Texture *GetRenderTexture()
const;
436 public:
template<
typename T>
438 {
return newImageFrame.Connect(_subscriber);}
443 {newImageFrame.Disconnect(_c);}
453 public:
static bool SaveFrame(
const unsigned char *_image,
454 unsigned int _width,
unsigned int _height,
int _depth,
455 const std::string &_format,
456 const std::string &_filename);
467 public:
bool IsVisible(
VisualPtr _visual);
473 public:
bool IsVisible(
const std::string &_visualName);
476 public:
bool IsAnimating()
const;
482 public:
virtual bool MoveToPosition(
const math::Pose &_pose,
492 public:
bool MoveToPositions(
const std::vector<math::Pose> &_pts,
494 boost::function<
void()> _onComplete =
NULL);
498 public: std::string GetScreenshotPath()
const;
501 protected:
virtual void RenderImpl();
504 protected:
void ReadPixelBuffer();
509 protected:
bool TrackVisualImpl(
const std::string &_visualName);
514 protected:
virtual bool TrackVisualImpl(
VisualPtr _visual);
525 protected:
virtual bool AttachToVisualImpl(
const std::string &_name,
526 bool _inheritOrientation,
527 double _minDist = 0,
double _maxDist = 0);
538 protected:
virtual bool AttachToVisualImpl(uint32_t _id,
539 bool _inheritOrientation,
540 double _minDist = 0,
double _maxDist = 0);
551 protected:
virtual bool AttachToVisualImpl(
VisualPtr _visual,
552 bool _inheritOrientation,
553 double _minDist = 0,
double _maxDist = 0);
557 protected: std::string GetFrameFilename();
561 protected:
virtual void AnimationComplete();
570 private:
void ConvertRGBToBAYER(
unsigned char *_dst,
unsigned char *_src,
571 std::string _format,
int _width,
int _height);
574 private:
void SetClipDist();
579 private:
static int GetOgrePixelFormat(
const std::string &_format);
583 private:
void OnCmdMsg(ConstCameraCmdPtr &_msg);
586 private:
void CreateCamera();
598 protected: sdf::ElementPtr
sdf;
662 unsigned int,
unsigned int,
unsigned int,
int imageHeight
Save image height.
Definition: Camera.hh:637
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:613
unsigned int saveCount
Number of saved frames.
Definition: Camera.hh:625
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:663
virtual float GetAvgFPS() const
Get the average FPS.
Definition: Camera.hh:309
bool captureData
True to capture frames into an image buffer.
Definition: Camera.hh:646
void DisconnectNewImageFrame(event::ConnectionPtr &_c)
Disconnect from an image frame.
Definition: Camera.hh:442
Ogre::Texture * renderTexture
Texture that receives results from rendering.
Definition: Camera.hh:643
unsigned char * bayerFrameBuffer
Buffer for a bayer image frame.
Definition: Camera.hh:622
bool initialized
True if initialized.
Definition: Camera.hh:672
Ogre::Camera * camera
The OGRE camera.
Definition: Camera.hh:610
Private data for the Camera class.
Definition: CameraPrivate.hh:37
event::ConnectionPtr ConnectNewImageFrame(T _subscriber)
Connect to the new image signal.
Definition: Camera.hh:437
Ogre::SceneNode * sceneNode
Scene node that controls camera position and orientation.
Definition: Camera.hh:616
std::list< msgs::Request > requests
List of requests.
Definition: Camera.hh:669
ScenePtr scene
Pointer to the scene.
Definition: Camera.hh:658
Ogre::RenderTarget * renderTarget
Target that renders frames.
Definition: Camera.hh:640
boost::function< void()> onAnimationComplete
User callback for when an animation completes.
Definition: Camera.hh:681
common::Time lastRenderWallTime
Time the last frame was rendered.
Definition: Camera.hh:655
unsigned int textureHeight
Height of the render texture.
Definition: Camera.hh:607
unsigned char * saveFrameBuffer
Definition: Camera.hh:619
bool captureDataOnce
True to capture a frame once and save to disk.
Definition: Camera.hh:649
A plane and related functions.
Definition: Plane.hh:33
A quaternion class.
Definition: Quaternion.hh:45
bool newData
True if new data is available.
Definition: Camera.hh:652
std::string screenshotPath
Path to saved screenshots.
Definition: Camera.hh:628
unsigned int windowId
ID of the window that the camera is attached to.
Definition: Camera.hh:601
unsigned int textureWidth
Width of the render texture.
Definition: Camera.hh:604
sdf::ElementPtr sdf
Camera's SDF values.
Definition: Camera.hh:598
#define NULL
Definition: CommonTypes.hh:30
int imageFormat
Format for saving images.
Definition: Camera.hh:631
std::string name
Name of the camera.
Definition: Camera.hh:589
std::string scopedName
Scene scoped name of the camera.
Definition: Camera.hh:592
std::vector< event::ConnectionPtr > connections
The camera's event connections.
Definition: Camera.hh:666
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:72
common::Time prevAnimTime
Previous time the camera animation was updated.
Definition: Camera.hh:678
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:100
Ogre::AnimationState * animState
Animation state, used to animate the camera.
Definition: Camera.hh:675
An angle and related functions.
Definition: Angle.hh:52
int imageWidth
Save image width.
Definition: Camera.hh:634
#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:595
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:313