38 @author Brice Rebsamen <brice [dot] rebsamen [gmail]>
42 roslib.load_manifest(
'diagnostic_updater')
44 import diagnostic_updater
45 import diagnostic_msgs
51 '''Used as a tutorial for loading and using diagnostic updater.
53 DummyClass and dummy_diagnostics show how to use a diagnostic_updater
66 if time_to_launch < 10:
68 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.ERROR,
69 "Buckle your seat belt. Launch in %f seconds!" % time_to_launch)
72 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.OK,
73 "Launch is in a long time. Have a soda.")
78 stat.add(
"Diagnostic Name",
"dummy")
80 stat.add(
"Time to Launch", time_to_launch)
82 stat.add(
"Geeky thing to say",
"The square of the time to launch %f is %f" % \
83 (time_to_launch, time_to_launch * time_to_launch) )
92 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.WARN,
"This is a silly updater.")
93 stat.add(
"Stupidicity of this updater", 1000.)
99 diagnostic_updater.DiagnosticTask.__init__(self,
100 "Updater Derived from DiagnosticTask")
103 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.WARN,
104 "This is another silly updater.")
105 stat.add(
"Stupidicity of this updater", 2000.)
110 if time_to_launch > 5:
111 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.OK,
"Lower-bound OK")
113 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.ERROR,
"Too low")
114 stat.add(
"Low-Side Margin", time_to_launch - 5)
119 if time_to_launch < 10:
120 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.OK,
"Upper-bound OK")
122 stat.summary(diagnostic_msgs.msg.DiagnosticStatus.WARN,
"Too high")
123 stat.add(
"Top-Side Margin", 10 - time_to_launch)
127 if __name__==
'__main__':
128 rospy.init_node(
"diagnostic_updater_example")
144 updater.setHardwareID(
"none")
146 updater.setHardwareID(
"Device-%i-%i" % (27, 46) )
154 updater.add(
"Function updater", dummy_diagnostic)
156 updater.add(
"Method updater", dc.produce_diagnostics)
178 bounds.addTask(lower)
179 bounds.addTask(upper)
191 updater.broadcast(0,
"Doing important initialization stuff.")
193 pub1 = rospy.Publisher(
"topic1", std_msgs.msg.Bool, queue_size=10)
194 pub2_temp = rospy.Publisher(
"topic2", std_msgs.msg.Bool, queue_size=10)
214 freq_bounds = {
'min':0.5,
'max':2}
226 pub1_freq.addTask(lower)
230 updater.force_update()
233 if not updater.removeByName(
"Bound check"):
234 rospy.logerr(
"The Bound check task was not found when trying to remove it.")
236 while not rospy.is_shutdown():
237 msg = std_msgs.msg.Bool()