def __init__(self, parent, id, title): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, (800, 600)) hbox= wx.BoxSizer(wx.HORIZONTAL) vbox = wx.BoxSizer(wx.VERTICAL) hboxcontrols = wx.BoxSizer(wx.HORIZONTAL) hboxlist = wx.BoxSizer(wx.HORIZONTAL) vbox.Add(hboxcontrols, 1, wx.EXPAND) vbox.Add(hboxlist, 1, wx.EXPAND) #comment load motor and load led when working on gui #load motor motorSettings = settings.MotorSettings().get() self.motorController = motorControl.MotorControl(motorSettings) self.motorController.setAllSpeed(100) #parse motor setting to get min and max angle, store result in hash motors motors = {} motorsConfig=motorSettings["motorConfig"] for motor in motorsConfig: motors[motor[3]] = [motor[1], motor[2]] #load led self.ledController = python2arduino.Arduino() #uncomment when working on gui #motors = {"bowl": [0, 150], "bottom": [0, 150], "mid": [0, 150], "top": [0, 150], "head": [0, 150]} #visual element #bowl button pnlBowl = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlBowl, 1, wx.ALL |wx.EXPAND, 1) self.sldBowl = wx.Slider(pnlBowl, -1, motors["bowl"][0], motors["bowl"][0], motors["bowl"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textBowl = wx.StaticText(pnlBowl, -1, 'Bowl') vboxBowl = wx.BoxSizer(wx.VERTICAL) vboxBowl.Add(self.sldBowl, 1, wx.CENTER, 0) vboxBowl.Add(textBowl, 1, wx.CENTER) pnlBowl.SetSizer(vboxBowl) #bottom button pnlBottom = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlBottom, 1, wx.ALL | wx.EXPAND, 1) self.sldBottom = wx.Slider(pnlBottom, -1, motors["bottom"][1], motors["bottom"][0], motors["bottom"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textBottom = wx.StaticText(pnlBottom, -1, 'Bottom') vboxBottom = wx.BoxSizer(wx.VERTICAL) vboxBottom.Add(self.sldBottom, 1, wx.CENTER) vboxBottom.Add(textBottom, 1, wx.CENTER) pnlBottom.SetSizer(vboxBottom) #middle button pnlMiddle = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlMiddle, 1, wx.ALL | wx.EXPAND, 1) self.sldMiddle = wx.Slider(pnlMiddle, -1, motors["mid"][0], motors["mid"][0], motors["mid"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textMiddle = wx.StaticText(pnlMiddle, -1, 'Middle') vboxMiddle= wx.BoxSizer(wx.VERTICAL) vboxMiddle.Add(self.sldMiddle, 1, wx.CENTER) vboxMiddle.Add(textMiddle, 1, wx.CENTER) pnlMiddle.SetSizer(vboxMiddle) #top button pnlTop = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlTop, 1, wx.ALL | wx.EXPAND, 1) self.sldTop = wx.Slider(pnlTop, -1, motors["top"][0], motors["top"][0], motors["top"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textTop = wx.StaticText(pnlTop, -1, 'Top') vboxTop = wx.BoxSizer(wx.VERTICAL) vboxTop.Add(self.sldTop, 1, wx.CENTER) vboxTop.Add(textTop, 1, wx.CENTER) pnlTop.SetSizer(vboxTop) #head button pnlHead = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlHead, 1, wx.ALL | wx.EXPAND, 1) self.sldHead = wx.Slider(pnlHead, -1, motors["head"][0], motors["head"][0], motors["head"][1], wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textHead = wx.StaticText(pnlHead, -1, 'Head') vboxHead = wx.BoxSizer(wx.VERTICAL) vboxHead.Add(self.sldHead, 1, wx.CENTER) vboxHead.Add(textHead, 1, wx.CENTER) pnlHead.SetSizer(vboxHead) #red button pnlRed = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlRed, 1, wx.ALL | wx.EXPAND, 1) self.sldRed = wx.Slider(pnlRed, -1, 0, 0, 255, wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textRed = wx.StaticText(pnlRed, -1, 'Red') vboxRed = wx.BoxSizer(wx.VERTICAL) vboxRed.Add(self.sldRed, 1, wx.CENTER) vboxRed.Add(textRed, 1, wx.CENTER) pnlRed.SetSizer(vboxRed) #green button pnlGreen = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlGreen, 1, wx.ALL | wx.EXPAND, 1) self.sldGreen = wx.Slider(pnlGreen, -1, 0, 0, 255, wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textGreen = wx.StaticText(pnlGreen, -1, 'Green') vboxGreen = wx.BoxSizer(wx.VERTICAL) vboxGreen.Add(self.sldGreen, 1, wx.CENTER) vboxGreen.Add(textGreen, 1, wx.CENTER) pnlGreen.SetSizer(vboxGreen) #blue button pnlBlue = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) hboxcontrols.Add(pnlBlue, 1, wx.ALL | wx.EXPAND, 1) self.sldBlue = wx.Slider(pnlBlue, -1, 0, 0, 255, wx.DefaultPosition, (-1, -1), wx.SL_VERTICAL | wx.SL_LABELS) textBlue = wx.StaticText(pnlBlue, -1, 'Blue') vboxBlue = wx.BoxSizer(wx.VERTICAL) vboxBlue.Add(self.sldBlue, 1, wx.CENTER) vboxBlue.Add(textBlue, 1, wx.CENTER) pnlBlue.SetSizer(vboxBlue) #buttons pnlButtons = wx.Panel(self, -1, style=wx.SIMPLE_BORDER) vboxButton = wx.BoxSizer(wx.VERTICAL) gotoButton = wx.Button(pnlButtons, 7, 'Go To') vboxButton.Add(gotoButton, 1, wx.ALIGN_CENTER | wx.TOP, 15) wx.EVT_BUTTON(self, 7, self.OnGoto) savePositionButton = wx.Button(pnlButtons, 8, 'Save to list') vboxButton.Add(savePositionButton, 1, wx.ALIGN_CENTER | wx.TOP, 15) wx.EVT_BUTTON(self, 8, self.OnSavePosition) deletePositionButton = wx.Button(pnlButtons, 9, 'Delete from list') vboxButton.Add(deletePositionButton, 1, wx.ALIGN_CENTER | wx.TOP, 15) wx.EVT_BUTTON(self, 9, self.OnDeletePosition) playButton = wx.Button(pnlButtons, 10, 'Play') vboxButton.Add(playButton, 1, wx.ALIGN_CENTER | wx.TOP, 15) wx.EVT_BUTTON(self, 10, self.OnPlay) stopButton = wx.Button(pnlButtons, 11, 'Stop') vboxButton.Add(stopButton, 1, wx.ALIGN_CENTER | wx.TOP | wx.BOTTOM, 15) wx.EVT_BUTTON(self, 11, self.OnStop) pnlButtons.SetSizer(vboxButton) #list of position self.positionList = wx.ListCtrl(self, -1, style=wx.LC_REPORT) self.positionList.InsertColumn(0, 'bowl') self.positionList.InsertColumn(1, 'bottom') self.positionList.InsertColumn(2, 'middle') self.positionList.InsertColumn(3, 'top') self.positionList.InsertColumn(4, 'head') self.positionList.InsertColumn(5, 'red') self.positionList.InsertColumn(6, 'green') self.positionList.InsertColumn(7, 'blue') hboxlist.Add(self.positionList, 1, wx.EXPAND) hbox.Add(vbox, 5, wx.EXPAND | wx.ALL, 1) hbox.Add(pnlButtons, 1, wx.EXPAND | wx.ALL, 1) self.SetSize((800, 600)) self.SetSizer(hbox) self.Centre()
import motorControl import plot sys.path.insert(0, "../settings/") import settings import time import cv2 import select def moveAndPlot(motorControler, plotter, values): motorControler.setMotorsByName(values) out = motorControler.readAllMotors() plotter.addNewVal(out, time.time() - initTime) motorSettings = settings.MotorSettings() motorControler = motorControl.MotorControl(motorSettings.get()) motorControler.setAllSpeed(100) plotter = plot.Ploting() initTime = time.time() exit = False while not exit: if select.select([sys.stdin], [], [], 0) == ([sys.stdin], [], []): cmd = sys.stdin.read(1) if cmd == 'q': exit = True elif cmd == 'p': plotter.plot()
import searchFaces import sleep sys.path.insert(0,"../control/") import motorControl import cameraControl sys.path.insert(0,"../computerVision/") import FaceDetection sys.path.insert(0,"../settings/") import settings import time sys.path.insert(0, "../arduino/") import python2arduino import cv2 #Chargement du bras controlé motorSettings = settings.MotorSettings() motorControler = motorControl.MotorControl(motorSettings.get()) #Chargement du joystick joystickSettings = settings.MotorSettings() joystickControler = motorControl.Control(motorSettings.get()) #Activation de la caméra pour avoir un retour du robot faceStream = FaceDetection.FaceStream(0) #Camera precision = 0.1 res = [360,240] apertureAngle = [50.,30.]
def __init__(self, settingPath=None, debug=False): if settingPath != None: motorSettings = settings.MotorSettings(settingPath) else: motorSettings = settings.MotorSettings() self.motorControl = motorControl.MotorControl(motorSettings.get())