Ejemplo n.º 1
0
  /** Update normal driver control */
  private void updateDriveControl() {
    // Set speed to twist because the robot should turn in place w/ button 2
    if (driverstation.JoystickDriverButton3) {
      speed = driverstation.JoystickDriverTwist;
    } else {
      speed =
          (driverstation.getStickDistance(
              driverstation.JoystickDriverX, driverstation.JoystickDriverY));
    }

    // sets the drive speed so it will not drive below a minimum speed
    if (Math.abs(speed) < MINUMUM_DRIVE_SPEED) {
      speed = 0.0;
    }

    // Decide drive mode
    if (driverstation.JoystickDriverButton3) {
      if (driverstation.JoystickDriverTrigger) {
        speed = speed / 2;
      }
      // Rotate in place if button 3 is pressed
      drive.turnDrive(-speed);
    } else {
      // Normally use crab drive
      drive.crabDrive(
          driverstation.getStickAngle(driverstation.JoystickDriverX, driverstation.JoystickDriverY),
          speed);
    }
  }