camera_display.h
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 #ifndef RVIZ_CAMERA_DISPLAY_H
31 #define RVIZ_CAMERA_DISPLAY_H
32 
33 #include <memory>
34 
35 #include <QObject>
36 
37 #ifndef Q_MOC_RUN
38 #include <OgreMaterial.h>
39 #include <OgreRenderTargetListener.h>
40 #include <OgreSharedPtr.h>
41 
42 #include <sensor_msgs/CameraInfo.h>
43 
45 #include <tf2_ros/message_filter.h>
46 
49 #include "rviz/render_panel.h"
50 #endif
51 
52 namespace Ogre
53 {
54 class SceneNode;
55 class ManualObject;
56 class Rectangle2D;
57 class Camera;
58 } // namespace Ogre
59 
60 namespace rviz
61 {
62 class EnumProperty;
63 class FloatProperty;
64 class IntProperty;
65 class RenderPanel;
66 class RosTopicProperty;
67 class DisplayGroupVisibilityProperty;
68 
73 class CameraDisplay : public ImageDisplayBase, public Ogre::RenderTargetListener
74 {
75  Q_OBJECT
76 public:
77  CameraDisplay();
78  ~CameraDisplay() override;
79 
80  // Overrides from Display
81  void onInitialize() override;
82  void fixedFrameChanged() override;
83  void update(float wall_dt, float ros_dt) override;
84  void reset() override;
85 
86  // Overrides from Ogre::RenderTargetListener
87  void preRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) override;
88  void postRenderTargetUpdate(const Ogre::RenderTargetEvent& evt) override;
89 
90  static const QString BACKGROUND;
91  static const QString OVERLAY;
92  static const QString BOTH;
93 
94 protected:
95  // overrides from Display
96  void onEnable() override;
97  void onDisable() override;
98 
101 
102 private Q_SLOTS:
103  void forceRender();
104  void updateAlpha();
105 
106  void updateQueueSize() override;
107 
108 private:
109  void subscribe() override;
110  void unsubscribe() override;
111 
112  void processMessage(const sensor_msgs::Image::ConstPtr& msg) override;
113  void caminfoCallback(const sensor_msgs::CameraInfo::ConstPtr& msg);
114 
115  bool updateCamera();
116 
117  void clear();
118  void updateStatus();
119 
120  Ogre::SceneNode* bg_scene_node_;
121  Ogre::SceneNode* fg_scene_node_;
122 
123  Ogre::Rectangle2D* bg_screen_rect_;
124  Ogre::MaterialPtr bg_material_;
125 
126  Ogre::Rectangle2D* fg_screen_rect_;
127  Ogre::MaterialPtr fg_material_;
128 
130  std::unique_ptr<tf2_ros::MessageFilter<sensor_msgs::CameraInfo>> caminfo_tf_filter_;
131 
136 
137  sensor_msgs::CameraInfo::ConstPtr current_caminfo_;
138  boost::mutex caminfo_mutex_;
139 
141 
143 
145 
146  uint32_t vis_bit_;
147 };
148 
149 } // namespace rviz
150 
151 #endif
FloatProperty * alpha_property_
sensor_msgs::CameraInfo::ConstPtr current_caminfo_
Ogre::SceneNode * bg_scene_node_
static const QString OVERLAY
static const QString BOTH
RenderPanel * render_panel_
Ogre::SceneNode * fg_scene_node_
Property specialized to enforce floating point max/min.
boost::mutex caminfo_mutex_
void update(const std::string &key, const XmlRpc::XmlRpcValue &v)
void subscribe()
EnumProperty * image_position_property_
Display subclass for subscribing and displaying to image messages.
Ogre::Rectangle2D * fg_screen_rect_
DisplayGroupVisibilityProperty * visibility_property_
FloatProperty * zoom_property_
Ogre::MaterialPtr fg_material_
static const QString BACKGROUND
Ogre::Rectangle2D * bg_screen_rect_
std::unique_ptr< tf2_ros::MessageFilter< sensor_msgs::CameraInfo > > caminfo_tf_filter_
void unsubscribe()
message_filters::Subscriber< sensor_msgs::CameraInfo > caminfo_sub_
Ogre::MaterialPtr bg_material_
ROSImageTexture texture_
Enum property.
Definition: enum_property.h:46


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Sat May 27 2023 02:06:24