32 #ifndef RVIZ_ANIMATED_VIEW_CONTROLLER_H 33 #define RVIZ_ANIMATED_VIEW_CONTROLLER_H 35 #include <boost/circular_buffer.hpp> 48 #include <geometry_msgs/Pose.h> 50 #include <std_msgs/Bool.h> 51 #include <std_msgs/Duration.h> 53 #include <view_controller_msgs/CameraMovement.h> 54 #include <view_controller_msgs/CameraPlacement.h> 55 #include <view_controller_msgs/CameraTrajectory.h> 57 #include <OGRE/OgreRenderWindow.h> 58 #include <OGRE/OgreVector3.h> 59 #include <OGRE/OgreQuaternion.h> 67 class QuaternionProperty;
68 class TfFrameProperty;
69 class EditableEnumProperty;
70 class RosTopicProperty;
82 enum { TRANSITION_LINEAR = 0,
83 TRANSITION_SPHERICAL};
90 const Ogre::Vector3& focus,
91 const Ogre::Vector3& up,
93 const uint8_t interpolation_speed)
97 , transition_duration(transition_duration)
98 , interpolation_speed(interpolation_speed)
115 void initializePublishers();
116 void initializeSubscribers();
122 virtual void onInitialize();
127 virtual void onActivate();
131 void move_focus_and_eye(
float x,
float y,
float z );
134 void move_eye(
float x,
float y,
float z );
139 void yaw_pitch_roll(
float yaw,
float pitch,
float roll );
145 void publishCameraPose();
149 virtual void lookAt(
const Ogre::Vector3& point );
153 void orbitCameraTo(
const Ogre::Vector3& point);
156 void moveEyeWithFocusTo(
const Ogre::Vector3& point);
159 virtual void reset();
184 virtual void updateAttachedFrame();
187 virtual void onDistancePropertyChanged();
190 virtual void onFocusPropertyChanged();
193 virtual void onEyePropertyChanged();
196 virtual void onUpPropertyChanged();
199 void updateWindowSizeProperties();
203 virtual void update(
float dt,
float ros_dt);
210 void pauseAnimationOnRequest();
224 double computeRelativeProgressInTime(
const ros::Duration& transition_duration);
247 float computeRelativeProgressInSpace(
double relative_progress_in_time,
248 uint8_t interpolation_speed);
251 void publishViewImage();
254 void getViewImage(std::shared_ptr<Ogre::PixelBox>& pixel_box);
256 void convertImage(std::shared_ptr<Ogre::PixelBox> input_image,
257 sensor_msgs::ImagePtr output_image);
260 void prepareNextMovement(
const ros::Duration& previous_transition_duration);
263 void connectPositionProperties();
266 void disconnectPositionProperties();
271 virtual void onAttachedFrameChanged(
const Ogre::Vector3& old_reference_position,
const Ogre::Quaternion& old_reference_orientation );
275 void updateAttachedSceneNode();
277 void cameraPlacementCallback(
const view_controller_msgs::CameraPlacementConstPtr &cp_ptr);
283 void cameraTrajectoryCallback(
const view_controller_msgs::CameraTrajectoryConstPtr& ct_ptr);
289 void pauseAnimationCallback(
const std_msgs::Duration::ConstPtr& pause_duration_msg);
297 void transformCameraToAttachedFrame(geometry_msgs::PointStamped& eye,
298 geometry_msgs::PointStamped& focus,
299 geometry_msgs::Vector3Stamped& up);
303 void setPropertiesFromCamera( Ogre::Camera* source_camera );
313 void beginNewTransition(
const Ogre::Vector3& eye,
314 const Ogre::Vector3& focus,
315 const Ogre::Vector3& up,
317 uint8_t interpolation_speed = view_controller_msgs::CameraMovement::WAVE);
320 void cancelTransition();
328 float getDistanceFromCameraToFocalPoint();
330 Ogre::Quaternion getOrientation();
391 #endif // RVIZ_ANIMATED_VIEW_CONTROLLER_H Ogre::Quaternion reference_orientation_
Used to store the orientation of the attached frame relative to <Fixed frame>=""> ...
Ogre::Vector3 reference_position_
Used to store the position of the attached frame relative to <Fixed frame>="">
ros::Duration transition_duration
rviz::TfFrameProperty * attached_frame_property_
rviz::BoolProperty * mouse_enabled_property_
If True, most user changes to camera state are disabled.
rviz::FloatProperty * distance_property_
The camera's distance from the focal point.
ros::Subscriber trajectory_subscriber_
int rendered_frames_counter_
bool isMovementAvailable()
Returns true if buffer contains at least one start and end pose needed for one movement.
OgreCameraMovement(const Ogre::Vector3 &eye, const Ogre::Vector3 &focus, const Ogre::Vector3 &up, const ros::Duration &transition_duration, const uint8_t interpolation_speed)
rviz::FloatProperty * window_width_property_
The width of the rviz visualization window in pixels.
rviz::BoolProperty * fixed_up_property_
If True, "up" is fixed to ... up.
uint8_t interpolation_speed
Ogre::Vector3 attachedLocalToFixedFrame(const Ogre::Vector3 &v)
Ogre::Vector3 fixedFrameToAttachedLocal(const Ogre::Vector3 &v)
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
bool dragging_
A flag indicating the dragging state of the mouse.
rviz::BoolProperty * publish_view_images_property_
If True, the camera view is published as images.
ros::WallTime transition_start_time_
ros::Publisher current_camera_pose_publisher_
rviz::RosTopicProperty * camera_placement_topic_property_
rviz::FloatProperty * window_height_property_
The height of the rviz visualization window in pixels.
ros::Subscriber placement_subscriber_
bool render_frame_by_frame_
rviz::EditableEnumProperty * interaction_mode_property_
Select between Orbit or FPS control style.
ros::Subscriber pause_animation_duration_subscriber_
QCursor interaction_disabled_cursor_
A cursor for indicating mouse interaction is disabled.
rviz::FloatProperty * default_transition_time_property_
A default time for any animation requests.
BufferCamMovements cam_movements_buffer_
rviz::VectorProperty * eye_point_property_
The position of the camera.
rviz::Shape * focal_shape_
A small ellipsoid to show the focus point.
rviz::VectorProperty * up_vector_property_
The up vector for the camera.
ros::Publisher finished_animation_publisher_
boost::circular_buffer< OgreCameraMovement > BufferCamMovements
rviz::RosTopicProperty * camera_trajectory_topic_property_
image_transport::Publisher camera_view_image_publisher_
An un-constrained "flying" camera, specified by an eye point, focus point, and up vector...
ros::WallDuration pause_animation_duration_
rviz::VectorProperty * focus_point_property_
The point around which the camera "orbits".
Ogre::SceneNode * attached_scene_node_