Skip to content

Commit

Permalink
Merge branch 'Gearfox-PracticeField3-6' of https://github.com/Titaniu…
Browse files Browse the repository at this point in the history
…mTitans/2024Crescendo into Gearfox-PracticeField3-6
  • Loading branch information
GearBoxFox committed Mar 7, 2024
2 parents a5185b2 + 3876ecb commit 107b412
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void robotInit() {
String logPath = "/media/sda1/aoide";

DataLogManager.start(logPath);
DriverStation.startDataLog(DataLogManager.getLog());
DriverStation.startDataLog(DataLogManager.getLog());`

SignalLogger.setPath(logPath);
SignalLogger.start();
Expand Down
43 changes: 16 additions & 27 deletions src/main/java/lib/logger/DataLogUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.function.BooleanSupplier;
import java.util.function.DoubleSupplier;
import java.util.function.Supplier;
Expand All @@ -22,7 +23,7 @@ public class DataLogUtil {

public static DataLogTable getTable(String name) {
for (DataLogTable table : logTables) {
if (table.name == name) {
if (Objects.equals(table.name, name)) {
return table;
}
}
Expand Down Expand Up @@ -73,15 +74,13 @@ public void addString(String logName, Supplier<String> updateChecker, boolean up
}

public void addPose2d(String logName, Supplier<Pose2d> updateChecker, boolean updateNT) {
addDoubleArray(logName + "/translation",
addDoubleArray(logName,
() -> new double[]{
updateChecker.get().getX(),
updateChecker.get().getY()
updateChecker.get().getY(),
updateChecker.get().getRotation().getRadians()
},
updateNT);
addDouble(logName + "/rotation",
() -> updateChecker.get().getRotation().getDegrees(),
updateNT);
}

public void addPose2dArray(String logName, Supplier<Pose2d[]> updateChecker, boolean updateNT) {
Expand All @@ -94,15 +93,11 @@ public void addPose2dArray(String logName, Supplier<Pose2d[]> updateChecker, boo
}

public void addPose3d(String logName, Supplier<Pose3d> updateChecker, boolean updateNT) {
addDoubleArray(logName + "/translation",
addDoubleArray(logName,
() -> new double[] {
updateChecker.get().getX(),
updateChecker.get().getY(),
updateChecker.get().getZ()
},
updateNT);
addDoubleArray(logName + "/rotation",
() -> new double[] {
updateChecker.get().getZ(),
updateChecker.get().getRotation().getQuaternion().getW(),
updateChecker.get().getRotation().getQuaternion().getX(),
updateChecker.get().getRotation().getQuaternion().getY(),
Expand All @@ -120,22 +115,16 @@ public void addPose3dArray(String logName, Supplier<Pose3d[]> updateChecker, boo
}
}

public void addSwerveModuleState(String logName, Supplier<SwerveModuleState> updateChecker, boolean updateNT) {
addDouble(logName + "/velocity",
() -> updateChecker.get().speedMetersPerSecond,
updateNT);
addDouble(logName + "/postion",
() -> updateChecker.get().angle.getRadians(),
updateNT);
}

public void addSwerveModuleStateArray(String logName, Supplier<SwerveModuleState[]> updateChecker, boolean updateNT) {
for (int i = 0; i < updateChecker.get().length; i++) {
int finalI = i;
addSwerveModuleState(logName + "/" + i,
() -> updateChecker.get()[finalI],
updateNT);
}
addDoubleArray(logName, () -> {
double[] stateArray = new double[8];
for (int i = 0; i < updateChecker.get().length * 2; i += 2) {
stateArray[i] = updateChecker.get()[(int) (i / 2.0)].angle.getRadians();
stateArray[i + 1] = updateChecker.get()[(int) (i / 2.0)].speedMetersPerSecond;
}
return stateArray;
},
updateNT);
}

public void updateLogs() {
Expand Down

0 comments on commit 107b412

Please sign in to comment.