Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Add AdvantageKit, REV Spark MAX logging #17

Merged
merged 4 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
39 changes: 38 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -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 {
Expand Down Expand Up @@ -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('.') {
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 4;
public static final int IN = 14;
Expand Down
42 changes: 40 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
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.networktables.NT4Publisher;
import org.littletonrobotics.junction.wpilog.WPILOGReader;
import org.littletonrobotics.junction.wpilog.WPILOGWriter;
import org.littletonrobotics.urcl.URCL;
import swervelib.parser.SwerveParser;

/**
Expand All @@ -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;
Expand All @@ -42,6 +51,35 @@ public static Robot getInstance() {
*/
@Override
public void robotInit() {
// Set up logging
Logger.recordMetadata("ProjectName", "2024-Robot"); // Set a metadata value

if (isReal()) {
Logger.addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables
PowerDistribution pdh =
new PowerDistribution(
HardwareConstants.REV_PDH_ID, ModuleType.kRev); // Enables power distribution logging
pdh.setSwitchableChannel(true);
pdh.close();
Logger.registerURCL(URCL.startExternal());

} else {
setUseTiming(false); // Run as fast as possible
String logPath =
LogFileUtil
.findReplayLog(); // Pull the replay log from AdvantageScope (or prompt the user)
Logger.setReplaySource(new WPILOGReader(logPath)); // Read replay log
Logger.addDataReceiver(
new WPILOGWriter(
LogFileUtil.addPathSuffix(logPath, "_sim"))); // Save outputs to a new log
}
Logger.recordMetadata("GitSHA", BuildConstants.GIT_SHA);

// Logger.disableDeterministicTimestamps() // See "Deterministic Timestamps" in the
// "Understanding Data Flow" page
Logger.start(); // Start logging! No more data receivers, replay sources, or metadata values may
// be added.

// Instantiate our RobotContainer. This will perform all our button bindings, and put our
// autonomous chooser on the dashboard.
m_robotContainer = new RobotContainer();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/frc/robot/subsystems/Dump.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
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;

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);
Expand Down
42 changes: 42 additions & 0 deletions vendordeps/AdvantageKit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"fileName": "AdvantageKit.json",
"name": "AdvantageKit",
"version": "3.0.2",
"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.0.2"
},
{
"groupId": "org.littletonrobotics.akit.junction",
"artifactId": "junction-core",
"version": "3.0.2"
},
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-api",
"version": "3.0.2"
}
],
"jniDependencies": [
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-wpilibio",
"version": "3.0.2",
"skipInvalidPlatforms": false,
"isJar": false,
"validPlatforms": [
"linuxathena",
"windowsx86-64",
"linuxx86-64",
"osxuniversal"
]
}
],
"cppDependencies": []
}
65 changes: 65 additions & 0 deletions vendordeps/URCL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"fileName": "URCL.json",
"name": "URCL",
"version": "2024.0.1",
"frcYear": "2024",
"uuid": "84246d17-a797-4d1e-bd9f-c59cd8d2477c",
"mavenUrls": [
"https://raw.githubusercontent.com/Mechanical-Advantage/URCL/2024.0.1"
],
"jsonUrl": "https://raw.githubusercontent.com/Mechanical-Advantage/URCL/maven/URCL.json",
"javaDependencies": [
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-java",
"version": "2024.0.1"
}
],
"jniDependencies": [
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-driver",
"version": "2024.0.1",
"skipInvalidPlatforms": true,
"isJar": false,
"validPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxathena",
"osxuniversal"
]
}
],
"cppDependencies": [
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-cpp",
"version": "2024.0.1",
"libName": "URCL",
"headerClassifier": "headers",
"sharedLibrary": false,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxathena",
"osxuniversal"
]
},
{
"groupId": "org.littletonrobotics.urcl",
"artifactId": "URCL-driver",
"version": "2024.0.1",
"libName": "URCLDriver",
"headerClassifier": "headers",
"sharedLibrary": false,
"skipInvalidPlatforms": true,
"binaryPlatforms": [
"windowsx86-64",
"linuxx86-64",
"linuxathena",
"osxuniversal"
]
}
]
}
Loading