def step(self, steps): """Step the motors in sync.""" biggest = int(max(abs(steps.r), abs(steps.t))) step_size = Steps(float(steps.r) / biggest, float(steps.t) / biggest) self.r_motor.set_direction(sign(steps.r)) self.t_motor.set_direction(sign(steps.t)) accumulation = Steps(0.0, 0.0) for i in range(biggest): accumulation += step_size while abs(accumulation.r) >= 1.0 or abs(accumulation.t) >= 1.0: this_step = Polar(0.0, 0.0) if abs(accumulation.r) >= 1.0: r_step = self.r_motor.step() this_step.r = r_step if r_step.is_boundry: accumulation.r = 0.0 else: accumulation.r = accumulation.r - sign(steps.r) if abs(accumulation.t) >= 1.0: this_step.t = self.t_motor.step() accumulation.t = accumulation.t - sign(steps.t) yield this_step
def step(self, steps): """Step the motors in sync.""" biggest = int(max(abs(steps.r), abs(steps.t))) step_size = Steps(float(steps.r) / biggest, float(steps.t) / biggest) accumulation = Steps(0.0, 0.0) for i in range(biggest): accumulation += step_size while abs(accumulation.r) >= 1.0 or abs(accumulation.t) >= 1.0: this_step = Polar(0.0, 0.0) if abs(accumulation.r) >= 1.0: r_step = self.r_motor.effective_step_distance * (self.r_motor.step_size * sign(steps.r)) this_step.r = r_step accumulation.r = accumulation.r - sign(steps.r) if abs(accumulation.t) >= 1.0: this_step.t = self.t_motor.effective_step_distance * (self.t_motor.step_size * sign(steps.t)) accumulation.t = accumulation.t - sign(steps.t) yield this_step