All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | List of all members
gazebo::rendering::UserCamera Class Reference

A camera used for user visualization of a scene. More...

#include <rendering/rendering.hh>

Inheritance diagram for gazebo::rendering::UserCamera:
Inheritance graph
[legend]

Public Member Functions

 UserCamera (const std::string &_name, Scene *_scene)
 Constructor.
 
virtual ~UserCamera ()
 Destructor.
 
void EnableViewController (bool _value) const
 Set whether the view controller is enabled.
 
void Fini ()
 Finialize.
 
float GetAvgFPS () const
 Get the average frames per second.
 
GUIOverlayGetGUIOverlay ()
 Get the GUI overlay.
 
float GetTriangleCount () const
 Get the triangle count.
 
VisualPtr GetVisual (const math::Vector2i &mousePos, std::string &mod)
 Get an entity at a pixel location using a camera.
 
VisualPtr GetVisual (const math::Vector2i &_mousePos) const
 Get a visual at a mouse position.
 
void HandleKeyPressEvent (const std::string &_key)
 Handle a key press.
 
void HandleKeyReleaseEvent (const std::string &_key)
 Handle a key release.
 
void HandleMouseEvent (const common::MouseEvent &_evt)
 Handle a mouse event.
 
void Init ()
 Initialize.
 
void Load (sdf::ElementPtr _sdf)
 Load the user camera.
 
void Load ()
 Generic load function.
 
virtual bool MoveToPosition (const math::Pose &_pose, double _time)
 Move the camera to a position.
 
void MoveToVisual (VisualPtr _visual)
 Move the camera to focus on a visual.
 
void MoveToVisual (const std::string &_visualName)
 Move the camera to focus on a visual.
 
virtual void PostRender ()
 Post render.
 
void Resize (unsigned int _w, unsigned int _h)
 Resize the camera.
 
void SetFocalPoint (const math::Vector3 &_pt)
 Set the point the camera should orbit around.
 
virtual void SetRenderTarget (Ogre::RenderTarget *_target)
 Set to true to enable rendering.
 
void SetViewController (const std::string &_type)
 Set view controller.
 
void SetViewController (const std::string &_type, const math::Vector3 &_pos)
 Set view controller.
 
void SetViewportDimensions (float _x, float _y, float _w, float _h)
 Set the dimensions of the viewport.
 
virtual void SetWorldPose (const math::Pose &_pose)
 Set the pose in the world coordinate frame.
 
virtual void Update ()
 Render the camera.
 
- Public Member Functions inherited from gazebo::rendering::Camera
 Camera (const std::string &_namePrefix, Scene *_scene, bool _autoRender=true)
 Constructor.
 
virtual ~Camera ()
 Destructor.
 
void AttachToVisual (const std::string &_visualName, bool _inheritOrientation, double _minDist=0.0, double _maxDist=0.0)
 Attach the camera to a scene node.
 
template<typename T >
event::ConnectionPtr ConnectNewImageFrame (T _subscriber)
 Connect a to the new image signal.
 
void CreateRenderTexture (const std::string &_textureName)
 Set the render target.
 
void DisconnectNewImageFrame (event::ConnectionPtr &_c)
 Disconnect from an image frame.
 
void EnableSaveFrame (bool _enable)
 Enable or disable saving.
 
void Fini ()
 Finalize the camera.
 
float GetAspectRatio () const
 Get the apect ratio.
 
virtual float GetAvgFPS ()
 Get the average FPS.
 
void GetCameraToViewportRay (int _screenx, int _screeny, math::Vector3 &_origin, math::Vector3 &_dir)
 Get a world space ray as cast from the camera through the viewport.
 
math::Vector3 GetDirection () const
 Get the camera's direction vector.
 
double GetFarClip ()
 Get the far clip distance.
 
math::Angle GetHFOV () const
 Get the camera FOV (horizontal)
 
size_t GetImageByteSize () const
 Get the image size in bytes.
 
virtual const unsigned char * GetImageData (unsigned int i=0)
 Get a pointer to the image data.
 
unsigned int GetImageDepth () const
 Get the depth of the image.
 
std::string GetImageFormat () const
 Get the height of the image.
 
unsigned int GetImageHeight () const
 Get the height of the image.
 
unsigned int GetImageWidth () const
 Get the width of the image.
 
bool GetInitialized () const
 Returns true if initialized.
 
common::Time GetLastRenderWallTime ()
 Get the last time the camera was rendered.
 
std::string GetName () const
 Get the camera's name.
 
double GetNearClip ()
 Get the near clip distance.
 
Ogre::Camera * GetOgreCamera () const
 Get a pointer to the ogre camera.
 
Ogre::Texture * GetRenderTexture () const
 Get the render texture.
 
math::Vector3 GetRight ()
 Get the viewport right vector.
 
SceneGetScene () const
 Get the scene this camera is in.
 
Ogre::SceneNode * GetSceneNode () const
 Get the camera's scene node.
 
unsigned int GetTextureHeight () const
 Get the height of the off-screen render texture.
 
unsigned int GetTextureWidth () const
 Get the width of the off-screen render texture.
 
virtual unsigned int GetTriangleCount ()
 Get the triangle count.
 
math::Vector3 GetUp ()
 Get the viewport up vector.
 
math::Angle GetVFOV () const
 Get the camera FOV (vertical)
 
Ogre::Viewport * GetViewport () const
 Get a pointer to the Ogre::Viewport.
 
unsigned int GetViewportHeight () const
 Get the viewport height in pixels.
 
unsigned int GetViewportWidth () const
 Get the viewport width in pixels.
 
unsigned int GetWindowId () const
 Get the ID of the window this camera is rendering into.
 
bool GetWorldPointOnPlane (int _x, int _y, const math::Plane &_plane, math::Vector3 &_result)
 Get point on a plane.
 
math::Pose GetWorldPose ()
 Get the global pose of the camera.
 
math::Vector3 GetWorldPosition () const
 Get the camera position in the world.
 
math::Quaternion GetWorldRotation () const
 Get the camera's orientation in the world.
 
double GetZValue (int _x, int _y)
 Get the Z-buffer value at the given image coordinate.
 
void Init ()
 Initialize the camera.
 
bool IsInitialized () const
 Return true if the camera has been initialized.
 
bool IsVisible (VisualPtr _visual)
 Return true if the visual is within the camera's view frustum.
 
bool IsVisible (const std::string &_visualName)
 Return true if the visual is within the camera's view frustum.
 
void Load (sdf::ElementPtr _sdf)
 Load the camera with a set of parmeters.
 
void Load ()
 Load the camera with default parmeters.
 
bool MoveToPositions (const std::vector< math::Pose > &_pts, double _time, boost::function< void()> _onComplete=NULL)
 Move the camera to a series of positions.
 
void Render ()
 Render the camera.
 
void RotatePitch (math::Angle _angle)
 Rotate the camera around the pitch axis.
 
void RotateYaw (math::Angle _angle)
 Rotate the camera around the yaw axis.
 
bool SaveFrame (const std::string &_filename)
 Save the last frame to disk.
 
void SetAspectRatio (float _ratio)
 Set the aspect ratio.
 
void SetCaptureData (bool _value)
 Set whether to capture data.
 
void SetClipDist (float _near, float _far)
 Set the clip distances.
 
void SetHFOV (math::Angle _angle)
 Set the camera FOV (horizontal)
 
void SetImageHeight (unsigned int _h)
 Set the image height.
 
void SetImageSize (unsigned int _w, unsigned int _h)
 Set the image size.
 
void SetImageWidth (unsigned int _w)
 Set the image height.
 
void SetName (const std::string &_name)
 Set the camera's name.
 
void SetRenderRate (double _hz)
 Set the render Hz rate.
 
void SetSaveFramePathname (const std::string &_pathname)
 Set the save frame pathname.
 
void SetScene (Scene *_scene)
 Set the scene this camera is viewing.
 
void SetSceneNode (Ogre::SceneNode *_node)
 Set the camera's scene node.
 
void SetWindowId (unsigned int _windowId)
 
void SetWorldPosition (const math::Vector3 &_pos)
 Set the world position.
 
void SetWorldRotation (const math::Quaternion &_quat)
 Set the world orientation.
 
void ShowWireframe (bool _s)
 Set whether to view the world in wireframe.
 
void ToggleShowWireframe ()
 Toggle whether to view the world in wireframe.
 
void TrackVisual (const std::string &_visualName)
 Set the camera to track a scene node.
 
void Translate (const math::Vector3 &_direction)
 Translate the camera.
 

Protected Member Functions

virtual bool AttachToVisualImpl (VisualPtr _visual, bool _inheritOrientation, double _minDist=0, double _maxDist=0)
 Set the camera to be attached to a visual.
 
virtual bool TrackVisualImpl (VisualPtr _visual)
 Set the camera to track a scene node.
 
- Protected Member Functions inherited from gazebo::rendering::Camera
virtual bool AttachToVisualImpl (const std::string &_name, bool _inheritOrientation, double _minDist=0, double _maxDist=0)
 Attach the camera to a scene node.
 
std::string GetFrameFilename ()
 Get the next frame filename based on SDF parameters.
 
virtual void RenderImpl ()
 Implementation of the render call.
 
bool TrackVisualImpl (const std::string &_visualName)
 Implementation of the Camera::TrackVisual call.
 

Additional Inherited Members

- Static Public Member Functions inherited from gazebo::rendering::Camera
static size_t GetImageByteSize (unsigned int _width, unsigned int _height, const std::string &_format)
 Calculate image byte size base on a few parameters.
 
static bool SaveFrame (const unsigned char *_image, unsigned int _width, unsigned int _height, int _depth, const std::string &_format, const std::string &_filename)
 Save a frame using an image buffer.
 
- Protected Attributes inherited from gazebo::rendering::Camera
Ogre::AnimationState * animState
 
unsigned char * bayerFrameBuffer
 
Ogre::Camera * camera
 
bool captureData
 
std::vector< event::ConnectionPtrconnections
 
int imageFormat
 
int imageHeight
 
int imageWidth
 
bool initialized
 
common::Time lastRenderWallTime
 
std::string name
 
bool newData
 
event::EventT< void(const
unsigned char *, unsigned int,
unsigned int, unsigned int,
const std::string &)> 
newImageFrame
 
boost::function< void()> onAnimationComplete
 
Ogre::SceneNode * pitchNode
 
common::Time prevAnimTime
 
Ogre::RenderTarget * renderTarget
 
Ogre::Texture * renderTexture
 
std::list< msgs::Request > requests
 
unsigned int saveCount
 
unsigned char * saveFrameBuffer
 
Scenescene
 
Ogre::SceneNode * sceneNode
 
sdf::ElementPtr sdf
 
unsigned int textureHeight
 
unsigned int textureWidth
 
Ogre::Viewport * viewport
 
unsigned int windowId
 

Detailed Description

A camera used for user visualization of a scene.

Constructor & Destructor Documentation

gazebo::rendering::UserCamera::UserCamera ( const std::string &  _name,
Scene _scene 
)

Constructor.

Parameters
[in]_nameName of the camera.
[in]_sceneScene to put the camera in.
virtual gazebo::rendering::UserCamera::~UserCamera ( )
virtual

Destructor.

Member Function Documentation

virtual bool gazebo::rendering::UserCamera::AttachToVisualImpl ( VisualPtr  _visual,
bool  _inheritOrientation,
double  _minDist = 0,
double  _maxDist = 0 
)
protectedvirtual

Set the camera to be attached to a visual.

This causes the camera to move in relation to the specified visual.

Parameters
[in]_visualThe visual to attach to.
[in]_inheritOrientationTrue if the camera should also rotate when the visual rotates.
[in]_minDistMinimum distance the camera can get to the visual.
[in]_maxDistMaximum distance the camera can get from the visual.
Returns
True if successfully attach to the visual.

Reimplemented from gazebo::rendering::Camera.

void gazebo::rendering::UserCamera::EnableViewController ( bool  _value) const

Set whether the view controller is enabled.

The view controller is used to handle user camera movements.

Parameters
[in]_valueTrue to enable viewcontroller, False to disable.
void gazebo::rendering::UserCamera::Fini ( )

Finialize.

float gazebo::rendering::UserCamera::GetAvgFPS ( ) const

Get the average frames per second.

Returns
The average rendering frames per second
GUIOverlay* gazebo::rendering::UserCamera::GetGUIOverlay ( )

Get the GUI overlay.

An overlay allows you to draw 2D elements on the viewport.

Returns
Pointer to the GUIOverlay.
float gazebo::rendering::UserCamera::GetTriangleCount ( ) const

Get the triangle count.

Returns
The number of triangles currently being rendered.
VisualPtr gazebo::rendering::UserCamera::GetVisual ( const math::Vector2i mousePos,
std::string &  mod 
)

Get an entity at a pixel location using a camera.

Used for mouse picking.

Parameters
[in]_mousePosThe position of the mouse in screen coordinates
[out]_modUsed for object manipulation
Returns
The selected entity, or NULL
VisualPtr gazebo::rendering::UserCamera::GetVisual ( const math::Vector2i _mousePos) const

Get a visual at a mouse position.

Parameters
[in]_mousePos2D position of the mouse in pixels.
void gazebo::rendering::UserCamera::HandleKeyPressEvent ( const std::string &  _key)

Handle a key press.

Parameters
[in]_keyThe key pressed.
void gazebo::rendering::UserCamera::HandleKeyReleaseEvent ( const std::string &  _key)

Handle a key release.

Parameters
[in]_keyThe key released.
void gazebo::rendering::UserCamera::HandleMouseEvent ( const common::MouseEvent _evt)

Handle a mouse event.

Parameters
[in]_evtThe mouse event.
void gazebo::rendering::UserCamera::Init ( )

Initialize.

void gazebo::rendering::UserCamera::Load ( sdf::ElementPtr  _sdf)

Load the user camera.

Parameters
[in]_sdfParameters for the camera.
void gazebo::rendering::UserCamera::Load ( )

Generic load function.

virtual bool gazebo::rendering::UserCamera::MoveToPosition ( const math::Pose _pose,
double  _time 
)
virtual

Move the camera to a position.

This is an animated motion

Parameters
[in]_poseEnd position of the camera
[in]_timeDuration of the camera's movement

Reimplemented from gazebo::rendering::Camera.

void gazebo::rendering::UserCamera::MoveToVisual ( VisualPtr  _visual)

Move the camera to focus on a visual.

Parameters
[in]_visualVisual to move the camera to.
void gazebo::rendering::UserCamera::MoveToVisual ( const std::string &  _visualName)

Move the camera to focus on a visual.

Parameters
[in]_visualNameName of the visual to move the camera to.
virtual void gazebo::rendering::UserCamera::PostRender ( )
virtual

Post render.

Reimplemented from gazebo::rendering::Camera.

void gazebo::rendering::UserCamera::Resize ( unsigned int  _w,
unsigned int  _h 
)

Resize the camera.

Parameters
[in]_wWidth of the camera image.
[in]_hHeight of the camera image.
void gazebo::rendering::UserCamera::SetFocalPoint ( const math::Vector3 _pt)

Set the point the camera should orbit around.

Parameters
[in]_ptThe focal point
virtual void gazebo::rendering::UserCamera::SetRenderTarget ( Ogre::RenderTarget *  _target)
virtual

Set to true to enable rendering.

Use this only if you really know what you're doing.

Parameters
[in]_targetThe new rendering target.

Reimplemented from gazebo::rendering::Camera.

void gazebo::rendering::UserCamera::SetViewController ( const std::string &  _type)

Set view controller.

Parameters
[in]_typeThe type of view controller: "orbit", "fps"
void gazebo::rendering::UserCamera::SetViewController ( const std::string &  _type,
const math::Vector3 _pos 
)

Set view controller.

Parameters
[in]_typeThe type of view controller: "orbit", "fps"
[in]_posThe initial pose of the camera.
void gazebo::rendering::UserCamera::SetViewportDimensions ( float  _x,
float  _y,
float  _w,
float  _h 
)

Set the dimensions of the viewport.

Parameters
[in]_xX position of the viewport.
[in]_yY position of the viewport.
[in]_wWidth of the viewport.
[in]_hHeight of the viewport.
virtual void gazebo::rendering::UserCamera::SetWorldPose ( const math::Pose _pose)
virtual

Set the pose in the world coordinate frame.

Parameters
[in]_poseNew pose of the camera.

Reimplemented from gazebo::rendering::Camera.

virtual bool gazebo::rendering::UserCamera::TrackVisualImpl ( VisualPtr  _visual)
protectedvirtual

Set the camera to track a scene node.

Tracking just causes the camera to rotate to follow the visual.

Parameters
[in]_visualVisual to track.
Returns
True if the camera is now tracking the visual.

Reimplemented from gazebo::rendering::Camera.

virtual void gazebo::rendering::UserCamera::Update ( )
virtual

Render the camera.

Reimplemented from gazebo::rendering::Camera.


The documentation for this class was generated from the following file: