Esempio n. 1
0
    def __init__(self, parent, id=wx.ID_ANY, title='Bilibot Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        wx.InitAllImageHandlers()
        
        rospy.init_node('bilibot_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("bilibot_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('Bilibot Dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('bilibot_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)
        
        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
        
        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path, "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Mode"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Breakers"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Breakers
        breaker_names = ["Digital Out 1", "Digital Out 1", "Digital Out 2"]
        self._breaker_ctrls = []
        for i in xrange(0, 3):
          ctrl = BreakerControl(self, wx.ID_ANY, i, breaker_names[i], icons_path)
          ctrl.SetToolTip(wx.ToolTip("%s"%(breaker_names[i])))
          self._breaker_ctrls.append(ctrl)
          static_sizer.Add(ctrl, 0)
        
#        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Runstops"), wx.HORIZONTAL)
#        sizer.Add(static_sizer, 0)
        
        # run-stop
#        self._runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop", False)
#        self._runstop_ctrl.SetToolTip(wx.ToolTip("Physical Runstop: Unknown"))
#        static_sizer.Add(self._runstop_ctrl, 0)
        
        # Wireless run-stop
#        self._wireless_runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop-wireless", False)
#        self._wireless_runstop_ctrl.SetToolTip(wx.ToolTip("Wireless Runstop: Unknown"))
#        static_sizer.Add(self._wireless_runstop_ctrl, 0)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Computer"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        # Laptop Battery State
        self._power_state_ctrl_laptop = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl_laptop.SetToolTip(wx.ToolTip("Computer Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl_laptop, 1, wx.EXPAND)

        self._config = wx.Config("bilibot_dashboard")
        
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        self.Layout()
        self.Fit()
        
        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)
        
        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)
        
        self.load_config()
        
        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)
    
        self._dashboard_agg_sub = rospy.Subscriber('diagnostics_agg', diagnostic_msgs.msg.DiagnosticArray, self.dashboard_callback)
        
        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
Esempio n. 2
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title='cob dashboard',
                 pos=wx.DefaultPosition,
                 size=(400, 50),
                 style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

        rospy.init_node('cob3_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("cob3_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass

        self.SetTitle('cob dashboard (%s)' % rosenv.get_master_uri())

        icons_path = path.join(roslib.packages.get_pkg_dir('pr2_dashboard'),
                               "icons/")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path,
                                                 "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)

        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)

        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Motors"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Motors"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Breakers
        breaker_names = ["Peft Arm", "Base/Body", "Right Arm"]
        self._breaker_ctrls = []
        for i in xrange(0, 3):
            ctrl = BreakerControl(self, wx.ID_ANY, i, breaker_names[i],
                                  icons_path)
            ctrl.SetToolTip(wx.ToolTip("Breaker %s" % (breaker_names[i])))
            self._breaker_ctrls.append(ctrl)
            static_sizer.Add(ctrl, 0)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "EM"),
                                         wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # run-stop
        self._runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path,
                                           "runstop", False)
        self._runstop_ctrl.SetToolTip(wx.ToolTip("Physical Runstop: Unknown"))
        static_sizer.Add(self._runstop_ctrl, 0)

        # Wireless run-stop
        #self._wireless_runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop-wireless", False)
        #self._wireless_runstop_ctrl.SetToolTip(wx.ToolTip("Wireless Runstop: Unknown"))
        #static_sizer.Add(self._wireless_runstop_ctrl, 0)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)

        self._config = wx.Config("pr2_dashboard")

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.Layout()
        self.Fit()

        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY,
                                                   "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON,
                                      self.on_diagnostics_clicked)

        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self.load_config()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)

        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg',
                                                   DashboardState,
                                                   self.dashboard_callback)

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
Esempio n. 3
0
class BilibotFrame(wx.Frame):
    _CONFIG_WINDOW_X="/Window/X"
    _CONFIG_WINDOW_Y="/Window/Y"
    
    def __init__(self, parent, id=wx.ID_ANY, title='Bilibot Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        wx.InitAllImageHandlers()
        
        rospy.init_node('bilibot_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("bilibot_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('Bilibot Dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('bilibot_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)
        
        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
        
        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path, "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Mode"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Breakers"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Breakers
        breaker_names = ["Digital Out 1", "Digital Out 1", "Digital Out 2"]
        self._breaker_ctrls = []
        for i in xrange(0, 3):
          ctrl = BreakerControl(self, wx.ID_ANY, i, breaker_names[i], icons_path)
          ctrl.SetToolTip(wx.ToolTip("%s"%(breaker_names[i])))
          self._breaker_ctrls.append(ctrl)
          static_sizer.Add(ctrl, 0)
        
#        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Runstops"), wx.HORIZONTAL)
#        sizer.Add(static_sizer, 0)
        
        # run-stop
#        self._runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop", False)
#        self._runstop_ctrl.SetToolTip(wx.ToolTip("Physical Runstop: Unknown"))
#        static_sizer.Add(self._runstop_ctrl, 0)
        
        # Wireless run-stop
#        self._wireless_runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop-wireless", False)
#        self._wireless_runstop_ctrl.SetToolTip(wx.ToolTip("Wireless Runstop: Unknown"))
#        static_sizer.Add(self._wireless_runstop_ctrl, 0)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Computer"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        # Laptop Battery State
        self._power_state_ctrl_laptop = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl_laptop.SetToolTip(wx.ToolTip("Computer Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl_laptop, 1, wx.EXPAND)

        self._config = wx.Config("bilibot_dashboard")
        
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        self.Layout()
        self.Fit()
        
        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)
        
        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)
        
        self.load_config()
        
        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)
    
        self._dashboard_agg_sub = rospy.Subscriber('diagnostics_agg', diagnostic_msgs.msg.DiagnosticArray, self.dashboard_callback)
        
        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
        
    def __del__(self):
        self._dashboard_agg_sub.unregister()
        
    def on_timer(self, evt):
      level = self._diagnostics_frame._diagnostics_panel.get_top_level_state()
      if (level == -1 or level == 3):
        if (self._diagnostics_button.set_stale()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Stale"))
      elif (level >= 2):
        if (self._diagnostics_button.set_error()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Error"))
      elif (level == 1):
        if (self._diagnostics_button.set_warn()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Warning"))
      else:
        if (self._diagnostics_button.set_ok()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: OK"))
        
      self.update_rosout()
      
      if (rospy.get_time() - self._last_dashboard_message_time > 5.0):
          self._motors_button.set_stale()
          self._power_state_ctrl.set_stale()
          self._power_state_ctrl_laptop.set_stale()
          [ctrl.reset() for ctrl in self._breaker_ctrls]
#          self._runstop_ctrl.set_stale()
#          self._wireless_runstop_ctrl.set_stale()
          ctrls = [self._motors_button, self._power_state_ctrl, self._power_state_ctrl_laptop]
          ctrls.extend(self._breaker_ctrls)
          for ctrl in ctrls:
              ctrl.SetToolTip(wx.ToolTip("No message received on dashboard_agg in the last 5 seconds"))
        
      if (rospy.is_shutdown()):
        self.Close()
        
    def on_diagnostics_clicked(self, evt):
      self._diagnostics_frame.Show()
      self._diagnostics_frame.Raise()
      
    def on_rosout_clicked(self, evt):
      self._rosout_frame.Show()
      self._rosout_frame.Raise()
      
    def on_motors_clicked(self, evt):
      menu = wx.Menu()
      menu.Bind(wx.EVT_MENU, self.on_passive_mode, menu.Append(wx.ID_ANY, "Passive Mode"))
      menu.Bind(wx.EVT_MENU, self.on_safe_mode, menu.Append(wx.ID_ANY, "Safety Mode"))
      menu.Bind(wx.EVT_MENU, self.on_full_mode, menu.Append(wx.ID_ANY, "Full Mode"))
      self._motors_button.toggle(True)
      self.PopupMenu(menu)
      self._motors_button.toggle(False)
      
    def on_passive_mode(self, evt):
      passive = rospy.ServiceProxy("/bilibot_node/set_operation_mode",bilibot_node.srv.SetBilibotMode )
      try:
        passive(bilibot_node.msg.BilibotSensorState.OI_MODE_PASSIVE)
      except rospy.ServiceException, e:
        wx.MessageBox("Failed to put the bilibot in passive mode: service call failed with error: %s"%(e), "Error", wx.OK|wx.ICON_ERROR)
Esempio n. 4
0
class PR2Frame(wx.Frame):
    _CONFIG_WINDOW_X="/Window/X"
    _CONFIG_WINDOW_Y="/Window/Y"
    
    def __init__(self, parent, id=wx.ID_ANY, title='PR2 Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        wx.InitAllImageHandlers()
        
        rospy.init_node('pr2_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("pr2_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('PR2 Dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('pr2_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)
        
        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
        
        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path, "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Motors"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Breakers"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Breakers
        breaker_names = ["Left Arm", "Base/Body", "Right Arm"]
        self._breaker_ctrls = []
        for i in xrange(0, 3):
          ctrl = BreakerControl(self, wx.ID_ANY, i, breaker_names[i], icons_path)
          ctrl.SetToolTip(wx.ToolTip("Breaker %s"%(breaker_names[i])))
          self._breaker_ctrls.append(ctrl)
          static_sizer.Add(ctrl, 0)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Runstops"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # run-stop
        self._runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop", False)
        self._runstop_ctrl.SetToolTip(wx.ToolTip("Physical Runstop: Unknown"))
        static_sizer.Add(self._runstop_ctrl, 0)
        
        # Wireless run-stop
        self._wireless_runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop-wireless", False)
        self._wireless_runstop_ctrl.SetToolTip(wx.ToolTip("Wireless Runstop: Unknown"))
        static_sizer.Add(self._wireless_runstop_ctrl, 0)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)
        
        self._config = wx.Config("pr2_dashboard")
        
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        self.Layout()
        self.Fit()
        
        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)
        
        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)
        
        self.load_config()
        
        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)
    
        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg', DashboardState, self.dashboard_callback)
        
        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
        
    def __del__(self):
        self._dashboard_agg_sub.unregister()
        
    def on_timer(self, evt):
      level = self._diagnostics_frame.get_top_level_state()
      if (level == -1 or level == 3):
        if (self._diagnostics_button.set_stale()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Stale"))
      elif (level >= 2):
        if (self._diagnostics_button.set_error()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Error"))
      elif (level == 1):
        if (self._diagnostics_button.set_warn()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Warning"))
      else:
        if (self._diagnostics_button.set_ok()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: OK"))
        
      self.update_rosout()
      
      if (rospy.get_time() - self._last_dashboard_message_time > 5.0):
          self._motors_button.set_stale()
          self._power_state_ctrl.set_stale()
          [ctrl.reset() for ctrl in self._breaker_ctrls]
          self._runstop_ctrl.set_stale()
          self._wireless_runstop_ctrl.set_stale()
          ctrls = [self._motors_button, self._power_state_ctrl, self._runstop_ctrl, self._wireless_runstop_ctrl]
          ctrls.extend(self._breaker_ctrls)
          for ctrl in ctrls:
              ctrl.SetToolTip(wx.ToolTip("No message received on dashboard_agg in the last 5 seconds"))
        
      if (rospy.is_shutdown()):
        self.Close()
        
    def on_diagnostics_clicked(self, evt):
      self._diagnostics_frame.Show()
      self._diagnostics_frame.Raise()
      
    def on_rosout_clicked(self, evt):
      self._rosout_frame.Show()
      self._rosout_frame.Raise()
      
    def on_motors_clicked(self, evt):
      menu = wx.Menu()
      menu.Bind(wx.EVT_MENU, self.on_reset_motors, menu.Append(wx.ID_ANY, "Reset"))
      menu.Bind(wx.EVT_MENU, self.on_halt_motors, menu.Append(wx.ID_ANY, "Halt"))
      self._motors_button.toggle(True)
      self.PopupMenu(menu)
      self._motors_button.toggle(False)
      
    def on_reset_motors(self, evt):
      # if any of the breakers is not enabled ask if they'd like to enable them
      if (self._dashboard_message is not None and self._dashboard_message.power_board_state_valid):
          all_breakers_enabled = reduce(lambda x,y: x and y, [state == PowerBoardState.STATE_ON for state in self._dashboard_message.power_board_state.circuit_state])
          if (not all_breakers_enabled):
              if (wx.MessageBox("Resetting the motors may not work because not all breakers are enabled.  Enable all the breakers first?", "Enable Breakers?", wx.YES_NO|wx.ICON_QUESTION, self) == wx.YES):
                  [breaker.set_enable() for breaker in self._breaker_ctrls]
        
      reset = rospy.ServiceProxy("pr2_etherCAT/reset_motors", std_srvs.srv.Empty)
       
      try:
        reset()
      except rospy.ServiceException, e:
        wx.MessageBox("Failed to reset the motors: service call failed with error: %s"%(e), "Error", wx.OK|wx.ICON_ERROR)
Esempio n. 5
0
class PR2Frame(wx.Frame):
    _CONFIG_WINDOW_X = "/Window/X"
    _CONFIG_WINDOW_Y = "/Window/Y"

    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title='cob dashboard',
                 pos=wx.DefaultPosition,
                 size=(400, 50),
                 style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

        rospy.init_node('cob3_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("cob3_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass

        self.SetTitle('cob dashboard (%s)' % rosenv.get_master_uri())

        icons_path = path.join(roslib.packages.get_pkg_dir('pr2_dashboard'),
                               "icons/")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path,
                                                 "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)

        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)

        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Motors"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Motors"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Breakers
        breaker_names = ["Peft Arm", "Base/Body", "Right Arm"]
        self._breaker_ctrls = []
        for i in xrange(0, 3):
            ctrl = BreakerControl(self, wx.ID_ANY, i, breaker_names[i],
                                  icons_path)
            ctrl.SetToolTip(wx.ToolTip("Breaker %s" % (breaker_names[i])))
            self._breaker_ctrls.append(ctrl)
            static_sizer.Add(ctrl, 0)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "EM"),
                                         wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # run-stop
        self._runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path,
                                           "runstop", False)
        self._runstop_ctrl.SetToolTip(wx.ToolTip("Physical Runstop: Unknown"))
        static_sizer.Add(self._runstop_ctrl, 0)

        # Wireless run-stop
        #self._wireless_runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop-wireless", False)
        #self._wireless_runstop_ctrl.SetToolTip(wx.ToolTip("Wireless Runstop: Unknown"))
        #static_sizer.Add(self._wireless_runstop_ctrl, 0)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)

        self._config = wx.Config("pr2_dashboard")

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.Layout()
        self.Fit()

        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY,
                                                   "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON,
                                      self.on_diagnostics_clicked)

        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self.load_config()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)

        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg',
                                                   DashboardState,
                                                   self.dashboard_callback)

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0

    def __del__(self):
        self._dashboard_agg_sub.unregister()

    def on_timer(self, evt):
        level = self._diagnostics_frame._diagnostics_panel.get_top_level_state(
        )
        if (level == -1 or level == 3):
            if (self._diagnostics_button.set_stale()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Stale"))
        elif (level >= 2):
            if (self._diagnostics_button.set_error()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Error"))
        elif (level == 1):
            if (self._diagnostics_button.set_warn()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Warning"))
        else:
            if (self._diagnostics_button.set_ok()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: OK"))

        self.update_rosout()

        if (rospy.get_time() - self._last_dashboard_message_time > 5.0):
            self._motors_button.set_stale()
            self._power_state_ctrl.set_stale()
            [ctrl.reset() for ctrl in self._breaker_ctrls]
            self._runstop_ctrl.set_stale()
            #self._wireless_runstop_ctrl.set_stale()
            ctrls = [
                self._motors_button, self._power_state_ctrl, self._runstop_ctrl
            ]
            ctrls.extend(self._breaker_ctrls)
            for ctrl in ctrls:
                ctrl.SetToolTip(
                    wx.ToolTip(
                        "No message received on dashboard_agg in the last 5 seconds"
                    ))

        if (rospy.is_shutdown()):
            self.Close()

    def on_diagnostics_clicked(self, evt):
        self._diagnostics_frame.Show()
        self._diagnostics_frame.Raise()

    def on_rosout_clicked(self, evt):
        self._rosout_frame.Show()
        self._rosout_frame.Raise()

    def on_motors_clicked(self, evt):
        menu = wx.Menu()
        menu.Bind(wx.EVT_MENU, self.on_reset_motors,
                  menu.Append(wx.ID_ANY, "Reset"))
        menu.Bind(wx.EVT_MENU, self.on_halt_motors,
                  menu.Append(wx.ID_ANY, "Halt"))
        self._motors_button.toggle(True)
        self.PopupMenu(menu)
        self._motors_button.toggle(False)

    def on_reset_motors(self, evt):
        # if any of the breakers is not enabled ask if they'd like to enable them
        if (self._dashboard_message is not None
                and self._dashboard_message.power_board_state_valid):
            all_breakers_enabled = reduce(lambda x, y: x and y, [
                state == PowerBoardState.STATE_ON for state in
                self._dashboard_message.power_board_state.circuit_state
            ])
            if (not all_breakers_enabled):
                if (wx.MessageBox(
                        "Resetting the motors may not work because not all breakers are enabled.  Enable all the breakers first?",
                        "Enable Breakers?", wx.YES_NO | wx.ICON_QUESTION,
                        self) == wx.YES):
                    [breaker.set_enable() for breaker in self._breaker_ctrls]

        reset = rospy.ServiceProxy("pr2_etherCAT/reset_motors",
                                   std_srvs.srv.Empty)

        try:
            reset()
        except rospy.ServiceException, e:
            wx.MessageBox(
                "Failed to reset the motors: service call failed with error: %s"
                % (e), "Error", wx.OK | wx.ICON_ERROR)
Esempio n. 6
0
class PR2Frame(wx.Frame):
    _CONFIG_WINDOW_X="/Window/X"
    _CONFIG_WINDOW_Y="/Window/Y"
    
    def __init__(self, parent, id=wx.ID_ANY, title='youbot_dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        wx.InitAllImageHandlers()
        
        rospy.init_node('youbot_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("youbot_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('youbot_dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('pr2_dashboard'), "icons/")
        youbot_icons_path = path.join(roslib.packages.get_pkg_dir('youbot_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagn."), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)
        
        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
        
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Platform"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # base status
        self._base_status = StatusControl(self, wx.ID_ANY, youbot_icons_path, "base", True)
        self._base_status.SetToolTip(wx.ToolTip("Base Motors: Stale"))
        static_sizer.Add(self._base_status, 0)
        self._base_status.Bind(wx.EVT_LEFT_DOWN, self.on_base_status_clicked)
        
        # arm status
        self._arm_status = StatusControl(self, wx.ID_ANY, youbot_icons_path, "arm", True)
        self._arm_status.SetToolTip(wx.ToolTip("Arm Motors: Stale"))
        static_sizer.Add(self._arm_status, 0)
        self._arm_status.Bind(wx.EVT_LEFT_DOWN, self.on_arm_status_clicked)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Drv"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # driver status
        self._driver_status = StatusControl(self, wx.ID_ANY, youbot_icons_path, "driver", True)
        self._driver_status.SetToolTip(wx.ToolTip("Driver: Stale"))
        static_sizer.Add(self._driver_status, 0)
        self._driver_status.Bind(wx.EVT_BUTTON, self.on_driver_status_clicked)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)
        
        self._config = wx.Config("youbot_dashboard")
        
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        self.Layout()
        self.Fit()
        
        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)
        
        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)
        
        self.load_config()
        
        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)
    
        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg', DashboardState, self.dashboard_callback)
        
        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
        
    def __del__(self):
        self._dashboard_agg_sub.unregister()
        
    def on_timer(self, evt):
#      level = self._diagnostics_frame._diagnostics_panel.get_top_level_state()
      level = self._diagnostics_frame.get_top_level_state()
      if (level == -1 or level == 3):
        if (self._diagnostics_button.set_stale()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Stale"))
      elif (level >= 2):
        if (self._diagnostics_button.set_error()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Error"))
      elif (level == 1):
        if (self._diagnostics_button.set_warn()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Warning"))
      else:
        if (self._diagnostics_button.set_ok()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: OK"))
        
      self.update_rosout()
      
      if (rospy.get_time() - self._last_dashboard_message_time > 5.0):
          self._power_state_ctrl.set_stale()
          self._arm_status.set_stale()
          self._base_status.set_stale()
          self._driver_status.set_stale()
                    
          ctrls = [self._power_state_ctrl, self._arm_status, self._base_status, self._driver_status]
          for ctrl in ctrls:
              ctrl.SetToolTip(wx.ToolTip("No message received on dashboard_agg in the last 5 seconds"))
        
      if (rospy.is_shutdown()):
        self.Close()
        
    def on_diagnostics_clicked(self, evt):
      self._diagnostics_frame.Show()
      self._diagnostics_frame.Raise()
      
    def on_rosout_clicked(self, evt):
      self._rosout_frame.Show()
      self._rosout_frame.Raise()
      
    def on_base_status_clicked(self, evt):
      menu = wx.Menu()
      menu.Bind(wx.EVT_MENU, self.on_base_switch_on, menu.Append(wx.ID_ANY, "Enable Base Motors"))
      menu.Bind(wx.EVT_MENU, self.on_base_switch_off, menu.Append(wx.ID_ANY, "Disable Base Motors"))
      self._base_status.toggle(True)
      self.PopupMenu(menu)
      self._base_status.toggle(False)
      
    def on_base_switch_on(self, evt):
      # if any of the breakers is not enabled ask if they'd like to enable them
      if (self._dashboard_message is not None and self._dashboard_message.power_board_state_valid):
          if (self._dashboard_message.power_board_state.circuit_state[0] == PowerBoardState.STATE_STANDBY):
              switch_on_base = rospy.ServiceProxy("/base/switchOnMotors", std_srvs.srv.Empty)
       
              try:
                  switch_on_base()
              except rospy.ServiceException, e:
                  wx.MessageBox("Failed to switch ON base motors: service call failed with error: %s"%(e), "Error", wx.OK|wx.ICON_ERROR)
          
          elif (self._dashboard_message.power_board_state.circuit_state[0] == PowerBoardState.STATE_ENABLED):
              wx.MessageBox("Base motors are already switched ON", "Error", wx.OK|wx.ICON_ERROR)
          elif (self._dashboard_message.power_board_state.circuit_state[0] == PowerBoardState.STATE_DISABLED):
              wx.MessageBox("Base is not connected", "Error", wx.OK|wx.ICON_ERROR)
Esempio n. 7
0
    def __init__(self, parent, id=wx.ID_ANY, title='youbot_dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        wx.InitAllImageHandlers()
        
        rospy.init_node('youbot_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("youbot_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('youbot_dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('pr2_dashboard'), "icons/")
        youbot_icons_path = path.join(roslib.packages.get_pkg_dir('youbot_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagn."), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)
        
        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
        
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Platform"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # base status
        self._base_status = StatusControl(self, wx.ID_ANY, youbot_icons_path, "base", True)
        self._base_status.SetToolTip(wx.ToolTip("Base Motors: Stale"))
        static_sizer.Add(self._base_status, 0)
        self._base_status.Bind(wx.EVT_LEFT_DOWN, self.on_base_status_clicked)
        
        # arm status
        self._arm_status = StatusControl(self, wx.ID_ANY, youbot_icons_path, "arm", True)
        self._arm_status.SetToolTip(wx.ToolTip("Arm Motors: Stale"))
        static_sizer.Add(self._arm_status, 0)
        self._arm_status.Bind(wx.EVT_LEFT_DOWN, self.on_arm_status_clicked)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Drv"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # driver status
        self._driver_status = StatusControl(self, wx.ID_ANY, youbot_icons_path, "driver", True)
        self._driver_status.SetToolTip(wx.ToolTip("Driver: Stale"))
        static_sizer.Add(self._driver_status, 0)
        self._driver_status.Bind(wx.EVT_BUTTON, self.on_driver_status_clicked)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)
        
        self._config = wx.Config("youbot_dashboard")
        
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        self.Layout()
        self.Fit()
        
        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)
        
        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)
        
        self.load_config()
        
        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)
    
        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg', DashboardState, self.dashboard_callback)
        
        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
Esempio n. 8
0
class PR2Frame(wx.Frame):
    _CONFIG_WINDOW_X = "/Window/X"
    _CONFIG_WINDOW_Y = "/Window/Y"

    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title='youbot_dashboard',
                 pos=wx.DefaultPosition,
                 size=(400, 50),
                 style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

        rospy.init_node('youbot_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("youbot_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass

        self.SetTitle('youbot_dashboard (%s)' % rosenv.get_master_uri())

        icons_path = path.join(roslib.packages.get_pkg_dir('pr2_dashboard'),
                               "icons/")
        youbot_icons_path = path.join(
            roslib.packages.get_pkg_dir('youbot_dashboard'), "icons/")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Diagn."), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path,
                                                 "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)

        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Platform"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # base status
        self._base_status = StatusControl(self, wx.ID_ANY, youbot_icons_path,
                                          "base", True)
        self._base_status.SetToolTip(wx.ToolTip("Base Motors: Stale"))
        static_sizer.Add(self._base_status, 0)
        self._base_status.Bind(wx.EVT_LEFT_DOWN, self.on_base_status_clicked)

        # arm status
        self._arm_status = StatusControl(self, wx.ID_ANY, youbot_icons_path,
                                         "arm", True)
        self._arm_status.SetToolTip(wx.ToolTip("Arm Motors: Stale"))
        static_sizer.Add(self._arm_status, 0)
        self._arm_status.Bind(wx.EVT_LEFT_DOWN, self.on_arm_status_clicked)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Drv"),
                                         wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # driver status
        self._driver_status = StatusControl(self, wx.ID_ANY, youbot_icons_path,
                                            "driver", True)
        self._driver_status.SetToolTip(wx.ToolTip("Driver: Stale"))
        static_sizer.Add(self._driver_status, 0)
        self._driver_status.Bind(wx.EVT_BUTTON, self.on_driver_status_clicked)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)

        self._config = wx.Config("youbot_dashboard")

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.Layout()
        self.Fit()

        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY,
                                                   "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON,
                                      self.on_diagnostics_clicked)

        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self.load_config()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)

        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg',
                                                   DashboardState,
                                                   self.dashboard_callback)

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0

    def __del__(self):
        self._dashboard_agg_sub.unregister()

    def on_timer(self, evt):
        #      level = self._diagnostics_frame._diagnostics_panel.get_top_level_state()
        level = self._diagnostics_frame.get_top_level_state()
        if (level == -1 or level == 3):
            if (self._diagnostics_button.set_stale()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Stale"))
        elif (level >= 2):
            if (self._diagnostics_button.set_error()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Error"))
        elif (level == 1):
            if (self._diagnostics_button.set_warn()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Warning"))
        else:
            if (self._diagnostics_button.set_ok()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: OK"))

        self.update_rosout()

        if (rospy.get_time() - self._last_dashboard_message_time > 5.0):
            self._power_state_ctrl.set_stale()
            self._arm_status.set_stale()
            self._base_status.set_stale()
            self._driver_status.set_stale()

            ctrls = [
                self._power_state_ctrl, self._arm_status, self._base_status,
                self._driver_status
            ]
            for ctrl in ctrls:
                ctrl.SetToolTip(
                    wx.ToolTip(
                        "No message received on dashboard_agg in the last 5 seconds"
                    ))

        if (rospy.is_shutdown()):
            self.Close()

    def on_diagnostics_clicked(self, evt):
        self._diagnostics_frame.Show()
        self._diagnostics_frame.Raise()

    def on_rosout_clicked(self, evt):
        self._rosout_frame.Show()
        self._rosout_frame.Raise()

    def on_base_status_clicked(self, evt):
        menu = wx.Menu()
        menu.Bind(wx.EVT_MENU, self.on_base_switch_on,
                  menu.Append(wx.ID_ANY, "Enable Base Motors"))
        menu.Bind(wx.EVT_MENU, self.on_base_switch_off,
                  menu.Append(wx.ID_ANY, "Disable Base Motors"))
        self._base_status.toggle(True)
        self.PopupMenu(menu)
        self._base_status.toggle(False)

    def on_base_switch_on(self, evt):
        # if any of the breakers is not enabled ask if they'd like to enable them
        if (self._dashboard_message is not None
                and self._dashboard_message.power_board_state_valid):
            if (self._dashboard_message.power_board_state.circuit_state[0] ==
                    PowerBoardState.STATE_STANDBY):
                switch_on_base = rospy.ServiceProxy("/base/switchOnMotors",
                                                    std_srvs.srv.Empty)

                try:
                    switch_on_base()
                except rospy.ServiceException, e:
                    wx.MessageBox(
                        "Failed to switch ON base motors: service call failed with error: %s"
                        % (e), "Error", wx.OK | wx.ICON_ERROR)

            elif (self._dashboard_message.power_board_state.circuit_state[0] ==
                  PowerBoardState.STATE_ENABLED):
                wx.MessageBox("Base motors are already switched ON", "Error",
                              wx.OK | wx.ICON_ERROR)
            elif (self._dashboard_message.power_board_state.circuit_state[0] ==
                  PowerBoardState.STATE_DISABLED):
                wx.MessageBox("Base is not connected", "Error",
                              wx.OK | wx.ICON_ERROR)
Esempio n. 9
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title='youbot_dashboard',
                 pos=wx.DefaultPosition,
                 size=(400, 50),
                 style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

        rospy.init_node('youbot_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("youbot_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass

        self.SetTitle('youbot_dashboard (%s)' % rosenv.get_master_uri())

        icons_path = path.join(roslib.packages.get_pkg_dir('pr2_dashboard'),
                               "icons/")
        youbot_icons_path = path.join(
            roslib.packages.get_pkg_dir('youbot_dashboard'), "icons/")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Diagn."), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path,
                                                 "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)

        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Platform"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # base status
        self._base_status = StatusControl(self, wx.ID_ANY, youbot_icons_path,
                                          "base", True)
        self._base_status.SetToolTip(wx.ToolTip("Base Motors: Stale"))
        static_sizer.Add(self._base_status, 0)
        self._base_status.Bind(wx.EVT_LEFT_DOWN, self.on_base_status_clicked)

        # arm status
        self._arm_status = StatusControl(self, wx.ID_ANY, youbot_icons_path,
                                         "arm", True)
        self._arm_status.SetToolTip(wx.ToolTip("Arm Motors: Stale"))
        static_sizer.Add(self._arm_status, 0)
        self._arm_status.Bind(wx.EVT_LEFT_DOWN, self.on_arm_status_clicked)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Drv"),
                                         wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # driver status
        self._driver_status = StatusControl(self, wx.ID_ANY, youbot_icons_path,
                                            "driver", True)
        self._driver_status.SetToolTip(wx.ToolTip("Driver: Stale"))
        static_sizer.Add(self._driver_status, 0)
        self._driver_status.Bind(wx.EVT_BUTTON, self.on_driver_status_clicked)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)

        self._config = wx.Config("youbot_dashboard")

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.Layout()
        self.Fit()

        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY,
                                                   "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON,
                                      self.on_diagnostics_clicked)

        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self.load_config()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)

        self._dashboard_agg_sub = rospy.Subscriber('dashboard_agg',
                                                   DashboardState,
                                                   self.dashboard_callback)

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
Esempio n. 10
0
    def __init__(self, parent, id=wx.ID_ANY, title='P2OS Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        wx.InitAllImageHandlers()

        self.motorStatePub = rospy.Publisher('cmd_motor_state', MotorState)
        self.motorStateSub = rospy.Subscriber("motor_state", MotorState, self.motorStateCallback)

        self.battStateSub = rospy.Subscriber("battery_state", BatteryState, self.battStateCallback)

        self.motorState = 0
        
        rospy.init_node('p2os_dashboard', anonymous=True)
        try:
            getattr(rqt, "initRoscpp")
            rqt.initRoscpp("p2os_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('P2OS Dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('p2os_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)
        
        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
        
        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path, "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Motors"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)
        
        self._config = wx.Config("p2os_dashboard")
        
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        self.Layout()
        self.Fit()
        
        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)
        
        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)
        
        self.load_config()
        
        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(1000)
        
        self.battery_msg_last_time = rospy.Time.now()
Esempio n. 11
0
class P2OSFrame(wx.Frame):
    _CONFIG_WINDOW_X="/Window/X"
    _CONFIG_WINDOW_Y="/Window/Y"
    
    def __init__(self, parent, id=wx.ID_ANY, title='P2OS Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)
        
        wx.InitAllImageHandlers()

        self.motorStatePub = rospy.Publisher('cmd_motor_state', MotorState)
        self.motorStateSub = rospy.Subscriber("motor_state", MotorState, self.motorStateCallback)

        self.battStateSub = rospy.Subscriber("battery_state", BatteryState, self.battStateCallback)

        self.motorState = 0
        
        rospy.init_node('p2os_dashboard', anonymous=True)
        try:
            getattr(rqt, "initRoscpp")
            rqt.initRoscpp("p2os_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('P2OS Dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('p2os_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)
        
        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
        
        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path, "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Motors"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)
        
        self._config = wx.Config("p2os_dashboard")
        
        self.Bind(wx.EVT_CLOSE, self.on_close)
        
        self.Layout()
        self.Fit()
        
        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)
        
        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)
        
        self.load_config()
        
        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(1000)
        
        self.battery_msg_last_time = rospy.Time.now()
        #self.motor_msg_good = false;
        
    def __del__(self):
        self._dashboard_agg_sub.unregister()

    def battStateCallback(self, msg):
		self.battery_msg_last_time = rospy.Time.now()
		self._power_state_ctrl.set_power_state(msg)

    def motorStateCallback(self, msg):
		self.motorState = msg.state

		if(self.motorState):
			self._motors_button.set_ok()
			self._motors_button.SetToolTip(wx.ToolTip("Motors: Running"))
		else:
			self._motors_button.set_error()
			self._motors_button.SetToolTip(wx.ToolTip("Motors: Halted"))

    def on_timer(self, evt):
      level = self._diagnostics_frame._diagnostics_panel.get_top_level_state()
      if (level == -1 or level == 3):
        if (self._diagnostics_button.set_stale()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Stale"))
      elif (level >= 2):
        if (self._diagnostics_button.set_error()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Error"))
      elif (level == 1):
        if (self._diagnostics_button.set_warn()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Warning"))
      else:
        if (self._diagnostics_button.set_ok()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: OK"))
        
      
      if (rospy.Time.now() > self.battery_msg_last_time + rospy.Duration(5.0)):
		  #battery msg status is stale
		  #print "setting battery to stale"
		  self._power_state_ctrl.set_stale()
      
      self.update_rosout()
      self._power_state_ctrl.updateToolTip()

      if (rospy.is_shutdown()):
        self.Close()
        
    def on_diagnostics_clicked(self, evt):
      self._diagnostics_frame.Show()
      self._diagnostics_frame.Raise()
		
    def on_rosout_clicked(self, evt):
      self._rosout_frame.Show()
      self._rosout_frame.Raise()
      
    def on_motors_clicked(self, evt):
      menu = wx.Menu()
      menu.Bind(wx.EVT_MENU, self.on_reset_motors, menu.Append(wx.ID_ANY, "Enable"))
      menu.Bind(wx.EVT_MENU, self.on_halt_motors, menu.Append(wx.ID_ANY, "Disable"))
      self._motors_button.toggle(True)
      self.PopupMenu(menu)
      self._motors_button.toggle(False)
      
    def on_reset_motors(self, evt):

      self.motorStatePub.publish(MotorState(1))
    
    def on_halt_motors(self, evt):
      self.motorStatePub.publish(MotorState(0))
                
    def update_rosout(self):
      summary_dur = 30.0
      if (rospy.get_time() < 30.0):
          summary_dur = rospy.get_time() - 1.0
          
      if (summary_dur < 0):
          summary_dur = 0.0
    
      summary = self._rosout_frame.get_panel().getMessageSummary(summary_dur)
      
      if (summary.fatal or summary.error):
        self._rosout_button.set_error()
      elif (summary.warn):
        self._rosout_button.set_warn()
      else:
        self._rosout_button.set_ok()
        
        
      tooltip = ""
      if (summary.fatal):
        tooltip += "\nFatal: %s"%(summary.fatal)
      if (summary.error):
        tooltip += "\nError: %s"%(summary.error)
      if (summary.warn):
        tooltip += "\nWarn: %s"%(summary.warn)
      if (summary.info):
        tooltip += "\nInfo: %s"%(summary.info)
      if (summary.debug):
        tooltip += "\nDebug: %s"%(summary.debug)
      
      if (len(tooltip) == 0):
        tooltip = "Rosout: no recent activity"
      else:
        tooltip = "Rosout: recent activity:" + tooltip
    
      if (tooltip != self._rosout_button.GetToolTip().GetTip()):
          self._rosout_button.SetToolTip(wx.ToolTip(tooltip))
        
    def load_config(self):
      # Load our window options
      (x, y) = self.GetPositionTuple()
      (width, height) = self.GetSizeTuple()
      if (self._config.HasEntry(self._CONFIG_WINDOW_X)):
          x = self._config.ReadInt(self._CONFIG_WINDOW_X)
      if (self._config.HasEntry(self._CONFIG_WINDOW_Y)):
          y = self._config.ReadInt(self._CONFIG_WINDOW_Y)
      
      self.SetPosition((x, y))
      self.SetSize((width, height))
        
    def save_config(self):
      config = self._config
      
      (x, y) = self.GetPositionTuple()
      (width, height) = self.GetSizeTuple()
      config.WriteInt(self._CONFIG_WINDOW_X, x)
      config.WriteInt(self._CONFIG_WINDOW_Y, y)
      
      config.Flush()
        
    def on_close(self, event):
      self.save_config()
      self.Destroy()
Esempio n. 12
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title='P2OS Dashboard',
                 pos=wx.DefaultPosition,
                 size=(400, 50),
                 style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

        self.motorStatePub = rospy.Publisher('cmd_motor_state', MotorState)
        self.motorStateSub = rospy.Subscriber("motor_state", MotorState,
                                              self.motorStateCallback)

        self.battStateSub = rospy.Subscriber("battery_state", BatteryState,
                                             self.battStateCallback)

        self.motorState = 0

        rospy.init_node('p2os_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("p2os_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass

        self.SetTitle('P2OS Dashboard (%s)' % rosenv.get_master_uri())

        icons_path = path.join(roslib.packages.get_pkg_dir('p2os_dashboard'),
                               "icons/")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path,
                                                 "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)

        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)

        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Motors"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)

        self._config = wx.Config("p2os_dashboard")

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.Layout()
        self.Fit()

        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY,
                                                   "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON,
                                      self.on_diagnostics_clicked)

        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self.load_config()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(1000)

        self.battery_msg_last_time = rospy.Time.now()
Esempio n. 13
0
class P2OSFrame(wx.Frame):
    _CONFIG_WINDOW_X = "/Window/X"
    _CONFIG_WINDOW_Y = "/Window/Y"

    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title='P2OS Dashboard',
                 pos=wx.DefaultPosition,
                 size=(400, 50),
                 style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

        self.motorStatePub = rospy.Publisher('cmd_motor_state', MotorState)
        self.motorStateSub = rospy.Subscriber("motor_state", MotorState,
                                              self.motorStateCallback)

        self.battStateSub = rospy.Subscriber("battery_state", BatteryState,
                                             self.battStateCallback)

        self.motorState = 0

        rospy.init_node('p2os_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("p2os_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass

        self.SetTitle('P2OS Dashboard (%s)' % rosenv.get_master_uri())

        icons_path = path.join(roslib.packages.get_pkg_dir('p2os_dashboard'),
                               "icons/")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path,
                                                 "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)

        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)

        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path,
                                            "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Motors"))
        static_sizer.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)

        static_sizer = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)

        # Battery State
        self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)

        self._config = wx.Config("p2os_dashboard")

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.Layout()
        self.Fit()

        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY,
                                                   "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON,
                                      self.on_diagnostics_clicked)

        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self.load_config()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(1000)

        self.battery_msg_last_time = rospy.Time.now()
        #self.motor_msg_good = false;

    def __del__(self):
        self._dashboard_agg_sub.unregister()

    def battStateCallback(self, msg):
        self.battery_msg_last_time = rospy.Time.now()
        self._power_state_ctrl.set_power_state(msg)

    def motorStateCallback(self, msg):
        self.motorState = msg.state

        if (self.motorState):
            self._motors_button.set_ok()
            self._motors_button.SetToolTip(wx.ToolTip("Motors: Running"))
        else:
            self._motors_button.set_error()
            self._motors_button.SetToolTip(wx.ToolTip("Motors: Halted"))

    def on_timer(self, evt):
        level = self._diagnostics_frame._diagnostics_panel.get_top_level_state(
        )
        if (level == -1 or level == 3):
            if (self._diagnostics_button.set_stale()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Stale"))
        elif (level >= 2):
            if (self._diagnostics_button.set_error()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Error"))
        elif (level == 1):
            if (self._diagnostics_button.set_warn()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: Warning"))
        else:
            if (self._diagnostics_button.set_ok()):
                self._diagnostics_button.SetToolTip(
                    wx.ToolTip("Diagnostics: OK"))

        if (rospy.Time.now() >
                self.battery_msg_last_time + rospy.Duration(5.0)):
            #battery msg status is stale
            #print "setting battery to stale"
            self._power_state_ctrl.set_stale()

        self.update_rosout()
        self._power_state_ctrl.updateToolTip()

        if (rospy.is_shutdown()):
            self.Close()

    def on_diagnostics_clicked(self, evt):
        self._diagnostics_frame.Show()
        self._diagnostics_frame.Raise()

    def on_rosout_clicked(self, evt):
        self._rosout_frame.Show()
        self._rosout_frame.Raise()

    def on_motors_clicked(self, evt):
        menu = wx.Menu()
        menu.Bind(wx.EVT_MENU, self.on_reset_motors,
                  menu.Append(wx.ID_ANY, "Enable"))
        menu.Bind(wx.EVT_MENU, self.on_halt_motors,
                  menu.Append(wx.ID_ANY, "Disable"))
        self._motors_button.toggle(True)
        self.PopupMenu(menu)
        self._motors_button.toggle(False)

    def on_reset_motors(self, evt):

        self.motorStatePub.publish(MotorState(1))

    def on_halt_motors(self, evt):
        self.motorStatePub.publish(MotorState(0))

    def update_rosout(self):
        summary_dur = 30.0
        if (rospy.get_time() < 30.0):
            summary_dur = rospy.get_time() - 1.0

        if (summary_dur < 0):
            summary_dur = 0.0

        summary = self._rosout_frame.get_panel().getMessageSummary(summary_dur)

        if (summary.fatal or summary.error):
            self._rosout_button.set_error()
        elif (summary.warn):
            self._rosout_button.set_warn()
        else:
            self._rosout_button.set_ok()

        tooltip = ""
        if (summary.fatal):
            tooltip += "\nFatal: %s" % (summary.fatal)
        if (summary.error):
            tooltip += "\nError: %s" % (summary.error)
        if (summary.warn):
            tooltip += "\nWarn: %s" % (summary.warn)
        if (summary.info):
            tooltip += "\nInfo: %s" % (summary.info)
        if (summary.debug):
            tooltip += "\nDebug: %s" % (summary.debug)

        if (len(tooltip) == 0):
            tooltip = "Rosout: no recent activity"
        else:
            tooltip = "Rosout: recent activity:" + tooltip

        if (tooltip != self._rosout_button.GetToolTip().GetTip()):
            self._rosout_button.SetToolTip(wx.ToolTip(tooltip))

    def load_config(self):
        # Load our window options
        (x, y) = self.GetPositionTuple()
        (width, height) = self.GetSizeTuple()
        if (self._config.HasEntry(self._CONFIG_WINDOW_X)):
            x = self._config.ReadInt(self._CONFIG_WINDOW_X)
        if (self._config.HasEntry(self._CONFIG_WINDOW_Y)):
            y = self._config.ReadInt(self._CONFIG_WINDOW_Y)

        self.SetPosition((x, y))
        self.SetSize((width, height))

    def save_config(self):
        config = self._config

        (x, y) = self.GetPositionTuple()
        (width, height) = self.GetSizeTuple()
        config.WriteInt(self._CONFIG_WINDOW_X, x)
        config.WriteInt(self._CONFIG_WINDOW_Y, y)

        config.Flush()

    def on_close(self, event):
        self.save_config()
        self.Destroy()
Esempio n. 14
0
class ElektronFrame(wx.Frame):
    _CONFIG_WINDOW_X = "/Window/X"
    _CONFIG_WINDOW_Y = "/Window/Y"

    def __init__(self, parent, id=wx.ID_ANY, title='Elektron Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

        rospy.init_node('elektron_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("elektron_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass

        self.SetTitle('Elektron Dashboard (%s)' % rosenv.get_master_uri())

        icons_path = path.join(roslib.packages.get_pkg_dir('elektron_dashboard'), "icons/")

        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Diagnostic"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "diag", True)
        self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
        static_sizer.Add(self._diagnostics_button, 0)

        # Rosout
        self._rosout_button = StatusControl(self, wx.ID_ANY, icons_path, "rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)
#~
        #~ # Motors
        #~ self._motors_button = StatusControl(self, wx.ID_ANY, icons_path, "motor", True)
        #~ self._motors_button.SetToolTip(wx.ToolTip("Mode"))
        #~ static_sizer.Add(self._motors_button, 0)
        #~ self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
#~
        #~ static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Breakers"), wx.HORIZONTAL)
        #~ sizer.Add(static_sizer, 0)
#~
        #~ # Breakers
        #~ breaker_names = ["Digital Out 1", "Digital Out 1", "Digital Out 2"]
        #~ self._breaker_ctrls = []
        #~ for i in xrange(0, 3):
          #~ ctrl = BreakerControl(self, wx.ID_ANY, i, breaker_names[i], icons_path)
          #~ ctrl.SetToolTip(wx.ToolTip("%s"%(breaker_names[i])))
          #~ self._breaker_ctrls.append(ctrl)
          #~ static_sizer.Add(ctrl, 0)

#        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Runstops"), wx.HORIZONTAL)
#        sizer.Add(static_sizer, 0)

        # run-stop
#        self._runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop", False)
#        self._runstop_ctrl.SetToolTip(wx.ToolTip("Physical Runstop: Unknown"))
#        static_sizer.Add(self._runstop_ctrl, 0)

        # Wireless run-stop
#        self._wireless_runstop_ctrl = StatusControl(self, wx.ID_ANY, icons_path, "runstop-wireless", False)
#        self._wireless_runstop_ctrl.SetToolTip(wx.ToolTip("Wireless Runstop: Unknown"))
#        static_sizer.Add(self._wireless_runstop_ctrl, 0)

        #~ static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
        #~ sizer.Add(static_sizer, 0)
#~
        #~ # Battery State
        #~ self._power_state_ctrl = PowerStateControl(self, wx.ID_ANY, icons_path)
        #~ self._power_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
        #~ static_sizer.Add(self._power_state_ctrl, 1, wx.EXPAND)

        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "CPU0"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        self._cpu0_state = CpuFrame(self, wx.ID_ANY)
        static_sizer.Add(self._cpu0_state, 1, wx.EXPAND)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "CPU1"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        self._cpu1_state = CpuFrame(self, wx.ID_ANY)
        static_sizer.Add(self._cpu1_state, 1, wx.EXPAND)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Memory"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        self._mem_state = MemFrame(self, wx.ID_ANY)
        static_sizer.Add(self._mem_state, 1, wx.EXPAND)


        # WiFi State
        self.wlan_interface = rospy.get_param('~wlan_interface', 'eth1')
        self.wlan_power = rospy.get_param('~wlan_power', 100)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "WiFi: %s" % self.wlan_interface), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        
        self._wifi_state = WifiControl(self, wx.ID_ANY, icons_path, self.wlan_interface, self.wlan_power)
        self._wifi_state.SetToolTip(wx.ToolTip("WiFi: Stale"))
        static_sizer.Add(self._wifi_state, 1, wx.EXPAND)
        
        # Laptop Battery State
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Laptop"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        self._power_state_ctrl_laptop = PowerStateControl(self, wx.ID_ANY, icons_path)
        self._power_state_ctrl_laptop.SetToolTip(wx.ToolTip("Laptop Battery: Stale"))
        static_sizer.Add(self._power_state_ctrl_laptop, 1, wx.EXPAND)
        
        
        
        # Laptop Battery State
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Main power"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        
        self._main_power_ctrl = MainPowerControl(self, wx.ID_ANY, icons_path)
        static_sizer.Add(self._main_power_ctrl, 1, wx.EXPAND)
        

        self._config = wx.Config("elektron_dashboard")

        self.Bind(wx.EVT_CLOSE, self.on_close)

        self.Layout()
        self.Fit()

        self._diagnostics_frame = DiagnosticsFrame(self, wx.ID_ANY, "Diagnostics")
        self._diagnostics_frame.Hide()
        self._diagnostics_frame.Center()
        self._diagnostics_button.Bind(wx.EVT_BUTTON, self.on_diagnostics_clicked)

        self._rosout_frame = RosoutFrame(self, wx.ID_ANY, "Rosout")
        self._rosout_frame.Hide()
        self._rosout_frame.Center()
        self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self.load_config()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer)
        self._timer.Start(500)

        self._dashboard_agg_sub = rospy.Subscriber('diagnostics_agg', diagnostic_msgs.msg.DiagnosticArray, self.dashboard_callback)

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0

    #~ def __del__(self):
        #~ self._dashboard_agg_sub.unregister()

    def on_timer(self, evt):
      level = self._diagnostics_frame._diagnostics_panel.get_top_level_state()
      if (level == -1 or level == 3):
         if (self._diagnostics_button.set_stale()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Stale"))
      elif (level >= 2):
         if (self._diagnostics_button.set_error()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Error"))
      elif (level == 1):
         if (self._diagnostics_button.set_warn()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: Warning"))
      else:
         if (self._diagnostics_button.set_ok()):
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics: OK"))

      self.update_rosout()

      #~ if (rospy.get_time() - self._last_dashboard_message_time > 5.0):
          #~ self._motors_button.set_stale()
          #~ self._power_state_ctrl.set_stale()
          #~ self._power_state_ctrl_laptop.set_stale()
          #~ [ctrl.reset() for ctrl in self._breaker_ctrls]
#~ #          self._runstop_ctrl.set_stale()
#~ #          self._wireless_runstop_ctrl.set_stale()
          #~ ctrls = [self._motors_button, self._power_state_ctrl, self._power_state_ctrl_laptop]
          #~ ctrls.extend(self._breaker_ctrls)
          #~ for ctrl in ctrls:
              #~ ctrl.SetToolTip(wx.ToolTip("No message received on dashboard_agg in the last 5 seconds"))

      if (rospy.is_shutdown()):
        self.Close()

    def on_diagnostics_clicked(self, evt):
        self._diagnostics_frame.Show()
        self._diagnostics_frame.Raise()

    def on_rosout_clicked(self, evt):
        self._rosout_frame.Show()
        self._rosout_frame.Raise()

    #~ def on_motors_clicked(self, evt):
      #~ menu = wx.Menu()
      #~ menu.Bind(wx.EVT_MENU, self.on_passive_mode, menu.Append(wx.ID_ANY, "Passive Mode"))
      #~ menu.Bind(wx.EVT_MENU, self.on_safe_mode, menu.Append(wx.ID_ANY, "Safety Mode"))
      #~ menu.Bind(wx.EVT_MENU, self.on_full_mode, menu.Append(wx.ID_ANY, "Full Mode"))
      #~ self._motors_button.toggle(True)
      #~ self.PopupMenu(menu)
      #~ self._motors_button.toggle(False)
#~
    #~ def on_passive_mode(self, evt):
      #~ passive = rospy.ServiceProxy("/turtlebot_node/set_operation_mode",turtlebot_node.srv.SetTurtlebotMode )
      #~ try:
        #~ passive(turtlebot_node.msg.TurtlebotSensorState.OI_MODE_PASSIVE)
      #~ except rospy.ServiceException, e:
        #~ wx.MessageBox("Failed to put the turtlebot in passive mode: service call failed with error: %s"%(e), "Error", wx.OK|wx.ICON_ERROR)
#~
    #~ def on_safe_mode(self, evt):
      #~ safe = rospy.ServiceProxy("/turtlebot_node/set_operation_mode",turtlebot_node.srv.SetTurtlebotMode)
      #~ try:
        #~ safe(turtlebot_node.msg.TurtlebotSensorState.OI_MODE_SAFE)
      #~ except rospy.ServiceException, e:
        #~ wx.MessageBox("Failed to put the turtlebot in safe mode: service call failed with error: %s"%(e), "Error", wx.OK|wx.ICON_ERROR)
#~
    #~ def on_full_mode(self, evt):
      #~ full = rospy.ServiceProxy("/turtlebot_node/set_operation_mode", turtlebot_node.srv.SetTurtlebotMode)
      #~ try:
        #~ full(turtlebot_node.msg.TurtlebotSensorState.OI_MODE_FULL)
      #~ except rospy.ServiceException, e:
        #~ wx.MessageBox("Failed to put the turtlebot in full mode: service call failed with error: %s"%(e), "Error", wx.OK|wx.ICON_ERROR)
#~
#~
#~
    def dashboard_callback(self, msg):
      wx.CallAfter(self.new_dashboard_message, msg)

    def new_dashboard_message(self, msg):
      self._dashboard_message = msg
      self._last_dashboard_message_time = rospy.get_time()

      battery_status = {}
      laptop_battery_status = {}
      breaker_status = {}
      wifi_status = {}
      cpu0_status = {}
      cpu1_status = {}
      mem_status = {}
      main_power_status = {}
      op_mode = None
      for status in msg.status:
          if status.name == "/Power System/Battery":
              for value in status.values:
                  battery_status[value.key] = value.value
          if status.name == "/Power System/Laptop Battery":
              for value in status.values:
                  laptop_battery_status[value.key] = value.value
              if status.message == "Stale":
                  laptop_battery_status = {}
          if status.name == "/Mode/Operating Mode":
              op_mode = status.message
          if status.name == "/Digital IO/Digital Outputs":
              for value in status.values:
                  breaker_status[value.key] = value.value
          if status.name == "/Network/%s" % self.wlan_interface:
              for value in status.values:
                  wifi_status[value.key] = value.value
          if status.name == "/System/cpu0":
              for value in status.values:
                  cpu0_status[value.key] = value.value
          if status.name == "/System/cpu1":
              for value in status.values:
                  cpu1_status[value.key] = value.value
          if status.name == "/System/Memory":
              for value in status.values:
                  mem_status[value.key] = value.value
          if status.name == "/Robot/Main Battery":
              for value in status.values:
                  main_power_status[value.key] = value.value

      #~ if (battery_status):
        #~ self._power_state_ctrl.set_power_state(battery_status)
      #~ else:
        #~ self._power_state_ctrl.set_stale()

      if (laptop_battery_status):
        self._power_state_ctrl_laptop.set_power_state(laptop_battery_status)
      else:
        self._power_state_ctrl_laptop.set_stale()
        
      if (cpu0_status):
        self._cpu0_state.set_state(cpu0_status)
      
      if (cpu1_status):
        self._cpu1_state.set_state(cpu1_status)

      if (mem_status):
        self._mem_state.set_state(mem_status)
        
      if (main_power_status):
        self._main_power_ctrl.set_power_state(main_power_status)
                
      if (wifi_status):
        self._wifi_state.set_wifi_state(wifi_status)
      else:
        self._wifi_state.set_stale()

      #~ if (op_mode):
        #~ if (op_mode=='Full'):
          #~ if (self._motors_button.set_ok()):
              #~ self._motors_button.SetToolTip(wx.ToolTip("Mode: Full"))
        #~ elif(op_mode=='Safe'):
          #~ if (self._motors_button.set_warn()):
              #~ self._motors_button.SetToolTip(wx.ToolTip("Mode: Safe"))
        #~ elif(op_mode=='Passive'):
          #~ if (self._motors_button.set_error()):
              #~ self._motors_button.SetToolTip(wx.ToolTip("Mode: Passive"))
      #~ else:
          #~ if (self._motors_button.set_stale()):
              #~ self._motors_button.SetToolTip(wx.ToolTip("Mode: Stale"))

      #~ if (breaker_status):
          #~ [ctrl.set_breaker_state(breaker_status) for ctrl in self._breaker_ctrls]


    def update_rosout(self):
        summary_dur = 30.0
        #if (rospy.get_time() < 30.0):
        #    summary_dur = rospy.get_time() - 1.0

        #if (summary_dur < 0):
        #    summary_dur = 0.0

        summary = self._rosout_frame.get_panel().getMessageSummary(summary_dur)

        if (summary.fatal or summary.error):
            self._rosout_button.set_error()
        elif (summary.warn):
            self._rosout_button.set_warn()
        else:
            self._rosout_button.set_ok()

        tooltip = ""
        if (summary.fatal):
            tooltip += "\nFatal: %s"%(summary.fatal)
        if (summary.error):
            tooltip += "\nError: %s"%(summary.error)
        if (summary.warn):
            tooltip += "\nWarn: %s"%(summary.warn)
        if (summary.info):
            tooltip += "\nInfo: %s"%(summary.info)
        if (summary.debug):
            tooltip += "\nDebug: %s"%(summary.debug)
        
        if (len(tooltip) == 0):
            tooltip = "Rosout: no recent activity"
        else:
            tooltip = "Rosout: recent activity:" + tooltip
        
        if (tooltip != self._rosout_button.GetToolTip().GetTip()):
            self._rosout_button.SetToolTip(wx.ToolTip(tooltip))



    def load_config(self):
      # Load our window options
      (x, y) = self.GetPositionTuple()
      (width, height) = self.GetSizeTuple()
      if (self._config.HasEntry(self._CONFIG_WINDOW_X)):
          x = self._config.ReadInt(self._CONFIG_WINDOW_X)
      if (self._config.HasEntry(self._CONFIG_WINDOW_Y)):
          y = self._config.ReadInt(self._CONFIG_WINDOW_Y)

      self.SetPosition((x, y))
      self.SetSize((width, height))



    def save_config(self):
      config = self._config

      (x, y) = self.GetPositionTuple()
      (width, height) = self.GetSizeTuple()
      config.WriteInt(self._CONFIG_WINDOW_X, x)
      config.WriteInt(self._CONFIG_WINDOW_Y, y)

      config.Flush()

    def on_close(self, event):
      self.save_config()

      self.Destroy()