Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
467966d
Added code from last year for the autochooser (broken).
The-Cool-Python-Guy Jan 18, 2026
d2039a9
The autochooser now has a basic errorless implementation.
The-Cool-Python-Guy Jan 18, 2026
f1ab6b7
Refactored AutoChooser2025 as AutoChooser2026.
The-Cool-Python-Guy Jan 18, 2026
b018e4a
Fixed bug that silently passed null as a providerIO.
The-Cool-Python-Guy Jan 24, 2026
6e8d5c3
Merge branch 'main' of https://github.com/FRC4048/Java_2026 into RM_L…
The-Cool-Python-Guy Jan 31, 2026
b562a11
Implemented the AdvantageKit Autochooser.
The-Cool-Python-Guy Jan 31, 2026
9c2f9a9
Added chooser to robotContainer and fixed some errors.
The-Cool-Python-Guy Jan 31, 2026
9cc422e
Added "DoSomethingCommand" for harmless visible output.
The-Cool-Python-Guy Jan 31, 2026
72423d9
Largened print message for DoSomethingCommand for better visibility i…
The-Cool-Python-Guy Jan 31, 2026
c055bf5
Deleted old autochooser files, cleaned up branch.
The-Cool-Python-Guy Jan 31, 2026
c72e11a
Merge branch 'main' into RM_LoggableAutochooser
The-Cool-Python-Guy Jan 31, 2026
28f384d
Merge branch 'main' into RM_LoggableAutochooser
The-Cool-Python-Guy Jan 31, 2026
8e7767e
I made the AutoChooser extend LoggedDashboardChooser rather than be a…
The-Cool-Python-Guy Feb 1, 2026
7228f1c
Merge branch 'main' into RM_LoggableAutochooser
The-Cool-Python-Guy Feb 1, 2026
febd78c
Fixed error due to changing the name of a method.
The-Cool-Python-Guy Feb 1, 2026
7589b95
Created two choosers instead of one to clean up the interface on elas…
The-Cool-Python-Guy Feb 3, 2026
8b6eb6d
Set up an area on the elastic dashboard for visual feedback on the se…
The-Cool-Python-Guy Feb 3, 2026
31293b6
Merge branch 'main' into RM_LoggableAutochooser
The-Cool-Python-Guy Feb 3, 2026
ae8f723
Got rid of unnecessary things.
The-Cool-Python-Guy Feb 6, 2026
10475f7
Differentiated between 'nothing' and 'invalid' for AutoCommand, and m…
The-Cool-Python-Guy Feb 6, 2026
38a6ccd
Added methods for getting the location of the robot.
The-Cool-Python-Guy Feb 6, 2026
5d1988a
Merge branch 'main' into RM_LoggableAutochooser
The-Cool-Python-Guy Feb 6, 2026
3245a6c
Cleaned indentation in RobotContainer.
The-Cool-Python-Guy Feb 7, 2026
5bbec3d
I cleaned up unnecessary changes to RobotContainer, some small whites…
The-Cool-Python-Guy Feb 7, 2026
1b9da62
Merge branch 'main' into RM_LoggableAutochooser
The-Cool-Python-Guy Feb 9, 2026
b7e1e32
Clean up merge.
The-Cool-Python-Guy Feb 9, 2026
7bb6c91
Made a getter for the starting position.
The-Cool-Python-Guy Feb 10, 2026
09f4f94
Reimplemented equals() ans hashCode() so that the AutoEvent class can…
The-Cool-Python-Guy Feb 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
import org.littletonrobotics.junction.networktables.NT4Publisher;
import org.littletonrobotics.junction.wpilog.WPILOGReader;
import org.littletonrobotics.junction.wpilog.WPILOGWriter;

import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
import edu.wpi.first.wpilibj.DriverStation.Alliance;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.CommandScheduler;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.autochooser.FieldLocation;
import frc.robot.constants.Constants;
import frc.robot.utils.logging.commands.CommandLogger;

Expand Down Expand Up @@ -124,6 +127,13 @@ public void robotPeriodic() {
SmartDashboard.putBoolean("Hub Active?", hubActive());
}

// Puts data on the elastic dashboard
SmartDashboard.putString("Alliance Color", Robot.allianceColorString());
SmartDashboard.putBoolean("Hub Active?", hubActive());
SmartDashboard.putString("Selected Action",
robotContainer.getAutoChooser().getCommandDescription());
SmartDashboard.putString("Starting Location", location().toString());

// Gets the alliance color.
if (DriverStation.isDSAttached() && allianceColor.isEmpty()) {
allianceColor = DriverStation.getAlliance();
Expand Down Expand Up @@ -247,8 +257,11 @@ public static Diagnostics getDiagnostics() {
return diagnostics;
}

// Getters
public boolean hubActive() {return hubActive;}
public static Optional<Alliance> allianceColor() {return allianceColor;}
public static String allianceColorString() {return String.valueOf(allianceColor.orElse(null));}
public FieldLocation location() {return robotContainer.getAutoChooser().getLocation();}
public Pose2d getStartingLocation() {return location().getLocation();}

}
}
22 changes: 14 additions & 8 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
import frc.robot.commands.feeder.SpinFeeder;
import frc.robot.commands.drive.FakeVision;
import frc.robot.commands.intake.SpinIntake;
import frc.robot.autochooser.AutoChooser;
import frc.robot.commands.angler.AimAngler;
import frc.robot.commands.shooter.SetShootingState;
import frc.robot.constants.Constants;
import frc.robot.subsystems.AnglerSubsystem;
import frc.robot.subsystems.HopperSubsystem;
import frc.robot.subsystems.ApriltagSubsystem;
import frc.robot.subsystems.HopperSubsystem;
import frc.robot.subsystems.FeederSubsystem;
import frc.robot.constants.ShootingState;
import frc.robot.constants.ShootingState.ShootState;
Expand Down Expand Up @@ -55,8 +56,9 @@
* subsystems, commands, and trigger mappings) should be declared here.
*/
public class RobotContainer {
// Instantiate the autochooser.
private final AutoChooser autoChooser = new AutoChooser();
// The robot's subsystems and commands are defined here...
//private final RollerSubsystem rollerSubsystem;
//private final TiltSubsystem tiltSubsystem;
private final AnglerSubsystem anglerSubsystem;
private final IntakeSubsystem intakeSubsystem;
Expand All @@ -70,7 +72,7 @@ public class RobotContainer {
private final CommandJoystick steerJoystick = new CommandJoystick(Constants.STEER_JOYSTICK_PORT);
private ShootingState shootState = new ShootingState(ShootState.STOPPED);

// Replace with CommandPS4Controller or CommandJoystick if needed
// Replace with CommandPS4Controller or CommandJoystick if needed
//new CommandXboxController(OperatorConstants.kDriverControllerPort);private final CommandXboxController controller = new CommandXboxController(Constants.XBOX_CONTROLLER_PORT);

/**
Expand Down Expand Up @@ -183,7 +185,7 @@ public void putShuffleboardCommands() {
"Tilt Up",
new TiltUp(tiltSubsystem));

SmartDashboard.putData(
SmartDashboard.putData(
"Tilt Down",
new TiltDown(tiltSubsystem));*/

Expand Down Expand Up @@ -250,8 +252,9 @@ public void putShuffleboardCommands() {
SmartDashboard.putData("AddApriltagReading", new AddApriltagReading(apriltagSubsystem,new ApriltagReading(0, 0, 0, 0, 0, 0, 0)));

}

//basic drive command
if(!Constants.TESTBED){
if(!Constants.TESTBED) {
Command driveDirectionTime = new DriveDirectionTime(drivebase, 0.1,0.1, true, 1);
SmartDashboard.putData("Drive Command", driveDirectionTime);
SmartDashboard.putData("Fake vision", new FakeVision(drivebase));
Expand All @@ -265,12 +268,15 @@ public void putShuffleboardCommands() {
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
// An example command will be run in autonomous
return null;
return autoChooser.getCommand();
}

public RobotVisualizer getRobotVisualizer() {
return robotVisualizer;
return robotVisualizer;
}

public AutoChooser getAutoChooser() {
return autoChooser;
}

public IntakeSubsystem getIntakeSubsystem() {
Expand Down
37 changes: 37 additions & 0 deletions src/main/java/frc/robot/autochooser/AutoAction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package frc.robot.autochooser;

import java.util.Arrays;
import java.util.HashMap;
import java.util.function.Function;
import java.util.stream.Collectors;

public enum AutoAction {
DO_NOTHING("Do Nothing"),
TWO_PIECE_HIGH("2 Piece L4"),
TWO_PIECE_LOW("2 Piece L2"),
ONE_PIECE("1 Piece"),
CROSS_THE_LINE("Cross The Line"),
INVALID("INVALID");
private final String name;
private static final HashMap<String, AutoAction> nameMap =
new HashMap<>(
Arrays.stream(AutoAction.values())
.collect(Collectors.toMap(AutoAction::getName, Function.identity())));

AutoAction(String name) {
this.name = name;
}

public String getName() {
return name;
}

@Override
public String toString() {
return getName();
}

public static AutoAction fromName(String name) {
return nameMap.get(name);
}
}
85 changes: 85 additions & 0 deletions src/main/java/frc/robot/autochooser/AutoChooser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package frc.robot.autochooser;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you have a way to differentiate between an invalid combination of action+position and driver intentionally selecting "do nothing".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This problem has actually been on my mind since I realized it a few minutes after leaving last Monday. I've got a solid distinction this time.


import java.util.HashMap;
import java.util.Map;

import org.littletonrobotics.junction.networktables.LoggedDashboardChooser;

import frc.robot.utils.logging.commands.LoggableCommand;

public class AutoChooser {

/** Drop-down chooser for the location. */
private LoggedDashboardChooser<FieldLocation> locationChooser;
/** Drop-down chooser for the action. */
private LoggedDashboardChooser<AutoAction> actionChooser;
/** Structure for mapping possible choices to commands. */
private final Map<AutoEvent, AutoCommand> commandMap = new HashMap<>();

private final AutoCommand DEFAULT_COMMAND = AutoCommand.Invalid;

public AutoChooser() {
this.locationChooser = new LoggedDashboardChooser<>(
"Location Chooser"
);
this.actionChooser = new LoggedDashboardChooser<>(
"Action Chooser"
);
populateChoosers();
populateMap();
}

/** Populates the drop-down choosers with enum constants. */
private void populateChoosers() {
for (FieldLocation location : FieldLocation.values()) {
switch (location) {
case INVALID -> {} // Skip the invalid case.
case ZERO -> { // Default
locationChooser.addDefaultOption(location.toString(), location);
}
default -> {locationChooser.addOption(location.toString(), location);}
};
}
for (AutoAction action : AutoAction.values()) {
switch (action) {
case INVALID -> {} // Skip the invalid case.
case DO_NOTHING -> { // Default
actionChooser.addDefaultOption(action.toString(), action);
}
default -> {actionChooser.addOption(action.toString(), action);}
};
}
}

/** Put mappings here.
* @see AutoCommand */
private void populateMap() {
// Currently, we have some example mappings.
commandMap.put(new AutoEvent(AutoAction.DO_NOTHING, FieldLocation.LEFT),
AutoCommand.DoNothing);
commandMap.put(new AutoEvent(AutoAction.DO_NOTHING, FieldLocation.RIGHT),
AutoCommand.DoSomething);
}

private AutoCommand get() {
AutoAction chosenAction = actionChooser.get();
FieldLocation chosenLocation = locationChooser.get();
AutoEvent event = new AutoEvent(chosenAction, chosenLocation);

return commandMap.getOrDefault(event, DEFAULT_COMMAND);
}

public LoggableCommand getCommand() {
return get().getCommand();
}

/** @return A human-readable description of the selected command. */
public String getCommandDescription() {
return get().getDescription();
}

public FieldLocation getLocation() {
return locationChooser.get();
}

}
47 changes: 47 additions & 0 deletions src/main/java/frc/robot/autochooser/AutoCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package frc.robot.autochooser;

import frc.robot.utils.logging.commands.LoggableCommand;
import frc.robot.utils.logging.commands.DoNothingCommand;
import frc.robot.utils.logging.commands.DoSomethingCommand;

/** An enum to associate commands with human-readable descriptions. */
public enum AutoCommand {

// Add commands here. Importantly, you should give each command
// a readable description so that the drive team can tell what
// the robot will actually do. This will be used to give the
// drive team visual feedback on the elastic dashboard when
// selecting an autonoumous command.
Invalid(
"The selection is invalid. (The robot won't do anything.)",
new DoNothingCommand()
),
DoNothing("The robot won't do anything.", new DoNothingCommand()),
DoSomething(
"Something will be printed to the terminal.",
new DoSomethingCommand("""
SUCCESSFULLY

DID

SOMETHING
""")
);

private String description;
private LoggableCommand command;

AutoCommand(String description, LoggableCommand command) {
this.description = description;
this.command = command;
}

public String getDescription() {
return description;
}

public LoggableCommand getCommand() {
return command;
}

}
51 changes: 51 additions & 0 deletions src/main/java/frc/robot/autochooser/AutoEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package frc.robot.autochooser;

/**
* Wrapper Class, that Contains a {@link frc.robot.autochooser.AutoAction} and a {@link
* frc.robot.autochooser.FieldLocation}
*/
public class AutoEvent {
private final AutoAction action;
private final FieldLocation location;

public AutoEvent(AutoAction action, FieldLocation location) {
this.action = action;
this.location = location;
}

public AutoAction getAction() {
return action;
}

public FieldLocation getLocation() {
return location;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((action == null) ? 0 : action.hashCode());
result = prime * result + ((location == null) ? 0 : location.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AutoEvent other = (AutoEvent) obj;
if (action != other.action)
return false;
if (location != other.location)
return false;
return true;
}



}
Loading