def jetson_callback(self, jetson): # Add timestamp self.arr.header.stamp = rospy.Time.now() # Status board and board info self.arr.status = [other_status(self.hardware, jetson, jtop.__version__)] # Make diagnostic message for each cpu self.arr.status += [cpu_status(self.hardware, name, jetson.cpu[name]) for name in jetson.cpu] # Merge all other diagnostics self.arr.status += [gpu_status(self.hardware, jetson.gpu)] self.arr.status += [ram_status(self.hardware, jetson.ram, 'mem')] self.arr.status += [swap_status(self.hardware, jetson.swap, 'mem')] self.arr.status += [emc_status(self.hardware, jetson.emc, 'mem')] # Temperature self.arr.status += [temp_status(self.hardware, jetson.temperature, self.level_options)] # Read power total, power = jetson.power if power: self.arr.status += [power_status(self.hardware, total, power)] # Fan controller if jetson.fan: self.arr.status += [fan_status(self.hardware, jetson.fan, 'board')] # Status board and board info self.arr.status += [self.board_status] # Add disk status self.arr.status += [disk_status(self.hardware, jetson.disk, 'board')] # Update status jtop rospy.logdebug("jtop message %s" % rospy.get_time()) self.pub.publish(self.arr)
def wrapper(jetson): # Load level options level_options = { rospy.get_param("~level/error", 60): DiagnosticStatus.ERROR, rospy.get_param("~level/warning", 40): DiagnosticStatus.WARN, rospy.get_param("~level/ok", 20): DiagnosticStatus.OK, } rospy.loginfo(level_options) # Initialization ros pubblisher pub = rospy.Publisher('/diagnostics', DiagnosticArray, queue_size=1) # Set default rate jetson stats 2hz rate_node = rospy.get_param("~rate", 2) rate = rospy.Rate(rate_node) # Extract board information board = jetson.board # Define hardware name hardware = board["info"]["Machine"] # Define Diagnostic array message # http://docs.ros.org/api/diagnostic_msgs/html/msg/DiagnosticStatus.html arr = DiagnosticArray() # Initialization Tegrastats while not rospy.is_shutdown(): # Save all stats stats = jetson.stats # Add timestamp arr.header.stamp = rospy.Time.now() # Status board and board info arr.status = [other_status(hardware, jetson)] # Make diagnostic message for each cpu arr.status += [cpu_status(hardware, cpu) for cpu in stats['CPU']] # Merge all other diagnostics if 'GR3D' in stats: arr.status += [gpu_status(hardware, stats['GR3D'])] if 'RAM' in stats: arr.status += [ram_status(hardware, stats['RAM'], 'mem')] if 'SWAP' in stats: arr.status += [swap_status(hardware, stats['SWAP'], 'mem')] if 'EMC' in stats: arr.status += [emc_status(hardware, stats['EMC'], 'mem')] if 'FAN' in stats: arr.status += [fan_status(hardware, stats['FAN'], 'board')] if 'WATT' in stats: arr.status += [power_status(hardware, stats['WATT'])] if 'TEMP' in stats: arr.status += [temp_status(hardware, stats['TEMP'], level_options)] # Status board and board info arr.status += [board_status(hardware, board, 'board')] # Add disk status arr.status += [disk_status(hardware, jetson.disk, 'board')] # Update status jtop rospy.logdebug("jtop message %s" % rospy.get_time()) pub.publish(arr) rate.sleep()
def jetson_callback(self, jetson): # Add timestamp self.arr.header.stamp = rospy.Time.now() # Status board and board info self.arr.status = [ other_status(self.hardware, jetson, jtop.__version__) ] # Make diagnostic message for each cpu self.arr.status += [ cpu_status(self.hardware, name, jetson.cpu[name]) for name in jetson.cpu ] # Merge all other diagnostics self.arr.status += [gpu_status(self.hardware, jetson.gpu)] self.arr.status += [ram_status(self.hardware, jetson.ram, 'mem')] self.arr.status += [swap_status(self.hardware, jetson.swap, 'mem')] self.arr.status += [emc_status(self.hardware, jetson.emc, 'mem')] # Temperature self.arr.status += [ temp_status(self.hardware, jetson.temperature, self.level_options) ] # Read power total, power = jetson.power if power: self.arr.status += [power_status(self.hardware, total, power)] # Fan controller if jetson.fan is not None: self.arr.status += [fan_status(self.hardware, jetson.fan, 'board')] # Status board and board info self.arr.status += [self.board_status] # Add disk status self.arr.status += [disk_status(self.hardware, jetson.disk, 'board')] # Update status jtop rospy.logdebug("jtop message %s" % rospy.get_time()) self.pub.publish(self.arr) # More condensed and plottable stats for Jetson supervision if ( len(self.arr.status) == 18 ): # The number and order of status entries depends on params/jtop.yaml !! # Create Message jetson_status = JetsonStatus() # Pass on the time stamp jetson_status.header.stamp = self.arr.header.stamp # RAM jetson_status.ram_used = KBYTE2MBYTE * float( self.arr.status[10].values[0].value) jetson_status.ram_shared = KBYTE2MBYTE * float( self.arr.status[10].values[1].value) jetson_status.ram_total = KBYTE2MBYTE * float( self.arr.status[10].values[2].value) # SWAP jetson_status.swap_used = float( self.arr.status[11].values[0].value) jetson_status.swap_total = float( self.arr.status[11].values[1].value) # CPU temp jetson_status.cpu_temp = float( self.arr.status[13].values[6].value.rstrip("C")) # GPU info jetson_status.gpu_load = PERCENT2SHARE * float( self.arr.status[9].values[0].value.rstrip("%")) jetson_status.gpu_freq = int(self.arr.status[9].values[1].value) # GPU temp jetson_status.gpu_temp = float( self.arr.status[13].values[4].value.rstrip("C")) # CPU info for i in range(1, 9): if self.arr.status[i].message.lower() != "off": jetson_status.cpu_load += [ PERCENT2SHARE * float(self.arr.status[i].values[0].value.rstrip("%")) ] jetson_status.cpu_freq += [ int(self.arr.status[i].values[1].value) ] jetson_status.cpu_freq_unit += [ self.arr.status[i].values[2].value ] jetson_status.cpu_governor += [ self.arr.status[i].values[3].value ] else: jetson_status.cpu_load += [0] jetson_status.cpu_freq += [0] jetson_status.cpu_freq_unit += [""] jetson_status.cpu_governor += [""] # Publish self.pub_jetson_status.publish(jetson_status)