|
67 | 67 | import frc.robot.subsystems.visionIO.VisionIOSim;
|
68 | 68 | import frc.robot.util.ChangeDetector;
|
69 | 69 | import frc.robot.util.MechanismManager;
|
| 70 | +import frc.robot.util.ModeManager; |
70 | 71 | import frc.robot.util.RedHawkUtil;
|
71 | 72 | import frc.robot.util.RumbleManager;
|
72 | 73 | import frc.robot.util.SwerveHeadingController;
|
@@ -104,10 +105,19 @@ public class Robot extends LoggedRobot {
|
104 | 105 | private Command autoCommand;
|
105 | 106 | private final LoggedDashboardChooser<RHRFullRoutine> autoChooser =
|
106 | 107 | new LoggedDashboardChooser<>("Autonomous Routine");
|
| 108 | + private final LoggedDashboardChooser<RobotMode> modeChooser = |
| 109 | + new LoggedDashboardChooser<>("Robot Mode"); |
107 | 110 |
|
108 | 111 | private ChangeDetector<Optional<Alliance>> allianceChangeDetector;
|
109 | 112 | private ChangeDetector<RHRFullRoutine> autoChangeDetector;
|
| 113 | + private ChangeDetector<RobotMode> modeChangeDetector; |
110 | 114 | private Rotation2d gyroInitial = Rotation2d.fromRadians(0);
|
| 115 | + public static final ModeManager modeManager = new ModeManager(RobotMode.DEMO); |
| 116 | + |
| 117 | + public enum RobotMode { |
| 118 | + DEMO, |
| 119 | + COMPETITION |
| 120 | + } |
111 | 121 |
|
112 | 122 | @Override
|
113 | 123 | public void robotInit() {
|
@@ -199,6 +209,12 @@ public void robotInit() {
|
199 | 209 | gyroInitial = auto.traj1.getInitialPose().getRotation();
|
200 | 210 | seedGyroBasedOnAlliance();
|
201 | 211 | });
|
| 212 | + |
| 213 | + modeChangeDetector = |
| 214 | + new ChangeDetector<>( |
| 215 | + (mode) -> { |
| 216 | + modeManager.setMode(mode); |
| 217 | + }); |
202 | 218 | }
|
203 | 219 |
|
204 | 220 | public void createDriverBindings() {
|
@@ -989,6 +1005,7 @@ public void disabledPeriodic() {
|
989 | 1005 | swerveDrive.seed();
|
990 | 1006 | allianceChangeDetector.feed(DriverStation.getAlliance());
|
991 | 1007 | autoChangeDetector.feed(autoChooser.get());
|
| 1008 | + modeChangeDetector.feed(modeChooser.get()); |
992 | 1009 | }
|
993 | 1010 |
|
994 | 1011 | @Override
|
@@ -1062,6 +1079,12 @@ public void buildAutoChooser() {
|
1062 | 1079 | autoChooser.addOption("NopeAmp", new NopeAmp());
|
1063 | 1080 | }
|
1064 | 1081 |
|
| 1082 | + public void buildModeChooser() { |
| 1083 | + modeChooser.addDefaultOption(modeManager.getMode().toString(), Robot.modeManager.getMode()); |
| 1084 | + modeChooser.addOption("Demo", RobotMode.DEMO); |
| 1085 | + modeChooser.addOption("Competition", RobotMode.COMPETITION); |
| 1086 | + } |
| 1087 | + |
1065 | 1088 | public void updatePreMatchDashboardValues() {
|
1066 | 1089 | var encoderReadings = swerveDrive.getAbsoluteEncoderAngles();
|
1067 | 1090 | SmartDashboard.putNumber("Dashboard/Battery Voltage", RobotController.getBatteryVoltage());
|
|
0 commit comments