Skip to content

Commit

Permalink
Merge pull request #2 from team-3482/telemetry
Browse files Browse the repository at this point in the history
Telemetry merge to main
  • Loading branch information
Maxb0tbeep committed Sep 12, 2024
2 parents 2cd8ebf + 46ce5bb commit 1f9f943
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 2 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,11 @@ logs/

# Folder that has CTRE Phoenix Sim device config storage
ctre_sim/

# build constants, see build.gradle
src/main/java/frc/robot/utilities/BuildConstants.java

networktables.json

simgui-ds.json
simgui.json
35 changes: 35 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2024.3.2"
id "com.peterabeles.gversion" version "1.10"
}

java {
Expand Down Expand Up @@ -47,6 +48,37 @@ wpi.java.debugJni = false
// Set this to true to enable desktop support.
def includeDesktopSupport = false

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"
}

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.utilities"
className = "BuildConstants"
dateFormat = "yyyy-MM-dd HH:mm:ss z"
timeZone = "America/Los_Angeles" // Use preferred time zone
indent = " "
}

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 5.
dependencies {
Expand All @@ -69,6 +101,9 @@ dependencies {

testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

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
Empty file modified gradlew
100644 → 100755
Empty file.
29 changes: 27 additions & 2 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
package frc.robot;

import edu.wpi.first.net.PortForwarder;
import edu.wpi.first.wpilibj.TimedRobot;
import edu.wpi.first.wpilibj.PowerDistribution;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import frc.robot.constants.PhysicalConstants.LimelightConstants;
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;

/**
* The VM is configured to automatically run this class, and to call the
Expand All @@ -19,7 +25,7 @@
* build.gradle file in the
* project.
*/
public class Robot extends TimedRobot {
public class Robot extends LoggedRobot {
private Command auton;

/**
Expand All @@ -35,6 +41,25 @@ public void robotInit() {
PortForwarder.add(port + 20, LimelightConstants.BACK_APRIL_TAG_LL + ".local", port);
}

// record buildconstants data in telemetry
Logger.recordMetadata("ProjectName", "Crescendo2024-Bot-2");
Logger.recordMetadata("GitSHA", BuildConstants.GIT_SHA);
Logger.recordMetadata("BuildDate", BuildConstants.BUILD_DATE);
Logger.recordMetadata("Dirty", String.valueOf(BuildConstants.DIRTY));

if (isReal()) {
Logger.addDataReceiver(new WPILOGWriter()); // Log to a USB stick ("/U/logs")
Logger.addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables
new PowerDistribution(1, PowerDistribution.ModuleType.kRev); // Enables power distribution logging
} 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.start();

// Initialize RobotContainer and all subsystems
RobotContainer.getInstance();
}
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.2.1",
"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.2.1"
},
{
"groupId": "org.littletonrobotics.akit.junction",
"artifactId": "junction-core",
"version": "3.2.1"
},
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-api",
"version": "3.2.1"
}
],
"jniDependencies": [
{
"groupId": "org.littletonrobotics.akit.conduit",
"artifactId": "conduit-wpilibio",
"version": "3.2.1",
"skipInvalidPlatforms": false,
"isJar": false,
"validPlatforms": [
"linuxathena",
"windowsx86-64",
"linuxx86-64",
"osxuniversal"
]
}
],
"cppDependencies": []
}

0 comments on commit 1f9f943

Please sign in to comment.