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 #include <rviz/display.h>
00041 #include <rviz/message_filter_display.h>
00042 #include <rviz/properties/color_property.h>
00043 #include <rviz/properties/bool_property.h>
00044 #include <rviz/properties/float_property.h>
00045 #include <rviz/properties/ros_topic_property.h>
00046 #include <rviz/ogre_helpers/shape.h>
00047 #include <rviz/ogre_helpers/billboard_line.h>
00048 #include <OGRE/OgreSceneNode.h>
00049 #include <image_geometry/pinhole_camera_model.h>
00050 #include <sensor_msgs/Image.h>
00051 #include <OGRE/OgreManualObject.h>
00052 #include <OGRE/OgreTextureManager.h>
00053 #include <OGRE/OgreTexture.h>
00054 #include <cv_bridge/cv_bridge.h>
00055 #include <sensor_msgs/image_encodings.h>
00056 
00057 namespace jsk_rviz_plugins
00058 {
00059   class TrianglePolygon
00060   {
00061   public:
00062     typedef boost::shared_ptr<TrianglePolygon> Ptr;
00063     TrianglePolygon(Ogre::SceneManager* manager,
00064                     Ogre::SceneNode* node,
00065                     const cv::Point3d& O,
00066                     const cv::Point3d& A,
00067                     const cv::Point3d& B,
00068                     const std::string& name,
00069                     const Ogre::ColourValue& color,
00070                     bool use_color,
00071                     bool upper_triangle);
00072     virtual ~TrianglePolygon();
00073   protected:
00074     Ogre::ManualObject* manual_;
00075     Ogre::SceneManager* manager_;
00076   private:
00077     
00078   };
00079   
00080   class CameraInfoDisplay:
00081     public rviz::MessageFilterDisplay<sensor_msgs::CameraInfo>
00082   {
00083     Q_OBJECT
00084   public:
00085     typedef boost::shared_ptr<rviz::Shape> ShapePtr;
00086     typedef boost::shared_ptr<rviz::BillboardLine> BillboardLinePtr;
00087     CameraInfoDisplay();
00088     virtual ~CameraInfoDisplay();
00089     
00090   protected:
00092     // methods required by super virtual class
00094     virtual void onInitialize();
00095     virtual void reset();
00096     virtual void processMessage(const sensor_msgs::CameraInfo::ConstPtr& msg);
00098     // methods
00100     virtual void update(float wall_dt, float ros_dt);
00101     virtual bool isSameCameraInfo(
00102       const sensor_msgs::CameraInfo::ConstPtr& camera_info);
00103     virtual void createCameraInfoShapes(
00104       const sensor_msgs::CameraInfo::ConstPtr& camera_info);
00105     virtual void addPointToEdge(
00106       const cv::Point3d& point);
00107     virtual void addPolygon(
00108       const cv::Point3d& O, const cv::Point3d& A, const cv::Point3d& B, std::string name,
00109       bool use_color, bool upper_triangle);
00110     virtual void prepareMaterial();
00111     virtual void createTextureForBottom(int width, int height);
00112     virtual void imageCallback(const sensor_msgs::Image::ConstPtr& msg);
00113     virtual void drawImageTexture();
00114     virtual void subscribeImage(std::string topic);
00116     // variables
00118     std::vector<TrianglePolygon::Ptr> polygons_;
00119     BillboardLinePtr edges_;
00120     sensor_msgs::CameraInfo::ConstPtr camera_info_;
00121     Ogre::MaterialPtr material_;
00122     Ogre::TexturePtr texture_;
00123     Ogre::MaterialPtr material_bottom_;
00124     Ogre::TexturePtr bottom_texture_;
00125     ros::Subscriber image_sub_;
00126     boost::mutex mutex_;
00128     // variables updated by rviz properties
00130     double alpha_;
00131     double far_clip_distance_;
00132     QColor color_;
00133     QColor edge_color_;
00134     bool show_polygons_;
00135     bool show_edges_;
00136     bool use_image_;
00137     bool image_updated_;
00138     bool not_show_side_polygons_;
00139     cv::Mat image_;
00141     // properties
00143     rviz::FloatProperty* far_clip_distance_property_;
00144     rviz::FloatProperty* alpha_property_;
00145     rviz::ColorProperty* color_property_;
00146     rviz::ColorProperty* edge_color_property_;
00147     rviz::BoolProperty* show_polygons_property_;
00148     rviz::BoolProperty* not_show_side_polygons_property_;
00149     rviz::BoolProperty* use_image_property_;
00150     rviz::RosTopicProperty* image_topic_property_;
00151     rviz::BoolProperty* show_edges_property_;
00152     
00153   protected Q_SLOTS:
00154     void updateFarClipDistance();
00155     void updateAlpha();
00156     void updateColor();
00157     void updateShowEdges();
00158     void updateShowPolygons();
00159     void updateNotShowSidePolygons();
00160     void updateImageTopic();
00161     void updateUseImage();
00162     void updateEdgeColor();
00163   };
00164   
00165 }
00166 
00167 #endif


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Sun Sep 13 2015 22:29:03