camera_info_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/o2r 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 
37 #ifndef JSK_RVIZ_PLUGINS_CAMERA_INFO_DISPLAY_H_
38 #define JSK_RVIZ_PLUGINS_CAMERA_INFO_DISPLAY_H_
39 
40 #ifndef Q_MOC_RUN
41 #include <rviz/display.h>
49 #include <OGRE/OgreSceneNode.h>
51 #include <sensor_msgs/Image.h>
52 #include <OGRE/OgreManualObject.h>
53 #include <OGRE/OgreSceneManager.h>
54 #include <OGRE/OgreTextureManager.h>
55 #include <OGRE/OgreTexture.h>
56 #include <cv_bridge/cv_bridge.h>
59 
61 #endif
62 
63 namespace jsk_rviz_plugins
64 {
66  {
67  public:
68 #if ROS_VERSION_MINIMUM(1,12,0)
69  typedef std::shared_ptr<TrianglePolygon> Ptr;
70 #else
72 #endif
73  TrianglePolygon(Ogre::SceneManager* manager,
74  Ogre::SceneNode* node,
75  const cv::Point3d& O,
76  const cv::Point3d& A,
77  const cv::Point3d& B,
78  const std::string& name,
79  const Ogre::ColourValue& color,
80  bool use_color,
81  bool upper_triangle);
82  virtual ~TrianglePolygon();
83  protected:
84  Ogre::ManualObject* manual_;
85  Ogre::SceneManager* manager_;
86  private:
87 
88  };
89 
91  public rviz::MessageFilterDisplay<sensor_msgs::CameraInfo>
92  {
93  Q_OBJECT
94  public:
95 #if ROS_VERSION_MINIMUM(1,12,0)
96  typedef std::shared_ptr<rviz::Shape> ShapePtr;
97  typedef std::shared_ptr<rviz::BillboardLine> BillboardLinePtr;
98 #else
101 #endif
103  virtual ~CameraInfoDisplay();
104 
105  protected:
107  // methods required by super virtual class
109  virtual void onInitialize();
110  virtual void reset();
111  virtual void processMessage(const sensor_msgs::CameraInfo::ConstPtr& msg);
113  // methods
115  virtual void update(float wall_dt, float ros_dt);
116  virtual bool isSameCameraInfo(
117  const sensor_msgs::CameraInfo::ConstPtr& camera_info);
118  virtual void createCameraInfoShapes(
119  const sensor_msgs::CameraInfo::ConstPtr& camera_info);
120  virtual void addPointToEdge(
121  const cv::Point3d& point);
122  virtual void addPolygon(
123  const cv::Point3d& O, const cv::Point3d& A, const cv::Point3d& B, std::string name,
124  bool use_color, bool upper_triangle);
125  virtual void prepareMaterial();
126  virtual void createTextureForBottom(int width, int height);
127  virtual void imageCallback(const sensor_msgs::Image::ConstPtr& msg);
128  virtual void drawImageTexture();
129  virtual void subscribeImage(std::string topic);
131  // variables
133  std::vector<TrianglePolygon::Ptr> polygons_;
134  BillboardLinePtr edges_;
135  sensor_msgs::CameraInfo::ConstPtr camera_info_;
136  Ogre::MaterialPtr material_;
137  Ogre::TexturePtr texture_;
138  Ogre::MaterialPtr material_bottom_;
139  Ogre::TexturePtr bottom_texture_;
141  boost::mutex mutex_;
143  // variables updated by rviz properties
145  double alpha_;
147  QColor color_;
148  QColor edge_color_;
154  cv::Mat image_;
156  // properties
168 
169  protected Q_SLOTS:
170  void updateFarClipDistance();
171  void updateAlpha();
172  void updateColor();
173  void updateShowEdges();
174  void updateShowPolygons();
175  void updateNotShowSidePolygons();
176  void updateImageTopic();
177  void updateUseImage();
178  void updateEdgeColor();
179  };
180 
181 }
182 
183 #endif
boost::shared_ptr< rviz::Shape > ShapePtr
rviz::RosTopicProperty * image_topic_property_
image_transport::Subscriber image_sub_
bool update(const T &new_val, T &my_val)
sensor_msgs::CameraInfo::ConstPtr camera_info_
void imageCallback(const sensor_msgs::ImageConstPtr &msg)
boost::shared_ptr< TrianglePolygon > Ptr
ImageTransportHintsProperty * image_transport_hints_property_
boost::shared_ptr< rviz::BillboardLine > BillboardLinePtr
std::vector< TrianglePolygon::Ptr > polygons_
TrianglePolygon(Ogre::SceneManager *manager, Ogre::SceneNode *node, const cv::Point3d &O, const cv::Point3d &A, const cv::Point3d &B, const std::string &name, const Ogre::ColourValue &color, bool use_color, bool upper_triangle)
rviz::FloatProperty * far_clip_distance_property_
rviz::BoolProperty * not_show_side_polygons_property_


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Sat Mar 20 2021 03:03:18