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 from diagnostic_msgs.msg import DiagnosticStatus
00036 from python_qt_binding.QtGui import QColor, QIcon
00037 import rospy
00038
00039
00040
00041
00042 _ERR_ICON = QIcon.fromTheme('dialog-error')
00043 _WARN_ICON = QIcon.fromTheme('dialog-warning')
00044 _OK_ICON = QIcon.fromTheme('emblem-default')
00045
00046 _STALE_ICON = QIcon.fromTheme('dialog-question')
00047
00048 _LEVEL_TO_ICON = {0: _OK_ICON, 1: _WARN_ICON, 2: _ERR_ICON, 3: _STALE_ICON}
00049
00050 _LEVEL_TO_COLOR = {0: QColor(85, 178, 76),
00051 1: QColor(222, 213, 17),
00052 2: QColor(178, 23, 46),
00053 3: QColor(40, 23, 176)
00054 }
00055
00056 _LEVEL_TO_TEXT = { 0: "OK", 1: "WARNING", 2: "ERROR", 3: "STALE" }
00057
00058 def level_to_icon(level):
00059 if level in _LEVEL_TO_ICON:
00060 return _LEVEL_TO_ICON[level]
00061 else:
00062 return _ERR_ICON
00063
00064 def level_to_color(level):
00065 if level in _LEVEL_TO_COLOR:
00066 return _LEVEL_TO_COLOR[level]
00067 else:
00068 return _LEVEL_TO_COLOR[2]
00069
00070 def level_to_text(level):
00071 if level in _LEVEL_TO_TEXT:
00072 return _LEVEL_TO_TEXT[level]
00073 else:
00074 return "UNKNOWN(%d)" % ( level )
00075
00076 def get_resource_name(status_name):
00077 """
00078 Get resource name from path
00079
00080 :param: status_name is a string that may consists of status names that
00081 are delimited by slash.
00082 :rtype: str
00083 """
00084 name = status_name.split('/')[-1]
00085 rospy.logdebug(' get_resource_name name = %s', name)
00086 return name
00087
00088 def get_color_for_message(msg):
00089 """
00090 Get the overall (worst) color for a DiagnosticArray
00091 :param msg: DiagnosticArray
00092 """
00093 level = 0
00094 min_level = 255
00095
00096 lookup = {}
00097 for status in msg.status:
00098 if (status.level > level):
00099 level = status.level
00100 if (status.level < min_level):
00101 min_level = status.level
00102
00103
00104 if (level > 2 and min_level <= 2):
00105 level = 2
00106
00107 rospy.logdebug(' get_color_for_message color lv=%d', level)
00108 return level_to_color(level)
00109
00110 def get_status_by_name(msg, name):
00111 for status in msg.status:
00112 if status.name == name:
00113 return status
00114 return None
rqt_robot_monitor
Author(s): Austin Hendrix, Isaac Saito, Ze'ev Klapow, Kevin Watts, Josh Faust
autogenerated on Fri Aug 28 2015 12:50:48