camera_info_display.h
Go to the documentation of this file.
00001 // -*- mode: c++ -*-
00002 /*********************************************************************
00003  * Software License Agreement (BSD License)
00004  *
00005  *  Copyright (c) 2014, JSK Lab
00006  *  All rights reserved.
00007  *
00008  *  Redistribution and use in source and binary forms, with or without
00009  *  modification, are permitted provided that the following conditions
00010  *  are met:
00011  *
00012  *   * Redistributions of source code must retain the above copyright
00013  *     notice, this list of conditions and the following disclaimer.
00014  *   * Redistributions in binary form must reproduce the above
00015  *     copyright notice, this list of conditions and the following
00016  *     disclaimer in the documentation and/o2r other materials provided
00017  *     with the distribution.
00018  *   * Neither the name of the JSK Lab nor the names of its
00019  *     contributors may be used to endorse or promote products derived
00020  *     from this software without specific prior written permission.
00021  *
00022  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025  *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026  *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027  *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028  *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029  *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030  *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031  *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032  *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033  *  POSSIBILITY OF SUCH DAMAGE.
00034  *********************************************************************/
00035 
00036 
00037 #ifndef JSK_RVIZ_PLUGINS_CAMERA_INFO_DISPLAY_H_
00038 #define JSK_RVIZ_PLUGINS_CAMERA_INFO_DISPLAY_H_
00039 
00040 #ifndef Q_MOC_RUN
00041 #include <rviz/display.h>
00042 #include <rviz/message_filter_display.h>
00043 #include <rviz/properties/color_property.h>
00044 #include <rviz/properties/bool_property.h>
00045 #include <rviz/properties/float_property.h>
00046 #include <rviz/properties/ros_topic_property.h>
00047 #include <rviz/ogre_helpers/shape.h>
00048 #include <rviz/ogre_helpers/billboard_line.h>
00049 #include <OGRE/OgreSceneNode.h>
00050 #include <image_geometry/pinhole_camera_model.h>
00051 #include <sensor_msgs/Image.h>
00052 #include <OGRE/OgreManualObject.h>
00053 #include <OGRE/OgreTextureManager.h>
00054 #include <OGRE/OgreTexture.h>
00055 #include <cv_bridge/cv_bridge.h>
00056 #include <sensor_msgs/image_encodings.h>
00057 #include <image_transport/subscriber.h>
00058 
00059 #include "image_transport_hints_property.h"
00060 #endif
00061 
00062 namespace jsk_rviz_plugins
00063 {
00064   class TrianglePolygon
00065   {
00066   public:
00067     typedef std::shared_ptr<TrianglePolygon> Ptr;
00068     TrianglePolygon(Ogre::SceneManager* manager,
00069                     Ogre::SceneNode* node,
00070                     const cv::Point3d& O,
00071                     const cv::Point3d& A,
00072                     const cv::Point3d& B,
00073                     const std::string& name,
00074                     const Ogre::ColourValue& color,
00075                     bool use_color,
00076                     bool upper_triangle);
00077     virtual ~TrianglePolygon();
00078   protected:
00079     Ogre::ManualObject* manual_;
00080     Ogre::SceneManager* manager_;
00081   private:
00082     
00083   };
00084   
00085   class CameraInfoDisplay:
00086     public rviz::MessageFilterDisplay<sensor_msgs::CameraInfo>
00087   {
00088     Q_OBJECT
00089   public:
00090     typedef std::shared_ptr<rviz::Shape> ShapePtr;
00091     typedef std::shared_ptr<rviz::BillboardLine> BillboardLinePtr;
00092     CameraInfoDisplay();
00093     virtual ~CameraInfoDisplay();
00094     
00095   protected:
00097     // methods required by super virtual class
00099     virtual void onInitialize();
00100     virtual void reset();
00101     virtual void processMessage(const sensor_msgs::CameraInfo::ConstPtr& msg);
00103     // methods
00105     virtual void update(float wall_dt, float ros_dt);
00106     virtual bool isSameCameraInfo(
00107       const sensor_msgs::CameraInfo::ConstPtr& camera_info);
00108     virtual void createCameraInfoShapes(
00109       const sensor_msgs::CameraInfo::ConstPtr& camera_info);
00110     virtual void addPointToEdge(
00111       const cv::Point3d& point);
00112     virtual void addPolygon(
00113       const cv::Point3d& O, const cv::Point3d& A, const cv::Point3d& B, std::string name,
00114       bool use_color, bool upper_triangle);
00115     virtual void prepareMaterial();
00116     virtual void createTextureForBottom(int width, int height);
00117     virtual void imageCallback(const sensor_msgs::Image::ConstPtr& msg);
00118     virtual void drawImageTexture();
00119     virtual void subscribeImage(std::string topic);
00121     // variables
00123     std::vector<TrianglePolygon::Ptr> polygons_;
00124     BillboardLinePtr edges_;
00125     sensor_msgs::CameraInfo::ConstPtr camera_info_;
00126     Ogre::MaterialPtr material_;
00127     Ogre::TexturePtr texture_;
00128     Ogre::MaterialPtr material_bottom_;
00129     Ogre::TexturePtr bottom_texture_;
00130     image_transport::Subscriber image_sub_;
00131     boost::mutex mutex_;
00133     // variables updated by rviz properties
00135     double alpha_;
00136     double far_clip_distance_;
00137     QColor color_;
00138     QColor edge_color_;
00139     bool show_polygons_;
00140     bool show_edges_;
00141     bool use_image_;
00142     bool image_updated_;
00143     bool not_show_side_polygons_;
00144     cv::Mat image_;
00146     // properties
00148     ImageTransportHintsProperty* image_transport_hints_property_;
00149     rviz::FloatProperty* far_clip_distance_property_;
00150     rviz::FloatProperty* alpha_property_;
00151     rviz::ColorProperty* color_property_;
00152     rviz::ColorProperty* edge_color_property_;
00153     rviz::BoolProperty* show_polygons_property_;
00154     rviz::BoolProperty* not_show_side_polygons_property_;
00155     rviz::BoolProperty* use_image_property_;
00156     rviz::RosTopicProperty* image_topic_property_;
00157     rviz::BoolProperty* show_edges_property_;
00158     
00159   protected Q_SLOTS:
00160     void updateFarClipDistance();
00161     void updateAlpha();
00162     void updateColor();
00163     void updateShowEdges();
00164     void updateShowPolygons();
00165     void updateNotShowSidePolygons();
00166     void updateImageTopic();
00167     void updateUseImage();
00168     void updateEdgeColor();
00169   };
00170   
00171 }
00172 
00173 #endif


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Wed May 1 2019 02:40:22