コード例 #1
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
コード例 #2
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
コード例 #3
0
    def __init__(self,
                 parent,
                 id=wx.ID_ANY,
                 title='Hrpsys Dashboard',
                 pos=wx.DefaultPosition,
                 size=(400, 50),
                 style=wx.CAPTION | wx.CLOSE_BOX | wx.STAY_ON_TOP,
                 use_diagnostics=True,
                 use_rosout=True,
                 use_battery=True):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

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

        self.SetTitle('%s (%s)' % (title, rosenv.get_master_uri()))

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

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

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

        # Diagnostics
        if use_diagnostics:
            self._diagnostics_button = StatusControl(self, wx.ID_ANY,
                                                     self._icons_path, "diag",
                                                     True)
            self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
            static_poser.Add(self._diagnostics_button, 0)
        else:
            self._diagnostics_button = None

        # Rosout
        if use_rosout:
            self._rosout_button = StatusControl(self, wx.ID_ANY,
                                                self._icons_path, "rosout",
                                                True)
            self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
            static_poser.Add(self._rosout_button, 0)
        else:
            self._rosout_button = None

        # Log
        self._log_button = StatusControl(self, wx.ID_ANY, self._icons_path,
                                         "breakerleft", True)
        self._log_button.SetToolTip(wx.ToolTip("Log"))
        static_poser.Add(self._log_button, 0)
        if not use_diagnostics:
            self._log_button.set_ok()

        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, self._icons_path,
                                            "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Mode"))
        static_poser.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
        if not use_diagnostics:
            self._motors_button.set_ok()

        # power / motor
        static_poser = wx.StaticBoxSizer(
            wx.StaticBox(self, wx.ID_ANY, "Power"), wx.HORIZONTAL)
        sizer.Add(static_poser, 0)

        self._power_button = StatusControl(self, wx.ID_ANY, self._icons_path,
                                           "runstop", False)
        self._power_button.SetToolTip(wx.ToolTip("Power"))
        static_poser.Add(self._power_button, 0)

        if use_battery:
            static_poser = wx.StaticBoxSizer(
                wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
            sizer.Add(static_poser, 0)

            # Battery State
            self._battery_state_ctrl = PowerStateControl(
                self, wx.ID_ANY, self._icons_path)
            self._battery_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
            static_poser.Add(self._battery_state_ctrl, 1, wx.EXPAND)
        else:
            self._battery_state_ctrl = None

        #
        self.setup_extra_layout()

        self._config = wx.Config("hrpsys_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()
        if self._diagnostics_button:
            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()
        if self._rosout_button:
            self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self._log_frame = RosoutFrame(self, wx.ID_ANY, "Log")
        self._log_frame.Hide()
        self._log_frame.Center()
        self._log_button.Bind(wx.EVT_BUTTON, self.on_log_clicked)

        self.load_config()

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

        if use_diagnostics:
            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
コード例 #4
0
    def __init__(self, parent, id=wx.ID_ANY, title='Dragonbot 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.battStateSub = rospy.Subscriber("battery_state", BatteryState, self.battStateCallback)
        self.motorState = 0

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

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

        icons_path = path.join(roslib.packages.get_pkg_dir('dragonbot_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)

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


        #sizer.Add(static_sizer, 0)

        # Battery State (not yet)
        #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("dragonbot_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
コード例 #5
0
ファイル: test_roslib_rosenv.py プロジェクト: Nishida-Lab/RCR
  def test_get_ros_master_uri(self):
    from roslib.rosenv import get_master_uri
    self.assertEquals(None, get_master_uri(required=False, env={}))
    self.assertEquals(None, get_master_uri(False, {}))
    try:
      get_master_uri(required=True, env={})
      self.fail("get_ros_package_path should have raised")
    except: pass
    env = {'ROS_MASTER_URI': 'http://localhost:1234'}
    self.assertEquals('http://localhost:1234', get_master_uri(True, env=env))
    self.assertEquals('http://localhost:1234', get_master_uri(False, env=env))

    argv = ['__master:=http://localhost:5678']
    self.assertEquals('http://localhost:5678', get_master_uri(False, env=env, argv=argv))

    try:
      argv = ['__master:=http://localhost:5678:=http://localhost:1234']
      get_master_uri(required=False, env=env, argv=argv)
      self.fail("should have thrown")
    except roslib.rosenv.ROSEnvException: pass

    try:
      argv = ['__master:=']
      get_master_uri(False, env=env, argv=argv)
      self.fail("should have thrown")
    except roslib.rosenv.ROSEnvException: pass
    
    # make sure test works with os.environ
    self.assertEquals(os.environ.get('ROS_MASTER_URI', None), get_master_uri(required=False))
コード例 #6
0
ファイル: main_frame.py プロジェクト: RCPRG-ros-pkg/lwr_gui
    def __init__(self, parent, id=wx.ID_ANY, title='Kuka LWR 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('lwr_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("lwr_dashboard_cpp", anonymous=True)
        except AttributeError:
            print "rxtools error"
            pass

        self.SetTitle('Kuka LWR Dashboard (%s)' % rosenv.get_master_uri())

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


        self._robots = rospy.get_param("robots", [""])

        if (len(self._robots) == 0):
            self._has_many = False
        else:
            self._has_many = True


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

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

        # Diagnostics
        self._diagnostics_button = StatusControl(self, wx.ID_ANY, icons_path, "btn_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, "btn_rosout", True)
        self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
        static_sizer.Add(self._rosout_button, 0)

        self.FRI_COMMAND = 1
        self.FRI_MONITOR = 2

        self._fri_state_button = {}
        self._fri_control = {}
        self._fri_mode_topic = {}
        self._robot_control = {}

        i = 0
        for robot in self._robots:
			
            print "Preparing robot: '%s'"%(robot)
            robot_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, " %s " % robot), wx.HORIZONTAL)


            # FRI State
            static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, " FRI "), wx.HORIZONTAL)
            robot_sizer.Add(static_sizer, 0)

            self._fri_state_button[robot] = StatusControl(self, wx.ID_ANY, icons_path, "btn_state", True)
            self._fri_state_button[robot].SetToolTip(wx.ToolTip("FRI state"))
           
            self._fri_state_button[robot].Bind(wx.EVT_BUTTON, lambda x, r=robot: self.on_fri_state_clicked(x, r))
            static_sizer.Add(self._fri_state_button[robot], 0)

            self._fri_control[robot] = FRIControl(self, wx.ID_ANY, icons_path)
            self._fri_control[robot].SetToolTip(wx.ToolTip("FRI: Stale"))
            static_sizer.Add(self._fri_control[robot], 1, wx.EXPAND)


            self._fri_mode_topic[robot] = rospy.Publisher("%sarm_controller/fri_set_mode" % robot, std_msgs.msg.Int32)

            # Robot State
            static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, " Robot "), wx.HORIZONTAL)
            robot_sizer.Add(static_sizer, 0)

            self._robot_control[robot] = RobotControl(self, wx.ID_ANY, icons_path)
            self._robot_control[robot].SetToolTip(wx.ToolTip("Robot: Stale"))
            static_sizer.Add(self._robot_control[robot], 1, wx.EXPAND)

            sizer.Add(robot_sizer, 0)

            i = i + 1


        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._topic = "diagnostic"

        self._subs = []
        sub = rospy.Subscriber(self._topic, diagnostic_msgs.msg.DiagnosticArray, self.dashboard_callback)
        self._subs.append(sub)

        print "Subs.size %d" % len(self._subs)

        self._dashboard_message = None
        self._last_dashboard_message_time = 0.0
コード例 #7
0
ファイル: pr2_frame.py プロジェクト: Abulala/youbot-ros-pkg
    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
コード例 #8
0
ファイル: pr2_frame.py プロジェクト: ram651991/youbot-ros-pkg
    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
コード例 #9
0
    def __init__(self, parent, id=wx.ID_ANY, title='Hrpsys Dashboard', pos=wx.DefaultPosition, size=(400, 50), style=wx.CAPTION|wx.CLOSE_BOX|wx.STAY_ON_TOP, use_diagnostics=True, use_rosout=True, use_battery=True):
        wx.Frame.__init__(self, parent, id, title, pos, size, style)

        wx.InitAllImageHandlers()

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

        self.SetTitle('%s (%s)'%(title,rosenv.get_master_uri()))

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

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

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

        # Diagnostics
        if use_diagnostics:
          self._diagnostics_button = StatusControl(self, wx.ID_ANY, self._icons_path, "diag", True)
          self._diagnostics_button.SetToolTip(wx.ToolTip("Diagnostics"))
          static_poser.Add(self._diagnostics_button, 0)
        else:
          self._diagnostics_button = None

        # Rosout
        if use_rosout:
          self._rosout_button = StatusControl(self, wx.ID_ANY, self._icons_path, "rosout", True)
          self._rosout_button.SetToolTip(wx.ToolTip("Rosout"))
          static_poser.Add(self._rosout_button, 0)
        else:
          self._rosout_button = None

        # Log
        self._log_button = StatusControl(self, wx.ID_ANY, self._icons_path, "breakerleft", True)
        self._log_button.SetToolTip(wx.ToolTip("Log"))
        static_poser.Add(self._log_button, 0)
        if not use_diagnostics:
          self._log_button.set_ok()

        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, self._icons_path, "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Mode"))
        static_poser.Add(self._motors_button, 0)
        self._motors_button.Bind(wx.EVT_LEFT_DOWN, self.on_motors_clicked)
        if not use_diagnostics:
          self._motors_button.set_ok()

        # power / motor
        static_poser = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Power"), wx.HORIZONTAL)
        sizer.Add(static_poser, 0)

        self._power_button = StatusControl(self, wx.ID_ANY, self._icons_path, "runstop", False)
        self._power_button.SetToolTip(wx.ToolTip("Power"))
        static_poser.Add(self._power_button, 0)


        if use_battery:
          static_poser = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Battery"), wx.HORIZONTAL)
          sizer.Add(static_poser, 0)

          # Battery State
          self._battery_state_ctrl = PowerStateControl(self, wx.ID_ANY, self._icons_path)
          self._battery_state_ctrl.SetToolTip(wx.ToolTip("Battery: Stale"))
          static_poser.Add(self._battery_state_ctrl, 1, wx.EXPAND)
        else:
          self._battery_state_ctrl = None

        #
        self.setup_extra_layout()

        self._config = wx.Config("hrpsys_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()
        if self._diagnostics_button:
          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()
        if self._rosout_button:
          self._rosout_button.Bind(wx.EVT_BUTTON, self.on_rosout_clicked)

        self._log_frame = RosoutFrame(self, wx.ID_ANY, "Log")
        self._log_frame.Hide()
        self._log_frame.Center()
        self._log_button.Bind(wx.EVT_BUTTON, self.on_log_clicked)

        self.load_config()

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

        if use_diagnostics:
          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
コード例 #10
0
    def test_get_ros_master_uri(self):
        from roslib.rosenv import get_master_uri
        self.assertEquals(None, get_master_uri(required=False, env={}))
        self.assertEquals(None, get_master_uri(False, {}))
        try:
            get_master_uri(required=True, env={})
            self.fail("get_ros_package_path should have raised")
        except:
            pass
        env = {'ROS_MASTER_URI': 'http://localhost:1234'}
        self.assertEquals('http://localhost:1234', get_master_uri(True,
                                                                  env=env))
        self.assertEquals('http://localhost:1234',
                          get_master_uri(False, env=env))

        argv = ['__master:=http://localhost:5678']
        self.assertEquals('http://localhost:5678',
                          get_master_uri(False, env=env, argv=argv))

        try:
            argv = ['__master:=http://localhost:5678:=http://localhost:1234']
            get_master_uri(required=False, env=env, argv=argv)
            self.fail("should have thrown")
        except roslib.rosenv.ROSEnvException:
            pass

        try:
            argv = ['__master:=']
            get_master_uri(False, env=env, argv=argv)
            self.fail("should have thrown")
        except roslib.rosenv.ROSEnvException:
            pass

        # make sure test works with os.environ
        self.assertEquals(os.environ.get('ROS_MASTER_URI', None),
                          get_master_uri(required=False))
コード例 #11
0
    def __init__(self, parent, id=wx.ID_ANY, title='Nao 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('nao_dashboard', anonymous=True)
        try:
            getattr(rxtools, "initRoscpp")
            rxtools.initRoscpp("nao_dashboard_cpp", anonymous=True)
        except AttributeError:
            pass
        
        self.SetTitle('Nao Dashboard (%s)'%rosenv.get_master_uri())
        
        icons_path = path.join(roslib.packages.get_pkg_dir('nao_dashboard'), "icons/")
        
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SetSizer(sizer)
        
        static_sizer = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Robot"), wx.HORIZONTAL)
        sizer.Add(static_sizer, 0)
        self._robot_combobox = wx.ComboBox(self, wx.ID_ANY, "", choices = [])
        static_sizer.Add(self._robot_combobox, 0)
        
        gobject.threads_init()
        dbus.glib.threads_init() 
        self.robots = []
        self.sys_bus = dbus.SystemBus()
        self.avahi_server = dbus.Interface(self.sys_bus.get_object(avahi.DBUS_NAME, '/'), avahi.DBUS_INTERFACE_SERVER)

        self.sbrowser = dbus.Interface(self.sys_bus.get_object(avahi.DBUS_NAME, self.avahi_server.ServiceBrowserNew(avahi.IF_UNSPEC,
            avahi.PROTO_INET, '_naoqi._tcp', 'local', dbus.UInt32(0))), avahi.DBUS_INTERFACE_SERVICE_BROWSER)

        self.sbrowser.connect_to_signal("ItemNew", self.avahiNewItem)
        self.sbrowser.connect_to_signal("ItemRemove", self.avahiItemRemove)

        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)
        
        # Joint temperature
        self._temp_joint_button = StatusControl(self, wx.ID_ANY, icons_path, "temperature_joints", True)
        self._temp_joint_button.SetToolTip(wx.ToolTip("Joint temperatures"))
        static_sizer.Add(self._temp_joint_button, 0)

        # CPU temperature
        self._temp_head_button = StatusControl(self, wx.ID_ANY, icons_path, "temperature_head", True)
        self._temp_head_button.SetToolTip(wx.ToolTip("CPU temperature"))
        static_sizer.Add(self._temp_head_button, 0)

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

        # Motors
        self._motors_button = StatusControl(self, wx.ID_ANY, icons_path, "motor", True)
        self._motors_button.SetToolTip(wx.ToolTip("Stiffness"))
        self._motors_button._ok = (wx.Bitmap(path.join(icons_path, "stiffness-off-untoggled.png"), wx.BITMAP_TYPE_PNG), 
                    wx.Bitmap(path.join(icons_path, "stiffness-off-toggled.png"), wx.BITMAP_TYPE_PNG))
        self._motors_button._warn = (wx.Bitmap(path.join(icons_path, "stiffness-partially-untoggled.png"), wx.BITMAP_TYPE_PNG), 
                    wx.Bitmap(path.join(icons_path, "stiffness-partially-toggled.png"), wx.BITMAP_TYPE_PNG))
        self._motors_button._error = (wx.Bitmap(path.join(icons_path, "stiffness-on-untoggled.png"), wx.BITMAP_TYPE_PNG), 
                     wx.Bitmap(path.join(icons_path, "stiffness-on-toggled.png"), wx.BITMAP_TYPE_PNG))
        self._motors_button._stale = (wx.Bitmap(path.join(icons_path, "stiffness-stale-untoggled.png"), wx.BITMAP_TYPE_PNG), 
                    wx.Bitmap(path.join(icons_path, "stiffness-stale-toggled.png"), wx.BITMAP_TYPE_PNG))
        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("nao_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._agg_sub = rospy.Subscriber('diagnostics_agg', DiagnosticArray, self.diagnostic_callback)
        self._last_diagnostics_message_time = 0.0
        self.bodyPoseClient = actionlib.SimpleActionClient('body_pose', BodyPoseAction)
        self.stiffnessEnableClient = rospy.ServiceProxy("body_stiffness/enable", std_srvs.srv.Empty)
        self.stiffnessDisableClient = rospy.ServiceProxy("body_stiffness/disable", std_srvs.srv.Empty)