Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions Robot2019/src/main/java/frc/robot/DrivetrainCharAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down
10 changes: 0 additions & 10 deletions Robot2019/src/main/java/frc/robot/RobotMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
16 changes: 16 additions & 0 deletions Robot2019/src/main/java/frc/robot/subsystems/Drivetrain.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down