OrbitOrientedViewController.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
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  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
29 
30 #include <OgreCamera.h>
31 #include <OgreQuaternion.h>
32 #include <OgreSceneManager.h>
33 #include <OgreSceneNode.h>
34 #include <OgreVector3.h>
35 #include <OgreViewport.h>
36 
40 
41 namespace rtabmap_rviz_plugins
42 {
43 
45 {
47  float yaw = yaw_property_->getFloat();
48  float pitch = pitch_property_->getFloat();
49 
50  Ogre::Matrix3 rot;
51  reference_orientation_.ToRotationMatrix(rot);
52  Ogre::Radian rollTarget, pitchTarget, yawTarget;
53  rot.ToEulerAnglesXYZ(yawTarget, pitchTarget, rollTarget);
54 
55  yaw += rollTarget.valueRadians();
56  pitch += pitchTarget.valueRadians();
57 
58  Ogre::Vector3 focal_point = focal_point_property_->getVector();
59 
60  float x = distance * cos( yaw ) * cos( pitch ) + focal_point.x;
61  float y = distance * sin( yaw ) * cos( pitch ) + focal_point.y;
62  float z = distance * sin( pitch ) + focal_point.z;
63 
64  Ogre::Vector3 pos( x, y, z );
65 
66  camera_->setPosition(pos);
67  camera_->setFixedYawAxis(true, target_scene_node_->getOrientation() * Ogre::Vector3::UNIT_Z);
68  camera_->setDirection(target_scene_node_->getOrientation() * (focal_point - pos));
69 
70  focal_shape_->setPosition( focal_point );
71 }
72 
73 }
74 
rviz::OrbitViewController::yaw
void yaw(float angle)
rviz::OrbitViewController::focal_point_property_
VectorProperty * focal_point_property_
rtabmap_rviz_plugins::OrbitOrientedViewController::updateCamera
virtual void updateCamera()
Definition: OrbitOrientedViewController.cpp:44
rviz::OrbitViewController::distance_property_
FloatProperty * distance_property_
rtabmap_rviz_plugins
Definition: InfoDisplay.h:37
y
Matrix3f y
distance
GLM_FUNC_DECL genType::value_type distance(genType const &p0, genType const &p1)
rot
int EIGEN_BLAS_FUNC() rot(int *n, RealScalar *px, int *incx, RealScalar *py, int *incy, RealScalar *pc, RealScalar *ps)
shape.h
float_property.h
rviz::OrbitViewController::focal_shape_
Shape * focal_shape_
rtabmap_rviz_plugins::OrbitOrientedViewController
Definition: OrbitOrientedViewController.h:36
PLUGINLIB_EXPORT_CLASS
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)
rviz::OrbitViewController::pitch_property_
FloatProperty * pitch_property_
rviz::FloatProperty::getFloat
virtual float getFloat() const
OrbitOrientedViewController.h
rviz::OrbitViewController::pitch
void pitch(float angle)
rviz::FramePositionTrackingViewController::reference_orientation_
Ogre::Quaternion reference_orientation_
z
z
x
x
rviz::OrbitViewController::yaw_property_
FloatProperty * yaw_property_
rviz::ViewController
rviz::ViewController::camera_
Ogre::Camera * camera_
cos
GLM_FUNC_DECL genType cos(genType const &angle)
class_list_macros.hpp
vector_property.h
pos
rviz::VectorProperty::getVector
virtual Ogre::Vector3 getVector() const
rviz::Shape::setPosition
void setPosition(const Ogre::Vector3 &position) override
sin
GLM_FUNC_DECL genType sin(genType const &angle)
rviz::FramePositionTrackingViewController::target_scene_node_
Ogre::SceneNode * target_scene_node_


rtabmap_rviz_plugins
Author(s): Mathieu Labbe
autogenerated on Mon Apr 28 2025 02:37:14