def __init__(self): 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 = 100
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)