From c9a4274c82b009e4dd4c388790c04e4b72b54b48 Mon Sep 17 00:00:00 2001 From: aarav18 Date: Fri, 10 Feb 2023 17:33:19 -0700 Subject: [PATCH] time --- .../java/frc4388/robot/commands/JoystickPlayback.java | 5 +++-- .../java/frc4388/robot/commands/JoystickRecorder.java | 11 ++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/frc4388/robot/commands/JoystickPlayback.java b/src/main/java/frc4388/robot/commands/JoystickPlayback.java index d26a818..774cffa 100644 --- a/src/main/java/frc4388/robot/commands/JoystickPlayback.java +++ b/src/main/java/frc4388/robot/commands/JoystickPlayback.java @@ -62,12 +62,13 @@ public class JoystickPlayback extends CommandBase { // Called once the command ends or is interrupted. @Override - public void end(boolean interrupted) {} + public void end(boolean interrupted) { + input.close(); + } // Returns true when the command should end. @Override public boolean isFinished() { - input.close(); return false; } } diff --git a/src/main/java/frc4388/robot/commands/JoystickRecorder.java b/src/main/java/frc4388/robot/commands/JoystickRecorder.java index d69eb6e..d658a6d 100644 --- a/src/main/java/frc4388/robot/commands/JoystickRecorder.java +++ b/src/main/java/frc4388/robot/commands/JoystickRecorder.java @@ -10,19 +10,21 @@ import java.nio.file.Path; import java.util.function.Supplier; import edu.wpi.first.wpilibj2.command.CommandBase; +import frc4388.utility.RobotTime; import frc4388.utility.controller.DeadbandedXboxController; public class JoystickRecorder extends CommandBase { DeadbandedXboxController joystick; Supplier joystickSupplier; - - int numEntries = 0; + + RobotTime time; /** Creates a new JoystickRecorder. */ public JoystickRecorder(Supplier joystickSupplier) { // Use addRequirements() here to declare subsystem dependencies. this.joystickSupplier = joystickSupplier; + time = RobotTime.getInstance(); } // Called when the command is initially scheduled. @@ -40,8 +42,7 @@ public class JoystickRecorder extends CommandBase { double rightY = joystick.getRightY(); try { - Files.writeString(Path.of("JoystickInputs.txt"), "leftX: " + leftX + ", " + "leftY: " + leftY + ", " + "rightX: " + rightX + ", " + "rightY: " + rightY); - numEntries = numEntries + 1; + Files.writeString(Path.of("JoystickInputs.txt"), "Time: " + time.m_robotTime + ", leftX: " + leftX + ", " + "leftY: " + leftY + ", " + "rightX: " + rightX + ", " + "rightY: " + rightY + "\n"); } catch (IOException e) { e.printStackTrace(); } @@ -54,6 +55,6 @@ public class JoystickRecorder extends CommandBase { // Returns true when the command should end. @Override public boolean isFinished() { - return numEntries > 10; + return false; } }