This commit is contained in:
aarav18
2023-02-10 17:33:19 -07:00
parent 867e16f0a7
commit c9a4274c82
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.
@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;
}
}
@@ -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<DeadbandedXboxController> joystickSupplier;
int numEntries = 0;
RobotTime time;
/** Creates a new JoystickRecorder. */
public JoystickRecorder(Supplier<DeadbandedXboxController> 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;
}
}