Skip to content
Open
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
18 changes: 18 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,12 @@ public enum RobotEdition {
private static final double lowBatteryDisabledTime = 1.5;
private static final double lowBatteryMinCycleCount = 10;

private final PowerDistribution pd = new PowerDistribution();
private final Timer timer = new Timer();
private double lastTimeStamp = 0.0;
private double totalCurrent = 0.0;
private double accumulatedCurrentAmps = 0.0;

/**
* As per the 2026+ ctre api we should be passing in the actual canbus object to any ctre device
* constructors, NOT the name as a string
Expand Down Expand Up @@ -664,6 +670,18 @@ private void addControllerBindings(Indexer indexer, Shooter shooter, Intake inta
.onFalse(Commands.runOnce(() -> operatorJoystickDisconnectedAlert.set(false)));
}

@AutoLogOutput(key = "Robot/Accumulated Current Amp")
private double AccumulatedCurrentAmp() {
double timeStamp = timer.getFPGATimestamp();
double dt = timeStamp - lastTimeStamp;
lastTimeStamp = timeStamp;
totalCurrent = pd.getTotalCurrent();

// integrate!
accumulatedCurrentAmps += totalCurrent * dt;
return accumulatedCurrentAmps;
}

private void addAutos() {
System.out.println("------- Regenerating Autos");
System.out.println(
Expand Down