This commit is contained in:
aarav18
2023-02-10 17:33:19 -07:00
parent 6346126e28
commit c9df71a7bb
2 changed files with 9 additions and 7 deletions
@@ -62,12 +62,13 @@ public class JoystickPlayback extends CommandBase {
// Called once the command ends or is interrupted. // Called once the command ends or is interrupted.
@Override @Override
public void end(boolean interrupted) {} public void end(boolean interrupted) {
input.close();
}
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
input.close();
return false; return false;
} }
} }
@@ -10,19 +10,21 @@ import java.nio.file.Path;
import java.util.function.Supplier; import java.util.function.Supplier;
import edu.wpi.first.wpilibj2.command.CommandBase; import edu.wpi.first.wpilibj2.command.CommandBase;
import frc4388.utility.RobotTime;
import frc4388.utility.controller.DeadbandedXboxController; import frc4388.utility.controller.DeadbandedXboxController;
public class JoystickRecorder extends CommandBase { public class JoystickRecorder extends CommandBase {
DeadbandedXboxController joystick; DeadbandedXboxController joystick;
Supplier<DeadbandedXboxController> joystickSupplier; Supplier<DeadbandedXboxController> joystickSupplier;
int numEntries = 0; RobotTime time;
/** Creates a new JoystickRecorder. */ /** Creates a new JoystickRecorder. */
public JoystickRecorder(Supplier<DeadbandedXboxController> joystickSupplier) { public JoystickRecorder(Supplier<DeadbandedXboxController> joystickSupplier) {
// Use addRequirements() here to declare subsystem dependencies. // Use addRequirements() here to declare subsystem dependencies.
this.joystickSupplier = joystickSupplier; this.joystickSupplier = joystickSupplier;
time = RobotTime.getInstance();
} }
// Called when the command is initially scheduled. // Called when the command is initially scheduled.
@@ -40,8 +42,7 @@ public class JoystickRecorder extends CommandBase {
double rightY = joystick.getRightY(); double rightY = joystick.getRightY();
try { try {
Files.writeString(Path.of("JoystickInputs.txt"), "leftX: " + leftX + ", " + "leftY: " + leftY + ", " + "rightX: " + rightX + ", " + "rightY: " + rightY); Files.writeString(Path.of("JoystickInputs.txt"), "Time: " + time.m_robotTime + ", leftX: " + leftX + ", " + "leftY: " + leftY + ", " + "rightX: " + rightX + ", " + "rightY: " + rightY + "\n");
numEntries = numEntries + 1;
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -54,6 +55,6 @@ public class JoystickRecorder extends CommandBase {
// Returns true when the command should end. // Returns true when the command should end.
@Override @Override
public boolean isFinished() { public boolean isFinished() {
return numEntries > 10; return false;
} }
} }