From 7e2f3ffa67754dc38dd58a4a3ef947343ec81d8b Mon Sep 17 00:00:00 2001 From: audrey Date: Mon, 23 Oct 2023 16:23:23 -0700 Subject: [PATCH] trying to add io (unfinished --- src/main/java/frc/robot/Robot.java | 30 +++++++++++++- .../robot/subsystems/DrivebaseSubsystem.java | 8 +++- vendordeps/AdvantageKit.json | 41 +++++++++++++++++++ 3 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 vendordeps/AdvantageKit.json diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 0dfaa1b..3482b56 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -4,7 +4,15 @@ package frc.robot; -import edu.wpi.first.wpilibj.TimedRobot; +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 edu.wpi.first.wpilibj.PowerDistribution; +import edu.wpi.first.wpilibj.PowerDistribution.ModuleType; import edu.wpi.first.wpilibj.livewindow.LiveWindow; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.CommandScheduler; @@ -15,7 +23,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 Command autonomousCommand; private RobotContainer robotContainer; @@ -30,6 +38,24 @@ public class Robot extends TimedRobot { public void robotInit() { // Instantiate our RobotContainer. This will perform all our button bindings, and put our // autonomous chooser on the dashboard. + + Logger.getInstance().recordMetadata("ProjectName", "MyProject"); // Set a metadata value + + if (isReal()) { + Logger.getInstance().addDataReceiver(new WPILOGWriter("/U")); // Log to a USB stick + Logger.getInstance().addDataReceiver(new NT4Publisher()); // Publish data to NetworkTables + new PowerDistribution(1, 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.getInstance().setReplaySource(new WPILOGReader(logPath)); // Read replay log + Logger.getInstance().addDataReceiver(new WPILOGWriter(LogFileUtil.addPathSuffix(logPath, "_sim"))); // Save outputs to a new log + } + +// Logger.getInstance().disableDeterministicTimestamps() // See "Deterministic Timestamps" in the "Understanding Data Flow" page +Logger.getInstance().start(); // Start logging! No more data receivers, replay sources, or metadata values may be added. + + robotContainer = new RobotContainer(); LiveWindow.disableAllTelemetry(); diff --git a/src/main/java/frc/robot/subsystems/DrivebaseSubsystem.java b/src/main/java/frc/robot/subsystems/DrivebaseSubsystem.java index 66f917c..46750b7 100644 --- a/src/main/java/frc/robot/subsystems/DrivebaseSubsystem.java +++ b/src/main/java/frc/robot/subsystems/DrivebaseSubsystem.java @@ -6,6 +6,8 @@ import static frc.robot.Constants.Drive.*; +import org.littletonrobotics.junction.Logger; + import com.kauailabs.navx.frc.AHRS; import com.playingwithfusion.TimeOfFlight; import com.playingwithfusion.TimeOfFlight.RangingMode; @@ -61,6 +63,9 @@ public class DrivebaseSubsystem extends SubsystemBase { // Not mission critical as it "technically" drives fine as of now; but I suspect this is a site // for future improvements + private final DriveIO io; + private final DriveIOInputsAutoLogged inputs = new DriveIOInputsAutoLogged(); + public AdvancedSwerveTrajectoryFollower getFollower() { return follower; } @@ -150,8 +155,9 @@ private SwerveModule createModule( } /** Creates a new DrivebaseSubsystem. */ - public DrivebaseSubsystem(VisionSubsystem visionSubsystem) { + public DrivebaseSubsystem(VisionSubsystem visionSubsystem, DriveIO io) { this.visionSubsystem = visionSubsystem; + this.io = io; if (!Config.DISABLE_SWERVE_MODULE_INIT) { diff --git a/vendordeps/AdvantageKit.json b/vendordeps/AdvantageKit.json new file mode 100644 index 0000000..fa08705 --- /dev/null +++ b/vendordeps/AdvantageKit.json @@ -0,0 +1,41 @@ +{ + "fileName": "AdvantageKit.json", + "name": "AdvantageKit", + "version": "2.2.4", + "uuid": "d820cc26-74e3-11ec-90d6-0242ac120003", + "mavenUrls": [], + "jsonUrl": "https://github.com/Mechanical-Advantage/AdvantageKit/releases/latest/download/AdvantageKit.json", + "javaDependencies": [ + { + "groupId": "org.littletonrobotics.akit.junction", + "artifactId": "wpilib-shim", + "version": "2.2.4" + }, + { + "groupId": "org.littletonrobotics.akit.junction", + "artifactId": "junction-core", + "version": "2.2.4" + }, + { + "groupId": "org.littletonrobotics.akit.conduit", + "artifactId": "conduit-api", + "version": "2.2.4" + } + ], + "jniDependencies": [ + { + "groupId": "org.littletonrobotics.akit.conduit", + "artifactId": "conduit-wpilibio", + "version": "2.2.4", + "skipInvalidPlatforms": false, + "isJar": false, + "validPlatforms": [ + "linuxathena", + "windowsx86-64", + "linuxx86-64", + "osxuniversal" + ] + } + ], + "cppDependencies": [] +} \ No newline at end of file