overlay_diagnostic_display.h
Go to the documentation of this file.
1 // -*- mode: c++; -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/or other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 #ifndef JSK_RVIZ_PLUGIN_OVERLAY_DIAGNOSTIC_DISPLAY_H_
36 #define JSK_RVIZ_PLUGIN_OVERLAY_DIAGNOSTIC_DISPLAY_H_
37 
38 #ifndef Q_MOC_RUN
39 #include <rviz/display.h>
40 #include <OGRE/OgreTexture.h>
41 #include <OGRE/OgreColourValue.h>
42 #include <OGRE/OgreMaterial.h>
43 
44 #include <QPainter>
45 #include <QPainterPath>
46 
53 
54 #include <diagnostic_msgs/DiagnosticArray.h>
55 
56 #include "overlay_utils.h"
57 #endif
58 
59 namespace jsk_rviz_plugins
60 {
61  class OverlayDiagnosticDisplay: public rviz::Display
62  {
63  Q_OBJECT
64  public:
67  virtual ~OverlayDiagnosticDisplay();
68 
69  // methods for OverlayPickerTool
70  virtual bool isInRegion(int x, int y);
71  virtual void movePosition(int x, int y);
72  virtual void setPosition(int x, int y);
73  virtual int getX() { return left_; };
74  virtual int getY() { return top_; };
75 
76  protected:
77  virtual bool isStalled();
78  virtual void processMessage(
79  const diagnostic_msgs::DiagnosticArray::ConstPtr& msg);
80  virtual void update(float wall_dt, float ros_dt);
81  virtual void onEnable();
82  virtual void onDisable();
83  virtual void onInitialize();
84  virtual void subscribe();
85  virtual void unsubscribe();
86  virtual void redraw();
87  virtual State getLatestState();
88  virtual void drawSAC(QImage& Hud);
89  virtual void drawEVA(QImage& Hud);
90  virtual void drawEVAConnectedRectangle(QPainter& painter,
91  QColor color,
92  QColor small_color,
93  int width);
94  virtual void drawEVANonConnectedRectangle(QPainter& painter,
95  QColor color,
96  QColor small_color,
97  int width,
98  double gap);
99  virtual void fillNamespaceList();
100  virtual QColor foregroundColor();
101  virtual QColor textColor();
102  virtual double textWidth(QPainter& painter, double font_size, const std::string& text);
103  virtual double textHeight(QPainter& painter, double font_size);
104  virtual QColor blendColor(QColor a, QColor b, double a_rate);
105  virtual void drawText(QPainter& painter, QColor fg_color,
106  const std::string& text);
107  virtual double drawAnimatingText(QPainter& painter,
108  QColor fg_color,
109  const double height,
110  const double font_size,
111  const std::string text);
112  // return true if plugin needs to animate
113  virtual bool isAnimating();
114  virtual double animationRate();
115  virtual std::string statusText();
116  boost::mutex mutex_;
118 
119 #if ROS_VERSION_MINIMUM(1,12,0)
120  std::shared_ptr<diagnostic_msgs::DiagnosticStatus> latest_status_;
121 #else
123 #endif
127  int size_;
128  std::string diagnostics_namespace_;
129  int type_;
130  std::set<std::string> namespaces_;
131  double alpha_;
132  int top_, left_;
133  double t_;
134  double stall_duration_;
135  bool is_animating_;
144 
146  protected Q_SLOTS:
147  virtual void updateType();
148  virtual void updateRosTopic();
149  virtual void updateDiagnosticsNamespace();
150  virtual void updateSize();
151  virtual void updateAlpha();
152  virtual void updateTop();
153  virtual void updateLeft();
154  virtual void updateStallDuration();
155  private:
156 
157  };
158 }
159 
160 #endif
jsk_rviz_plugins::OverlayDiagnosticDisplay::textWidth
virtual double textWidth(QPainter &painter, double font_size, const std::string &text)
Definition: overlay_diagnostic_display.cpp:414
jsk_rviz_plugins::OverlayDiagnosticDisplay::size_
int size_
Definition: overlay_diagnostic_display.h:191
rviz::RosTopicProperty
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateDiagnosticsNamespace
virtual void updateDiagnosticsNamespace()
Definition: overlay_diagnostic_display.cpp:688
jsk_rviz_plugins::OverlayDiagnosticDisplay::~OverlayDiagnosticDisplay
virtual ~OverlayDiagnosticDisplay()
Definition: overlay_diagnostic_display.cpp:128
jsk_rviz_plugins::OverlayDiagnosticDisplay::left_property_
rviz::IntProperty * left_property_
Definition: overlay_diagnostic_display.h:204
jsk_rviz_plugins::OverlayDiagnosticDisplay::top_property_
rviz::IntProperty * top_property_
Definition: overlay_diagnostic_display.h:203
jsk_rviz_plugins::OverlayDiagnosticDisplay::blendColor
virtual QColor blendColor(QColor a, QColor b, double a_rate)
Definition: overlay_diagnostic_display.cpp:406
boost::shared_ptr< OverlayObject >
jsk_rviz_plugins::OverlayDiagnosticDisplay::unsubscribe
virtual void unsubscribe()
Definition: overlay_diagnostic_display.cpp:274
jsk_rviz_plugins::OverlayDiagnosticDisplay::processMessage
virtual void processMessage(const diagnostic_msgs::DiagnosticArray::ConstPtr &msg)
Definition: overlay_diagnostic_display.cpp:144
jsk_rviz_plugins::OverlayDiagnosticDisplay::getX
virtual int getX()
Definition: overlay_diagnostic_display.h:137
jsk_rviz_plugins::OverlayDiagnosticDisplay::latest_message_time_
ros::WallTime latest_message_time_
Definition: overlay_diagnostic_display.h:189
jsk_rviz_plugins::OverlayDiagnosticDisplay::isInRegion
virtual bool isInRegion(int x, int y)
Definition: overlay_diagnostic_display.cpp:719
rviz::EditableEnumProperty
int_property.h
jsk_rviz_plugins::OverlayDiagnosticDisplay::OK_STATE
@ OK_STATE
Definition: overlay_diagnostic_display.h:130
jsk_rviz_plugins::OverlayDiagnosticDisplay::foregroundColor
virtual QColor foregroundColor()
Definition: overlay_diagnostic_display.cpp:360
jsk_rviz_plugins::OverlayDiagnosticDisplay::subscribe
virtual void subscribe()
Definition: overlay_diagnostic_display.cpp:279
enum_property.h
jsk_rviz_plugins::OverlayDiagnosticDisplay::textColor
virtual QColor textColor()
Definition: overlay_diagnostic_display.cpp:382
jsk_rviz_plugins::OverlayDiagnosticDisplay::mutex_
boost::mutex mutex_
Definition: overlay_diagnostic_display.h:180
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateSize
virtual void updateSize()
Definition: overlay_diagnostic_display.cpp:694
display.h
jsk_rviz_plugins::OverlayDiagnosticDisplay::stall_duration_
double stall_duration_
Definition: overlay_diagnostic_display.h:198
jsk_rviz_plugins::OverlayDiagnosticDisplay::is_animating_
bool is_animating_
Definition: overlay_diagnostic_display.h:199
jsk_rviz_plugins::OverlayDiagnosticDisplay::animationRate
virtual double animationRate()
Definition: overlay_diagnostic_display.cpp:237
jsk_rviz_plugins::OverlayDiagnosticDisplay::movePosition
virtual void movePosition(int x, int y)
Definition: overlay_diagnostic_display.cpp:725
jsk_rviz_plugins::OverlayDiagnosticDisplay::ros_topic_property_
rviz::RosTopicProperty * ros_topic_property_
Definition: overlay_diagnostic_display.h:200
float_property.h
jsk_rviz_plugins::OverlayDiagnosticDisplay::ERROR_STATE
@ ERROR_STATE
Definition: overlay_diagnostic_display.h:130
jsk_rviz_plugins::OverlayDiagnosticDisplay::drawAnimatingText
virtual double drawAnimatingText(QPainter &painter, QColor fg_color, const double height, const double font_size, const std::string text)
Definition: overlay_diagnostic_display.cpp:448
jsk_rviz_plugins::OverlayDiagnosticDisplay::drawText
virtual void drawText(QPainter &painter, QColor fg_color, const std::string &text)
Definition: overlay_diagnostic_display.cpp:480
jsk_rviz_plugins::OverlayDiagnosticDisplay::drawEVA
virtual void drawEVA(QImage &Hud)
Definition: overlay_diagnostic_display.cpp:596
overlay_sample.text
text
Definition: overlay_sample.py:21
rviz::Display
rviz::EnumProperty
rviz::FloatProperty
jsk_rviz_plugins::OverlayDiagnosticDisplay::getY
virtual int getY()
Definition: overlay_diagnostic_display.h:138
jsk_rviz_plugins::OverlayDiagnosticDisplay::statusText
virtual std::string statusText()
Definition: overlay_diagnostic_display.cpp:305
overlay_menu_sample.b
b
Definition: overlay_menu_sample.py:20
overlay_utils.h
jsk_rviz_plugins::OverlayDiagnosticDisplay::stall_duration_property_
rviz::FloatProperty * stall_duration_property_
Definition: overlay_diagnostic_display.h:207
jsk_rviz_plugins::OverlayDiagnosticDisplay::overlay_
OverlayObject::Ptr overlay_
Definition: overlay_diagnostic_display.h:181
editable_enum_property.h
jsk_rviz_plugins::OverlayDiagnosticDisplay::top_
int top_
Definition: overlay_diagnostic_display.h:196
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateType
virtual void updateType()
Definition: overlay_diagnostic_display.cpp:737
jsk_rviz_plugins::OverlayDiagnosticDisplay::type_
int type_
Definition: overlay_diagnostic_display.h:193
bounding_box_sample.x
x
Definition: bounding_box_sample.py:26
jsk_rviz_plugins::OverlayDiagnosticDisplay::alpha_property_
rviz::FloatProperty * alpha_property_
Definition: overlay_diagnostic_display.h:205
jsk_rviz_plugins::OverlayDiagnosticDisplay::onInitialize
virtual void onInitialize()
Definition: overlay_diagnostic_display.cpp:260
jsk_rviz_plugins::OverlayDiagnosticDisplay::isAnimating
virtual bool isAnimating()
Definition: overlay_diagnostic_display.cpp:232
jsk_rviz_plugins::OverlayDiagnosticDisplay::t_
double t_
Definition: overlay_diagnostic_display.h:197
jsk_rviz_plugins::OverlayDiagnosticDisplay::textHeight
virtual double textHeight(QPainter &painter, double font_size)
Definition: overlay_diagnostic_display.cpp:431
jsk_rviz_plugins::OverlayDiagnosticDisplay::update
virtual void update(float wall_dt, float ros_dt)
Definition: overlay_diagnostic_display.cpp:195
ros::WallTime
bounding_box_sample.y
y
Definition: bounding_box_sample.py:27
jsk_rviz_plugins::OverlayDiagnosticDisplay::WARN_STATE
@ WARN_STATE
Definition: overlay_diagnostic_display.h:130
jsk_rviz_plugins::OverlayDiagnosticDisplay::isStalled
virtual bool isStalled()
Definition: overlay_diagnostic_display.cpp:288
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateAlpha
virtual void updateAlpha()
Definition: overlay_diagnostic_display.cpp:699
jsk_rviz_plugins::OverlayDiagnosticDisplay::sub_
ros::Subscriber sub_
Definition: overlay_diagnostic_display.h:209
jsk_rviz_plugins::OverlayDiagnosticDisplay::namespaces_
std::set< std::string > namespaces_
Definition: overlay_diagnostic_display.h:194
jsk_rviz_plugins::OverlayDiagnosticDisplay::fillNamespaceList
virtual void fillNamespaceList()
Definition: overlay_diagnostic_display.cpp:669
jsk_rviz_plugins::OverlayDiagnosticDisplay::diagnostics_namespace_property_
rviz::EditableEnumProperty * diagnostics_namespace_property_
Definition: overlay_diagnostic_display.h:201
jsk_rviz_plugins::OverlayDiagnosticDisplay::drawEVANonConnectedRectangle
virtual void drawEVANonConnectedRectangle(QPainter &painter, QColor color, QColor small_color, int width, double gap)
Definition: overlay_diagnostic_display.cpp:558
jsk_rviz_plugins::OverlayDiagnosticDisplay::onEnable
virtual void onEnable()
Definition: overlay_diagnostic_display.cpp:242
jsk_rviz_plugins::OverlayDiagnosticDisplay::type_property_
rviz::EnumProperty * type_property_
Definition: overlay_diagnostic_display.h:202
jsk_rviz_plugins::OverlayDiagnosticDisplay::setPosition
virtual void setPosition(int x, int y)
Definition: overlay_diagnostic_display.cpp:731
jsk_rviz_plugins::OverlayDiagnosticDisplay::previous_state_
State previous_state_
Definition: overlay_diagnostic_display.h:188
jsk_rviz_plugins::OverlayDiagnosticDisplay::size_property_
rviz::IntProperty * size_property_
Definition: overlay_diagnostic_display.h:206
jsk_rviz_plugins::OverlayDiagnosticDisplay::drawSAC
virtual void drawSAC(QImage &Hud)
Definition: overlay_diagnostic_display.cpp:507
jsk_rviz_plugins::OverlayDiagnosticDisplay::drawEVAConnectedRectangle
virtual void drawEVAConnectedRectangle(QPainter &painter, QColor color, QColor small_color, int width)
Definition: overlay_diagnostic_display.cpp:532
jsk_rviz_plugins::OverlayDiagnosticDisplay::alpha_
double alpha_
Definition: overlay_diagnostic_display.h:195
jsk_rviz_plugins::OverlayDiagnosticDisplay::left_
int left_
Definition: overlay_diagnostic_display.h:196
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateTop
virtual void updateTop()
Definition: overlay_diagnostic_display.cpp:704
jsk_rviz_plugins::OverlayDiagnosticDisplay::OverlayDiagnosticDisplay
OverlayDiagnosticDisplay()
Definition: overlay_diagnostic_display.cpp:85
jsk_rviz_plugins::OverlayDiagnosticDisplay::redraw
virtual void redraw()
Definition: overlay_diagnostic_display.cpp:656
jsk_rviz_plugins::OverlayDiagnosticDisplay::onDisable
virtual void onDisable()
Definition: overlay_diagnostic_display.cpp:251
jsk_rviz_plugins::OverlayDiagnosticDisplay::State
State
Definition: overlay_diagnostic_display.h:130
jsk_rviz_plugins::OverlayDiagnosticDisplay::latest_status_
boost::shared_ptr< diagnostic_msgs::DiagnosticStatus > latest_status_
Definition: overlay_diagnostic_display.h:186
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateStallDuration
virtual void updateStallDuration()
Definition: overlay_diagnostic_display.cpp:714
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateLeft
virtual void updateLeft()
Definition: overlay_diagnostic_display.cpp:709
jsk_rviz_plugins::OverlayDiagnosticDisplay::diagnostics_namespace_
std::string diagnostics_namespace_
Definition: overlay_diagnostic_display.h:192
jsk_rviz_plugins::OverlayDiagnosticDisplay::getLatestState
virtual State getLatestState()
Definition: overlay_diagnostic_display.cpp:332
jsk_rviz_plugins
Definition: __init__.py:1
color_property.h
ros_topic_property.h
jsk_rviz_plugins::OverlayDiagnosticDisplay::STALL_STATE
@ STALL_STATE
Definition: overlay_diagnostic_display.h:130
jsk_rviz_plugins::OverlayDiagnosticDisplay::updateRosTopic
virtual void updateRosTopic()
Definition: overlay_diagnostic_display.cpp:681
ros::Subscriber
overlay_sample.fg_color
fg_color
Definition: overlay_sample.py:44
rviz::IntProperty
jsk_rviz_plugins::OverlayDiagnosticDisplay::animation_start_time_
ros::WallTime animation_start_time_
Definition: overlay_diagnostic_display.h:190


jsk_rviz_plugins
Author(s): Kei Okada , Yohei Kakiuchi , Shohei Fujii , Ryohei Ueda
autogenerated on Fri Aug 2 2024 08:50:14