def _show(self, frame): cb = self.hidecbs[self.frames_names[frame]] if cb is not None: cb() if frame in self.tabs: frame.pack(fill=X, expand=1) else: raise CancelGUIAction("Requested frame not found: ", frame)
def __init__(self): try: from soar.serial import Serial except ImportError: print( "You are missing some serial support libraries. Probably you are on windows and you need to get pywin32. Check out http://sourceforge.net/projects/pywin32/ for details." ) raise CancelGUIAction self.portName = settings.SERIAL_PORT_NAME self.sonarsChanged = [0, 0, 0, 0, 0, 0, 0, 0] self.connectionState = STATE_NO_SYNC self.port = None self.lastxpos, self.lastypos = 0, 0 self.storedsonars = SharedVar([0, 0, 0, 0, 0, 0, 0, 0]) self.temperature = SharedVar(0) self.ldr = SharedVar([0, 0]) self.trans, self.rot = SharedVar(0), SharedVar(0) self.odpose = SharedVar((0, 0, 0)) self.stalled = SharedVar(False) self.analogInputs = SharedVar([0, 0, 0, 0]) self.analogOut = SharedVar(0) self.asynchronous = True self.setters = { "motorOutput": self.motorOutput, "discreteMotorOutput": self.discreteMotorOutput, "say": self.cmdSay, "analogOutput": self.analogOutput, "setMaxEffectiveSonarDistance": self.setMaxEffectiveSonarDistance, "enableAccelerationCap": self.enableAccelerationCap, "setMaxVelocities": self.setMaxVelocities } self.getters = { "pose": self.odpose.get, "sonarDistances": self.storedsonars.get, "stalled": self.stalled.get, "analogInputs": self.analogInputs.get } debug("Pioneer variables set up", 2) self.serialready = False try: self.open(Serial) debug("Serial Connection started", 2) except: debug("Could not open the serial port", 0) raise CancelGUIAction("Error opening serial port") self.cmdEnable(1) debug("Robot cmdEnabled", 2) app.soar.addFlowTriplet( (self.startmoving, self.update, self.stopmoving)) self.currentthread = None self.acceptMotorCmds = False self.startSerialThread()
def removeFrame(self, frame): if isinstance(frame,StringType): frame = self.names_frames[frame] if frame in self.tabs: self.tabs[frame].forget() frame.forget() self.tabs.pop(frame) self.active_tabs.pop(frame) title = self.frames_names.pop(frame) self.namepool.release(title) self.names_frames.pop(title) else: raise CancelGUIAction("Requested frame not found: ", frame)
def addFrame(self, title): self.hidecbs[title] = None if title in self.names_frames: raise CancelGUIAction("Requested frame already exists: "+title) frame = Frame(self) self.active_tabs[frame] = IntVar() self.names_frames[title] = frame self.frames_names[frame] = title title_text = title if os.name == "posix" and platform.system() == "Darwin": title_text = " " + title_text + " " tab = Checkbutton(self.tabframe, text = title_text, indicatoron = False, variable = self.active_tabs[frame], command = lambda: self._toggle(frame)) tab.select() tab.pack(fill=BOTH, side=LEFT) self.tabs[frame] = tab self._show(frame) return frame
def __init__(self): try: from soar.serial import Serial except ImportError: print "You are missing some serial support libraries. Probably you are on windows and you need to get pywin32. Check out http://sourceforge.net/projects/pywin32/ for details." raise CancelGUIAction self.sonarValues = [0, 0, 0, 0, 0, 0] self.all_Values = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] self.port = None self.serialReady = False self.ldrvalue = [0, 0] self.p_value = [0, 0] self.acc_values = [0, 0, 0, 0, 0, 0] self.pos_values = [0, 0, 0] self.EKF = Locator_EKF([0., 0.], 0.) self.offset_counter = 0 self.thread_flag = 0 self.heading = 0. self.offset_counter_iteration = 200 self.Ultrasonic_rear_right = 0 self.Ultrasonic_right = 0 self.Ultrasonic_front = 0 self.Ultrasonic_left = 0 self.Ultrasonic_rear_left = 0 self.Ultrasonic_back = 0 self.portName = -1 self.sonarsChanged = [0, 0, 0, 0, 0, 0, 0, 0] #Change to 6 after self.from_update = 0 self.connectionState = STATE_NO_SYNC self.port = None self.lastxpos, self.lastypos = 0, 0 self.storedsonars = SharedVar([0, 0, 0, 0, 0, 0, 0, 0]) #Change to 6 after self.trans, self.rot = SharedVar(0), SharedVar(0) self.odpose = SharedVar((0, 0, 0)) self.stalled = SharedVar(False) self.analogInputs = SharedVar([0, 0, 0, 0]) self.analogOut = SharedVar(0) self.asynchronous = True self.zero_recv_cnt = 0 # Added -> Not in pioneer self.setters = { "motorOutput": self.motorOutput, "discreteMotorOutput": self.discreteMotorOutput, "say": self.cmdSay, "analogOutput": self.analogOutput, "setMaxEffectiveSonarDistance": self.setMaxEffectiveSonarDistance, "enableAccelerationCap": self.enableAccelerationCap, "setMaxVelocities": self.setMaxVelocities } self.getters = { "pose": self.odpose.get, "sonarDistances": self.storedsonars.get, "stalled": self.stalled.get, "analogInputs": self.analogInputs.get } debug("eBot variables set up", 2) self.serialReady = False self.prev_sonar = [0, 0, 0, 0, 0, 0] try: self.connect(Serial) self.open() debug("Serial Connection started", 2) print "eBot connection successful" except: sys.stderr.write("Couldn't connect to eBot.\n") sys.stderr.write( "- Check if eBot is on, paired and connected. If not, power up and try again. \n" ) #sys.stderr.write("- Check to see if COM port below is eBot. If not, remove device and try again. \n") debug("Could not open the serial port", 0) print 5 raise CancelGUIAction("Error opening serial port") app.soar.addFlowTriplet( (self.startmoving, self.update, self.stopmoving)) self.currentthread = None self.acceptMotorCmds = False self.startSerialThread() sleep(7)
def _hide(self, frame): if frame in self.tabs: frame.forget() else: raise CancelGUIAction("Requested frame not found: ", frame)