Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
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
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
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