Skip to content

Commit

Permalink
added file only setting + spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
PGgit08 committed Dec 19, 2024
1 parent 23bbb8a commit 17589c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/main/java/frc/lib/FaultLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.util.Set;
import java.util.function.BooleanSupplier;
import java.util.function.Supplier;

import org.photonvision.PhotonCamera;

// (from team 1155 but slightly modified)
Expand Down Expand Up @@ -242,10 +241,13 @@ public static void register(Pigeon2 pigeon) {

/**
* Registers a new PhotonCamera (more detailed logs on the web ui).
*
*
* @param photonCamera The PhotonCamera.
*/
public static void register(PhotonCamera photonCamera) {
register(() -> !photonCamera.isConnected(), photonCamera.getName() + ": Disconnected.", FaultType.ERROR);
register(
() -> !photonCamera.isConnected(),
photonCamera.getName() + ": Disconnected.",
FaultType.ERROR);
}
}
22 changes: 21 additions & 1 deletion src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,20 @@ public class Robot extends TimedRobot {

private Command _autonomousCommand = Autos.none();

private boolean _fileOnlySet = false;

/**
* This function is run when the robot is first started up and should be used for any
* initialization code.
*/
public Robot() {
// set up loggers
DogLog.setOptions(new DogLogOptions().withNtPublish(true));
DogLog.setOptions(new DogLogOptions().withCaptureDs(true));
Epilogue.bind(this);
SignalLogger.start();

setFileOnly(false); // file-only once connected to fms

DriverStation.silenceJoystickConnectionWarning(isSimulation());

FaultLogger.setup();
Expand All @@ -72,6 +76,16 @@ public Robot() {
addPeriodic(FaultLogger::update, 1);
}

// set logging to be file only or not
private void setFileOnly(boolean fileOnly) {
DogLog.setOptions(DogLog.getOptions().withNtPublish(!fileOnly));

Epilogue.configure(
config -> {
// TODO
});
}

private void configureBindings() {
_swerve.setDefaultCommand(
_swerve.drive(
Expand Down Expand Up @@ -103,6 +117,12 @@ public void robotPeriodic() {
// and running subsystem periodic() methods. This must be called from the robot's periodic
// block in order for anything in the Command-based framework to work.
CommandScheduler.getInstance().run();

if (DriverStation.isFMSAttached() && !_fileOnlySet) {
setFileOnly(true);

_fileOnlySet = true;
}
}

/** This autonomous runs the autonomous command. */
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/utils/VisionPoseEstimator.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.geometry.Transform3d;
import edu.wpi.first.networktables.NetworkTableInstance;
import frc.lib.FaultLogger;
import frc.robot.Constants.FieldConstants;
import frc.robot.Constants.VisionConstants;
import frc.lib.FaultLogger;
import frc.robot.Robot;
import java.util.ArrayList;
import java.util.Comparator;
Expand Down

0 comments on commit 17589c5

Please sign in to comment.