facing_visualizer.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_PLUGIN_FACING_VISUALIZER_H_
00038 #define JSK_RVIZ_PLUGIN_FACING_VISUALIZER_H_
00039 
00040 #include <OGRE/OgreTexture.h>
00041 #include <OGRE/OgreSceneManager.h>
00042 #include <OGRE/OgreSceneNode.h>
00043 #include <OGRE/OgreTexture.h>
00044 #include <OGRE/OgreMaterial.h>
00045 #include <OGRE/OgreManualObject.h>
00046 #include <rviz/display_context.h>
00047 #include <ros/time.h>
00048 #include <rviz/ogre_helpers/billboard_line.h>
00049 #include <rviz/ogre_helpers/movable_text.h>
00050 #include "overlay_utils.h"
00051 
00052 namespace jsk_rviz_plugins
00053 {
00054 
00055   // outer radius
00056   // inner radius
00057   class SquareObject
00058   {
00059   public:
00060     typedef boost::shared_ptr<SquareObject> Ptr;
00061     SquareObject(Ogre::SceneManager* manager,
00062                  double outer_radius,
00063                  double inner_radius,
00064                  std::string name);
00065     enum PolygonType
00066     {
00067       CIRCLE, SQUARE
00068     };
00069     
00070     virtual ~SquareObject();
00071     virtual Ogre::ManualObject* getManualObject();
00072     virtual void setOuterRadius(double outer_radius);
00073     virtual void setInnerRadius(double inner_radius);
00074     virtual void rebuildPolygon();
00075     virtual void setPolygonType(PolygonType type);
00076   protected:
00077     Ogre::ManualObject* manual_;
00078     Ogre::SceneManager* manager_;
00079     double outer_radius_;
00080     double inner_radius_;
00081     std::string name_;
00082     PolygonType polygon_type_;
00083   private:
00084   };
00085 
00086   class TextureObject           // utility class for texture
00087   {
00088   public:
00089     typedef boost::shared_ptr<TextureObject> Ptr;
00090     TextureObject(const int width, const int height, const std::string name);
00091     virtual ~TextureObject();
00092     virtual int getWidth() { return width_; };
00093     virtual int getHeight() { return height_; };
00094     virtual ScopedPixelBuffer getBuffer();
00095     virtual std::string getMaterialName();
00096   protected:
00097     Ogre::TexturePtr texture_;
00098     Ogre::MaterialPtr material_;
00099     const int width_;
00100     const int height_;
00101     const std::string name_;
00102   private:
00103     
00104   };
00105 
00106   class FacingObject
00107   {
00108   public:
00109     typedef boost::shared_ptr<FacingObject> Ptr;
00110     FacingObject(Ogre::SceneManager* manager,
00111                  Ogre::SceneNode* parent,
00112                  double size);
00113     virtual ~FacingObject();
00114     virtual void setPosition(Ogre::Vector3& pos);
00115     virtual void setOrientation(rviz::DisplayContext* context);
00116     virtual void setOrientation(Ogre::Quaternion& rot); // non facing API
00117     virtual void update(float wall_dt, float ros_dt) = 0;
00118     virtual void setSize(double size);
00119     virtual void setEnable(bool enable);
00120     virtual void setColor(QColor color);
00121     virtual void setColor(Ogre::ColourValue color);
00122     virtual void setText(std::string text);
00123     virtual void setAlpha(double alpha);
00124   protected:
00125     virtual void updateColor() = 0;
00126     virtual void updateText() = 0;
00127     Ogre::SceneManager* scene_manager_;
00128     Ogre::SceneNode* node_;
00129     Ogre::ColourValue color_;
00130     double size_;
00131     bool enable_;
00132     std::string text_;
00133   private:
00134     
00135   };
00136 
00137   class SimpleCircleFacingVisualizer: public FacingObject
00138   {
00139   public:
00140     typedef boost::shared_ptr<SimpleCircleFacingVisualizer> Ptr;
00141     SimpleCircleFacingVisualizer(Ogre::SceneManager* manager,
00142                                  Ogre::SceneNode* parent,
00143                                  rviz::DisplayContext* context,
00144                                  double size,
00145                                  std::string text = "");
00146     virtual ~SimpleCircleFacingVisualizer();
00147     virtual void update(float wall_dt, float ros_dt);
00148     virtual void reset();
00149     
00150     virtual void setSize(double size);
00151     virtual void setEnable(bool enable);
00152     virtual void setText(std::string text);
00153   protected:
00154     virtual void updateArrowsObjects(Ogre::ColourValue color);
00155     virtual void createArrows(rviz::DisplayContext* context);
00156     virtual void updateLine();
00157     virtual void updateTextUnderLine();
00158     virtual void updateText();
00159     virtual void updateColor();
00160     rviz::BillboardLine* line_;
00161     rviz::BillboardLine* text_under_line_;
00162     Ogre::ManualObject* upper_arrow_;
00163     Ogre::ManualObject* lower_arrow_;
00164     Ogre::ManualObject* left_arrow_;
00165     Ogre::ManualObject* right_arrow_;
00166     Ogre::SceneNode* upper_arrow_node_;
00167     Ogre::SceneNode* lower_arrow_node_;
00168     Ogre::SceneNode* left_arrow_node_;
00169     Ogre::SceneNode* right_arrow_node_;
00170     Ogre::MaterialPtr upper_material_;
00171     Ogre::MaterialPtr lower_material_;
00172     Ogre::MaterialPtr left_material_;
00173     Ogre::MaterialPtr right_material_;
00174     std::string upper_material_name_;
00175     std::string left_material_name_;
00176     std::string lower_material_name_;
00177     std::string right_material_name_;
00178     rviz::MovableText* msg_;
00179     Ogre::SceneNode* target_text_node_;
00180   private:
00181     
00182   };
00183   
00184   class FacingTexturedObject: public FacingObject
00185   {
00186   public:
00187     typedef boost::shared_ptr<FacingTexturedObject> Ptr;
00188     FacingTexturedObject(Ogre::SceneManager* manager,
00189                          Ogre::SceneNode* parent,
00190                          double size);
00191     virtual void setSize(double size);
00192   protected:
00193     SquareObject::Ptr square_object_;
00194     TextureObject::Ptr texture_object_;
00195 
00196   private:
00197     
00198   };
00199   
00200   class GISCircleVisualizer: public FacingTexturedObject
00201   {
00202   public:
00203     typedef boost::shared_ptr<GISCircleVisualizer> Ptr;
00204     GISCircleVisualizer(Ogre::SceneManager* manager,
00205                         Ogre::SceneNode* parent,
00206                         double size,
00207                         std::string text = "");
00208     virtual void setText(std::string text) { text_ = text; }
00209     virtual void update(float wall_dt, float ros_dt);
00210     virtual void setAnonymous(bool anonymous);
00211   protected:
00212     virtual void updateColor() {}
00213     virtual void updateText() {}
00214     virtual void setSize(double size);
00215     bool anonymous_;
00216     std::string text_;
00217   private:
00218   };
00219   
00220 }
00221 
00222 #endif


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