Example #1
0
 def run(self):
     '''Update the progress bar based on a PID controller
     '''
     delta = 0.0001
     controller = PID.Controller(self.desired_speed)
     self.running = True
     while self.running:
         s = time.time()
         self.current_position = sp.Gauges.find_speed(self)[0]
         self.current_position *= controller.calculate(
             self.current_position, delta)
         #setting upper and lower bounds for the throttle commanded values
         if self.current_position < 0:
             self.current_position = 0
         elif self.current_position > 100:
             self.current_position = 100
         #emit a signal for the throttle position, would probably be read
         #from the encoder on the stepper motor
         self.throttle_position.emit(self.current_position)
         time.sleep(0.1)
         delta = time.time() - s
     self.throttle_position.emit(0)