diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 7475f9f..87669a6 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -4,6 +4,7 @@ package frc.robot; +import com.ctre.phoenix6.SignalLogger; import edu.wpi.first.wpilibj.Filesystem; import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; import edu.wpi.first.wpilibj.Timer; @@ -12,6 +13,7 @@ import frc.robot.Constants.HardwareConstants; import java.io.File; import java.io.IOException; +import java.nio.file.Paths; import org.littletonrobotics.junction.LogFileUtil; import org.littletonrobotics.junction.LoggedRobot; import org.littletonrobotics.junction.Logger; @@ -71,19 +73,22 @@ public void robotInit() { break; } + Logger.addDataReceiver(new NT4Publisher()); if (isReal()) { - Logger.addDataReceiver(new NT4Publisher()); LoggedPowerDistribution.getInstance(HardwareConstants.REV_PDH_ID, ModuleType.kRev); Logger.registerURCL(URCL.startExternal()); - } else { - setUseTiming(false); // Run as fast as possible - String logPath = LogFileUtil.findReplayLog(); - if (logPath != null) { - Logger.setReplaySource(new WPILOGReader(logPath)); + if (Paths.get("/U").getParent() != null) { + Logger.addDataReceiver(new WPILOGWriter()); + SignalLogger.start(); } else { - Logger.addDataReceiver(new NT4Publisher()); + setUseTiming(false); + try { + String logPath = LogFileUtil.findReplayLog(); + Logger.setReplaySource(new WPILOGReader(logPath)); + } catch (Exception e) { + e.printStackTrace(); + } } - Logger.addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim"))); } // Start logging diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index 63d50f6..111f31f 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -8,6 +8,7 @@ import edu.wpi.first.math.geometry.Pose2d; import edu.wpi.first.math.geometry.Rotation2d; import edu.wpi.first.math.geometry.Translation2d; +import edu.wpi.first.wpilibj.DriverStation; import edu.wpi.first.wpilibj.Filesystem; import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj2.command.Command; @@ -106,6 +107,49 @@ public RobotContainer() { () -> MathUtil.applyDeadband(driverXbox.getLeftX(), OperatorConstants.LEFT_X_DEADBAND), () -> driverXbox.getRawAxis(2)); + // Checks if the git repo is dirty and output warnings as errors + if (BuildConstants.DIRTY != 0) { + DriverStation.reportError( + "WARNING! THERE ARE CHANGES THAT CURRENTLY IS NOT COMMITTED! PLEASE COMMIT THOSE CHANGES TO GIT/GITHUB OR REVERT THOSE CHANGES!", + false); + DriverStation.reportError("To see the changes, run `git status` in the terminal", false); + DriverStation.reportError( + "To commit the changes, run `git add .` to stage the changes, then run `git commit -m \"\"` to commit the changes", + false); + DriverStation.reportError( + "To revert the changes, run `git reset --hard` to revert the changes. This will permanently delete those changes", + false); + DriverStation.reportError( + "You can also open the GitHub Desktop application to perform these actions", false); + DriverStation.reportError("Remember to push your changes after committing", false); + } + // Checks if the branch is currently not on 'main' and output the warnings as errors + if (!BuildConstants.GIT_BRANCH.equals("main")) { + DriverStation.reportError( + "WARNING! YOU ARE NOT ON THE MAIN BRANCH! PLEASE MERGE YOUR CHANGES TO MAIN OR REVERT THOSE CHANGES!", + false); + DriverStation.reportError( + "To see the current branch, run `git branch` in the terminal", false); + DriverStation.reportError( + "To merge your changes to main, push your changes to GitHub and go to the GitHub repository and create a pull request", + false); + DriverStation.reportError("Wait for the pull request to be reviewed and merged", false); + } else if (BuildConstants.GIT_BRANCH.contains("event")) { + DriverStation.reportWarning( + "You are currently on an `event` branch. After an event, please merge your changes to main as the event progresses or after the event is over", + false); + DriverStation.reportWarning( + "With event branches, changes made on the fly here should be committed before each build/deploy to the robot", + false); + DriverStation.reportWarning( + "If you are done with the event, please merge and delete the event branch", false); + DriverStation.reportWarning( + "If you are not done with the event, please keep the event branch and continue working on it", + false); + DriverStation.reportWarning( + "If you are not sure, please ask your team leader or mentor for help", false); + } + drivebase.setDefaultCommand(driveFieldOrientedDirectAngle); }