rviz_animated_view_controller.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009, Willow Garage, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Willow Garage, Inc. nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 
32 
33 #include "rviz/load_resource.h"
35 #include "rviz/display_context.h"
37 #include "rviz/frame_manager.h"
38 #include "rviz/geometry.h"
39 #include "rviz/view_manager.h"
40 #include "rviz/render_panel.h"
48 
49 #include "view_controller_msgs/CameraPlacement.h"
50 
51 #include <OGRE/OgreViewport.h>
52 #include <OGRE/OgreQuaternion.h>
53 #include <OGRE/OgreVector3.h>
54 #include <OGRE/OgreSceneNode.h>
55 #include <OGRE/OgreSceneManager.h>
56 #include <OGRE/OgreCamera.h>
57 #include <OGRE/OgreRenderWindow.h>
58 
60 {
61 using namespace view_controller_msgs;
62 using namespace rviz;
63 
64 // Strings for selecting control mode styles
65 static const std::string MODE_ORBIT = "Orbit";
66 static const std::string MODE_FPS = "FPS";
67 
68 // Limits to prevent orbit controller singularity, but not currently used.
69 //static const Ogre::Radian PITCH_LIMIT_LOW = Ogre::Radian(-Ogre::Math::HALF_PI + 0.02);
70 //static const Ogre::Radian PITCH_LIMIT_HIGH = Ogre::Radian( Ogre::Math::HALF_PI - 0.02);
71 static const Ogre::Radian PITCH_LIMIT_LOW = Ogre::Radian( 0.02 );
72 static const Ogre::Radian PITCH_LIMIT_HIGH = Ogre::Radian( Ogre::Math::PI - 0.02);
73 
74 
75 // Some convenience functions for Ogre / geometry_msgs conversions
76 static inline Ogre::Vector3 vectorFromMsg(const geometry_msgs::Point &m) { return Ogre::Vector3(m.x, m.y, m.z); }
77 static inline Ogre::Vector3 vectorFromMsg(const geometry_msgs::Vector3 &m) { return Ogre::Vector3(m.x, m.y, m.z); }
78 static inline geometry_msgs::Point pointOgreToMsg(const Ogre::Vector3 &o)
79 {
80  geometry_msgs::Point m;
81  m.x = o.x; m.y = o.y; m.z = o.z;
82  return m;
83 }
84 static inline void pointOgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Point &m) { m.x = o.x; m.y = o.y; m.z = o.z; }
85 
86 static inline geometry_msgs::Vector3 vectorOgreToMsg(const Ogre::Vector3 &o)
87 {
88  geometry_msgs::Vector3 m;
89  m.x = o.x; m.y = o.y; m.z = o.z;
90  return m;
91 }
92 static inline void vectorOgreToMsg(const Ogre::Vector3 &o, geometry_msgs::Vector3 &m) { m.x = o.x; m.y = o.y; m.z = o.z; }
93 
94 // -----------------------------------------------------------------------------
95 
96 
98  : nh_("")
99  , cam_movements_buffer_(100)
100  , animate_(false)
101  , dragging_(false)
102  , render_frame_by_frame_(false)
103  , target_fps_(60)
104  , rendered_frames_counter_(0)
105  , pause_animation_duration_(0.0)
106 {
107  interaction_disabled_cursor_ = makeIconCursor( "package://rviz/icons/forbidden.svg" );
108 
109  mouse_enabled_property_ = new BoolProperty("Mouse Enabled", true,
110  "Enables mouse control of the camera.",
111  this);
112  interaction_mode_property_ = new EditableEnumProperty("Control Mode", QString::fromStdString(MODE_ORBIT),
113  "Select the style of mouse interaction.",
114  this);
118 
119  fixed_up_property_ = new BoolProperty( "Maintain Vertical Axis", true,
120  "If enabled, the camera is not allowed to roll side-to-side.",
121  this);
122  attached_frame_property_ = new TfFrameProperty("Target Frame",
124  "TF frame the camera is attached to.",
125  this, NULL, true );
126  eye_point_property_ = new VectorProperty( "Eye", Ogre::Vector3( 5, 5, 10 ),
127  "Position of the camera.", this );
128  focus_point_property_ = new VectorProperty( "Focus", Ogre::Vector3::ZERO,
129  "Position of the focus/orbit point.", this );
130  up_vector_property_ = new VectorProperty( "Up", Ogre::Vector3::UNIT_Z,
131  "The vector which maps to \"up\" in the camera image plane.", this );
133  "The distance between the camera position and the focus point.",
134  this );
135  distance_property_->setMin( 0.01 );
136  default_transition_time_property_ = new FloatProperty( "Transition Time", 0.5,
137  "The default time to use for camera transitions.",
138  this );
139  camera_placement_topic_property_ = new RosTopicProperty("Placement Topic", "/rviz/camera_placement",
140  QString::fromStdString(ros::message_traits::datatype<view_controller_msgs::CameraPlacement>() ),
141  "Topic for CameraPlacement messages", this, SLOT(updateTopics()));
142 
143  camera_trajectory_topic_property_ = new RosTopicProperty("Trajectory Topic", "/rviz/camera_trajectory",
144  QString::fromStdString(
145  ros::message_traits::datatype<view_controller_msgs::CameraTrajectory>()),
146  "Topic for CameraTrajectory messages", this,
147  SLOT(updateTopics()));
148 
149  window_width_property_ = new FloatProperty("Window Width", 1000, "The width of the rviz visualization window in pixels.", this);
150  window_height_property_ = new FloatProperty("Window Height", 1000, "The height of the rviz visualization window in pixels.", this);
151 
152  publish_view_images_property_ = new BoolProperty("Publish View Images During Animation", false,
153  "If enabled, publishes images of what the user sees in the visualization window during an animation.",
154  this);
157 }
158 
160 {
161  delete focal_shape_;
162  context_->getSceneManager()->destroySceneNode( attached_scene_node_ );
163 }
164 
166 {
167  placement_subscriber_ = nh_.subscribe<view_controller_msgs::CameraPlacement>
169  boost::bind(&AnimatedViewController::cameraPlacementCallback, this, _1));
170 
171  trajectory_subscriber_ = nh_.subscribe<view_controller_msgs::CameraTrajectory>
173  boost::bind(&AnimatedViewController::cameraTrajectoryCallback, this, _1));
174 }
175 
177 {
178  current_camera_pose_publisher_ = nh_.advertise<geometry_msgs::Pose>("/rviz/current_camera_pose", 1);
179  finished_animation_publisher_ = nh_.advertise<std_msgs::Bool>("/rviz/finished_animation", 1);
180 
182  camera_view_image_publisher_ = it.advertise("/rviz/view_image", 1);
183 }
184 
186 {
187  pause_animation_duration_subscriber_ = nh_.subscribe("/rviz/pause_animation_duration", 1,
189 }
190 
191 void AnimatedViewController::pauseAnimationCallback(const std_msgs::Duration::ConstPtr& pause_duration_msg)
192 {
193  pause_animation_duration_.sec = pause_duration_msg->data.sec;
194  pause_animation_duration_.nsec = pause_duration_msg->data.nsec;
195 }
196 
198 {
200  attached_scene_node_ = context_->getSceneManager()->getRootSceneNode()->createChildSceneNode();
201  camera_->detachFromParent();
202  attached_scene_node_->attachObject( camera_ );
203 
204  camera_->setProjectionType( Ogre::PT_PERSPECTIVE );
205 
207  focal_shape_->setScale(Ogre::Vector3(0.05f, 0.05f, 0.01f));
208  focal_shape_->setColor(1.0f, 1.0f, 0.0f, 0.5f);
209  focal_shape_->getRootNode()->setVisible(false);
210 
212 }
213 
215 {
218 }
219 
221 {
223 
224  // Before activation, changes to target frame property should have
225  // no side-effects. After activation, changing target frame
226  // property has the side effect (typically) of changing an offset
227  // property so that the view does not jump. Therefore we make the
228  // signal/slot connection from the property here in onActivate()
229  // instead of in the constructor.
230  connect( attached_frame_property_, SIGNAL( changed() ), this, SLOT( updateAttachedFrame() ));
231  connect( fixed_up_property_, SIGNAL( changed() ), this, SLOT( onUpPropertyChanged() ));
233 
234  // Only do this once activated!
235  updateTopics();
236 
237 }
238 
240 {
241  connect( distance_property_, SIGNAL( changed() ), this, SLOT( onDistancePropertyChanged() ), Qt::UniqueConnection);
242  connect( eye_point_property_, SIGNAL( changed() ), this, SLOT( onEyePropertyChanged() ), Qt::UniqueConnection);
243  connect( focus_point_property_, SIGNAL( changed() ), this, SLOT( onFocusPropertyChanged() ), Qt::UniqueConnection);
244  connect( up_vector_property_, SIGNAL( changed() ), this, SLOT( onUpPropertyChanged() ), Qt::UniqueConnection);
245 }
246 
248 {
249  disconnect( distance_property_, SIGNAL( changed() ), this, SLOT( onDistancePropertyChanged() ));
250  disconnect( eye_point_property_, SIGNAL( changed() ), this, SLOT( onEyePropertyChanged() ));
251  disconnect( focus_point_property_, SIGNAL( changed() ), this, SLOT( onFocusPropertyChanged() ));
252  disconnect( up_vector_property_, SIGNAL( changed() ), this, SLOT( onUpPropertyChanged() ));
253 }
254 
256 {
258 }
259 
261 {
263 }
264 
266 {
268  Ogre::Vector3 new_eye_position = focus_point_property_->getVector() + distance_property_->getFloat()* camera_->getOrientation().zAxis();
269  eye_point_property_->setVector(new_eye_position);
271 }
272 
274 {
275  disconnect( up_vector_property_, SIGNAL( changed() ), this, SLOT( onUpPropertyChanged() ));
277  up_vector_property_->setVector(Ogre::Vector3::UNIT_Z);
278  camera_->setFixedYawAxis(true, reference_orientation_ * Ogre::Vector3::UNIT_Z);
279  }
280  else {
281  // force orientation to match up vector; first call doesn't actually change the quaternion
282  camera_->setFixedYawAxis(true, reference_orientation_ * up_vector_property_->getVector());
284  // restore normal behavior
285  camera_->setFixedYawAxis(false);
286  }
287  connect( up_vector_property_, SIGNAL( changed() ), this, SLOT( onUpPropertyChanged() ), Qt::UniqueConnection);
288 }
289 
291 {
292  Ogre::Vector3 old_position = attached_scene_node_->getPosition();
293  Ogre::Quaternion old_orientation = attached_scene_node_->getOrientation();
294 
296 
297  onAttachedFrameChanged( old_position, old_orientation );
298 }
299 
301 {
302  Ogre::Vector3 new_reference_position;
303  Ogre::Quaternion new_reference_orientation;
304 
305  bool queue = false;
307  new_reference_position, new_reference_orientation ))
308  {
309  attached_scene_node_->setPosition( new_reference_position );
310  attached_scene_node_->setOrientation( new_reference_orientation );
311  reference_position_ = new_reference_position;
312  reference_orientation_ = new_reference_orientation;
313  queue = true;
314  }
315  if(queue) context_->queueRender();
316 }
317 
318 void AnimatedViewController::onAttachedFrameChanged(const Ogre::Vector3& old_reference_position, const Ogre::Quaternion& old_reference_orientation)
319 {
320  Ogre::Vector3 fixed_frame_focus_position = old_reference_orientation*focus_point_property_->getVector() + old_reference_position;
321  Ogre::Vector3 fixed_frame_eye_position = old_reference_orientation*eye_point_property_->getVector() + old_reference_position;
322  Ogre::Vector3 new_focus_position = fixedFrameToAttachedLocal(fixed_frame_focus_position);
323  Ogre::Vector3 new_eye_position = fixedFrameToAttachedLocal(fixed_frame_eye_position);
324  Ogre::Vector3 new_up_vector = reference_orientation_.Inverse()*old_reference_orientation*up_vector_property_->getVector();
325 
326  //Ogre::Quaternion new_camera_orientation = reference_orientation_.Inverse()*old_reference_orientation*getOrientation();
327 
328  focus_point_property_->setVector(new_focus_position);
329  eye_point_property_->setVector(new_eye_position);
330  up_vector_property_->setVector(fixed_up_property_->getBool() ? Ogre::Vector3::UNIT_Z : new_up_vector);
332 
333  // force orientation to match up vector; first call doesn't actually change the quaternion
334  camera_->setFixedYawAxis(true, reference_orientation_ * up_vector_property_->getVector());
336 }
337 
339 {
341 }
342 
344 {
345  eye_point_property_->setVector(Ogre::Vector3(5, 5, 10));
346  focus_point_property_->setVector(Ogre::Vector3::ZERO);
347  up_vector_property_->setVector(Ogre::Vector3::UNIT_Z);
351 
352 
353  // Hersh says: why is the following junk necessary? I don't know.
354  // However, without this you need to call reset() twice after
355  // switching from TopDownOrtho to FPS. After the first call the
356  // camera is in the right position but pointing the wrong way.
357  updateCamera();
358  camera_->lookAt( 0, 0, 0 );
360 }
361 
363 {
365  {
367  setStatus( "<b>Mouse interaction is disabled. You can enable it by checking the \"Mouse Enabled\" check-box in the Views panel." );
368  return;
369  }
370  else if ( event.shift() )
371  {
372  setStatus( "TODO: Fix me! <b>Left-Click:</b> Move X/Y. <b>Right-Click:</b>: Move Z." );
373  }
374  else if ( event.control() )
375  {
376  setStatus( "TODO: Fix me! <b>Left-Click:</b> Move X/Y. <b>Right-Click:</b>: Move Z." );
377  }
378  else
379  {
380  setStatus( "TODO: Fix me! <b>Left-Click:</b> Rotate. <b>Middle-Click:</b> Move X/Y. <b>Right-Click:</b>: Zoom. <b>Shift</b>: More options." );
381  }
382 
383  float distance = distance_property_->getFloat();
384  int32_t diff_x = 0;
385  int32_t diff_y = 0;
386  bool moved = false;
387 
388  if( event.type == QEvent::MouseButtonPress )
389  {
390  focal_shape_->getRootNode()->setVisible(true);
391  moved = true;
392  dragging_ = true;
393  cancelTransition(); // Stop any automated movement
394  }
395  else if( event.type == QEvent::MouseButtonRelease )
396  {
397  focal_shape_->getRootNode()->setVisible(false);
398  moved = true;
399  dragging_ = false;
400  }
401  else if( dragging_ && event.type == QEvent::MouseMove )
402  {
403  diff_x = event.x - event.last_x;
404  diff_y = event.y - event.last_y;
405  moved = true;
406  }
407 
408  // regular left-button drag
409  if( event.left() && !event.shift() )
410  {
411  setCursor( Rotate3D );
412  yaw_pitch_roll( -diff_x*0.005, -diff_y*0.005, 0 );
413  }
414  // middle or shift-left drag
415  else if( event.middle() || ( event.shift() && event.left() ))
416  {
417  setCursor( MoveXY );
418  if(interaction_mode_property_->getStdString() == MODE_ORBIT) // Orbit style
419  {
420  float fovY = camera_->getFOVy().valueRadians();
421  float fovX = 2.0f * atan( tan( fovY / 2.0f ) * camera_->getAspectRatio() );
422 
423  int width = camera_->getViewport()->getActualWidth();
424  int height = camera_->getViewport()->getActualHeight();
425 
426  move_focus_and_eye( -((float)diff_x / (float)width) * distance * tan( fovX / 2.0f ) * 2.0f,
427  ((float)diff_y / (float)height) * distance * tan( fovY / 2.0f ) * 2.0f,
428  0.0f );
429  }
430  else if(interaction_mode_property_->getStdString() == MODE_FPS) // Orbit style
431  {
432  move_focus_and_eye( diff_x*0.01, -diff_y*0.01, 0.0f );
433  }
434  }
435  else if( event.right() )
436  {
437  if( event.shift() || (interaction_mode_property_->getStdString() == MODE_FPS) )
438  {
439  setCursor( MoveZ );
440  move_focus_and_eye(0.0f, 0.0f, diff_y * 0.01 * distance);
441  }
442  else
443  {
444  setCursor( Zoom );
445  move_eye( 0, 0, diff_y * 0.01 * distance );
446  }
447  }
448  else
449  {
450  setCursor( event.shift() ? MoveXY : Rotate3D );
451  }
452 
453  if ( event.wheel_delta != 0 )
454  {
455  int diff = event.wheel_delta;
456 
457  if( event.shift() )
458  {
459  move_focus_and_eye(0, 0, -diff * 0.001 * distance );
460  }
461  else if(event.control())
462  {
463  yaw_pitch_roll(0, 0, diff*0.001 );
464  }
465  else
466  {
467  move_eye( 0, 0, -diff * 0.001 * distance );
468  }
469  moved = true;
470  }
471 
472  if(event.type == QEvent::MouseButtonPress && event.left() && event.control() && event.shift())
473  {
474  bool was_orbit = (interaction_mode_property_->getStdString() == MODE_ORBIT);
476  }
477 
478  if (moved)
479  {
482  }
483 }
484 
486 {
487  geometry_msgs::Pose cam_pose;
488  cam_pose.position.x = camera_->getPosition().x;
489  cam_pose.position.y = camera_->getPosition().y;
490  cam_pose.position.z = camera_->getPosition().z;
491  cam_pose.orientation.w = camera_->getOrientation().w;
492  cam_pose.orientation.x = camera_->getOrientation().x;
493  cam_pose.orientation.y = camera_->getOrientation().y;
494  cam_pose.orientation.z = camera_->getOrientation().z;
496 }
497 
498 //void AnimatedViewController::setUpVectorPropertyModeDependent( const Ogre::Vector3 &vector )
499 //{
500 // if(fixed_up_property_->getBool())
501 // {
502 // //up_vector_property_->setVector(Ogre::Vector3::UNIT_Z);
503 // }
504 // else {
505 // up_vector_property_->setVector(vector);
506 // }
507 //}
508 
509 
510 void AnimatedViewController::setPropertiesFromCamera( Ogre::Camera* source_camera )
511 {
513  Ogre::Vector3 direction = source_camera->getOrientation() * Ogre::Vector3::NEGATIVE_UNIT_Z;
514  eye_point_property_->setVector( source_camera->getPosition() );
515  focus_point_property_->setVector( source_camera->getPosition() + direction*distance_property_->getFloat());
517  up_vector_property_->setVector(Ogre::Vector3::UNIT_Z);
518  else
519  up_vector_property_->setVector(source_camera->getOrientation().yAxis());
520 
521  //setUpVectorPropertyModeDependent(source_camera->getOrientation().yAxis());
523 }
524 
526 {
527  QVariant target_frame = source_view->subProp( "Target Frame" )->getValue();
528  if( target_frame.isValid() )
529  {
531  }
532 
533  Ogre::Camera* source_camera = source_view->getCamera();
534  Ogre::Vector3 position = source_camera->getPosition();
535  Ogre::Quaternion orientation = source_camera->getOrientation();
536 
537  if( source_view->getClassId() == "rviz/Orbit" )
538  {
539  distance_property_->setFloat( source_view->subProp( "Distance" )->getValue().toFloat() );
540  }
541  else
542  {
543  distance_property_->setFloat( position.length() );
544  }
546 
547  Ogre::Vector3 direction = orientation * (Ogre::Vector3::NEGATIVE_UNIT_Z * distance_property_->getFloat() );
548  focus_point_property_->setVector( position + direction );
549  eye_point_property_->setVector(position);
550  updateCamera();
551 }
552 
554 {
555  AnimatedViewController* fvc = dynamic_cast<AnimatedViewController*>(previous_view);
556  if(fvc)
557  {
558  Ogre::Vector3 new_eye = eye_point_property_->getVector();
559  Ogre::Vector3 new_focus = focus_point_property_->getVector();
560  Ogre::Vector3 new_up = up_vector_property_->getVector();
561 
565 
567  }
568 }
569 
570 void AnimatedViewController::beginNewTransition(const Ogre::Vector3 &eye,
571  const Ogre::Vector3 &focus,
572  const Ogre::Vector3 &up,
573  ros::Duration transition_duration,
574  uint8_t interpolation_speed)
575 {
576  if(transition_duration.toSec() < 0.0)
577  return;
578 
579  // convert positional jumps to very fast movements to prevent numerical problems
580  if(transition_duration.isZero())
581  transition_duration = ros::Duration(0.001);
582 
583  // if the buffer is empty we set the first element in it to the current camera pose
584  if(cam_movements_buffer_.empty())
585  {
587 
591  ros::Duration(0.001),
592  interpolation_speed))); // interpolation_speed doesn't make a difference for very short times
593  }
594 
595  if(cam_movements_buffer_.full())
596  cam_movements_buffer_.set_capacity(cam_movements_buffer_.capacity() + 20);
597 
598  cam_movements_buffer_.push_back(std::move(OgreCameraMovement(eye, focus, up, transition_duration, interpolation_speed)));
599 
600  animate_ = true;
601 }
602 
604 {
605  animate_ = false;
606 
607  cam_movements_buffer_.clear();
609 
611  {
612  std_msgs::Bool finished_animation;
613  finished_animation.data = 1; // set to true, but std_msgs::Bool is uint8 internally
614  finished_animation_publisher_.publish(finished_animation);
615  render_frame_by_frame_ = false;
616  }
617 }
618 
619 void AnimatedViewController::cameraPlacementCallback(const CameraPlacementConstPtr &cp_ptr)
620 {
621  CameraPlacement cp = *cp_ptr;
622 
623  // Handle control parameters
624  mouse_enabled_property_->setBool( !cp.interaction_disabled );
625  fixed_up_property_->setBool( !cp.allow_free_yaw_axis );
626  if(cp.mouse_interaction_mode != cp.NO_CHANGE)
627  {
628  std::string name = "";
629  if(cp.mouse_interaction_mode == cp.ORBIT) name = MODE_ORBIT;
630  else if(cp.mouse_interaction_mode == cp.FPS) name = MODE_FPS;
632  }
633 
634  if(cp.target_frame != "")
635  {
636  attached_frame_property_->setStdString(cp.target_frame);
638  }
639 
640  if(cp.time_from_start.toSec() >= 0)
641  {
642  ROS_DEBUG_STREAM("Received a camera placement request! \n" << cp);
644  cp.focus,
645  cp.up);
646  ROS_DEBUG_STREAM("After transform, we have \n" << cp);
647 
648  Ogre::Vector3 eye = vectorFromMsg(cp.eye.point);
649  Ogre::Vector3 focus = vectorFromMsg(cp.focus.point);
650  Ogre::Vector3 up = vectorFromMsg(cp.up.vector);
651 
652  beginNewTransition(eye, focus, up, cp.time_from_start);
653  }
654 }
655 
656 void AnimatedViewController::cameraTrajectoryCallback(const view_controller_msgs::CameraTrajectoryConstPtr& ct_ptr)
657 {
658  view_controller_msgs::CameraTrajectory ct = *ct_ptr;
659 
660  if(ct.trajectory.empty())
661  return;
662 
663  // Handle control parameters
664  mouse_enabled_property_->setBool(!ct.interaction_disabled);
665  fixed_up_property_->setBool(!ct.allow_free_yaw_axis);
666  if(ct.mouse_interaction_mode != view_controller_msgs::CameraTrajectory::NO_CHANGE)
667  {
668  std::string name = "";
669  if(ct.mouse_interaction_mode == view_controller_msgs::CameraTrajectory::ORBIT)
670  name = MODE_ORBIT;
671  else if(ct.mouse_interaction_mode == view_controller_msgs::CameraTrajectory::FPS)
672  name = MODE_FPS;
674  }
675 
676  if(ct.render_frame_by_frame > 0)
677  {
678  render_frame_by_frame_ = true;
679  target_fps_ = static_cast<int>(ct.frames_per_second);
681  }
682 
683  for(auto& cam_movement : ct.trajectory)
684  {
685  if(cam_movement.transition_duration.toSec() >= 0.0)
686  {
687  if(ct.target_frame != "")
688  {
689  attached_frame_property_->setStdString(ct.target_frame);
691  }
692 
693  transformCameraToAttachedFrame(cam_movement.eye,
694  cam_movement.focus,
695  cam_movement.up);
696 
697  Ogre::Vector3 eye = vectorFromMsg(cam_movement.eye.point);
698  Ogre::Vector3 focus = vectorFromMsg(cam_movement.focus.point);
699  Ogre::Vector3 up = vectorFromMsg(cam_movement.up.vector);
700  beginNewTransition(eye, focus, up, cam_movement.transition_duration, cam_movement.interpolation_speed);
701  }
702  else
703  {
704  ROS_WARN("Transition duration of camera movement is below zero. Skipping that movement.");
705  }
706  }
707 }
708 
709 void AnimatedViewController::transformCameraToAttachedFrame(geometry_msgs::PointStamped& eye,
710  geometry_msgs::PointStamped& focus,
711  geometry_msgs::Vector3Stamped& up)
712 {
713  Ogre::Vector3 position_fixed_eye, position_fixed_focus, position_fixed_up;
714  Ogre::Quaternion rotation_fixed_eye, rotation_fixed_focus, rotation_fixed_up;
715 
716  context_->getFrameManager()->getTransform(eye.header.frame_id, ros::Time(0), position_fixed_eye, rotation_fixed_eye);
717  context_->getFrameManager()->getTransform(focus.header.frame_id, ros::Time(0), position_fixed_focus, rotation_fixed_focus);
718  context_->getFrameManager()->getTransform(up.header.frame_id, ros::Time(0), position_fixed_up, rotation_fixed_up);
719 
720  Ogre::Vector3 ogre_eye = vectorFromMsg(eye.point);
721  Ogre::Vector3 ogre_focus = vectorFromMsg(focus.point);
722  Ogre::Vector3 ogre_up = vectorFromMsg(up.vector);
723 
724  ogre_eye = fixedFrameToAttachedLocal(position_fixed_eye + rotation_fixed_eye * ogre_eye);
725  ogre_focus = fixedFrameToAttachedLocal(position_fixed_focus + rotation_fixed_focus * ogre_focus);
726  ogre_up = reference_orientation_.Inverse() * rotation_fixed_up * ogre_up;
727 
728  eye.point = pointOgreToMsg(ogre_eye);
729  focus.point = pointOgreToMsg(ogre_focus);
730  up.vector = vectorOgreToMsg(ogre_up);
731  eye.header.frame_id = attached_frame_property_->getStdString();
732  focus.header.frame_id = attached_frame_property_->getStdString();
733  up.header.frame_id = attached_frame_property_->getStdString();
734 }
735 
736 // We must assume that this point is in the Rviz Fixed frame since it came from Rviz...
737 void AnimatedViewController::lookAt( const Ogre::Vector3& point )
738 {
739  if( !mouse_enabled_property_->getBool() ) return;
740 
741  Ogre::Vector3 new_point = fixedFrameToAttachedLocal(point);
742 
746 
747  // // Just for easily testing the other movement styles:
748  // orbitCameraTo(point);
749  // moveCameraWithFocusTo(point);
750 }
751 
752 void AnimatedViewController::orbitCameraTo( const Ogre::Vector3& point)
753 {
757 }
758 
759 void AnimatedViewController::moveEyeWithFocusTo( const Ogre::Vector3& point)
760 {
764 }
765 
766 
767 void AnimatedViewController::update(float dt, float ros_dt)
768 {
770 
772  {
774 
775  auto start = cam_movements_buffer_.begin();
776  auto goal = ++(cam_movements_buffer_.begin());
777 
778  double relative_progress_in_time = computeRelativeProgressInTime(goal->transition_duration);
779 
780  // make sure we get all the way there before turning off
781  bool finished_current_movement = false;
782  if(relative_progress_in_time >= 1.0)
783  {
784  relative_progress_in_time = 1.0;
785  finished_current_movement = true;
786  }
787 
788  float relative_progress_in_space = computeRelativeProgressInSpace(relative_progress_in_time,
789  goal->interpolation_speed);
790 
791  Ogre::Vector3 new_position = start->eye + relative_progress_in_space * (goal->eye - start->eye);
792  Ogre::Vector3 new_focus = start->focus + relative_progress_in_space * (goal->focus - start->focus);
793  Ogre::Vector3 new_up = start->up + relative_progress_in_space * (goal->up - start->up);
794 
796  eye_point_property_->setVector( new_position );
797  focus_point_property_->setVector( new_focus );
801 
802  // This needs to happen so that the camera orientation will update properly when fixed_up_property == false
803  camera_->setFixedYawAxis(true, reference_orientation_ * up_vector_property_->getVector());
805 
807 
810 
811  if(finished_current_movement)
812  {
813  // delete current start element in buffer
814  cam_movements_buffer_.pop_front();
815 
816  if(isMovementAvailable())
817  prepareNextMovement(goal->transition_duration);
818  else
820  }
821  }
822  updateCamera();
824 }
825 
827 {
828  if(pause_animation_duration_.toSec() > 0.0)
829  {
833  }
834 }
835 
837 {
838  double relative_progress_in_time = 0.0;
840  {
841  relative_progress_in_time = rendered_frames_counter_ / (target_fps_ * transition_duration.toSec());
843  }
844  else
845  {
847  relative_progress_in_time = duration_from_start.toSec() / transition_duration.toSec();
848  }
849  return relative_progress_in_time;
850 }
851 
852 float AnimatedViewController::computeRelativeProgressInSpace(double relative_progress_in_time,
853  uint8_t interpolation_speed)
854 {
855  switch(interpolation_speed)
856  {
857  case view_controller_msgs::CameraMovement::RISING:
858  return 1.f - static_cast<float>(cos(relative_progress_in_time * M_PI_2));
859  case view_controller_msgs::CameraMovement::DECLINING:
860  return static_cast<float>(-cos(relative_progress_in_time * M_PI_2 + M_PI_2));
861  case view_controller_msgs::CameraMovement::FULL:
862  return static_cast<float>(relative_progress_in_time);
863  case view_controller_msgs::CameraMovement::WAVE:
864  default:
865  return 0.5f * (1.f - static_cast<float>(cos(relative_progress_in_time * M_PI)));
866  }
867 }
868 
870 {
872  {
873  std::shared_ptr<Ogre::PixelBox> pixel_box = std::make_shared<Ogre::PixelBox>();
874  getViewImage(pixel_box);
875 
876  sensor_msgs::ImagePtr image_msg = sensor_msgs::ImagePtr(new sensor_msgs::Image());
877  convertImage(pixel_box, image_msg);
878 
880 
881  delete[] (unsigned char*)pixel_box->data;
882  }
883 }
884 
885 void AnimatedViewController::getViewImage(std::shared_ptr<Ogre::PixelBox>& pixel_box)
886 {
887  const unsigned int image_height = context_->getViewManager()->getRenderPanel()->getRenderWindow()->getHeight();
888  const unsigned int image_width = context_->getViewManager()->getRenderPanel()->getRenderWindow()->getWidth();
889 
890  // create a PixelBox to store the rendered view image
891  const Ogre::PixelFormat pixel_format = Ogre::PF_BYTE_BGR;
892  const auto bytes_per_pixel = Ogre::PixelUtil::getNumElemBytes(pixel_format);
893  auto image_data = new unsigned char[image_width * image_height * bytes_per_pixel];
894  Ogre::Box image_extents(0, 0, image_width, image_height);
895  pixel_box = std::make_shared<Ogre::PixelBox>(image_extents, pixel_format, image_data);
896  context_->getViewManager()->getRenderPanel()->getRenderWindow()->copyContentsToMemory(*pixel_box,
897  Ogre::RenderTarget::FB_AUTO);
898 }
899 
900 void AnimatedViewController::convertImage(std::shared_ptr<Ogre::PixelBox> input_image,
901  sensor_msgs::ImagePtr output_image)
902 {
903  const auto bytes_per_pixel = Ogre::PixelUtil::getNumElemBytes(input_image->format);
904  const auto image_height = input_image->getHeight();
905  const auto image_width = input_image->getWidth();
906 
907  output_image->header.frame_id = attached_frame_property_->getStdString();
908  output_image->header.stamp = ros::Time::now();
909  output_image->height = image_height;
910  output_image->width = image_width;
911  output_image->encoding = sensor_msgs::image_encodings::BGR8;
912  output_image->is_bigendian = false;
913  output_image->step = static_cast<unsigned int>(image_width * bytes_per_pixel);
914  size_t size = image_width * image_height * bytes_per_pixel;
915  output_image->data.resize(size);
916  memcpy((char*)(&output_image->data[0]), input_image->data, size);
917 }
918 
919 void AnimatedViewController::prepareNextMovement(const ros::Duration& previous_transition_duration)
920 {
921  transition_start_time_ += ros::WallDuration(previous_transition_duration.toSec());
923 }
924 
926 {
927  camera_->setPosition( eye_point_property_->getVector() );
930  //camera_->setDirection( (focus_point_property_->getVector() - eye_point_property_->getVector()));
932 }
933 
934 void AnimatedViewController::yaw_pitch_roll( float yaw, float pitch, float roll )
935 {
936  Ogre::Quaternion old_camera_orientation = camera_->getOrientation();
937  Ogre::Radian old_pitch = old_camera_orientation.getPitch(false);// - Ogre::Radian(Ogre::Math::HALF_PI);
938 
939  if(fixed_up_property_->getBool()) yaw = cos(old_pitch.valueRadians() - Ogre::Math::HALF_PI)*yaw; // helps to reduce crazy spinning!
940 
941  Ogre::Quaternion yaw_quat, pitch_quat, roll_quat;
942  yaw_quat.FromAngleAxis( Ogre::Radian( yaw ), Ogre::Vector3::UNIT_Y );
943  pitch_quat.FromAngleAxis( Ogre::Radian( pitch ), Ogre::Vector3::UNIT_X );
944  roll_quat.FromAngleAxis( Ogre::Radian( roll ), Ogre::Vector3::UNIT_Z );
945  Ogre::Quaternion orientation_change = yaw_quat * pitch_quat * roll_quat;
946  Ogre::Quaternion new_camera_orientation = old_camera_orientation * orientation_change;
947  Ogre::Radian new_pitch = new_camera_orientation.getPitch(false);// - Ogre::Radian(Ogre::Math::HALF_PI);
948 
949  if( fixed_up_property_->getBool() &&
950  ((new_pitch > PITCH_LIMIT_HIGH && new_pitch > old_pitch) || (new_pitch < PITCH_LIMIT_LOW && new_pitch < old_pitch)) )
951  {
952  orientation_change = yaw_quat * roll_quat;
953  new_camera_orientation = old_camera_orientation * orientation_change;
954  }
955 
956 // Ogre::Radian new_roll = new_camera_orientation.getRoll(false);
957 // Ogre::Radian new_yaw = new_camera_orientation.getYaw(false);
958  //ROS_INFO("old_pitch: %.3f, new_pitch: %.3f", old_pitch.valueRadians(), new_pitch.valueRadians());
959 
960  camera_->setOrientation( new_camera_orientation );
962  {
963  // In orbit mode the focal point stays fixed, so we need to compute the new camera position.
964  Ogre::Vector3 new_eye_position = focus_point_property_->getVector() + distance_property_->getFloat()* new_camera_orientation.zAxis();
965  eye_point_property_->setVector(new_eye_position);
966  camera_->setPosition(new_eye_position);
968  }
969  else
970  {
971  // In FPS mode the camera stays fixed, so we can just apply the rotations and then rely on the property update to set the new focal point.
973  }
974 }
975 
976 Ogre::Quaternion AnimatedViewController::getOrientation() // Do we need this?
977 {
978  return camera_->getOrientation();
979 }
980 
981 void AnimatedViewController::move_focus_and_eye( float x, float y, float z )
982 {
983  Ogre::Vector3 translate( x, y, z );
984  eye_point_property_->add( getOrientation() * translate );
985  focus_point_property_->add( getOrientation() * translate );
986 }
987 
988 void AnimatedViewController::move_eye( float x, float y, float z )
989 {
990  Ogre::Vector3 translate( x, y, z );
991  // Only update the camera position if it won't "pass through" the origin
992  Ogre::Vector3 new_position = eye_point_property_->getVector() + getOrientation() * translate;
993  if( (new_position - focus_point_property_->getVector()).length() > distance_property_->getMin() )
994  eye_point_property_->setVector(new_position);
996 }
997 
998 
999 
1000 } // end namespace rviz
1001 
rviz_animated_view_controller::AnimatedViewController::handleMouseEvent
virtual void handleMouseEvent(rviz::ViewportMouseEvent &evt)
Definition: rviz_animated_view_controller.cpp:362
rviz::BoolProperty::getBool
virtual bool getBool() const
rviz_animated_view_controller::vectorFromMsg
static Ogre::Vector3 vectorFromMsg(const geometry_msgs::Point &m)
Definition: rviz_animated_view_controller.cpp:76
rviz::Shape::getRootNode
Ogre::SceneNode * getRootNode()
ros::WallDuration::sleep
bool sleep() const
rviz_animated_view_controller::AnimatedViewController::onUpPropertyChanged
virtual void onUpPropertyChanged()
Called when up vector property is changed (does nothing for now...).
Definition: rviz_animated_view_controller.cpp:273
rviz_animated_view_controller::AnimatedViewController::interaction_mode_property_
rviz::EditableEnumProperty * interaction_mode_property_
Select between Orbit or FPS control style.
Definition: rviz_animated_view_controller.h:341
rviz::RosTopicProperty
rviz_animated_view_controller::AnimatedViewController::placement_subscriber_
ros::Subscriber placement_subscriber_
Definition: rviz_animated_view_controller.h:374
rviz::DisplayContext::queueRender
virtual void queueRender()=0
DurationBase< WallDuration >::fromSec
WallDuration & fromSec(double t)
NULL
#define NULL
rviz::Shape::setColor
void setColor(const Ogre::ColourValue &c)
image_transport::ImageTransport
rviz_animated_view_controller::AnimatedViewController::update
virtual void update(float dt, float ros_dt)
Called at 30Hz by ViewManager::update() while this view is active. Override with code that needs to r...
Definition: rviz_animated_view_controller.cpp:767
rviz_animated_view_controller::AnimatedViewController::interaction_disabled_cursor_
QCursor interaction_disabled_cursor_
A cursor for indicating mouse interaction is disabled.
Definition: rviz_animated_view_controller.h:372
rviz_animated_view_controller::AnimatedViewController::cancelTransition
void cancelTransition()
Cancels any currently active camera movement.
Definition: rviz_animated_view_controller.cpp:603
rviz_animated_view_controller::AnimatedViewController::pauseAnimationCallback
void pauseAnimationCallback(const std_msgs::Duration::ConstPtr &pause_duration_msg)
Sets the duration the rendering has to wait for during the next update cycle.
Definition: rviz_animated_view_controller.cpp:191
rviz_animated_view_controller::AnimatedViewController::fixed_up_property_
rviz::BoolProperty * fixed_up_property_
If True, "up" is fixed to ... up.
Definition: rviz_animated_view_controller.h:342
rviz_animated_view_controller::AnimatedViewController::window_width_property_
rviz::FloatProperty * window_width_property_
The width of the rviz visualization window in pixels.
Definition: rviz_animated_view_controller.h:353
rviz::BoolProperty::setBool
bool setBool(bool value)
rviz_animated_view_controller::AnimatedViewController::cam_movements_buffer_
BufferCamMovements cam_movements_buffer_
Definition: rviz_animated_view_controller.h:367
rviz_animated_view_controller::AnimatedViewController::current_camera_pose_publisher_
ros::Publisher current_camera_pose_publisher_
Definition: rviz_animated_view_controller.h:378
rviz_animated_view_controller::vectorOgreToMsg
static geometry_msgs::Vector3 vectorOgreToMsg(const Ogre::Vector3 &o)
Definition: rviz_animated_view_controller.cpp:86
rviz::EditableEnumProperty
rviz::BoolProperty
rviz::ViewportMouseEvent
image_transport::Publisher::getNumSubscribers
uint32_t getNumSubscribers() const
frame_manager.h
rviz_animated_view_controller::AnimatedViewController::beginNewTransition
void beginNewTransition(const Ogre::Vector3 &eye, const Ogre::Vector3 &focus, const Ogre::Vector3 &up, ros::Duration transition_duration, uint8_t interpolation_speed=view_controller_msgs::CameraMovement::WAVE)
Begins a camera movement animation to the given goal point.
Definition: rviz_animated_view_controller.cpp:570
rviz_animated_view_controller::AnimatedViewController::pause_animation_duration_subscriber_
ros::Subscriber pause_animation_duration_subscriber_
Definition: rviz_animated_view_controller.h:376
rviz_animated_view_controller::AnimatedViewController::eye_point_property_
rviz::VectorProperty * eye_point_property_
The position of the camera.
Definition: rviz_animated_view_controller.h:345
DurationBase< WallDuration >::nsec
int32_t nsec
viewport_mouse_event.h
rviz_animated_view_controller::AnimatedViewController::updateAttachedSceneNode
void updateAttachedSceneNode()
Update the position of the attached_scene_node_ from the TF frame specified in the Attached Frame pro...
Definition: rviz_animated_view_controller.cpp:300
rviz_animated_view_controller::AnimatedViewController::getDistanceFromCameraToFocalPoint
float getDistanceFromCameraToFocalPoint()
Return the distance between camera and focal point.
Definition: rviz_animated_view_controller.cpp:338
rviz::TfFrameProperty::getFrameStd
std::string getFrameStd() const
rviz_animated_view_controller::AnimatedViewController::render_frame_by_frame_
bool render_frame_by_frame_
Definition: rviz_animated_view_controller.h:382
rviz_animated_view_controller::AnimatedViewController::move_eye
void move_eye(float x, float y, float z)
Applies a translation to only the eye point.
Definition: rviz_animated_view_controller.cpp:988
rviz_animated_view_controller::AnimatedViewController::~AnimatedViewController
virtual ~AnimatedViewController()
Definition: rviz_animated_view_controller.cpp:159
rviz::Property::subProp
virtual Property * subProp(const QString &sub_name)
rviz_animated_view_controller::AnimatedViewController::target_fps_
int target_fps_
Definition: rviz_animated_view_controller.h:383
rviz_animated_view_controller::AnimatedViewController::animate_
bool animate_
Definition: rviz_animated_view_controller.h:365
rviz_animated_view_controller::AnimatedViewController::publishCameraPose
void publishCameraPose()
Publishes the current camera pose.
Definition: rviz_animated_view_controller.cpp:485
rviz_animated_view_controller::AnimatedViewController::attached_frame_property_
rviz::TfFrameProperty * attached_frame_property_
Definition: rviz_animated_view_controller.h:358
rviz_animated_view_controller::AnimatedViewController::setPropertiesFromCamera
void setPropertiesFromCamera(Ogre::Camera *source_camera)
Definition: rviz_animated_view_controller.cpp:510
rviz::TfFrameProperty::setValue
bool setValue(const QVariant &new_value) override
rviz_animated_view_controller::AnimatedViewController::computeRelativeProgressInTime
double computeRelativeProgressInTime(const ros::Duration &transition_duration)
Computes the fraction of time we already used for the current movement.
Definition: rviz_animated_view_controller.cpp:836
rviz::ViewportMouseEvent::left
bool left()
rviz_animated_view_controller::AnimatedViewController::onDistancePropertyChanged
virtual void onDistancePropertyChanged()
Called when distance property is changed; computes new eye position.
Definition: rviz_animated_view_controller.cpp:265
rviz_animated_view_controller::AnimatedViewController::cameraPlacementCallback
void cameraPlacementCallback(const view_controller_msgs::CameraPlacementConstPtr &cp_ptr)
Definition: rviz_animated_view_controller.cpp:619
rviz::Property::getValue
virtual QVariant getValue() const
ROS_DEBUG_STREAM
#define ROS_DEBUG_STREAM(args)
shape.h
ros::Publisher::publish
void publish(const boost::shared_ptr< M > &message) const
rviz_animated_view_controller::AnimatedViewController::updateTopics
void updateTopics()
Definition: rviz_animated_view_controller.cpp:165
ros::NodeHandle::advertise
Publisher advertise(AdvertiseOptions &ops)
rviz_animated_view_controller::AnimatedViewController::nh_
ros::NodeHandle nh_
Definition: rviz_animated_view_controller.h:338
rviz::FloatProperty::setMin
void setMin(float min)
rviz_animated_view_controller::AnimatedViewController::updateWindowSizeProperties
void updateWindowSizeProperties()
Definition: rviz_animated_view_controller.cpp:214
rviz::EditableEnumProperty::addOptionStd
void addOptionStd(const std::string &option)
rviz_animated_view_controller::pointOgreToMsg
static geometry_msgs::Point pointOgreToMsg(const Ogre::Vector3 &o)
Definition: rviz_animated_view_controller.cpp:78
rviz::DisplayContext::getSceneManager
virtual Ogre::SceneManager * getSceneManager() const=0
float_property.h
f
f
rviz_animated_view_controller::AnimatedViewController::finished_animation_publisher_
ros::Publisher finished_animation_publisher_
Definition: rviz_animated_view_controller.h:379
rviz::DisplayContext::getViewManager
virtual ViewManager * getViewManager() const=0
rviz::ViewController::context_
DisplayContext * context_
rviz_animated_view_controller::AnimatedViewController::attached_scene_node_
Ogre::SceneNode * attached_scene_node_
Definition: rviz_animated_view_controller.h:359
rviz::ViewportMouseEvent::right
bool right()
rviz::FloatProperty
rviz_animated_view_controller::PITCH_LIMIT_LOW
static const Ogre::Radian PITCH_LIMIT_LOW
Definition: rviz_animated_view_controller.cpp:71
rviz_animated_view_controller::AnimatedViewController::disconnectPositionProperties
void disconnectPositionProperties()
Convenience function; disconnects the signals/slots for position properties.
Definition: rviz_animated_view_controller.cpp:247
class_list_macros.h
rviz_animated_view_controller::AnimatedViewController::getOrientation
Ogre::Quaternion getOrientation()
Return a Quaternion.
Definition: rviz_animated_view_controller.cpp:976
rviz_animated_view_controller::AnimatedViewController::distance_property_
rviz::FloatProperty * distance_property_
The camera's distance from the focal point.
Definition: rviz_animated_view_controller.h:344
rviz_animated_view_controller::AnimatedViewController::orbitCameraTo
void orbitCameraTo(const Ogre::Vector3 &point)
Calls beginNewTransition() with the focus point fixed, moving the eye to the point given.
Definition: rviz_animated_view_controller.cpp:752
rviz::ViewManager::getRenderPanel
RenderPanel * getRenderPanel() const
rviz_animated_view_controller::AnimatedViewController::onActivate
virtual void onActivate()
called by activate().
Definition: rviz_animated_view_controller.cpp:220
rviz_animated_view_controller::AnimatedViewController::camera_trajectory_topic_property_
rviz::RosTopicProperty * camera_trajectory_topic_property_
Definition: rviz_animated_view_controller.h:351
rviz_animated_view_controller::AnimatedViewController::up_vector_property_
rviz::VectorProperty * up_vector_property_
The up vector for the camera.
Definition: rviz_animated_view_controller.h:347
bool_property.h
editable_enum_property.h
PLUGINLIB_EXPORT_CLASS
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
rviz::FloatProperty::getFloat
virtual float getFloat() const
rviz_animated_view_controller.h
rviz_animated_view_controller::AnimatedViewController::AnimatedViewController
AnimatedViewController()
Definition: rviz_animated_view_controller.cpp:97
rviz_animated_view_controller::AnimatedViewController::updateCamera
void updateCamera()
Updates the Ogre camera properties from the view controller properties.
Definition: rviz_animated_view_controller.cpp:925
rviz_animated_view_controller::AnimatedViewController::default_transition_time_property_
rviz::FloatProperty * default_transition_time_property_
A default time for any animation requests.
Definition: rviz_animated_view_controller.h:348
render_panel.h
rviz
rviz::RenderWidget::getRenderWindow
Ogre::RenderWindow * getRenderWindow()
rviz::VectorProperty::setVector
virtual bool setVector(const Ogre::Vector3 &vector)
rviz_animated_view_controller::AnimatedViewController::mouse_enabled_property_
rviz::BoolProperty * mouse_enabled_property_
If True, most user changes to camera state are disabled.
Definition: rviz_animated_view_controller.h:340
ros::WallTime::now
static WallTime now()
rviz_animated_view_controller::AnimatedViewController::focus_point_property_
rviz::VectorProperty * focus_point_property_
The point around which the camera "orbits".
Definition: rviz_animated_view_controller.h:346
rviz::StringProperty::getStdString
std::string getStdString()
rviz::ViewportMouseEvent::middle
bool middle()
rviz_animated_view_controller::PITCH_LIMIT_HIGH
static const Ogre::Radian PITCH_LIMIT_HIGH
Definition: rviz_animated_view_controller.cpp:72
rviz_animated_view_controller::AnimatedViewController::onAttachedFrameChanged
virtual void onAttachedFrameChanged(const Ogre::Vector3 &old_reference_position, const Ogre::Quaternion &old_reference_orientation)
Override to implement the change in properties which nullifies the change in attached frame.
Definition: rviz_animated_view_controller.cpp:318
rviz_animated_view_controller::AnimatedViewController::onEyePropertyChanged
virtual void onEyePropertyChanged()
Called when eye property is changed; computes new distance.
Definition: rviz_animated_view_controller.cpp:255
load_resource.h
rviz::ViewportMouseEvent::type
QEvent::Type type
rviz_animated_view_controller::MODE_ORBIT
static const std::string MODE_ORBIT
Definition: rviz_animated_view_controller.cpp:65
rviz_animated_view_controller::AnimatedViewController::focal_shape_
rviz::Shape * focal_shape_
A small ellipsoid to show the focus point.
Definition: rviz_animated_view_controller.h:369
rviz_animated_view_controller::MODE_FPS
static const std::string MODE_FPS
Definition: rviz_animated_view_controller.cpp:66
ROS_WARN
#define ROS_WARN(...)
ros::NodeHandle::subscribe
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
makeIconCursor
QCursor makeIconCursor(const QPixmap &icon, const QString &cache_key, bool fill_cache)
rviz_animated_view_controller::AnimatedViewController::reference_orientation_
Ogre::Quaternion reference_orientation_
Used to store the orientation of the attached frame relative to <Fixed Frame>
Definition: rviz_animated_view_controller.h:361
rviz::ViewportMouseEvent::control
bool control()
rviz_animated_view_controller::AnimatedViewController::pause_animation_duration_
ros::WallDuration pause_animation_duration_
Definition: rviz_animated_view_controller.h:386
rviz_animated_view_controller::AnimatedViewController::getViewImage
void getViewImage(std::shared_ptr< Ogre::PixelBox > &pixel_box)
Get the current image rviz is showing as an Ogre::PixelBox.
Definition: rviz_animated_view_controller.cpp:885
image_transport::Publisher::publish
void publish(const sensor_msgs::Image &message) const
rviz::DisplayContext::getFrameManager
virtual FrameManager * getFrameManager() const=0
rviz_animated_view_controller::AnimatedViewController::moveEyeWithFocusTo
void moveEyeWithFocusTo(const Ogre::Vector3 &point)
Calls beginNewTransition() to move the eye to the point given, keeping the direction fixed.
Definition: rviz_animated_view_controller.cpp:759
rviz_animated_view_controller::AnimatedViewController::reference_position_
Ogre::Vector3 reference_position_
Used to store the position of the attached frame relative to <Fixed Frame>
Definition: rviz_animated_view_controller.h:362
rviz::Shape::Sphere
Sphere
rviz_animated_view_controller::AnimatedViewController
An un-constrained "flying" camera, specified by an eye point, focus point, and up vector.
Definition: rviz_animated_view_controller.h:77
rviz::FloatProperty::getMin
float getMin()
rviz::ViewportMouseEvent::wheel_delta
int wheel_delta
tf_frame_property.h
rviz::TfFrameProperty
rviz_animated_view_controller::AnimatedViewController::lookAt
virtual void lookAt(const Ogre::Vector3 &point)
Calls beginNewTransition() to move the focus point to the point provided, assumed to be in the Rviz F...
Definition: rviz_animated_view_controller.cpp:737
rviz_animated_view_controller::AnimatedViewController::reset
virtual void reset()
Resets the camera parameters to a sane value.
Definition: rviz_animated_view_controller.cpp:343
view_manager.h
rviz::ViewportMouseEvent::shift
bool shift()
start
ROSCPP_DECL void start()
rviz_animated_view_controller::AnimatedViewController::trajectory_subscriber_
ros::Subscriber trajectory_subscriber_
Definition: rviz_animated_view_controller.h:375
rviz_animated_view_controller::AnimatedViewController::transitionFrom
virtual void transitionFrom(ViewController *previous_view)
Called by ViewManager when this ViewController is being made current.
Definition: rviz_animated_view_controller.cpp:553
rviz::FrameManager::getTransform
bool getTransform(const Header &header, Ogre::Vector3 &position, Ogre::Quaternion &orientation)
rviz::ViewController::getCamera
Ogre::Camera * getCamera() const
rviz::TfFrameProperty::FIXED_FRAME_STRING
static const QString FIXED_FRAME_STRING
geometry.h
ros::Time
rviz::FloatProperty::setFloat
bool setFloat(float new_value)
rviz_animated_view_controller::AnimatedViewController::onFocusPropertyChanged
virtual void onFocusPropertyChanged()
Called focus property is changed; computes new distance.
Definition: rviz_animated_view_controller.cpp:260
rviz_animated_view_controller::AnimatedViewController::rendered_frames_counter_
int rendered_frames_counter_
Definition: rviz_animated_view_controller.h:384
rviz::ViewController
rviz::ViewController::camera_
Ogre::Camera * camera_
rviz_animated_view_controller::AnimatedViewController::yaw_pitch_roll
void yaw_pitch_roll(float yaw, float pitch, float roll)
Applies a body-fixed-axes sequence of rotations; only accurate for small angles.
Definition: rviz_animated_view_controller.cpp:934
rviz_animated_view_controller::AnimatedViewController::transformCameraToAttachedFrame
void transformCameraToAttachedFrame(geometry_msgs::PointStamped &eye, geometry_msgs::PointStamped &focus, geometry_msgs::Vector3Stamped &up)
Transforms the camera defined by eye, focus and up into the attached frame.
Definition: rviz_animated_view_controller.cpp:709
rviz_animated_view_controller::AnimatedViewController::mimic
virtual void mimic(ViewController *source_view)
Configure the settings of this view controller to give, as much as possible, a similar view as that g...
Definition: rviz_animated_view_controller.cpp:525
rviz_animated_view_controller::AnimatedViewController::isMovementAvailable
bool isMovementAvailable()
Returns true if buffer contains at least one start and end pose needed for one movement.
Definition: rviz_animated_view_controller.h:213
rviz_animated_view_controller::AnimatedViewController::cameraTrajectoryCallback
void cameraTrajectoryCallback(const view_controller_msgs::CameraTrajectoryConstPtr &ct_ptr)
Initiate camera motion from incoming CameraTrajectory.
Definition: rviz_animated_view_controller.cpp:656
rviz::StringProperty::setStdString
bool setStdString(const std::string &std_str)
rviz::Shape
rviz_animated_view_controller::AnimatedViewController::camera_view_image_publisher_
image_transport::Publisher camera_view_image_publisher_
Definition: rviz_animated_view_controller.h:380
rviz::ViewController::Zoom
Zoom
rviz::Property::changed
void changed()
rviz_animated_view_controller::AnimatedViewController::pauseAnimationOnRequest
void pauseAnimationOnRequest()
Pauses the animation if pause_animation_duration_ is larger than zero.
Definition: rviz_animated_view_controller.cpp:826
rviz::TfFrameProperty::setFrameManager
void setFrameManager(FrameManager *frame_manager)
target_frame
std::string target_frame
rviz_animated_view_controller::AnimatedViewController::transition_start_time_
ros::WallTime transition_start_time_
Definition: rviz_animated_view_controller.h:366
rviz_animated_view_controller::AnimatedViewController::move_focus_and_eye
void move_focus_and_eye(float x, float y, float z)
Applies a translation to the focus and eye points.
Definition: rviz_animated_view_controller.cpp:981
sensor_msgs::image_encodings::BGR8
const std::string BGR8
rviz_animated_view_controller::AnimatedViewController::convertImage
void convertImage(std::shared_ptr< Ogre::PixelBox > input_image, sensor_msgs::ImagePtr output_image)
Definition: rviz_animated_view_controller.cpp:900
rviz_animated_view_controller::AnimatedViewController::fixedFrameToAttachedLocal
Ogre::Vector3 fixedFrameToAttachedLocal(const Ogre::Vector3 &v)
Definition: rviz_animated_view_controller.h:325
rviz::VectorProperty
rviz_animated_view_controller::AnimatedViewController::publish_view_images_property_
rviz::BoolProperty * publish_view_images_property_
If True, the camera view is published as images.
Definition: rviz_animated_view_controller.h:356
rviz_animated_view_controller::AnimatedViewController::computeRelativeProgressInSpace
float computeRelativeProgressInSpace(double relative_progress_in_time, uint8_t interpolation_speed)
Convert the relative progress in time to the corresponding relative progress in space wrt....
Definition: rviz_animated_view_controller.cpp:852
DurationBase< Duration >::toSec
double toSec() const
rviz_animated_view_controller::AnimatedViewController::connectPositionProperties
void connectPositionProperties()
Convenience function; connects the signals/slots for position properties.
Definition: rviz_animated_view_controller.cpp:239
rviz_animated_view_controller::AnimatedViewController::camera_placement_topic_property_
rviz::RosTopicProperty * camera_placement_topic_property_
Definition: rviz_animated_view_controller.h:350
ros::WallDuration
rviz::Shape::setScale
void setScale(const Ogre::Vector3 &scale) override
rviz::ViewController::setCursor
void setCursor(CursorType cursor_type)
vector_property.h
rviz_animated_view_controller::AnimatedViewController::prepareNextMovement
void prepareNextMovement(const ros::Duration &previous_transition_duration)
Updates the transition_start_time_ and resets the rendered_frames_counter_ for next movement.
Definition: rviz_animated_view_controller.cpp:919
rviz_animated_view_controller::AnimatedViewController::OgreCameraMovement
Definition: rviz_animated_view_controller.h:85
rviz::ViewController::MoveXY
MoveXY
rviz_animated_view_controller::AnimatedViewController::initializeSubscribers
void initializeSubscribers()
Definition: rviz_animated_view_controller.cpp:185
rviz::ViewController::Rotate3D
Rotate3D
rviz::ViewController::getClassId
virtual QString getClassId() const
rviz_animated_view_controller::AnimatedViewController::dragging_
bool dragging_
A flag indicating the dragging state of the mouse.
Definition: rviz_animated_view_controller.h:370
rviz::VectorProperty::getVector
virtual Ogre::Vector3 getVector() const
rviz_animated_view_controller
Definition: rviz_animated_view_controller.h:73
rviz::ViewController::setStatus
void setStatus(const QString &message)
rviz::Shape::setPosition
void setPosition(const Ogre::Vector3 &position) override
rviz_animated_view_controller::AnimatedViewController::updateAttachedFrame
virtual void updateAttachedFrame()
Called when Target Frame property changes while view is active. Purpose is to change values in the vi...
Definition: rviz_animated_view_controller.cpp:290
ros::Duration
rviz_animated_view_controller::AnimatedViewController::initializePublishers
void initializePublishers()
Definition: rviz_animated_view_controller.cpp:176
rviz_animated_view_controller::AnimatedViewController::publishViewImage
void publishViewImage()
Publish the rendered image that is visible to the user in rviz.
Definition: rviz_animated_view_controller.cpp:869
DurationBase< WallDuration >::sec
int32_t sec
rviz::VectorProperty::add
bool add(const Ogre::Vector3 &offset)
ros_topic_property.h
DurationBase< Duration >::isZero
bool isZero() const
rviz_animated_view_controller::AnimatedViewController::onInitialize
virtual void onInitialize()
Do subclass-specific initialization. Called by ViewController::initialize after context_ and camera_ ...
Definition: rviz_animated_view_controller.cpp:197
rviz::ViewController::MoveZ
MoveZ
rviz_animated_view_controller::AnimatedViewController::window_height_property_
rviz::FloatProperty * window_height_property_
The height of the rviz visualization window in pixels.
Definition: rviz_animated_view_controller.h:354
uniform_string_stream.h
ros::Time::now
static Time now()
display_context.h


rviz_animated_view_controller
Author(s): Adam Leeper
autogenerated on Wed Mar 2 2022 01:03:32