def update(self, stop_event): # Mobot hardware update loop # self.alphacv() # Removed: Image Processing doesnt happen here anymore while not stop_event.is_set(): self.touchcount = abs(self.touchcount - 1) BrickPi.MotorSpeed[L] = self.vL BrickPi.MotorSpeed[L1] = self.vL BrickPi.MotorSpeed[R] = self.vR BrickPi.MotorSpeed[R1] = self.vR result = BrickPiUpdateValues() if not result: # Successfully updated values # Read touch sensor values if BrickPi.Sensor[S2]: # Prevent signal disturbances threshold = int(28 - self.values['TCHS'] * 20) self.touchcount += 2 if self.touchcount > threshold: # Increment gates count self.status['GATC'] += 1 # Reset signal strength self.touchcount = 0 # Update encoder values self.encL = BrickPi.Encoder[L] self.encR = BrickPi.Encoder[R] speeds = self.calculateMobotMovement() self._setMotorSpeed(speeds[0], speeds[1]) self._updateStatus() # Emergency Abort if (not GPIO.input(ABORT_BTN)): warn('manually aborting mission!!!') self.stopMission() CAMERA.close() sys.exit(0) # Ramp Adapatation incline_btn = not GPIO.input(RAMP_BTN) if ((not self.incline_btn_prev) and incline_btn): # Button is pressed, set inclined self.setInclined() elif ((self.incline_btn_prev) and not incline_btn): # Button is released, unset inclined self.unsetInclined() self.incline_btn_prev = incline_btn # Update Terminal Feedback # Should be disabled for safety considerations -> STABLE_MODE if term2 != None and not STABLE_MODE: c = term2.scr.getch() if c == 410: info("@terminal: resize event") term2.resizeAll() term2.refreshAll()
def update(self, stop_event): # Mobot hardware update loop # self.alphacv() # Removed: Image Processing doesnt happen here anymore while not stop_event.is_set(): self.touchcount = abs(self.touchcount - 1) BrickPi.MotorSpeed[L] = self.vL BrickPi.MotorSpeed[L1] = self.vL BrickPi.MotorSpeed[R] = self.vR BrickPi.MotorSpeed[R1] = self.vR result = BrickPiUpdateValues() if not result: # Successfully updated values # Read touch sensor values if BrickPi.Sensor[S2]: # Prevent signal disturbances threshold = int(28 - self.values['TCHS'] * 20) self.touchcount += 2 if self.touchcount > threshold: # Increment gates count self.status['GATC'] += 1 # Reset signal strength self.touchcount = 0 # Update encoder values self.encL = BrickPi.Encoder[L] self.encR = BrickPi.Encoder[R] speeds = self.calculateMobotMovement() self._setMotorSpeed(speeds[0], speeds[1]) self._updateStatus() # Update Terminal Feedback if term2 != None and not STABLE_MODE: c = term2.scr.getch() if c == 410: info("@terminal: resize event") term2.resizeAll() term2.refreshAll()