overlay_diagnostic_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 #ifndef JSK_RVIZ_PLUGIN_OVERLAY_DIAGNOSTIC_DISPLAY_H_
00036 #define JSK_RVIZ_PLUGIN_OVERLAY_DIAGNOSTIC_DISPLAY_H_
00037 
00038 #ifndef Q_MOC_RUN
00039 #include <rviz/display.h>
00040 #include <OGRE/OgreTexture.h>
00041 #include <OGRE/OgreColourValue.h>
00042 #include <OGRE/OgreMaterial.h>
00043 
00044 #include <QPainter>
00045 
00046 #include <rviz/properties/ros_topic_property.h>
00047 #include <rviz/properties/editable_enum_property.h>
00048 #include <rviz/properties/enum_property.h>
00049 #include <rviz/properties/int_property.h>
00050 #include <rviz/properties/float_property.h>
00051 #include <rviz/properties/color_property.h>
00052 
00053 #include <diagnostic_msgs/DiagnosticArray.h>
00054 
00055 #include "overlay_utils.h"
00056 #endif
00057 
00058 namespace jsk_rviz_plugins
00059 {
00060   class OverlayDiagnosticDisplay: public rviz::Display
00061   {
00062     Q_OBJECT
00063   public:
00064     OverlayDiagnosticDisplay();
00065     typedef enum {OK_STATE, ERROR_STATE, WARN_STATE, STALL_STATE} State;
00066     virtual ~OverlayDiagnosticDisplay();
00067 
00068     // methods for OverlayPickerTool
00069     virtual bool isInRegion(int x, int y);
00070     virtual void movePosition(int x, int y);
00071     virtual void setPosition(int x, int y);
00072     virtual int getX() { return left_; };
00073     virtual int getY() { return top_; };
00074 
00075   protected:
00076     virtual bool isStalled();
00077     virtual void processMessage(
00078       const diagnostic_msgs::DiagnosticArray::ConstPtr& msg);
00079     virtual void update(float wall_dt, float ros_dt);
00080     virtual void onEnable();
00081     virtual void onDisable();
00082     virtual void onInitialize();
00083     virtual void subscribe();
00084     virtual void unsubscribe();
00085     virtual void redraw();
00086     virtual State getLatestState();
00087     virtual void drawSAC(QImage& Hud);
00088     virtual void drawEVA(QImage& Hud);
00089     virtual void drawEVAConnectedRectangle(QPainter& painter,
00090                                            QColor color,
00091                                            QColor small_color,
00092                                            int width);
00093     virtual void drawEVANonConnectedRectangle(QPainter& painter,
00094                                               QColor color,
00095                                               QColor small_color,
00096                                               int width,
00097                                               double gap);
00098     virtual void fillNamespaceList();
00099     virtual QColor foregroundColor();
00100     virtual QColor textColor();
00101     virtual double textWidth(QPainter& painter, double font_size, const std::string& text);
00102     virtual double textHeight(QPainter& painter, double font_size);
00103     virtual QColor blendColor(QColor a, QColor b, double a_rate);
00104     virtual void drawText(QPainter& painter, QColor fg_color,
00105                           const std::string& text);
00106     virtual double drawAnimatingText(QPainter& painter,
00107                                      QColor fg_color,
00108                                      const double height,
00109                                      const double font_size,
00110                                      const std::string text);
00111     // return true if plugin needs to animate
00112     virtual bool isAnimating();
00113     virtual double animationRate();
00114     virtual std::string statusText();
00115     boost::mutex mutex_;
00116     OverlayObject::Ptr overlay_;
00117     
00118     std::shared_ptr<diagnostic_msgs::DiagnosticStatus> latest_status_;
00119     State previous_state_;
00120     ros::WallTime latest_message_time_;
00121     ros::WallTime animation_start_time_;
00122     int size_;
00123     std::string diagnostics_namespace_;
00124     int type_;
00125     std::set<std::string> namespaces_;
00126     double alpha_;
00127     int top_, left_;
00128     double t_;
00129     double stall_duration_;
00130     bool is_animating_;
00131     rviz::RosTopicProperty* ros_topic_property_;
00132     rviz::EditableEnumProperty* diagnostics_namespace_property_;
00133     rviz::EnumProperty* type_property_;
00134     rviz::IntProperty* top_property_;
00135     rviz::IntProperty* left_property_;
00136     rviz::FloatProperty* alpha_property_;
00137     rviz::IntProperty* size_property_;
00138     rviz::FloatProperty* stall_duration_property_;
00139     
00140     ros::Subscriber sub_;
00141   protected Q_SLOTS:
00142     virtual void updateType();
00143     virtual void updateRosTopic();
00144     virtual void updateDiagnosticsNamespace();
00145     virtual void updateSize();
00146     virtual void updateAlpha();
00147     virtual void updateTop();
00148     virtual void updateLeft();
00149     virtual void updateStallDuration();
00150   private:
00151     
00152   };
00153 }
00154 
00155 #endif


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