overlay_camera_display.h
Go to the documentation of this file.
1 // -*- mode: c++; -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_RVIZ_PLUGINS_OVERLAY_CAMERA_DISPLAY_H_
37 #define JSK_RVIZ_PLUGINS_OVERLAY_CAMERA_DISPLAY_H_
38 
40 
41 #ifndef Q_MOC_RUN
42 #include <QObject>
43 
44 #include <OgreMaterial.h>
45 #include <OgreRenderTargetListener.h>
46 #include <OgreSharedPtr.h>
47 
48 # include <sensor_msgs/CameraInfo.h>
49 
51 #if ROS_VERSION_MINIMUM(1, 15, 0) // noetic and greater
52 # include <tf2_ros/message_filter.h>
53 #else
54 # include <tf/message_filter.h>
55 #endif
56 
59 # include "rviz/render_panel.h"
60 
61 #include "overlay_utils.h"
62 #endif
63 
64 namespace Ogre
65 {
66 class SceneNode;
67 class ManualObject;
68 class Rectangle2D;
69 class Camera;
70 }
71 
72 namespace rviz
73 {
74 
75 class EnumProperty;
76 class FloatProperty;
77 class IntProperty;
78 class RenderPanel;
79 class RosTopicProperty;
80 class DisplayGroupVisibilityProperty;
81 }
86 namespace jsk_rviz_plugins
87 {
88 using namespace rviz;
89 class OverlayCameraDisplay: public rviz::ImageDisplayBase, public Ogre::RenderTargetListener
90 {
91 Q_OBJECT
92 public:
94  virtual ~OverlayCameraDisplay();
95 
96  // Overrides from Display
97  virtual void onInitialize();
98  virtual void fixedFrameChanged();
99  virtual void update( float wall_dt, float ros_dt );
100  virtual void reset();
101 
102  // Overrides from Ogre::RenderTargetListener
103  virtual void preRenderTargetUpdate( const Ogre::RenderTargetEvent& evt );
104  virtual void postRenderTargetUpdate( const Ogre::RenderTargetEvent& evt );
105 
106  static const QString BACKGROUND;
107  static const QString OVERLAY;
108  static const QString BOTH;
109 
110 protected:
111  // overrides from Display
112  virtual void onEnable();
113  virtual void onDisable();
114 
117 
118 private Q_SLOTS:
119  void forceRender();
120  void updateAlpha();
121 
122  virtual void updateQueueSize();
123 
124 private:
125  void subscribe();
126  void unsubscribe();
127 
128  virtual void processMessage(const sensor_msgs::Image::ConstPtr& msg);
129  void caminfoCallback( const sensor_msgs::CameraInfo::ConstPtr& msg );
130 
131  bool updateCamera();
132 
133  void clear();
134  void updateStatus();
135 
136  Ogre::SceneNode* bg_scene_node_;
137  Ogre::SceneNode* fg_scene_node_;
138 
139  Ogre::Rectangle2D* bg_screen_rect_;
140  Ogre::MaterialPtr bg_material_;
141 
142  Ogre::Rectangle2D* fg_screen_rect_;
143  Ogre::MaterialPtr fg_material_;
144 
146 #if ROS_VERSION_MINIMUM(1, 15, 0) // noetic and greater
148 #else
150 #endif
151 
156 
157  sensor_msgs::CameraInfo::ConstPtr current_caminfo_;
158  boost::mutex caminfo_mutex_;
159 
161 
163 
165 
166  uint32_t vis_bit_;
167 protected:
169  void redraw();
175  int width_, height_;
176  int left_, top_;
179 private Q_SLOTS:
180  void updateWidth();
181  void updateHeight();
182  void updateLeft();
183  void updateTop();
184  void updateTextureAlpha();
185 };
186 
187 }
188 
189 #endif
jsk_rviz_plugins::OverlayCameraDisplay::render_panel_
RenderPanel * render_panel_
Definition: overlay_camera_display.h:116
jsk_rviz_plugins::OverlayCameraDisplay
Definition: overlay_camera_display.h:89
jsk_rviz_plugins::OverlayCameraDisplay::overlay_
OverlayObject::Ptr overlay_
Definition: overlay_camera_display.h:168
unsubscribe
void unsubscribe()
jsk_rviz_plugins::OverlayCameraDisplay::OVERLAY
static const QString OVERLAY
Definition: overlay_camera_display.h:107
jsk_rviz_plugins::OverlayCameraDisplay::top_
int top_
Definition: overlay_camera_display.h:176
Ogre
tf2_ros::MessageFilter
jsk_rviz_plugins::OverlayCameraDisplay::bg_screen_rect_
Ogre::Rectangle2D * bg_screen_rect_
Definition: overlay_camera_display.h:139
boost::shared_ptr< OverlayObject >
jsk_rviz_plugins::OverlayCameraDisplay::height_property_
rviz::IntProperty * height_property_
Definition: overlay_camera_display.h:171
jsk_rviz_plugins::OverlayCameraDisplay::texture_alpha_property_
rviz::FloatProperty * texture_alpha_property_
Definition: overlay_camera_display.h:174
jsk_rviz_plugins::OverlayCameraDisplay::texture_
ROSImageTexture texture_
Definition: overlay_camera_display.h:115
jsk_rviz_plugins::OverlayCameraDisplay::left_property_
rviz::IntProperty * left_property_
Definition: overlay_camera_display.h:172
rviz::ROSImageTexture
jsk_rviz_plugins::OverlayCameraDisplay::bg_scene_node_
Ogre::SceneNode * bg_scene_node_
Definition: overlay_camera_display.h:136
jsk_rviz_plugins::OverlayCameraDisplay::caminfo_ok_
bool caminfo_ok_
Definition: overlay_camera_display.h:162
update
bool update(const T &new_val, T &my_val)
jsk_rviz_plugins::OverlayCameraDisplay::top_property_
rviz::IntProperty * top_property_
Definition: overlay_camera_display.h:173
jsk_rviz_plugins::OverlayCameraDisplay::caminfo_sub_
message_filters::Subscriber< sensor_msgs::CameraInfo > caminfo_sub_
Definition: overlay_camera_display.h:145
jsk_rviz_plugins::OverlayCameraDisplay::alpha_property_
FloatProperty * alpha_property_
Definition: overlay_camera_display.h:152
jsk_rviz_plugins::OverlayCameraDisplay::texture_alpha_
float texture_alpha_
Definition: overlay_camera_display.h:177
jsk_rviz_plugins::OverlayCameraDisplay::visibility_property_
DisplayGroupVisibilityProperty * visibility_property_
Definition: overlay_camera_display.h:155
jsk_rviz_plugins::OverlayCameraDisplay::caminfo_tf_filter_
tf::MessageFilter< sensor_msgs::CameraInfo > * caminfo_tf_filter_
Definition: overlay_camera_display.h:149
jsk_rviz_plugins::OverlayCameraDisplay::vis_bit_
uint32_t vis_bit_
Definition: overlay_camera_display.h:166
message_filters::Subscriber< sensor_msgs::CameraInfo >
rviz::EnumProperty
jsk_rviz_plugins::OverlayCameraDisplay::bg_material_
Ogre::MaterialPtr bg_material_
Definition: overlay_camera_display.h:140
rviz::FloatProperty
overlay_utils.h
jsk_rviz_plugins::OverlayCameraDisplay::fg_screen_rect_
Ogre::Rectangle2D * fg_screen_rect_
Definition: overlay_camera_display.h:142
jsk_rviz_plugins::OverlayCameraDisplay::initializedp_
bool initializedp_
Definition: overlay_camera_display.h:178
message_filter.h
render_panel.h
rviz
jsk_rviz_plugins::OverlayCameraDisplay::BOTH
static const QString BOTH
Definition: overlay_camera_display.h:108
subscriber.h
subscribe
void subscribe()
jsk_rviz_plugins::OverlayCameraDisplay::width_
int width_
Definition: overlay_camera_display.h:175
jsk_rviz_plugins::OverlayCameraDisplay::force_render_
bool force_render_
Definition: overlay_camera_display.h:164
jsk_rviz_plugins::OverlayCameraDisplay::fg_scene_node_
Ogre::SceneNode * fg_scene_node_
Definition: overlay_camera_display.h:137
rviz::ImageDisplayBase
jsk_rviz_plugins::OverlayCameraDisplay::fg_material_
Ogre::MaterialPtr fg_material_
Definition: overlay_camera_display.h:143
image_display_base.h
jsk_rviz_plugins::OverlayCameraDisplay::BACKGROUND
static const QString BACKGROUND
Definition: overlay_camera_display.h:106
tf::MessageFilter< sensor_msgs::CameraInfo >
jsk_rviz_plugins::OverlayCameraDisplay::image_position_property_
EnumProperty * image_position_property_
Definition: overlay_camera_display.h:153
rviz::RenderPanel
jsk_rviz_plugins::OverlayCameraDisplay::current_caminfo_
sensor_msgs::CameraInfo::ConstPtr current_caminfo_
Definition: overlay_camera_display.h:157
jsk_rviz_plugins::OverlayCameraDisplay::caminfo_mutex_
boost::mutex caminfo_mutex_
Definition: overlay_camera_display.h:158
ros_image_texture.h
jsk_rviz_plugins::OverlayCameraDisplay::width_property_
rviz::IntProperty * width_property_
Definition: overlay_camera_display.h:170
jsk_rviz_plugins
Definition: __init__.py:1
camera_display.h
jsk_rviz_plugins::OverlayCameraDisplay::zoom_property_
FloatProperty * zoom_property_
Definition: overlay_camera_display.h:154
rviz::IntProperty
jsk_rviz_plugins::OverlayCameraDisplay::new_caminfo_
bool new_caminfo_
Definition: overlay_camera_display.h:160
rviz::DisplayGroupVisibilityProperty


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Aug 2 2024 08:50:14