コード例 #1
0
 /**
  * @param wheelDiameter
  * @param gearRatio
  * @param threshold Amount of allowable error in number of encoder ticks to destination.
  * @param slowDownStart Number of wheel revolutions before slowing down the first time.
  * @param fineTuneStart Number of wheel revolutions before slowing down the second time.
  * @param typePID Determines conversion factor (degrees to ticks or distance to ticks based off
  *     type)
  * @param motors
  */
 public EncoderPIDController(
     double wheelDiameter,
     int gearRatio,
     double threshold,
     double slowDownStart,
     double fineTuneStart,
     TypePID typePID,
     DcMotor... motors) {
   super(threshold, motors);
   boolean isSymmetrical = (motors.length % 2 == 0);
   int sides = 1;
   if (isSymmetrical) {
     sides = 2;
   }
   super.setSides(sides);
   this.wheelDiameter = wheelDiameter;
   this.gearRatio = gearRatio;
   this.slowDownStart = slowDownStart;
   this.fineTuneStart = fineTuneStart;
   this.typePID = typePID;
   switch (typePID) {
     case DRIVE:
       super.setConversionFactor(TICKS_PER_REVOLUTION / (wheelDiameter * Math.PI * gearRatio));
       Log.d("SetTargets", "" + conversionFactor);
       break;
     case LIFT:
       break;
     default:
       break;
   }
   targets = new double[sides];
 }