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 import roslib
00033 roslib.load_manifest('diag_sim')
00034
00035 import rospy
00036 import diagnostic_msgs.msg
00037
00038
00039 def diag_sim():
00040 diag_pub = rospy.Publisher('/diagnostics', diagnostic_msgs.msg.DiagnosticArray)
00041 rospy.init_node('diag_sim')
00042
00043 cnt = 0
00044
00045 while not rospy.is_shutdown():
00046
00047 cnt = cnt + 1
00048
00049
00050 diag = diagnostic_msgs.msg.DiagnosticArray()
00051 diag.header.stamp = rospy.Time.now()
00052
00053 state = ""
00054 qual = ""
00055 msg = ""
00056 warning = ""
00057 error = ""
00058 power = ""
00059 strategy = ""
00060 lvl = diagnostic_msgs.msg.DiagnosticStatus.OK
00061
00062
00063 stat = diagnostic_msgs.msg.DiagnosticStatus()
00064 stat.name = "FRI state"
00065
00066
00067 [div, mod] = divmod(cnt, 4)
00068 if mod == 0:
00069 lvl = diagnostic_msgs.msg.DiagnosticStatus.OK
00070 msg = "Communication quality PERFECT"
00071 qual = "PERFECT"
00072 state = "monitor"
00073 error = "0000000"
00074 warning = "0000000"
00075 power = "1111111"
00076 strategy = "Position"
00077 if mod == 1:
00078 lvl = diagnostic_msgs.msg.DiagnosticStatus.OK
00079 msg = "Communication quality OK"
00080 qual = "OK"
00081 state = "monitor"
00082 error = "0000000"
00083 warning = "0000000"
00084 power = "1110011"
00085 strategy = "Cartesian impedance"
00086 if mod == 2:
00087 lvl = diagnostic_msgs.msg.DiagnosticStatus.WARN
00088 msg = "Communication quality BAD"
00089 qual = "BAD"
00090 state = "command"
00091 error = "0000001"
00092 warning = "0000100"
00093 power = "1111111"
00094 strategy = "Joint impedance"
00095 if mod == 3:
00096 lvl = diagnostic_msgs.msg.DiagnosticStatus.ERROR
00097 msg = "Communication quality UNACCEPTABLE"
00098 qual = "UNACCEPTABLE"
00099 state = "command"
00100 error = "1000000"
00101 warning = "0100000"
00102 power = "1110011"
00103 strategy = "Invalid"
00104
00105 stat.level = lvl
00106 stat.message = msg
00107
00108 stat.values.append(diagnostic_msgs.msg.KeyValue("Kuka System Time", "0"))
00109 stat.values.append(diagnostic_msgs.msg.KeyValue("State", state))
00110 stat.values.append(diagnostic_msgs.msg.KeyValue("Quality", qual))
00111 stat.values.append(diagnostic_msgs.msg.KeyValue("Desired Send Sample Time", "3"))
00112 stat.values.append(diagnostic_msgs.msg.KeyValue("Desired Command Sample Time", str(mod*0.025+0.025)))
00113 stat.values.append(diagnostic_msgs.msg.KeyValue("Safety Limits", "5"))
00114 stat.values.append(diagnostic_msgs.msg.KeyValue("Answer Rate", "6"))
00115 stat.values.append(diagnostic_msgs.msg.KeyValue("Latency", "7"))
00116 stat.values.append(diagnostic_msgs.msg.KeyValue("Jitter", "8"))
00117 stat.values.append(diagnostic_msgs.msg.KeyValue("Average Missed Answer Packages", "9"))
00118 stat.values.append(diagnostic_msgs.msg.KeyValue("Total Missed Packages", "10"))
00119
00120
00121 diag.status.append(stat)
00122
00123
00124
00125 stat = diagnostic_msgs.msg.DiagnosticStatus()
00126 stat.name = "robot state"
00127 stat.level = diagnostic_msgs.msg.DiagnosticStatus.OK
00128 stat.message = "OK"
00129
00130
00131 stat.values.append(diagnostic_msgs.msg.KeyValue("Power", power))
00132 stat.values.append(diagnostic_msgs.msg.KeyValue("Control Strategy", strategy))
00133 stat.values.append(diagnostic_msgs.msg.KeyValue("Error", error))
00134 stat.values.append(diagnostic_msgs.msg.KeyValue("Warning", warning))
00135
00136
00137 diag.status.append(stat)
00138
00139
00140 diag_pub.publish(diag)
00141 rospy.sleep(1.0)
00142
00143
00144 if __name__ == '__main__':
00145 try:
00146 diag_sim()
00147 except rospy.ROSInterruptException: pass
00148 except IOError: pass
00149 except KeyError: pass