35 from diagnostic_msgs.msg
import DiagnosticStatus
36 from python_qt_binding.QtGui
import QColor, QIcon
42 _ERR_ICON = QIcon.fromTheme(
'dialog-error')
43 _WARN_ICON = QIcon.fromTheme(
'dialog-warning')
44 _OK_ICON = QIcon.fromTheme(
'emblem-default')
46 _STALE_ICON = QIcon.fromTheme(
'dialog-question')
48 _LEVEL_TO_ICON = {0: _OK_ICON, 1: _WARN_ICON, 2: _ERR_ICON, 3: _STALE_ICON}
50 _LEVEL_TO_COLOR = {0: QColor(85, 178, 76),
51 1: QColor(222, 213, 17),
52 2: QColor(178, 23, 46),
53 3: QColor(40, 23, 176)
56 _LEVEL_TO_TEXT = { 0:
"OK", 1:
"WARNING", 2:
"ERROR", 3:
"STALE" }
59 if level
in _LEVEL_TO_ICON:
60 return _LEVEL_TO_ICON[level]
65 if level
in _LEVEL_TO_COLOR:
66 return _LEVEL_TO_COLOR[level]
68 return _LEVEL_TO_COLOR[2]
71 if level
in _LEVEL_TO_TEXT:
72 return _LEVEL_TO_TEXT[level]
74 return "UNKNOWN(%d)" % ( level )
78 Get resource name from path 80 :param: status_name is a string that may consists of status names that 81 are delimited by slash. 84 name = status_name.split(
'/')[-1]
85 rospy.logdebug(
' get_resource_name name = %s', name)
90 Get the overall (worst) color for a DiagnosticArray 91 :param msg: DiagnosticArray 97 for status
in msg.status:
98 if (status.level > level):
100 if (status.level < min_level):
101 min_level = status.level
104 if (level > 2
and min_level <= 2):
107 rospy.logdebug(
' get_color_for_message color lv=%d', level)
111 for status
in msg.status:
112 if status.name == name:
def get_color_for_message(msg)
def get_resource_name(status_name)
def get_status_by_name(msg, name)
def level_to_color(level)