Ejemplo n.º 1
0
    def __init__(self, state, title, params, takeoffalt):
        self.state = state
        wx.Frame.__init__(self, None, title=title, size=(
            1400, 500), style=wx.DEFAULT_FRAME_STYLE)
        self.panel = scrolled.ScrolledPanel(self, style=wx.FULL_REPAINT_ON_RESIZE)
        self.panel.SetBackgroundColour(wx.WHITE)

        # Icon
        self.SetIcon(icon.SimpleIcon("Swarm").get_ico())

        # Params to show (array)
        self.parmsToShow = params

        self.takeoffalt = takeoffalt

        self.last_layout_send = time.time()

        # layout. Column per leader, with followers underneath
        self.sizer = wx.FlexGridSizer(1, 1, 0, 0)

        # add in the pipe from MAVProxy
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, lambda evt,
                  panel=self.panel: self.on_timer(evt), self.timer)
        self.timer.Start(100)

        #Fires on window resize
        self.Bind(wx.EVT_SIZE, self.OnSize)

        # layout
        self.panel.SetSizer(self.sizer)
        self.panel.Layout()
        self.panel.SetupScrolling()
        self.Show(True)
Ejemplo n.º 2
0
    def __init__(self, state, title):
        self.state = state
        wx.Frame.__init__(self,
                          None,
                          title=title,
                          size=(350, 400),
                          style=wx.DEFAULT_FRAME_STYLE ^ wx.RESIZE_BORDER)

        #use tabs for the individual checklists
        self.createLists()
        self.panel = wx.Panel(self)
        self.nb = wx.Choicebook(self.panel, wx.ID_ANY)

        #create the tabs
        self.createWidgets()

        #assign events to the buttons on the tabs
        self.createActions()

        #add in the pipe from MAVProxy
        self.timer = wx.Timer(self)
        #self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.Bind(wx.EVT_TIMER,
                  lambda evt, notebook=self.nb: self.on_timer(evt, notebook),
                  self.timer)
        self.timer.Start(100)

        # finally, put the notebook in a sizer for the panel to manage
        # the layout
        sizer = wx.BoxSizer()
        sizer.Add(self.nb, 1, wx.EXPAND)
        self.panel.SetSizer(sizer)

        self.Show(True)
        self.pending = []
Ejemplo n.º 3
0
    def __init__(self, *k, **kw):
        kw['attribList'] = (glcanvas.WX_GL_SAMPLES, 4)
        super(Vehicle, self).__init__(*k, **kw)

        self.context = glcanvas.GLContext(self)
        self.vehicle_wavefront = None

        self.script = None
        self.script_command = 0
        self.script_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnScriptTimer, self.script_timer)

        self.angvel = None
        self.desired_quaternion = None
        self.attitude_callback = None

        self.actuation_state = None
        self.actuation_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnActuationTimer, self.actuation_timer)
Ejemplo n.º 4
0
 def kill(self, event):
     '''disarm force (kill) the drone'''
     if self.doKill.GetLabel() == "KILL":
         self.doKill.SetLabel("KILL Sure?")
         # start a 1 sec timer
         self.killTimer = wx.Timer(self)
         self.Bind(wx.EVT_TIMER, self.killTimeout, self.killTimer)
         self.killTimer.Start(1000)
     else:
         self.state.child_pipe.send(("kill", self.sysid, self.compid))
Ejemplo n.º 5
0
    def __init__(self, conn):
        super(MagicalFrame, self).__init__(None, title='Magical')

        self.state = None
        self.grid = None
        self.conn = conn
        self.button_state = None
        self.ui_is_active = False
        self.countdown = 0
        self.calibration_instruction_idx = 0

        self.InitUI()

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(60)

        self.loader_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnLoaderTimer, self.loader_timer)
        self.loader_timer.Start(50)

        self.countdown_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnCountdownTimer, self.countdown_timer)

        self.calibration_instructions_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnCalibrationInstructionsTimer,
                  self.calibration_instructions_timer)

        self.SetState('idle')
        self.main_panel.GetSizer().Fit(self)

        p = os.path
        path = p.join(p.dirname(__file__), 'data', 'quadcopter.obj')
        self.vehicle_loader = wv.ParserWorker(
            wv.ObjParser(filename=path, enable_cache=True),
            complete_callback=self.VehicleLoadCompleteCallback,
        )
        self.vehicle_loader.start()
Ejemplo n.º 6
0
 def killall(self, event):
     '''disarm force (kill) the whole swarm'''
     if self.doKillAll.GetLabel() == "ALL":
         self.doKillAll.SetLabel("ALL Sure?")
         # start a 1 sec timer
         self.killAllTimer = wx.Timer(self)
         self.Bind(wx.EVT_TIMER, self.killAllTimeout, self.killAllTimer)
         self.killAllTimer.Start(1000)
     else:
         self.state.child_pipe.send(("kill", self.sysid, self.compid))
         if len(self.listFollowers) > 0:
             for (sysidFollow, compidFollow, vehtype) in self.listFollowers:
                 self.state.child_pipe.send(
                     ("kill", sysidFollow, compidFollow))
Ejemplo n.º 7
0
    def __init__(self, state, title):
        self.state = state
        wx.Frame.__init__(self, None, title=title, size=(800, 300))
        self.panel = wx.Panel(self)
        self.panel.SetBackgroundColour('white')
        state.frame = self

        # values for the status bar
        self.values = {}

        self.menu = None
        self.menu_callback = None
        self.last_layout_send = time.time()

        #array of the names of my MPButtons
        self.buttonnames = {}
        #array of the MPButtons
        self.buttons = []

        self.control = wx.TextCtrl(self.panel,
                                   size=(800, 150),
                                   style=wx.TE_MULTILINE | wx.TE_READONLY
                                   | wx.TE_AUTO_URL)
        self.vbox = wx.BoxSizer(wx.VERTICAL)
        # start with one status row
        self.status = [wx.BoxSizer(wx.HORIZONTAL)]
        self.vbox.Add(self.status[0], 0, flag=wx.ALIGN_LEFT | wx.TOP)

        # place to hold up to  9 buttons
        self.buttongridsizer = wx.GridSizer(3, 3, 0)
        # for i in range(1, 2):
        #     btn = "Btn" + str(i)
        #     self.buttongridsizer.Add(wx.Button(self.panel, label=btn), 0, wx.EXPAND)

        self.vbox.Add(self.buttongridsizer, 1, flag=wx.GROW)
        self.vbox.Add(self.control, 0, flag=wx.LEFT | wx.BOTTOM | wx.GROW)

        self.panel.SetSizer(self.vbox)

        self.timer = wx.Timer(self)

        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(100)

        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_TEXT_URL, self.on_text_url)

        self.Show(True)
        self.pending = []
Ejemplo n.º 8
0
    def __init__(self, parent, state):
        wx.Panel.__init__(self, parent)
        self.frame = parent
        self.state = state
        self.img = None
        self.redraw_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer)
        self.Bind(wx.EVT_SET_FOCUS, self.on_focus)
        self.redraw_timer.Start(100)

        self.mouse_down = None
        self.drag_step = 10
        self.zoom = 1.0
        self.menu = None
        self.popup_menu = None
        self.wx_popup_menu = None
        self.popup_pos = None
        self.last_size = None
        self.done_PIL_warning = False
        state.brightness = 1.0

        # dragpos is the top left position in image coordinates
        self.dragpos = wx.Point(0, 0)
        self.need_redraw = True

        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.mainSizer)

        # panel for the main image
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            self.imagePanel = mp_widgets.ImagePanel(
                self, wx.EmptyImage(state.width, state.height))
        self.mainSizer.Add(self.imagePanel,
                           flag=wx.TOP | wx.LEFT | wx.GROW,
                           border=0)
        if state.mouse_events:
            self.imagePanel.Bind(wx.EVT_MOUSE_EVENTS, self.on_event)
        else:
            self.imagePanel.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse_event)
        if state.key_events:
            self.imagePanel.Bind(wx.EVT_KEY_DOWN, self.on_event)
        else:
            self.imagePanel.Bind(wx.EVT_KEY_DOWN, self.on_key_event)
        self.imagePanel.Bind(wx.EVT_MOUSEWHEEL, self.on_mouse_wheel)

        self.redraw()
        state.frame.Fit()
Ejemplo n.º 9
0
    def __init__(self, title, close_event, mlog, timestamp_in_range):
        super(MagFitUI, self).__init__(None, title=title, size=(600, 800))

        # capture the close event, log and timestamp range function
        self.close_event = close_event
        self.mlog = mlog
        self.timestamp_in_range = timestamp_in_range

        # events
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(100)
        self.Bind(wx.EVT_IDLE, self.OnIdle)

        # initialise the panels etc.
        self.init_ui()
Ejemplo n.º 10
0
    def __init__(self, state):
        wx.Frame.__init__(self, None, -1, state.title)
        self.state = state
        self.data = []
        for i in range(len(state.fields)):
            self.data.append([])
        self.paused = False

        self.create_main_panel()

        self.Bind(wx.EVT_IDLE, self.on_idle)

        self.redraw_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer)
        self.redraw_timer.Start(1000 * self.state.tickresolution)

        self.last_yrange = (None, None)
Ejemplo n.º 11
0
    def __init__(self, state, title):
        self.state = state
        wx.Frame.__init__(self, None, title=title, size=(800, 300))
        # different icons for MAVExplorer and MAVProxy
        try:
            if title == "MAVExplorer":
                self.SetIcon(icon.SimpleIcon("EXPLORER").get_ico())
            else:
                self.SetIcon(icon.SimpleIcon("CONSOLE").get_ico())
        except Exception:
            pass
        self.panel = wx.Panel(self)
        self.panel.SetBackgroundColour('white')
        state.frame = self

        # values for the status bar
        self.values = {}

        self.menu = None
        self.menu_callback = None
        self.last_layout_send = time.time()

        self.control = wx.TextCtrl(self.panel,
                                   style=wx.TE_MULTILINE | wx.TE_READONLY
                                   | wx.TE_AUTO_URL)

        self.vbox = wx.BoxSizer(wx.VERTICAL)
        # start with one status row
        self.status = [wx.BoxSizer(wx.HORIZONTAL)]
        self.vbox.Add(self.status[0], 0, flag=wx.ALIGN_LEFT | wx.TOP)
        self.vbox.Add(self.control, 1, flag=wx.LEFT | wx.BOTTOM | wx.GROW)

        self.panel.SetSizer(self.vbox)

        self.timer = wx.Timer(self)

        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(100)

        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_TEXT_URL, self.on_text_url)

        self.Show(True)
        self.pending = []
Ejemplo n.º 12
0
    def __init__(self, *k, **kw):
        super(GeodesicGrid, self).__init__(*k, **kw)

        self.vehicle_wavefront = None
        self.dragging = False

        self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
        self.Bind(wx.EVT_MOTION, self.OnMotion)

        self.attitude_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnAttitudeTimer, self.attitude_timer)
        self.attitude_timer.Start(40)

        self.gyro = Vector3(0, 0, 0)
        self.mag = Vector3(0, 0, 0)
        self.filtered_mag = Vector3(0, 0, 0)
        self.attitude_timer_last = 0
        self.attitude_timestamp = 0
Ejemplo n.º 13
0
    def __init__(self, state, title):
        self.state = state
        wx.Frame.__init__(self, None, title=title, size=(800, 300))
        self.panel = wx.Panel(self)
        self.panel.SetBackgroundColour('white')
        state.frame = self

        # values for the status bar
        self.values = {}

        # values for restserver
        # self.values_rest = {}

        # text for restserver
        # self.text_rest = TextList()

        self.menu = None
        self.menu_callback = None
        self.last_layout_send = time.time()

        self.control = wx.TextCtrl(self.panel,
                                   style=wx.TE_MULTILINE | wx.TE_READONLY
                                   | wx.TE_AUTO_URL)

        self.vbox = wx.BoxSizer(wx.VERTICAL)
        # start with one status row
        self.status = [wx.BoxSizer(wx.HORIZONTAL)]
        self.vbox.Add(self.status[0], 0, flag=wx.ALIGN_LEFT | wx.TOP)
        self.vbox.Add(self.control, 1, flag=wx.LEFT | wx.BOTTOM | wx.GROW)

        self.panel.SetSizer(self.vbox)

        self.timer = wx.Timer(self)

        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(100)

        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_TEXT_URL, self.on_text_url)

        self.Show(True)  # comment out to hide console
        self.pending = []
Ejemplo n.º 14
0
    def __init__(self, state):
        wx.Frame.__init__(self, None, -1, state.title)
        try:
            self.SetIcon(icon.SimpleIcon().get_ico())
        except Exception:
            pass
        self.state = state
        self.data = []
        for i in range(len(state.fields)):
            self.data.append([])
        self.paused = False

        self.create_main_panel()

        self.Bind(wx.EVT_IDLE, self.on_idle)

        self.redraw_timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_redraw_timer, self.redraw_timer)
        self.redraw_timer.Start(int(1000*self.state.tickresolution))

        self.last_yrange = (None, None)
Ejemplo n.º 15
0
    def __init__(self, conn):
        super(MagcalFrame, self).__init__(
            None,
            wx.ID_ANY,
            title='Magcal Graph',
        )

        self.SetMinSize((300, 300))

        self._conn = conn

        self._main_panel = wx.ScrolledWindow(self, wx.ID_ANY)
        self._main_panel.SetScrollbars(1, 1, 1, 1)

        self._magcal_panels = {}

        self._sizer = wx.BoxSizer(wx.VERTICAL)
        self._main_panel.SetSizer(self._sizer)

        idle_text = wx.StaticText(self._main_panel, wx.ID_ANY)
        idle_text.SetLabelMarkup(
            '<i>No calibration messages received yet...</i>')
        idle_text.SetForegroundColour('#444444')

        self._sizer.AddStretchSpacer()
        self._sizer.Add(
            idle_text,
            proportion=0,
            flag=wx.ALIGN_CENTER | wx.ALL,
            border=10,
        )
        self._sizer.AddStretchSpacer()

        self._timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.timer_callback, self._timer)
        self._timer.Start(200)
Ejemplo n.º 16
0
    def initUI(self):
        # Create Event Timer and Bindings
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
        self.timer.Start(100)
        self.Bind(wx.EVT_IDLE, self.on_idle)
        self.Bind(wx.EVT_CHAR_HOOK, self.on_KeyPress)

        # Create Panel
        self.panel = wx.Panel(self)
        self.vertSize = 0.09
        self.resized = False

        # Create Matplotlib Panel
        self.createPlotPanel()

        # Fix Axes - vertical is of length 2, horizontal keeps the same lengthscale
        self.rescaleX()
        self.calcFontScaling()

        # Create Horizon Polygons
        self.createHorizonPolygons()

        # Center Pointer Marker
        self.thick = 0.015
        self.createCenterPointMarker()

        # Pitch Markers
        self.dist10deg = 0.2  # Graph distance per 10 deg
        self.createPitchMarkers()

        # Add Roll, Pitch, Yaw Text
        self.createRPYText()

        # Add Airspeed, Altitude, Climb Rate Text
        self.createAARText()

        # Create Heading Pointer
        self.createHeadingPointer()

        # Create North Pointer
        self.createNorthPointer()

        # Create Battery Bar
        self.batWidth = 0.1
        self.batHeight = 0.2
        self.rOffset = 0.35
        self.createBatteryBar()

        # Create Mode & State Text
        self.createStateText()

        # Create Waypoint Text
        self.createWPText()

        # Create Waypoint Pointer
        self.createWPPointer()

        # Create Altitude History Plot
        self.createAltHistoryPlot()

        # Show Frame
        self.Show(True)
        self.pending = []
Ejemplo n.º 17
0
    def __init__(self, state, title, size):
        super(SailingDashboardFrame, self).__init__(None,
                                                    title=title,
                                                    size=size)
        self._state = state
        self._title = title

        # control update rate
        self._timer = wx.Timer(self)
        self._fps = 10.0
        self._start_time = time.time()

        # events
        self.Bind(wx.EVT_TIMER, self.OnTimer, self._timer)
        self.Bind(wx.EVT_IDLE, self.OnIdle)
        self.Bind(wx.EVT_CHAR_HOOK, self.OnKeyPress)

        # restart the timer
        self._timer.Start(milliseconds=100)

        # create wind meters for true and apparent wind
        self._wind_meter1 = WindMeter(self)
        self._wind_meter1.SetWindReference(WindReference.RELATIVE)
        self._wind_meter1.SetWindSpeedUnit(SpeedUnit.KNOTS)
        self._wind_meter1.SetWindAngle(0)
        self._wind_meter1.SetWindSpeed(0)

        self._wind_meter2 = WindMeter(self)
        self._wind_meter2.SetWindReference(WindReference.TRUE)
        self._wind_meter2.SetWindSpeedUnit(SpeedUnit.KNOTS)
        self._wind_meter2.SetWindAngle(0)
        self._wind_meter2.SetWindSpeed(0)

        # instrument display
        self._instr1 = InstrumentDisplay(self)
        self._instr1.label = "AWS"
        self._instr1.unit = "kn"
        self._instr1.value = 0.0

        self._instr2 = InstrumentDisplay(self)
        self._instr2.label = "TWS"
        self._instr2.unit = "kn"
        self._instr2.value = 0.0

        self._instr3 = InstrumentDisplay(self)
        self._instr3.label = "STW"
        self._instr3.unit = "kn"
        self._instr3.value = 0.0

        self._instr4 = InstrumentDisplay(self)
        self._instr4.label = "AWA"
        self._instr4.unit = "deg"
        self._instr4.value = 0.0

        self._instr5 = InstrumentDisplay(self)
        self._instr5.label = "TWA"
        self._instr5.unit = "deg"
        self._instr5.value = 0.0

        self._instr6 = InstrumentDisplay(self)
        self._instr6.label = "HDT"
        self._instr6.unit = "deg"
        self._instr3.value = 0.0

        # instrument panel sizers
        self._instr_sizer1 = wx.BoxSizer(wx.VERTICAL)
        self._instr_sizer1.Add(self._instr1, 1, wx.EXPAND)
        self._instr_sizer1.Add(self._instr2, 1, wx.EXPAND)
        self._instr_sizer1.Add(self._instr3, 1, wx.EXPAND)

        self._instr_sizer2 = wx.BoxSizer(wx.VERTICAL)
        self._instr_sizer2.Add(self._instr4, 1, wx.EXPAND)
        self._instr_sizer2.Add(self._instr5, 1, wx.EXPAND)
        self._instr_sizer2.Add(self._instr6, 1, wx.EXPAND)

        # top level sizers
        self._top_sizer = wx.BoxSizer(wx.HORIZONTAL)
        self._top_sizer.Add(self._wind_meter1, 2, wx.EXPAND)
        self._top_sizer.Add(self._wind_meter2, 2, wx.EXPAND)
        self._top_sizer.Add(self._instr_sizer1, 1, wx.EXPAND)
        self._top_sizer.Add(self._instr_sizer2, 1, wx.EXPAND)

        # layout sizers
        self.SetSizer(self._top_sizer)
        self.SetAutoLayout(1)