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
00036
00037
00038 from __future__ import with_statement, division
00039
00040 PKG = 'pr2_computer_monitor'
00041 import roslib; roslib.load_manifest(PKG)
00042
00043 import rospy
00044
00045 from diagnostic_msgs.msg import DiagnosticArray, DiagnosticStatus
00046 from pr2_msgs.msg import GPUStatus
00047
00048 import pr2_computer_monitor
00049
00050 class NVidiaTempMonitor(object):
00051 def __init__(self):
00052 self._pub = rospy.Publisher('/diagnostics', DiagnosticArray)
00053 self._gpu_pub = rospy.Publisher('gpu_status', GPUStatus)
00054
00055 def pub_status(self):
00056 gpu_stat = GPUStatus()
00057 stat = DiagnosticStatus()
00058 try:
00059 card_out = pr2_computer_monitor.get_gpu_status()
00060 gpu_stat = pr2_computer_monitor.parse_smi_output(card_out)
00061 stat = pr2_computer_monitor.gpu_status_to_diag(gpu_stat)
00062 except Exception, e:
00063 import traceback
00064 rospy.logerr('Unable to process nVidia GPU data')
00065 rospy.logerr(traceback.format_exc())
00066
00067 gpu_stat.header.stamp = rospy.get_rostime()
00068
00069 array = DiagnosticArray()
00070 array.header.stamp = rospy.get_rostime()
00071
00072 array.status = [ stat ]
00073
00074 self._pub.publish(array)
00075 self._gpu_pub.publish(gpu_stat)
00076
00077 if __name__ == '__main__':
00078 rospy.init_node('nvidia_temp_monitor')
00079
00080 monitor = NVidiaTempMonitor()
00081 my_rate = rospy.Rate(1.0)
00082 while not rospy.is_shutdown():
00083 monitor.pub_status()
00084 my_rate.sleep()
00085
00086