frame_position_tracking_view_controller.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, 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 #include <OgreCamera.h>
31 #include <OgreSceneManager.h>
32 #include <OgreSceneNode.h>
33 
34 #include <rviz/display_context.h>
35 #include <rviz/frame_manager.h>
39 #include <rviz/view_manager.h>
40 
42 
43 namespace rviz
44 {
46 {
49  "TF frame whose motion this view will follow.", this, nullptr, true);
50 }
51 
53 {
55 
56  target_scene_node_ = context_->getSceneManager()->getRootSceneNode()->createChildSceneNode();
57  camera_->detachFromParent();
58  target_scene_node_->attachObject(camera_);
59 }
60 
62 {
63  context_->getSceneManager()->destroySceneNode(target_scene_node_);
64 }
65 
67 {
69 
70  // Before activation, changes to target frame property should have
71  // no side-effects. After activation, changing target frame
72  // property has the side effect (typically) of changing an offset
73  // property so that the view does not jump. Therefore we make the
74  // signal/slot connection from the property here in onActivate()
75  // instead of in the constructor.
78 }
79 
80 void FramePositionTrackingViewController::update(float /*dt*/, float /*ros_dt*/)
81 {
83 }
84 
86 {
87  Ogre::Vector3 old_position = target_scene_node_->getPosition();
88  Ogre::Quaternion old_orientation = target_scene_node_->getOrientation();
89 
91 
92  onTargetFrameChanged(old_position, old_orientation);
93 }
94 
96 {
97  Ogre::Vector3 new_reference_position;
98  Ogre::Quaternion new_reference_orientation;
99 
100  bool got_transform =
102  new_reference_position, new_reference_orientation);
103  if (got_transform)
104  {
105  reference_position_ = new_reference_position;
106  reference_orientation_ = new_reference_orientation;
107  }
108  return got_transform;
109 }
110 
112 {
113  if (getNewTransform())
114  {
116 
118  }
119 
120  // Need to incorporate this functionality somehow.... Maybe right into TfFrameProperty itself.
132 }
133 
135 {
136  QVariant target_frame = source_view->subProp("Target Frame")->getValue();
137  if (target_frame.isValid())
138  {
140  }
141 }
142 
143 } // end namespace rviz
rviz::FramePositionTrackingViewController::reference_position_
Ogre::Vector3 reference_position_
Definition: frame_position_tracking_view_controller.h:101
view_manager.h
frame_manager.h
rviz::DisplayContext::queueRender
virtual void queueRender()=0
Queues a render. Multiple calls before a render happens will only cause a single render.
rviz::FramePositionTrackingViewController::updateTargetFrame
virtual void updateTargetFrame()
Called when Target Frame property changes while view is active. Purpose is to change values in the vi...
Definition: frame_position_tracking_view_controller.cpp:85
rviz::FramePositionTrackingViewController::updateTargetSceneNode
virtual void updateTargetSceneNode()
Update the position of the target_scene_node_ from the TF frame specified in the Target Frame propert...
Definition: frame_position_tracking_view_controller.cpp:111
viewport_mouse_event.h
rviz::TfFrameProperty::getFrameStd
std::string getFrameStd() const
Definition: tf_frame_property.cpp:109
rviz::Property::subProp
virtual Property * subProp(const QString &sub_name)
Return the first child Property with the given name, or the FailureProperty if no child has the name.
Definition: property.cpp:179
rviz::TfFrameProperty::setValue
bool setValue(const QVariant &new_value) override
Override from Property to resolve the frame name on the way in.
Definition: tf_frame_property.cpp:55
rviz::Property::getValue
virtual QVariant getValue() const
Return the value of this Property as a QVariant. If the value has never been set, an invalid QVariant...
Definition: property.cpp:150
rviz::DisplayContext::getSceneManager
virtual Ogre::SceneManager * getSceneManager() const =0
Returns the Ogre::SceneManager used for the main RenderPanel.
rviz::ViewController::context_
DisplayContext * context_
Definition: view_controller.h:225
rviz::Property::connect
QMetaObject::Connection connect(const QObject *receiver, const char *slot, Qt::ConnectionType type=Qt::AutoConnection)
Connect changed() signal to given slot of receiver.
Definition: property.cpp:78
frame_position_tracking_view_controller.h
rviz::FramePositionTrackingViewController::onInitialize
void onInitialize() override
Do subclass-specific initialization.
Definition: frame_position_tracking_view_controller.cpp:52
rviz
Definition: add_display_dialog.cpp:54
rviz::FramePositionTrackingViewController::~FramePositionTrackingViewController
~FramePositionTrackingViewController() override
Definition: frame_position_tracking_view_controller.cpp:61
rviz::FramePositionTrackingViewController::target_frame_property_
TfFrameProperty * target_frame_property_
Definition: frame_position_tracking_view_controller.h:98
rviz::FramePositionTrackingViewController::reference_orientation_
Ogre::Quaternion reference_orientation_
Definition: frame_position_tracking_view_controller.h:100
rviz::FramePositionTrackingViewController::getNewTransform
bool getNewTransform()
Definition: frame_position_tracking_view_controller.cpp:95
rviz::DisplayContext::getFrameManager
virtual FrameManager * getFrameManager() const =0
Return the FrameManager instance.
rviz::TfFrameProperty
Definition: tf_frame_property.h:41
rviz::FramePositionTrackingViewController::mimic
void mimic(ViewController *source_view) override
Configure the settings of this view controller to give, as much as possible, a similar view as that g...
Definition: frame_position_tracking_view_controller.cpp:134
tf_frame_property.h
rviz::FrameManager::getTransform
bool getTransform(const Header &header, Ogre::Vector3 &position, Ogre::Quaternion &orientation)
Return the pose for a header, relative to the fixed frame, in Ogre classes.
Definition: frame_manager.h:125
rviz::TfFrameProperty::FIXED_FRAME_STRING
static const QString FIXED_FRAME_STRING
Definition: tf_frame_property.h:92
ros::Time
rviz::FramePositionTrackingViewController::FramePositionTrackingViewController
FramePositionTrackingViewController()
Definition: frame_position_tracking_view_controller.cpp:45
rviz::ViewController
Definition: view_controller.h:55
rviz::FramePositionTrackingViewController::update
void update(float dt, float ros_dt) override
Called at 30Hz by ViewManager::update() while this view is active. Override with code that needs to r...
Definition: frame_position_tracking_view_controller.cpp:80
rviz::ViewController::camera_
Ogre::Camera * camera_
Definition: view_controller.h:226
rviz::FramePositionTrackingViewController::onTargetFrameChanged
virtual void onTargetFrameChanged(const Ogre::Vector3 &, const Ogre::Quaternion &)
Override to implement the change in properties which nullifies the change in target frame.
Definition: frame_position_tracking_view_controller.h:87
rviz::Property::changed
void changed()
Emitted by setValue() just after the value has changed.
rviz::TfFrameProperty::setFrameManager
void setFrameManager(FrameManager *frame_manager)
Definition: tf_frame_property.cpp:67
target_frame
std::string target_frame
display_context.h
rviz::FramePositionTrackingViewController::onActivate
void onActivate() override
called by activate().
Definition: frame_position_tracking_view_controller.cpp:66
rviz::FramePositionTrackingViewController::target_scene_node_
Ogre::SceneNode * target_scene_node_
Definition: frame_position_tracking_view_controller.h:99
enum_property.h


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust, William Woodall
autogenerated on Fri Dec 13 2024 03:31:02