diff --git a/Robot2019/src/main/java/frc/robot/DrivetrainCharAnalysis.java b/Robot2019/src/main/java/frc/robot/DrivetrainCharAnalysis.java index d2f7807..f9116e7 100644 --- a/Robot2019/src/main/java/frc/robot/DrivetrainCharAnalysis.java +++ b/Robot2019/src/main/java/frc/robot/DrivetrainCharAnalysis.java @@ -7,9 +7,11 @@ import java.io.IOException; import java.io.Reader; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.apache.commons.math3.stat.regression.OLSMultipleLinearRegression; +import org.apache.commons.math3.linear.SingularMatrixException; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.csv.CSVRecord; import org.apache.commons.csv.CSVFormat; @@ -64,9 +66,14 @@ public static void ordinaryLeastSquares(String file1, String file2, String outfi ys[i] = voltages[i]; } - algorithm = new OLSMultipleLinearRegression(); - algorithm.newSampleData(ys, xs); - params = algorithm.estimateRegressionParameters(); + try { + algorithm = new OLSMultipleLinearRegression(); + algorithm.newSampleData(ys, xs); + params = algorithm.estimateRegressionParameters(); + } catch (SingularMatrixException e) { + System.out.println(Arrays.deepToString(xs)); + System.out.println(Arrays.toString(ys)); + } // System.out.println(params.length); rightKv = params[1]; rightKa = params[2]; diff --git a/Robot2019/src/main/java/frc/robot/RobotMap.java b/Robot2019/src/main/java/frc/robot/RobotMap.java index c9c477c..49da18a 100644 --- a/Robot2019/src/main/java/frc/robot/RobotMap.java +++ b/Robot2019/src/main/java/frc/robot/RobotMap.java @@ -120,11 +120,6 @@ private static WPI_TalonSRX createConfiguredTalon(int port) { catchError(tsrx.configNeutralDeadband(0.001, 10)); tsrx.setNeutralMode(NeutralMode.Brake); - ecDeadband = tsrx.configNeutralDeadband(0.001, 10); - if (!ecDeadband.equals(ErrorCode.OK)) { - throw new RuntimeException(ecDeadband.toString()); - } - return tsrx; } @@ -140,11 +135,6 @@ private static WPI_VictorSPX createConfiguredVictor(int port) { catchError(vspx.configNeutralDeadband(0.001, 10)); vspx.setNeutralMode(NeutralMode.Brake); - ecDeadband = vspx.configNeutralDeadband(0.001, 10); - if (!ecDeadband.equals(ErrorCode.OK)) { - throw new RuntimeException(ecDeadband.toString()); - } - return vspx; } diff --git a/Robot2019/src/main/java/frc/robot/subsystems/Drivetrain.java b/Robot2019/src/main/java/frc/robot/subsystems/Drivetrain.java index 7e35027..892b29c 100644 --- a/Robot2019/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/Robot2019/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -198,6 +198,22 @@ public void updateDrivetrainParameters() { blKA = avg; brKA = avg; } catch (FileNotFoundException e) { + flKV = 0.06369046755507658; + flKA = 0.0215894793277297; + flVI = 0.8403701236277824; + + frKV = 0.0619423013628032; + frKA = 0.04044703465602449; + frVI = 0.810212379284332; + + blKV = 0.06388520699977113; + blKA = 0.025492804438184545; + blVI = 0.8071078220643216; + + brKV = 0.06140765089854154; + brKA = 0.042046502553651215; + brVI = 0.7929289166816246; + e.printStackTrace(); } }