18 #ifndef _GAZEBO_RENDERING_CAMERA_HH_ 19 #define _GAZEBO_RENDERING_CAMERA_HH_ 24 #include <boost/enable_shared_from_this.hpp> 31 #include <ignition/math/Angle.hh> 32 #include <ignition/math/Vector3.hh> 33 #include <ignition/math/Quaternion.hh> 34 #include <ignition/math/Pose3.hh> 51 #include "gazebo/msgs/MessageTypes.hh" 86 public boost::enable_shared_from_this<Camera>
93 bool _autoRender =
true);
100 public:
virtual void Load(sdf::ElementPtr _sdf);
103 public:
virtual void Load();
106 public:
virtual void Init();
110 public:
void SetRenderRate(
const double _hz);
119 public:
double RenderRate()
const;
126 public:
void Render(
const bool _force =
false);
131 public:
virtual void PostRender();
138 public:
virtual void Update();
143 public:
virtual void Fini();
152 public:
bool Initialized()
const;
157 public:
void SetWindowId(
unsigned int _windowId);
166 public:
unsigned int WindowId()
const;
170 public:
void SetScene(
ScenePtr _scene);
180 public: ignition::math::Vector3d WorldPosition()
const;
190 public: ignition::math::Quaterniond WorldRotation()
const;
195 public:
virtual void SetWorldPose(
const math::Pose &_pose)
200 public:
virtual void SetWorldPose(
const ignition::math::Pose3d &_pose);
210 public: ignition::math::Pose3d WorldPose()
const;
220 public:
void SetWorldPosition(
const ignition::math::Vector3d &_pos);
230 public:
void SetWorldRotation(
const ignition::math::Quaterniond &_quat);
240 public:
void Translate(
const ignition::math::Vector3d &_direction);
249 Ogre::Node::TransformSpace _relativeTo =
256 public:
void Roll(
const ignition::math::Angle &_angle,
266 Ogre::Node::TransformSpace _relativeTo =
273 public:
void Pitch(
const ignition::math::Angle &_angle,
283 Ogre::Node::TransformSpace _relativeTo =
290 public:
void Yaw(
const ignition::math::Angle &_angle,
296 public:
virtual void SetClipDist(
const float _near,
const float _far);
305 public:
void SetHFOV(
const ignition::math::Angle &_angle);
315 public: ignition::math::Angle HFOV()
const;
327 public: ignition::math::Angle VFOV()
const;
332 public:
void SetImageSize(
const unsigned int _w,
const unsigned int _h);
336 public:
void SetImageWidth(
const unsigned int _w);
340 public:
void SetImageHeight(
const unsigned int _h);
349 public:
virtual unsigned int ImageWidth()
const;
358 public:
unsigned int TextureWidth()
const;
363 public:
virtual unsigned int GetImageHeight()
const 368 public:
virtual unsigned int ImageHeight()
const;
377 public:
unsigned int ImageDepth()
const;
386 public: std::string ImageFormat()
const;
395 public:
unsigned int TextureHeight()
const;
404 public:
size_t ImageByteSize()
const;
412 public:
static size_t GetImageByteSize(
unsigned int _width,
413 unsigned int _height,
414 const std::string &_format)
422 public:
static size_t ImageByteSize(
const unsigned int _width,
423 const unsigned int _height,
424 const std::string &_format);
439 public:
double ZValue(
const int _x,
const int _y);
448 public:
double NearClip()
const;
457 public:
double FarClip()
const;
461 public:
void EnableSaveFrame(
const bool _enable);
470 public:
bool CaptureData()
const;
474 public:
void SetSaveFramePathname(
const std::string &_pathname);
479 public:
bool SaveFrame(
const std::string &_filename);
488 public: Ogre::Camera *OgreCamera()
const;
497 public: Ogre::Viewport *OgreViewport()
const;
506 public:
unsigned int ViewportWidth()
const;
515 public:
unsigned int ViewportHeight()
const;
525 public: ignition::math::Vector3d Up()
const;
535 public: ignition::math::Vector3d Right()
const;
544 public:
virtual float AvgFPS()
const;
549 public:
virtual unsigned int GetTriangleCount()
const 554 public:
virtual unsigned int TriangleCount()
const;
558 public:
void SetAspectRatio(
float _ratio);
567 public:
float AspectRatio()
const;
571 public:
void SetSceneNode(Ogre::SceneNode *_node);
580 public: Ogre::SceneNode *SceneNode()
const;
588 public:
virtual const unsigned char *GetImageData(
unsigned int i = 0)
596 public:
virtual const unsigned char *ImageData(
const unsigned int i = 0)
606 public: std::string Name()
const;
615 public: std::string ScopedName()
const;
619 public:
void SetName(
const std::string &_name);
622 public:
void ToggleShowWireframe();
626 public:
void ShowWireframe(
const bool _s);
637 public:
void GetCameraToViewportRay(
int _screenx,
int _screeny,
649 public:
void CameraToViewportRay(
const int _screenx,
const int _screeny,
650 ignition::math::Vector3d &_origin,
651 ignition::math::Vector3d &_dir)
const;
655 public:
void SetCaptureData(
const bool _value);
658 public:
void SetCaptureDataOnce();
662 public:
void CreateRenderTexture(
const std::string &_textureName);
676 public:
bool GetWorldPointOnPlane(
int _x,
int _y,
686 public:
bool WorldPointOnPlane(
const int _x,
const int _y,
687 const ignition::math::Planed &_plane,
688 ignition::math::Vector3d &_result);
692 public:
virtual void SetRenderTarget(Ogre::RenderTarget *_target);
702 public:
void AttachToVisual(
const std::string &_visualName,
703 const bool _inheritOrientation,
704 const double _minDist = 0.0,
const double _maxDist = 0.0);
714 public:
void AttachToVisual(uint32_t _id,
715 const bool _inheritOrientation,
716 const double _minDist = 0.0,
const double _maxDist = 0.0);
720 public:
void TrackVisual(
const std::string &_visualName);
729 public: Ogre::Texture *RenderTexture()
const;
739 public: ignition::math::Vector3d Direction()
const;
746 std::function<
void (
const unsigned char *,
unsigned int,
unsigned int,
747 unsigned int,
const std::string &)> _subscriber);
761 public:
static bool SaveFrame(
const unsigned char *_image,
762 const unsigned int _width,
const unsigned int _height,
763 const int _depth,
const std::string &_format,
764 const std::string &_filename);
779 public:
bool IsVisible(
VisualPtr _visual);
785 public:
bool IsVisible(
const std::string &_visualName);
788 public:
bool IsAnimating()
const;
795 public:
virtual bool MoveToPosition(
const math::Pose &_pose,
802 public:
virtual bool MoveToPosition(
const ignition::math::Pose3d &_pose,
813 public:
bool MoveToPositions(
const std::vector<math::Pose> &_pts,
815 std::function<
void()> _onComplete =
NULL)
825 public:
bool MoveToPositions(
826 const std::vector<ignition::math::Pose3d> &_pts,
828 std::function<
void()> _onComplete =
NULL);
837 public: std::string ScreenshotPath()
const;
853 public:
virtual bool SetProjectionType(
const std::string &_type);
864 public: std::string ProjectionType()
const;
868 public: ignition::math::Matrix4d ProjectionMatrix()
const;
873 public: ignition::math::Vector2i Project(
874 const ignition::math::Vector3d &_pt)
const;
877 protected:
virtual void RenderImpl();
880 protected:
void ReadPixelBuffer();
885 protected:
bool TrackVisualImpl(
const std::string &_visualName);
890 protected:
virtual bool TrackVisualImpl(
VisualPtr _visual);
901 protected:
virtual bool AttachToVisualImpl(
const std::string &_name,
902 const bool _inheritOrientation,
903 const double _minDist = 0,
const double _maxDist = 0);
914 protected:
virtual bool AttachToVisualImpl(uint32_t _id,
915 const bool _inheritOrientation,
916 const double _minDist = 0,
const double _maxDist = 0);
927 protected:
virtual bool AttachToVisualImpl(
VisualPtr _visual,
928 const bool _inheritOrientation,
929 const double _minDist = 0,
const double _maxDist = 0);
938 protected: std::string FrameFilename();
942 protected:
virtual void AnimationComplete();
945 protected:
virtual void UpdateFOV();
954 private:
void ConvertRGBToBAYER(
unsigned char *_dst,
955 const unsigned char *_src,
const std::string &_format,
956 const int _width,
const int _height);
959 private:
virtual void SetClipDist();
964 private:
static int OgrePixelFormat(
const std::string &_format);
968 private:
void OnCmdMsg(ConstCameraCmdPtr &_msg);
971 private:
void CreateCamera();
983 protected: sdf::ElementPtr
sdf;
1047 unsigned int,
unsigned int,
unsigned int,
1070 private: std::unique_ptr<CameraPrivate> dataPtr;
Basic camera sensor.
Definition: Camera.hh:85
common::Time lastRenderWallTime
Time the last frame was rendered.
Definition: Camera.hh:1040
ReferenceFrame
Frame of reference.
Definition: RenderTypes.hh:234
bool initialized
True if initialized.
Definition: Camera.hh:1057
Ogre::Texture * renderTexture
Texture that receives results from rendering.
Definition: Camera.hh:1028
Forward declarations for the common classes.
Definition: Animation.hh:33
boost::shared_ptr< Distortion > DistortionPtr
Definition: RenderTypes.hh:196
Encapsulates a position and rotation in three space.
Definition: Pose.hh:37
std::string scopedUniqueName
Scene scoped name of the camera with a unique ID.
Definition: Camera.hh:980
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
unsigned char * saveFrameBuffer
Buffer for a single image frame.
Definition: Camera.hh:1004
unsigned char * bayerFrameBuffer
Buffer for a bayer image frame.
Definition: Camera.hh:1007
std::string screenshotPath
Path to saved screenshots.
Definition: Camera.hh:1013
#define GAZEBO_DEPRECATED(version)
Definition: CommonTypes.hh:48
bool captureDataOnce
True to capture a frame once and save to disk.
Definition: Camera.hh:1034
bool captureData
True to capture frames into an image buffer.
Definition: Camera.hh:1031
sdf::ElementPtr sdf
Camera's SDF values.
Definition: Camera.hh:983
Ogre::RenderTarget * renderTarget
Target that renders frames.
Definition: Camera.hh:1025
Ogre::SceneNode * sceneNode
Scene node that controls camera position and orientation.
Definition: Camera.hh:1001
Local frame.
Definition: RenderTypes.hh:237
std::vector< event::ConnectionPtr > connections
The camera's event connections.
Definition: Camera.hh:1051
Ogre::Viewport * viewport
Viewport the ogre camera uses.
Definition: Camera.hh:998
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:80
int imageWidth
Save image width.
Definition: Camera.hh:1019
bool newData
True if new data is available.
Definition: Camera.hh:1037
unsigned int windowId
ID of the window that the camera is attached to.
Definition: Camera.hh:986
common::Time prevAnimTime
Previous time the camera animation was updated.
Definition: Camera.hh:1063
std::string scopedName
Scene scoped name of the camera.
Definition: Camera.hh:977
ScenePtr scene
Pointer to the scene.
Definition: Camera.hh:1043
unsigned int saveCount
Number of saved frames.
Definition: Camera.hh:1010
A plane and related functions.
Definition: Plane.hh:35
std::list< msgs::Request > requests
List of requests.
Definition: Camera.hh:1054
unsigned int textureHeight
Height of the render texture.
Definition: Camera.hh:992
A quaternion class.
Definition: Quaternion.hh:42
int imageHeight
Save image height.
Definition: Camera.hh:1022
World frame.
Definition: RenderTypes.hh:243
boost::shared_ptr< Connection > ConnectionPtr
Definition: CommonTypes.hh:153
std::function< void()> onAnimationComplete
User callback for when an animation completes.
Definition: Camera.hh:1066
#define NULL
Definition: CommonTypes.hh:31
Definition: JointMaker.hh:41
int imageFormat
Format for saving images.
Definition: Camera.hh:1016
unsigned int textureWidth
Width of the render texture.
Definition: Camera.hh:989
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:112
std::string name
Name of the camera.
Definition: Camera.hh:974
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
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:1048
A class for event processing.
Definition: Event.hh:186
Ogre::AnimationState * animState
Animation state, used to animate the camera.
Definition: Camera.hh:1060
An angle and related functions.
Definition: Angle.hh:53
A Time class, can be used to hold wall- or sim-time.
Definition: Time.hh:44
Ogre::Camera * camera
The OGRE camera.
Definition: Camera.hh:995