Esempio n. 1
0
    def robotLoop(self, stop):
        bT = pikitlib.Timer()
        bT.start()
        while not stop():

            if bT.get() > 0.2:
                self.sendBatteryData()
                bT.reset()

            if not self.disabled:

                self.timer.start()
                try:
                    if self.current_mode == "Auton":
                        self.auton()
                    elif self.current_mode == "Teleop":
                        self.teleop()
                except Exception as e:
                    self.catchErrorAndLog(e)
                    break
                self.timer.stop()
                ts = 0.02 - self.timer.get()

                self.timer.reset()
                if ts < -0.5:
                    logging.critical("Program taking too long!")
                    self.quit()
                elif ts < 0:
                    logging.warning("%s has slipped by %s miliseconds!",
                                    self.current_mode, ts * -1000)
                else:
                    time.sleep(ts)
            else:
                self.disable()
        self.disable()
Esempio n. 2
0
    def __init__(self):
        """
        Construct robot disconnect, and powered on
        """
        self.r = robot.MyRobot()
        self.current_mode = ""
        self.disabled = True

        self.timer = pikitlib.Timer()
Esempio n. 3
0
    def __init__(self):
        """
        Construct robot disconnect, and powered on
        """
        self.r = None
        self.current_mode = ""
        self.disabled = True

        self.timer = pikitlib.Timer()
        self.connectedIP = None
        self.isRunning = False
Esempio n. 4
0
 def autonomousInit(self):
     self.timer = pikitlib.Timer()
     self.timer.start()