mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-09 08:38:02 -06:00
unified choosers
This commit is contained in:
@@ -11,12 +11,12 @@ import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
import frc4388.robot.subsystems.SwerveDrive;
|
||||
|
||||
public class PlaybackChooser {
|
||||
private ArrayList<SendableChooser<Command>> m_choosers = new ArrayList<>();
|
||||
private SendableChooser<Command> m_playback = new SendableChooser<>();
|
||||
private HashMap<String, Command> m_commandPool = new HashMap<>();
|
||||
private final ArrayList<SendableChooser<Command>> m_choosers = new ArrayList<>();
|
||||
private final SendableChooser<Command> m_playback;
|
||||
private final HashMap<String, Command> m_commandPool = new HashMap<>();
|
||||
|
||||
private File m_dir = new File("/home/lvuser/autos/");
|
||||
private SwerveDrive m_swerve;
|
||||
private final File m_dir = new File("/home/lvuser/autos/");
|
||||
private final SwerveDrive m_swerve;
|
||||
|
||||
// commands
|
||||
private Command m_noAuto = new InstantCommand();
|
||||
@@ -32,12 +32,8 @@ public class PlaybackChooser {
|
||||
m_commandPool.put((String) pool[i], (Command) pool[i + 1]);
|
||||
}
|
||||
|
||||
for (String auto : m_dir.list()) {
|
||||
m_playback.addOption(auto, new JoystickPlayback(m_swerve, auto));
|
||||
}
|
||||
m_playback.addOption("No Auto", m_noAuto);
|
||||
|
||||
m_choosers.add(m_playback);
|
||||
appendCommand();
|
||||
m_playback = m_choosers.get(0);
|
||||
SmartDashboard.putData("Command: 0", m_playback);
|
||||
}
|
||||
|
||||
@@ -45,21 +41,13 @@ public class PlaybackChooser {
|
||||
public void appendCommand() {
|
||||
var chooser = new SendableChooser<Command>();
|
||||
|
||||
for (var cmd_name : m_commandPool.keySet()) {
|
||||
chooser.addOption(cmd_name, m_commandPool.get(cmd_name));
|
||||
}
|
||||
|
||||
m_choosers.add(chooser);
|
||||
SmartDashboard.putData("Command: " + m_choosers.size(), chooser);
|
||||
}
|
||||
|
||||
// This will be bound to a button for the time being
|
||||
public void appendPlayback() {
|
||||
var chooser = new SendableChooser<Command>();
|
||||
|
||||
for (String auto : m_dir.list()) {
|
||||
m_playback.addOption(auto, new JoystickPlayback(m_swerve, auto));
|
||||
}
|
||||
for (var cmd_name : m_commandPool.keySet()) {
|
||||
chooser.addOption(cmd_name, m_commandPool.get(cmd_name));
|
||||
}
|
||||
chooser.addOption("No Auto", m_noAuto);
|
||||
|
||||
m_choosers.add(chooser);
|
||||
SmartDashboard.putData("Command: " + m_choosers.size(), chooser);
|
||||
@@ -73,7 +61,7 @@ public class PlaybackChooser {
|
||||
for (int i = 0; i < m_choosers.size()-1; i++) {
|
||||
Command command2 = m_choosers.get(i + 1).getSelected();
|
||||
command2 = command2 == null ? m_noAuto : command2.asProxy();
|
||||
|
||||
|
||||
commands[i] = command2.asProxy();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user