def loop(self): ModeProgram.loop(self) if self.is_mode_done(): self.next_mode() return self.status()
def loop(self): ModeProgram.loop(self) if self.mode == 0: return self.goto('fwd-1') if self.mode == 'fwd-1': d = obstacle_average() if d > self.params['obstacle_thresh']: self.first_obstacle_reading = d return self.goto('ccw-c') if self.mode == 'ccw-c': if self.has_rotated(self.params['compare_rotation']): myro.stop() d = obstacle_average() if d < self.first_obstacle_reading: self.around_mult_f = 1 else: self.around_mult_f = -1 return self.goto('cw-c') if self.mode == 'cw-c': if self.has_rotated(self.params['compare_rotation']): self.around_mult = self.around_mult_f return self.goto('ccw-1') if self.mode == 'ccw-1': if self.at_right_angle(): return self.goto('fwd-2') if self.mode == 'fwd-2': if self.has_travelled(self.params['check_dist']): return self.goto('cw-1') if self.mode == 'cw-1': if self.at_right_angle(): myro.stop() if obstacle_average() > self.params['obstacle_thresh']: return self.goto('ccw-1') else: return self.goto('ccw-2') if self.mode == 'ccw-2': if self.at_right_angle(): return self.goto('fwd-3') if self.mode == 'fwd-3': if self.has_travelled(self.params['overshoot_front']): return self.goto('cw-2') if self.mode == 'cw-2': if self.at_right_angle(): if self.side == 'front': return self.goto('fwd-4') else: return self.goto('fwd-5') if self.mode == 'fwd-4': if self.has_travelled(self.params['overshoot_side']): self.side = 'side' return self.goto('cw-1') if obstacle_average() > self.params['obstacle_thresh']: myro.stop() return self.goto('ccw-1') if self.mode == 'fwd-5': if self.has_travelled(self.x_pos * self.params['return_factor']): return self.goto('ccw-3') if obstacle_average() > self.params['obstacle_thresh']: myro.stop() return self.goto('ccw-1') if self.mode == 'ccw-3': if self.at_right_angle(): self.reset() self.start() return "restarting program"
def loop(self): ModeProgram.loop(self) if self.mode == 0: return self.goto('fwd-1') if self.mode == 'fwd-1': d = obstacle_average() if d > self.params['obstacle_thresh']: self.first_obstacle_reading = d return self.goto('ccw-c') if self.mode == 'ccw-c': if self.has_rotated(self.params['compare_rotation']): myro.stop() d = obstacle_average() if d < self.first_obstacle_reading: self.around_mult_f = 1 else: self.around_mult_f = -1 return self.goto('cw-c') if self.mode == 'cw-c': if self.has_rotated(self.params['compare_rotation']): self.around_mult = self.around_mult_f return self.goto('ccw-1') if self.mode == 'ccw-1': if self.at_right_angle(): return self.goto('fwd-2') if self.mode == 'fwd-2': if self.has_travelled(self.params['check_dist']): return self.goto('cw-1') if self.mode == 'cw-1': if self.at_right_angle(): myro.stop() if obstacle_average() > self.params['obstacle_thresh']: return self.goto('ccw-1') else: return self.goto('ccw-2') if self.mode == 'ccw-2': if self.at_right_angle(): return self.goto('fwd-3') if self.mode == 'fwd-3': if self.has_travelled(self.params['overshoot_front']): return self.goto('cw-2') if self.mode == 'cw-2': if self.at_right_angle(): if self.side == 'front': return self.goto('fwd-4') else: return self.goto('fwd-5') if self.mode == 'fwd-4': if self.has_travelled(self.params['overshoot_side']): self.side = 'side' return self.goto('cw-1') if obstacle_average() > self.params['obstacle_thresh']: myro.stop() return self.goto('ccw-1') if self.mode == 'fwd-5': if self.has_travelled(self.x_pos * self.params['return_factor']): return self.goto('ccw-3') if obstacle_average() > self.params['obstacle_thresh']: myro.stop() return self.goto('ccw-1') if self.mode == 'ccw-3': if self.at_right_angle(): self.reset() self.start() return "restarting program"
def loop(self): ModeProgram.loop(self) if self.is_mode_done(): self.next_mode() return self.status()