def _turnMotors(leftMotorSpeed=100, rightMotorSpeed=100, indent=1): if _check(): _trace("{:{}}Turn motors at L={} R={}".format(" ", indent * 3, leftMotorSpeed, rightMotorSpeed)) pz.setMotor(MOTOR_LEFT, leftMotorSpeed) pz.setMotor(MOTOR_RIGHT, rightMotorSpeed)
def _moveTime(motorSpeed=100, seconds=0, indent=1): if _check(): _trace ("{:{}}Move for {} seconds at speed {}".format(" ", indent*3, round(seconds,3), motorSpeed)) pz.setMotor(MOTOR_LEFT, motorSpeed) pz.setMotor(MOTOR_RIGHT, motorSpeed) time.sleep(seconds) stop() _bufferWait()
def _spinTime(seconds, direction=1, indent=1): if _check(): pz.setMotor(MOTOR_LEFT, int(100 * math.copysign(1, direction))) pz.setMotor(MOTOR_RIGHT, int(100 * math.copysign(1, -direction))) _trace("{:{}}Spin for {} seconds".format(" ", indent * 3, seconds)) time.sleep(seconds) stop() _bufferWait()
def _spinAngle(degrees, indent=1): if _check(): pz.setMotor(MOTOR_LEFT, int(100 * math.copysign(1,degrees))) pz.setMotor(MOTOR_RIGHT, int(100 * math.copysign(1,-degrees))) seconds = abs(degrees) / 360.0 / _calibratedSpinsPerSecond _trace ("{:{}}Spin Angle {} for {} seconds".format(" ", indent*3, degrees, round(seconds,2))) time.sleep(seconds) stop() _bufferWait()
def stop(): pz.setMotor(MOTOR_LEFT, 0) pz.setMotor(MOTOR_RIGHT, 0)