Skip to content

Commit

Permalink
Merge pull request #25 from OakvilleDynamics/feature/driver-station-f…
Browse files Browse the repository at this point in the history
…eedback

Add more driver station feedback and diagnostic logging
  • Loading branch information
garrettsummerfi3ld authored Mar 9, 2024
2 parents e6d326b + e0afacb commit cd3c54d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
44 changes: 44 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 \"<commit message>\"` 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);
}

Expand Down

0 comments on commit cd3c54d

Please sign in to comment.