def loop(self): """Advances to the next mode and performs the instruction when it is time (when the condition is met), otherwise does nothing.""" BaseProgram.loop(self) if self.condition_satisfied(): self.increment_mode() self.perform_instruction() return self.s
def __call__(self, command): base_response = BaseProgram.__call__(self, command) if base_response: return base_response return "unrecognized command"
def start(self): """Fixes the start time so that the pause doesn't count towards the elapsed time, and continues the previous motion of the robot.""" BaseProgram.start(self) self.start_time += time.time() - self.pause_time self.perform_instruction()
def stop(self): """Record the time when the program is paused.""" BaseProgram.stop(self) self.pause_time = time.time()
def reset(self): """Resets the program to the first mode.""" BaseProgram.reset(self) self.mode_ind = -1
def __init__(self, seq): """Creates a program that interprets the given sequence.""" BaseProgram.__init__(self) self.seq = seq self.build_maps() self.reset()