35 """ diagnostic_updater for Python.
36 @author Brice Rebsamen <brice [dot] rebsamen [gmail]>
40 from diagnostic_msgs.msg
import DiagnosticStatus, KeyValue
42 OK = DiagnosticStatus.OK
43 WARN = DiagnosticStatus.WARN
44 ERROR = DiagnosticStatus.ERROR
47 """ Wrapper for the :diagnostic_msgs:`DiagnosticStatus` message that makes it
50 This class handles common string formatting and vector handling issues
51 for filling the :diagnostic_msgs:`DiagnosticStatus` message. It is a subclass of
52 :diagnostic_msgs:`DiagnosticStatus`, so it can be passed directly to
53 diagnostic publish calls.
58 Constructor. Any message fields that are implicitly/explicitly
59 set to None will be assigned a default value. The recommend
60 use is keyword arguments as this is more robust to future message
61 changes. You cannot mix in-order arguments and keyword arguments.
63 The available fields are:
64 level,name,message,hardware_id,values
66 :param args: complete set of field values, in .msg order
67 :param kwds: use keyword arguments corresponding to message field names
68 to set specific fields.
70 DiagnosticStatus.__init__(self, *args, **kwds)
74 """ Fills out the level and message fields of the :diagnostic_msgs:`DiagnosticStatus`.
78 `summary(diagnostic_status)`: Copies the summary from a :diagnostic_msgs:`DiagnosticStatus` message
80 `summary(lvl,msg)`: sets from lvl and messages
91 """ Clears the summary, setting the level to zero and the message to "".
97 """ Merges a level and message with the existing ones.
99 It is sometimes useful to merge two :diagnostic_msgs:`DiagnosticStatus` messages. In that case,
100 the key value pairs can be unioned, but the level and summary message
101 have to be merged more intelligently. This function does the merge in
102 an intelligent manner, combining the summary in this, with the one
105 The combined level is the greater of the two levels to be merged.
106 If both levels are non-zero (not OK), the messages are combined with a
107 semicolon separator. If only one level is zero, and the other is
108 non-zero, the message for the zero level is discarded. If both are
109 zero, the new message is ignored.
113 `mergeSummary(diagnostic_status)`: merge from a :diagnostic_msgs:`DiagnosticStatus` message
115 `mergeSummary(lvl,msg)`: sets from lvl and msg
119 msg = args[0].message
124 if (lvl>0) == (self.
level>0):
128 elif lvl > self.
level:
136 """ Add a key-value pair.
138 This method adds a key-value pair.
141 :param key: Key to be added.
143 :param value: Value to be added.
145 self.values.append(KeyValue(key,str(val)))