$search
00001 #!/usr/bin/env python 00002 # 00003 # Software License Agreement (BSD License) 00004 # 00005 # Copyright (c) 2010, Willow Garage, Inc. 00006 # All rights reserved. 00007 # 00008 # Redistribution and use in source and binary forms, with or without 00009 # modification, are permitted provided that the following conditions 00010 # are met: 00011 # 00012 # * Redistributions of source code must retain the above copyright 00013 # notice, this list of conditions and the following disclaimer. 00014 # * Redistributions in binary form must reproduce the above 00015 # copyright notice, this list of conditions and the following 00016 # disclaimer in the documentation and/or other materials provided 00017 # with the distribution. 00018 # * Neither the name of the Willow Garage nor the names of its 00019 # contributors may be used to endorse or promote products derived 00020 # from this software without specific prior written permission. 00021 # 00022 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00023 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00024 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00025 # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00026 # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00028 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00029 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00030 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00031 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 00032 # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00033 # POSSIBILITY OF SUCH DAMAGE. 00034 00035 ##\author Kevin Watts 00036 ##\brief Publishes diagnostic data on temperature and usage for a Quadro 600 GPU 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