diff --git a/.gitignore b/.gitignore index 5528d4f..0d25b78 100644 --- a/.gitignore +++ b/.gitignore @@ -176,3 +176,6 @@ logs/ # Folder that has CTRE Phoenix Sim device config storage ctre_sim/ + +# Build Constants for Git infomation +src/main/java/frc/robot/BuildConstants.java \ No newline at end of file diff --git a/build.gradle b/build.gradle index 1d6bf89..5d1a5f0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,8 @@ plugins { id "java" id "edu.wpi.first.GradleRIO" version "2024.2.1" - id 'com.diffplug.spotless' version '6.25.0' + id "com.diffplug.spotless" version "6.25.0" + id "com.peterabeles.gversion" version "1.10" } sourceCompatibility = JavaVersion.VERSION_17 @@ -45,6 +46,20 @@ wpi.java.debugJni = false // Set this to true to enable desktop support. def includeDesktopSupport = true +repositories { + maven { + url = uri("https://maven.pkg.github.com/Mechanical-Advantage/AdvantageKit") + credentials { + username = "Mechanical-Advantage-Bot" + password = "\u0067\u0068\u0070\u005f\u006e\u0056\u0051\u006a\u0055\u004f\u004c\u0061\u0079\u0066\u006e\u0078\u006e\u0037\u0051\u0049\u0054\u0042\u0032\u004c\u004a\u006d\u0055\u0070\u0073\u0031\u006d\u0037\u004c\u005a\u0030\u0076\u0062\u0070\u0063\u0051" + } + } + mavenLocal() +} + +configurations.all { + exclude group: "edu.wpi.first.wpilibj" +} // Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries. // Also defines JUnit 5. @@ -69,6 +84,10 @@ dependencies { testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.2' testImplementation 'org.junit.jupiter:junit-jupiter-params:5.10.2' testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.2' + + // AdvantageKit + def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text) + annotationProcessor "org.littletonrobotics.akit.junction:junction-autolog:$akitJson.version" } test { @@ -103,6 +122,24 @@ tasks.withType(JavaCompile) { options.compilerArgs.add '-XDstringConcat=inline' } +task(checkAkitInstall, dependsOn: "classes", type: JavaExec) { + mainClass = "org.littletonrobotics.junction.CheckInstall" + classpath = sourceSets.main.runtimeClasspath +} +compileJava.finalizedBy checkAkitInstall + +project.compileJava.dependsOn(createVersionFile) +gversion { + srcDir = "src/main/java/" + classPackage = "frc.robot" + className = "BuildConstants" + dateFormat = "yyyy-MM-dd HH:mm:ss z" + timeZone = "America/Chicago" // Use preferred time zone + indent = " " +} +compileJava.dependsOn 'spotlessApply' + + spotless { java { target fileTree('.') { diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index eadaa16..8565018 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -32,12 +32,13 @@ public static final class Auton { public static final double MAX_ACCELERATION = 2; } - public static final class PneumaticsConstants { - - public static final int PneumaticsMoudleID = 61; + public static final class HardwareConstants { + public static final int REV_PDH_ID = 60; + public static final int REV_PH_ID = 61; + } + public static final class PneumaticsConstants { public static final class DumpConstants { - // Uppy Downy solonoid public static final int OUT = 1; public static final int IN = 0; diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 8a9977a..7af1bb3 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -5,12 +5,21 @@ package frc.robot; import edu.wpi.first.wpilibj.Filesystem; -import edu.wpi.first.wpilibj.TimedRobot; +import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; import edu.wpi.first.wpilibj.Timer; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; +import frc.robot.Constants.HardwareConstants; import java.io.File; import java.io.IOException; +import org.littletonrobotics.junction.LogFileUtil; +import org.littletonrobotics.junction.LoggedRobot; +import org.littletonrobotics.junction.Logger; +import org.littletonrobotics.junction.inputs.LoggedPowerDistribution; +import org.littletonrobotics.junction.networktables.NT4Publisher; +import org.littletonrobotics.junction.wpilog.WPILOGReader; +import org.littletonrobotics.junction.wpilog.WPILOGWriter; +import org.littletonrobotics.urcl.URCL; import swervelib.parser.SwerveParser; /** @@ -19,7 +28,7 @@ * the package after creating this project, you must also update the build.gradle file in the * project. */ -public class Robot extends TimedRobot { +public class Robot extends LoggedRobot { private static Robot instance; private Command m_autonomousCommand; @@ -42,6 +51,45 @@ public static Robot getInstance() { */ @Override public void robotInit() { + // Record metadata about robot code + Logger.recordMetadata("ProjectName", "2024-Robot"); + Logger.recordMetadata("RuntimeType", getRuntimeType().toString()); + Logger.recordMetadata("BuildDate", BuildConstants.BUILD_DATE); + Logger.recordMetadata("GitSHA", null); + Logger.recordMetadata("GitDate", null); + Logger.recordMetadata("GitBranch", null); + // Determine if the git repo is dirty + switch (BuildConstants.DIRTY) { + case 0: + Logger.recordMetadata("GitDirty", "Clean"); + break; + case 1: + Logger.recordMetadata("GitDirty", "Uncommitted changes"); + break; + default: + Logger.recordMetadata("GitDirty", "Unknown"); + break; + } + + 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)); + } else { + Logger.addDataReceiver(new NT4Publisher()); + } + Logger.addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim"))); + } + Logger.recordMetadata("GitSHA", BuildConstants.GIT_SHA); + + // Start logging + Logger.start(); + // Instantiate our RobotContainer. This will perform all our button bindings, and put our // autonomous chooser on the dashboard. m_robotContainer = new RobotContainer(); diff --git a/src/main/java/frc/robot/subsystems/Dump.java b/src/main/java/frc/robot/subsystems/Dump.java index 579c51a..cf3ad1f 100644 --- a/src/main/java/frc/robot/subsystems/Dump.java +++ b/src/main/java/frc/robot/subsystems/Dump.java @@ -8,7 +8,7 @@ import edu.wpi.first.wpilibj.PneumaticsModuleType; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.SubsystemBase; -import frc.robot.Constants.PneumaticsConstants; +import frc.robot.Constants.HardwareConstants; import frc.robot.Constants.PneumaticsConstants.DumpConstants; import frc.robot.util.Time; @@ -17,7 +17,7 @@ public class Dump extends SubsystemBase { // The double solenoid that controls the piston private DoubleSolenoid doubleSolenoid = new DoubleSolenoid( - PneumaticsConstants.PneumaticsMoudleID, + HardwareConstants.REV_PH_ID, PneumaticsModuleType.REVPH, DumpConstants.IN, DumpConstants.OUT); diff --git a/vendordeps/AdvantageKit.json b/vendordeps/AdvantageKit.json new file mode 100644 index 0000000..f461213 --- /dev/null +++ b/vendordeps/AdvantageKit.json @@ -0,0 +1,42 @@ +{ + "fileName": "AdvantageKit.json", + "name": "AdvantageKit", + "version": "3.1.0", + "uuid": "d820cc26-74e3-11ec-90d6-0242ac120003", + "frcYear": "2024", + "mavenUrls": [], + "jsonUrl": "https://github.com/Mechanical-Advantage/AdvantageKit/releases/latest/download/AdvantageKit.json", + "javaDependencies": [ + { + "groupId": "org.littletonrobotics.akit.junction", + "artifactId": "wpilib-shim", + "version": "3.1.0" + }, + { + "groupId": "org.littletonrobotics.akit.junction", + "artifactId": "junction-core", + "version": "3.1.0" + }, + { + "groupId": "org.littletonrobotics.akit.conduit", + "artifactId": "conduit-api", + "version": "3.1.0" + } + ], + "jniDependencies": [ + { + "groupId": "org.littletonrobotics.akit.conduit", + "artifactId": "conduit-wpilibio", + "version": "3.1.0", + "skipInvalidPlatforms": false, + "isJar": false, + "validPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64", + "osxuniversal" + ] + } + ], + "cppDependencies": [] +} \ No newline at end of file diff --git a/vendordeps/URCL.json b/vendordeps/URCL.json new file mode 100644 index 0000000..998c261 --- /dev/null +++ b/vendordeps/URCL.json @@ -0,0 +1,65 @@ +{ + "fileName": "URCL.json", + "name": "URCL", + "version": "2024.1.0", + "frcYear": "2024", + "uuid": "84246d17-a797-4d1e-bd9f-c59cd8d2477c", + "mavenUrls": [ + "https://raw.githubusercontent.com/Mechanical-Advantage/URCL/2024.1.0" + ], + "jsonUrl": "https://raw.githubusercontent.com/Mechanical-Advantage/URCL/maven/URCL.json", + "javaDependencies": [ + { + "groupId": "org.littletonrobotics.urcl", + "artifactId": "URCL-java", + "version": "2024.1.0" + } + ], + "jniDependencies": [ + { + "groupId": "org.littletonrobotics.urcl", + "artifactId": "URCL-driver", + "version": "2024.1.0", + "skipInvalidPlatforms": true, + "isJar": false, + "validPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxathena", + "osxuniversal" + ] + } + ], + "cppDependencies": [ + { + "groupId": "org.littletonrobotics.urcl", + "artifactId": "URCL-cpp", + "version": "2024.1.0", + "libName": "URCL", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxathena", + "osxuniversal" + ] + }, + { + "groupId": "org.littletonrobotics.urcl", + "artifactId": "URCL-driver", + "version": "2024.1.0", + "libName": "URCLDriver", + "headerClassifier": "headers", + "sharedLibrary": false, + "skipInvalidPlatforms": true, + "binaryPlatforms": [ + "windowsx86-64", + "linuxx86-64", + "linuxathena", + "osxuniversal" + ] + } + ] +} \ No newline at end of file