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 import roslib
00034 roslib.load_manifest('cob_dashboard')
00035 import rospy
00036
00037 from pr2_msgs.msg import PowerBoardState, DashboardState
00038 import std_srvs.srv
00039
00040 from rqt_robot_dashboard.dashboard import Dashboard
00041 from rqt_robot_dashboard.widgets import MonitorDashWidget, ConsoleDashWidget
00042
00043 from python_qt_binding.QtCore import QSize
00044 from python_qt_binding.QtGui import QMessageBox
00045
00046 from cob_battery import COBBattery
00047 from rqt_pr2_dashboard.pr2_runstop import PR2Runstops
00048
00049
00050 class CobDashboard(Dashboard):
00051 """
00052 Dashboard for Care-O-bots
00053
00054 :param context: the plugin context
00055 :type context: qt_gui.plugin.Plugin
00056 """
00057 def setup(self, context):
00058 self.name = 'CobDashboard'
00059 self.max_icon_size = QSize(50, 30)
00060 self.message = None
00061
00062 self._dashboard_message = None
00063 self._last_dashboard_message_time = 0.0
00064
00065 self._raw_byte = None
00066 self.digital_outs = [0, 0, 0]
00067
00068 self._console = ConsoleDashWidget(self.context, minimal=False)
00069 self._monitor = MonitorDashWidget(self.context)
00070 self._runstop = PR2Runstops('RunStops')
00071 self._batteries = [COBBattery(self.context)]
00072
00073 self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg', DashboardState, self.dashboard_callback)
00074
00075 def get_widgets(self):
00076 return [[self._monitor, self._console], [self._runstop], self._batteries]
00077
00078 def dashboard_callback(self, msg):
00079 """
00080 callback to process dashboard_agg messages
00081
00082 :param msg: dashboard_agg DashboardState message
00083 :type msg: pr2_msgs.msg.DashboardState
00084 """
00085 self._dashboard_message = msg
00086 self._last_dashboard_message_time = rospy.get_time()
00087
00088 if (msg.power_state_valid):
00089 self._batteries[0].set_power_state(msg.power_state)
00090 else:
00091 self._batteries[0].set_stale()
00092
00093 if (msg.power_board_state_valid):
00094 if msg.power_board_state.run_stop:
00095 self._runstop.set_ok()
00096 self._runstop.setToolTip(self.tr("Physical Runstop: OK\nWireless Runstop: OK"))
00097 elif msg.power_board_state.wireless_stop:
00098 self._runstop.set_physical_engaged()
00099 self._runstop.setToolTip(self.tr("Physical Runstop: Pressed\nWireless Runstop: OK"))
00100 if not msg.power_board_state.wireless_stop:
00101 self._runstop.set_wireless_engaged()
00102 self._runstop.setToolTip(self.tr("Physical Runstop: Unknown\nWireless Runstop: Pressed"))
00103 else:
00104 self._runstop.set_stale()
00105 self._runstop.setToolTip(self.tr("Physical Runstop: Stale\nWireless Runstop: Stale"))
00106
00107
00108 def shutdown_dashboard(self):
00109 self._dashboard_agg_sub.unregister()
00110
00111 def save_settings(self, plugin_settings, instance_settings):
00112 self._console.save_settings(plugin_settings, instance_settings)
00113 self._monitor.save_settings(plugin_settings, instance_settings)
00114
00115 def restore_settings(self, plugin_settings, instance_settings):
00116 self._console.restore_settings(plugin_settings, instance_settings)
00117 self._monitor.restore_settings(plugin_settings, instance_settings)