##

UserCamera.hh
Go to the documentation of this file.
/*
* Copyright (C) 2012 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
#ifndef GAZEBO_RENDERING_USERCAMERA_HH_
#define GAZEBO_RENDERING_USERCAMERA_HH_
#include <string>
#include <vector>
#include <ignition/math/Pose3.hh>
#include <ignition/math/Vector2.hh>
#include "gazebo/rendering/Camera.hh"
#include "gazebo/rendering/RenderTypes.hh"
#include "gazebo/util/system.hh"
namespace gazebo
{
namespace common
{
class MouseEvent;
}
// Forward declare private data
class UserCameraPrivate;
namespace rendering
{
class GZ_RENDERING_VISIBLE UserCamera : public Camera
{
public: UserCamera(const std::string &_name, ScenePtr _scene,
bool _stereoEnabled = false);
public: virtual ~UserCamera();
public: void Load(sdf::ElementPtr _sdf);
// Documentation inherited
public: virtual void SetClipDist(const float _near, const float _far);
using Camera::SetClipDist;
public: void Load();
public: void Init();
public: virtual void Update();
public: virtual void Render(const bool _force = false);
using Camera::Render;
public: virtual void PostRender();
public: void Fini();
// Documentation inherited.
public: virtual void SetWorldPose(const ignition::math::Pose3d &_pose);
public: void SetInitialPose(const ignition::math::Pose3d &_pose);
public: ignition::math::Pose3d InitialPose() const;
public: void HandleMouseEvent(const common::MouseEvent &_evt);
public: void HandleKeyPressEvent(const std::string &_key);
public: void HandleKeyReleaseEvent(const std::string &_key);
public: void SetViewController(const std::string &_type);
public: void SetViewController(const std::string &_type,
const ignition::math::Vector3d &_pos);
public: std::string GetViewControllerTypeString();
public: void Resize(unsigned int _w, unsigned int _h);
public: void SetViewportDimensions(float _x, float _y,
float _w, float _h);
public: void MoveToVisual(VisualPtr _visual);
public: void MoveToVisual(const std::string &_visualName);
public: void SetDevicePixelRatio(const double _ratio);
public: double DevicePixelRatio() const;
// Documentation Inherited
public: virtual void CameraToViewportRay(const int _screenx,
const int _screeny,
ignition::math::Vector3d &_origin,
ignition::math::Vector3d &_dir) const;
public: virtual void SetRenderTarget(Ogre::RenderTarget *_target);
public: void EnableViewController(bool _value) const;
public: VisualPtr Visual(const ignition::math::Vector2i &_mousePos,
std::string &_mod) const;
public: VisualPtr Visual(
const ignition::math::Vector2i &_mousePos) const;
public: void SetFocalPoint(const ignition::math::Vector3d &_pt);
// Documentation inherited
public: virtual unsigned int GetImageWidth() const;
// Documentation inherited
public: virtual unsigned int GetImageHeight() const;
public: bool IsCameraSetInWorldFile();
public: void SetUseSDFPose(bool _value);
public: void SetJoyTwistControl(bool _value);
public: void SetJoyPoseControl(bool _value);
public: bool StereoEnabled() const;
public: void EnableStereo(bool _enable);
// Documentation inherited.
public: virtual bool SetProjectionType(const std::string &_type);
// Documentation inherited.
public: virtual ignition::math::Vector2i Project(
const ignition::math::Vector3d &_pt) const;
protected: virtual bool AttachToVisualImpl(VisualPtr _visual,
const bool _inheritOrientation, const double _minDist = 0,
const double _maxDist = 0);
using Camera::AttachToVisualImpl;
// Documentation inherited.
protected: virtual void AnimationComplete();
protected: virtual bool TrackVisualImpl(VisualPtr _visual);
// Documentation inherited.
protected: virtual void UpdateFOV();
private: void ToggleShowVisual();
private: void ShowVisual(bool _show);
private: void OnMoveToVisualComplete();
private: void OnJoyTwist(ConstJoystickPtr &_msg);
private: void OnJoyPose(ConstPosePtr &_msg);
private: UserCameraPrivate *dataPtr;
};
}
}
#endif
gazebo::rendering::UserCamera::EnableViewController
void EnableViewController(bool _value) const
Set whether the view controller is enabled.
gazebo::rendering::UserCamera::HandleKeyReleaseEvent
void HandleKeyReleaseEvent(const std::string &_key)
Handle a key release.
gazebo::rendering::UserCamera::GetImageWidth
virtual unsigned int GetImageWidth() const
gazebo::rendering::UserCamera::SetInitialPose
void SetInitialPose(const ignition::math::Pose3d &_pose)
Set the initial pose in the world coordinate frame and set that as the current camera world pose.
gazebo
Forward declarations for the common classes.
Definition: Animation.hh:26
gazebo::rendering::UserCamera::SetFocalPoint
void SetFocalPoint(const ignition::math::Vector3d &_pt)
Set the point the camera should orbit around.
gazebo::rendering::UserCamera::AttachToVisualImpl
virtual bool AttachToVisualImpl(VisualPtr _visual, const bool _inheritOrientation, const double _minDist=0, const double _maxDist=0)
Set the camera to be attached to a visual.
gazebo::rendering::UserCamera::Init
void Init()
Initialize.
gazebo::rendering::UserCamera::Resize
void Resize(unsigned int _w, unsigned int _h)
Resize the camera.
gazebo::rendering::UserCamera::HandleMouseEvent
void HandleMouseEvent(const common::MouseEvent &_evt)
Handle a mouse event.
common
common
Definition: FuelModelDatabase.hh:37
gazebo::rendering::UserCamera::Visual
VisualPtr Visual(const ignition::math::Vector2i &_mousePos, std::string &_mod) const
Get an entity at a pixel location using a camera.
system.hh
gazebo::rendering::UserCamera::PostRender
virtual void PostRender()
Post render.
gazebo::rendering::UserCamera::~UserCamera
virtual ~UserCamera()
Destructor.
Camera.hh
gazebo::rendering::UserCamera::Load
void Load()
Generic load function.
gazebo::rendering::UserCamera
A camera used for user visualization of a scene.
Definition: UserCamera.hh:46
gazebo::rendering::UserCamera::SetViewportDimensions
void SetViewportDimensions(float _x, float _y, float _w, float _h)
Set the dimensions of the viewport.
gazebo::rendering::UserCamera::SetJoyPoseControl
void SetJoyPoseControl(bool _value)
brief Enable or disable camera control through ~/user_camera/joy_pose gz topic.
gazebo::rendering::UserCamera::HandleKeyPressEvent
void HandleKeyPressEvent(const std::string &_key)
Handle a key press.
gazebo::rendering::ScenePtr
boost::shared_ptr< Scene > ScenePtr
Definition: RenderTypes.hh:82
gazebo::rendering::UserCamera::SetJoyTwistControl
void SetJoyTwistControl(bool _value)
brief Enable or disable camera control through ~/user_camera/joy_twist gz topic.
RenderTypes.hh
gazebo::rendering::UserCamera::UpdateFOV
virtual void UpdateFOV()
Update the camera's field of view.
gazebo::rendering::Camera::AttachToVisualImpl
virtual bool AttachToVisualImpl(const std::string &_name, const bool _inheritOrientation, const double _minDist=0, const double _maxDist=0)
Attach the camera to a scene node.
rendering
rendering
Definition: RenderEngine.hh:31
gazebo::rendering::UserCamera::SetProjectionType
virtual bool SetProjectionType(const std::string &_type)
Set the type of projection used by the camera.
gazebo::rendering::Visual
A renderable object.
Definition: Visual.hh:60
gazebo::rendering::UserCamera::Render
virtual void Render(const bool _force=false)
Render the camera.
gazebo::rendering::UserCamera::GetImageHeight
virtual unsigned int GetImageHeight() const
gazebo::rendering::UserCamera::SetViewController
void SetViewController(const std::string &_type)
Set view controller.
gazebo::rendering::UserCamera::Update
virtual void Update()
Render the camera.
gazebo::rendering::UserCamera::CameraToViewportRay
virtual void CameraToViewportRay(const int _screenx, const int _screeny, ignition::math::Vector3d &_origin, ignition::math::Vector3d &_dir) const
Get a world space ray as cast from the camera through the viewport.
gazebo::rendering::UserCamera::IsCameraSetInWorldFile
bool IsCameraSetInWorldFile()
brief Show if the user camera pose has changed in the world file.
gazebo::rendering::UserCamera::StereoEnabled
bool StereoEnabled() const
Get whether stereo is enabled.
gazebo::rendering::UserCamera::MoveToVisual
void MoveToVisual(VisualPtr _visual)
Move the camera to focus on a visual.
gazebo::msgs::Init
GAZEBO_VISIBLE void Init(google::protobuf::Message &_message, const std::string &_id="")
Initialize a message.
gazebo::rendering::Camera::Render
virtual void Render(const bool _force=false)
Render the camera.
gazebo::rendering::Camera::SetClipDist
virtual void SetClipDist()
Set the clip distance based on stored SDF values.
gazebo::rendering::UserCamera::Fini
void Fini()
Finialize.
gazebo::rendering::UserCamera::EnableStereo
void EnableStereo(bool _enable)
Turn on/off stereo rendering.
gazebo::rendering::UserCamera::TrackVisualImpl
virtual bool TrackVisualImpl(VisualPtr _visual)
Set the camera to track a scene node.
gazebo::rendering::UserCamera::SetRenderTarget
virtual void SetRenderTarget(Ogre::RenderTarget *_target)
Set to true to enable rendering.
gazebo::rendering::VisualPtr
std::shared_ptr< Visual > VisualPtr
Definition: RenderTypes.hh:114
gazebo::rendering::UserCamera::Project
virtual ignition::math::Vector2i Project(const ignition::math::Vector3d &_pt) const
Project 3D world coordinates to 2D screen coordinates.
gazebo::rendering::Camera
Basic camera sensor.
Definition: Camera.hh:84
gazebo::rendering::UserCamera::AnimationComplete
virtual void AnimationComplete()
Internal function used to indicate that an animation has completed.
gazebo::rendering::UserCamera::SetDevicePixelRatio
void SetDevicePixelRatio(const double _ratio)
Set the screen point to device pixel ratio.
gazebo::rendering::UserCamera::GetViewControllerTypeString
std::string GetViewControllerTypeString()
Get current view controller type.
gazebo::rendering::UserCamera::InitialPose
ignition::math::Pose3d InitialPose() const
Get the initial pose in the world coordinate frame.
gazebo::rendering::UserCamera::SetUseSDFPose
void SetUseSDFPose(bool _value)
brief Set if the user camera pose has changed in the world file.
gazebo::common::MouseEvent
Generic description of a mouse event.
Definition: MouseEvent.hh:35
gazebo::rendering::UserCamera::SetWorldPose
virtual void SetWorldPose(const ignition::math::Pose3d &_pose)
Set the global pose of the camera.
gazebo::rendering::UserCamera::DevicePixelRatio
double DevicePixelRatio() const
Get the screen point to device pixel ratio.
gazebo::rendering::UserCamera::UserCamera
UserCamera(const std::string &_name, ScenePtr _scene, bool _stereoEnabled=false)
Constructor.