Skip to content

Commit

Permalink
Add draft version of shimless replay
Browse files Browse the repository at this point in the history
  • Loading branch information
jwbonner committed Nov 2, 2024
1 parent e004975 commit 7208ed1
Show file tree
Hide file tree
Showing 9 changed files with 169 additions and 652 deletions.
10 changes: 0 additions & 10 deletions docs/docs/installation/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,6 @@ repositories {
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
dependencies {
// ...
def akitJson = new groovy.json.JsonSlurper().parseText(new File(projectDir.getAbsolutePath() + "/vendordeps/AdvantageKit.json").text)
Expand Down
10 changes: 0 additions & 10 deletions example_projects/wpilib_build_file/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,6 @@ repositories {
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

// Defining my dependencies. In this case, WPILib (+ friends), and vendor libraries.
// Also defines JUnit 4.
dependencies {
Expand Down
74 changes: 0 additions & 74 deletions junction/core/src/org/littletonrobotics/junction/CheckInstall.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ protected void finalize() {
@Override
@SuppressWarnings("UnsafeFinalization")
public void startCompetition() {
// Check for invalid AdvantageKit install in sim
if (isSimulation()) {
CheckInstall.run();
}

// Robot init methods
long initStart = Logger.getRealTimestamp();
robotInit();
Expand Down Expand Up @@ -141,7 +136,7 @@ private static final class GcStatsCollector {
private List<GarbageCollectorMXBean> gcBeans = ManagementFactory.getGarbageCollectorMXBeans();
private final long[] lastTimes = new long[gcBeans.size()];
private final long[] lastCounts = new long[gcBeans.size()];

public void update() {
long accumTime = 0;
long accumCounts = 0;
Expand All @@ -150,11 +145,11 @@ public void update() {
long gcCount = gcBeans.get(i).getCollectionCount();
accumTime += gcTime - lastTimes[i];
accumCounts += gcCount - lastCounts[i];

lastTimes[i] = gcTime;
lastCounts[i] = gcCount;
}

Logger.recordOutput("LoggedRobot/GCTimeMS", (double) accumTime);
Logger.recordOutput("LoggedRobot/GCCounts", (double) accumCounts);
}
Expand Down
34 changes: 21 additions & 13 deletions junction/core/src/org/littletonrobotics/junction/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -263,13 +263,18 @@ static void periodicBeforeUser() {
}
}

// Update Driver Station
long dsStart = getRealTimestamp();
if (hasReplaySource()) {
LoggedDriverStation.replayFromLog(entry.getSubtable("DriverStation"));
}

// Update default inputs
long saveDataStart = getRealTimestamp();
LoggedDriverStation.periodic();
LoggedSystemStats.periodic();
LoggedSystemStats.periodic(entry.getSubtable("SystemStats"));
LoggedPowerDistribution loggedPowerDistribution = LoggedPowerDistribution.getInstance();
if (loggedPowerDistribution != null) {
loggedPowerDistribution.periodic();
loggedPowerDistribution.periodic(entry.getSubtable("PowerDistribution"));
}
for (int i = 0; i < dashboardInputs.size(); i++) {
dashboardInputs.get(i).periodic();
Expand Down Expand Up @@ -300,18 +305,12 @@ static void periodicBeforeUser() {
long saveDataEnd = getRealTimestamp();

// Log output data
if (hasReplaySource()) {
recordOutput("Logger/DriverStationPeriodicMS", (saveDataEnd - saveDataStart) / 1000.0);
}
recordOutput("Logger/ConduitPeriodicMS", (conduitCaptureEnd - conduitCaptureStart) / 1000.0);
recordOutput("Logger/SavePeriodicMS", (saveDataEnd - saveDataStart) / 1000.0);
recordOutput("Logger/SavePeriodicMS", (saveDataStart - dsStart) / 1000.0);
recordOutput("Logger/QueuedCycles", receiverQueue.size());
} else {
// Retrieve new data even if logger is disabled
ConduitApi.getInstance().captureData();
LoggedDriverStation.periodic();
LoggedPowerDistribution loggedPowerDistribution = LoggedPowerDistribution.getInstance();
if (loggedPowerDistribution != null) {
loggedPowerDistribution.periodic();
}
LoggedSystemStats.periodic();
}
}

Expand All @@ -322,6 +321,12 @@ static void periodicBeforeUser() {
*/
static void periodicAfterUser(long userCodeLength, long periodicBeforeLength) {
if (running) {
// Update Driver Station
long dsStart = getRealTimestamp();
if (!hasReplaySource()) {
LoggedDriverStation.saveToLog(entry.getSubtable("DriverStation"));
}

// Update final outputs
long autoLogStart = getRealTimestamp();
AutoLogOutputManager.periodic();
Expand All @@ -337,6 +342,9 @@ static void periodicAfterUser(long userCodeLength, long periodicBeforeLength) {
long consoleCaptureEnd = getRealTimestamp();

// Record timing data
if (!hasReplaySource()) {
recordOutput("Logger/DriverStationPeriodicMS", (autoLogStart - dsStart) / 1000.0);
}
recordOutput("Logger/AutoLogPeriodicMS", (alertLogStart - autoLogStart) / 1000.0);
recordOutput("Logger/AlertLogPeriodicMS", (consoleCaptureStart - alertLogStart) / 1000.0);
recordOutput("Logger/ConsolePeriodicMS", (consoleCaptureEnd - consoleCaptureStart) / 1000.0);
Expand Down
Loading

0 comments on commit 7208ed1

Please sign in to comment.