private static double getAcceleration(
      LXXRobotState robot, double turnRateRadians, double robotHeading) {
    final double speed = min(robot.getVelocityModule(), Rules.MAX_VELOCITY);
    final double acceleratedSpeed = min(speed + 1, Rules.MAX_VELOCITY);
    final double deceleratedSpeed1 = max(speed - 1, 0);
    final double newHeading = Utils.normalAbsoluteAngle(robotHeading + turnRateRadians);
    final int acceleration;
    if (robot
        .getBattleField()
        .contains(robot.project(newHeading, LXXUtils.getStopDistance(acceleratedSpeed) + 12))) {
      acceleration = 1;
    } else if (robot
        .getBattleField()
        .contains(robot.project(newHeading, LXXUtils.getStopDistance(speed) + 12))) {
      acceleration = 0;
    } else if (robot
        .getBattleField()
        .contains(robot.project(newHeading, LXXUtils.getStopDistance(deceleratedSpeed1) + 12))) {
      acceleration = -1;
    } else {
      acceleration = -2;
    }

    if (robot.getVelocityModule() + acceleration > Rules.MAX_VELOCITY) {
      return Rules.MAX_VELOCITY - robot.getVelocityModule();
    }
    if (robot.getVelocityModule() + acceleration < 0) {
      return -robot.getVelocityModule();
    }

    return acceleration;
  }