Files
2025RidgeScape/src/main/java/frc4388/robot/RobotContainer.java
T

770 lines
42 KiB
Java
Raw Normal View History

2025-01-04 16:09:10 -07:00
/*----------------------------------------------------------------------------*/
/* Copyright (c) 2018-2019 FIRST. All Rights Reserved. */
/* Open Source Software - may be modified and shared by FRC teams. The code */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project. */
/*----------------------------------------------------------------------------*/
package frc4388.robot;
// Drive Systems
import edu.wpi.first.wpilibj.DriverStation;
2025-02-10 19:38:43 -07:00
import java.io.File;
2025-01-04 16:09:10 -07:00
import java.util.ArrayList;
import java.util.List;
2025-02-26 15:40:29 -07:00
import java.util.function.BooleanSupplier;
2025-03-06 17:34:16 -07:00
import java.util.function.Supplier;
2025-01-04 16:09:10 -07:00
import edu.wpi.first.cameraserver.CameraServer;
2025-02-27 19:47:21 -07:00
import edu.wpi.first.math.geometry.Rotation2d;
2025-01-16 19:41:08 -07:00
import edu.wpi.first.math.geometry.Translation2d;
2025-02-19 21:28:28 -07:00
import edu.wpi.first.math.util.Units;
2025-01-04 16:09:10 -07:00
import edu.wpi.first.wpilibj.GenericHID;
2025-02-25 19:47:57 -07:00
import edu.wpi.first.wpilibj.Joystick;
2025-01-23 19:32:12 -07:00
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser;
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
2025-01-04 16:09:10 -07:00
import frc4388.utility.controller.XboxController;
2025-02-10 16:16:50 -07:00
import frc4388.utility.controller.ButtonBox;
2025-01-04 16:09:10 -07:00
import frc4388.utility.controller.DeadbandedXboxController;
2025-02-18 19:39:01 -07:00
import frc4388.robot.Constants.FieldConstants;
2025-03-06 19:55:26 -07:00
import frc4388.robot.Constants.LiDARConstants;
2025-01-04 16:09:10 -07:00
import frc4388.robot.Constants.OIConstants;
2025-01-14 17:16:09 -07:00
import frc4388.robot.Constants.SwerveDriveConstants;
2025-02-28 11:46:48 -07:00
import frc4388.robot.Constants.AutoConstants;
2025-01-04 16:09:10 -07:00
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
import edu.wpi.first.wpilibj2.command.button.Trigger;
// Commands
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.RunCommand;
2025-01-24 20:41:09 -07:00
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;
2025-01-14 17:26:32 -07:00
import edu.wpi.first.wpilibj2.command.Commands;
2025-02-28 11:46:48 -07:00
import edu.wpi.first.wpilibj2.command.ConditionalCommand;
2025-01-04 16:09:10 -07:00
// Autos
import frc4388.utility.controller.VirtualController;
2025-03-06 19:55:26 -07:00
import frc4388.robot.commands.DriveUntilLiDAR;
2025-02-01 15:52:06 -07:00
import frc4388.robot.commands.GotoLastApril;
2025-01-30 19:28:46 -07:00
import frc4388.robot.commands.LidarAlign;
2025-02-04 16:34:54 -07:00
import frc4388.robot.commands.MoveForTimeCommand;
2025-03-05 13:07:28 -07:00
import frc4388.robot.commands.WhileTrueCommand;
2025-02-18 19:39:01 -07:00
import frc4388.robot.commands.waitElevatorRefrence;
import frc4388.robot.commands.waitEndefectorRefrence;
2025-02-28 18:46:30 -07:00
import frc4388.robot.commands.waitFeedCoral;
2025-03-03 17:49:06 -07:00
import frc4388.robot.commands.waitSupplier;
2025-01-04 16:09:10 -07:00
import frc4388.robot.commands.Swerve.neoJoystickPlayback;
import frc4388.robot.commands.Swerve.neoJoystickRecorder;
2025-01-20 15:37:37 -07:00
2025-01-23 19:32:12 -07:00
import com.pathplanner.lib.auto.AutoBuilder;
2025-01-20 15:37:37 -07:00
import com.pathplanner.lib.auto.NamedCommands;
2025-01-14 17:26:32 -07:00
import com.pathplanner.lib.commands.PathPlannerAuto;
2025-01-04 16:09:10 -07:00
// Subsystems
2025-02-26 16:05:18 -07:00
import frc4388.robot.subsystems.LED;
2025-01-14 17:26:32 -07:00
import frc4388.robot.subsystems.Vision;
2025-01-27 19:35:08 -07:00
import frc4388.robot.subsystems.Elevator.CoordinationState;
2025-01-18 15:08:23 -07:00
import frc4388.robot.subsystems.Lidar;
2025-01-17 19:53:14 -07:00
import frc4388.robot.subsystems.Elevator;
// import frc4388.robot.subsystems.Endeffector;
2025-01-04 16:09:10 -07:00
import frc4388.robot.subsystems.SwerveDrive;
// Utilites
import frc4388.utility.DeferredBlock;
2025-02-25 19:49:10 -07:00
import frc4388.utility.DeferredBlockMulti;
2025-01-16 19:41:05 -07:00
import frc4388.utility.ReefPositionHelper;
2025-01-04 16:09:10 -07:00
import frc4388.utility.Subsystem;
2025-02-24 17:59:44 -07:00
import frc4388.utility.TimesNegativeOne;
2025-01-16 19:41:05 -07:00
import frc4388.utility.ReefPositionHelper.Side;
2025-01-04 16:09:10 -07:00
import frc4388.utility.configurable.ConfigurableString;
/**
* This class is where the bulk of the robot should be declared. Since
* Command-based is a "declarative" paradigm, very little robot logic should
* actually be handled in the {@link Robot} periodic methods (other than the
* scheduler calls). Instead, the structure of the robot (including subsystems,
* commands, and button mappings) should be declared here.
*/
public class RobotContainer {
/* RobotMap */
public final RobotMap m_robotMap = new RobotMap();
/* Subsystems */
public final LED m_robotLED = new LED();
2025-02-06 13:02:39 -07:00
public final Vision m_vision = new Vision(m_robotMap.leftCamera, m_robotMap.rightCamera);
2025-03-06 19:55:26 -07:00
public final Lidar m_reefLidar = new Lidar(LiDARConstants.REEF_LIDAR_DIO_CHANNEL, "Reef");
public final Lidar m_reverseLidar = new Lidar(LiDARConstants.REVERSE_LIDAR_DIO_CHANNEL, "Reverse");
2025-03-04 19:46:52 -07:00
public final Elevator m_robotElevator = new Elevator(m_robotMap.elevator, m_robotMap.endeffector, m_robotMap.basinLimitSwitch, m_robotMap.endeffectorLimitSwitch, m_robotMap.IRIntakeBeam, m_robotLED);
2025-01-14 17:26:32 -07:00
public final SwerveDrive m_robotSwerveDrive = new SwerveDrive(m_robotMap.swerveDrivetrain, m_vision);
// public final SwerveDrive m_robotSwerveDrive = new SwerveDrive(m_robotMap.swerveDrivetrain);
2025-01-04 16:09:10 -07:00
/* Controllers */
private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID);
2025-02-10 16:16:50 -07:00
private final DeadbandedXboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID);
private final ButtonBox m_buttonBox = new ButtonBox(OIConstants.BUTTONBOX_ID);
2025-01-04 16:09:10 -07:00
private final DeadbandedXboxController m_autoRecorderXbox = new DeadbandedXboxController(OIConstants.XBOX_PROGRAMMER_ID);
/* Virtual Controllers */
private final VirtualController m_virtualDriver = new VirtualController(0);
private final VirtualController m_virtualOperator = new VirtualController(1);
// public List<Subsystem> subsystems = new ArrayList<>();
// ! Teleop Commands
2025-01-25 14:47:23 -07:00
public void stop() {
2025-03-03 17:49:06 -07:00
new InstantCommand(()->{}, m_robotSwerveDrive).schedule();
2025-01-25 14:47:23 -07:00
m_robotSwerveDrive.stopModules();
}
2025-01-04 16:09:10 -07:00
// ! /* Autos */
private String lastAutoName = "defualt.auto";
2025-02-10 19:38:43 -07:00
private SendableChooser<String> autoChooser;
private Command autoCommand;
2025-02-27 19:47:21 -07:00
2025-03-03 17:49:06 -07:00
private Command waitFeedStation = new waitSupplier(m_robotElevator::readyToMove);
2025-03-07 21:46:25 -07:00
// private Command waitDebuger = new waitSupplier(m_driverXbox::getYButtonPressed);
private Command waitDebuger = new waitSupplier(() -> true);
2025-03-03 17:49:06 -07:00
2025-02-10 19:38:43 -07:00
// private ConfigurableString autoplaybackName = new ConfigurableString("Auto Playback Name", lastAutoName);
// private neoJoystickPlayback autoPlayback = new neoJoystickPlayback(m_robotSwerveDrive,
// () -> autoplaybackName.get(), // lastAutoName
// new VirtualController[]{getVirtualDriverController(), getVirtualOperatorController()},
// true, false);
2025-02-18 19:39:01 -07:00
// private Command AutoGotoPosition = new GotoLastApril(m_robotSwerveDrive, m_vision);
2025-02-21 21:14:12 -07:00
private Command AprilLidarAlignL4Right = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-02-28 11:46:48 -07:00
new ConditionalCommand(Commands.none(), new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedFour), m_robotElevator),
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L4_DISTANCE_PREP, Side.RIGHT, true)
2025-02-28 11:46:48 -07:00
), () -> m_robotElevator.isL4Primed()),
2025-02-24 17:10:12 -07:00
2025-02-26 15:40:29 -07:00
// new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedFour), m_robotElevator),
// new GotoLastApril(m_robotSwerveDrive, m_vision, FieldConstants.L4_DISTANCE_2, Side.RIGHT),
2025-02-24 17:10:12 -07:00
2025-02-19 21:28:28 -07:00
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-02-24 17:10:12 -07:00
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L4_DISTANCE_SCORE, Side.RIGHT, true),
waitDebuger.asProxy(),
2025-03-06 19:55:26 -07:00
new LidarAlign(m_robotSwerveDrive, m_reefLidar),
2025-03-07 21:46:25 -07:00
waitDebuger.asProxy(),
2025-02-24 17:10:12 -07:00
2025-02-19 21:28:28 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.ScoringFour), m_robotElevator),
2025-02-24 17:10:12 -07:00
2025-02-19 21:28:28 -07:00
new waitEndefectorRefrence(m_robotElevator),
2025-02-24 17:10:12 -07:00
2025-02-19 21:28:28 -07:00
new MoveForTimeCommand(m_robotSwerveDrive,
2025-02-28 11:46:48 -07:00
new Translation2d(0,1), new Translation2d(), AutoConstants.L4_DRIVE_TIME, true),
2025-03-03 16:32:27 -07:00
new ConditionalCommand(
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedFour), m_robotElevator),
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.Waiting), m_robotElevator),
() -> m_robotElevator.hasCoral()),
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-02-19 21:28:28 -07:00
);
2025-02-21 21:14:12 -07:00
private Command AprilLidarAlignL4Left = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-02-25 11:33:46 -07:00
2025-02-27 19:45:18 -07:00
// new IfCommand(() -> m_robotElevator.isL4Primed(), new SequentialCommandGroup(
2025-02-28 11:46:48 -07:00
new ConditionalCommand(Commands.none(), new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedFour), m_robotElevator),
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L4_DISTANCE_PREP, Side.LEFT, true)
2025-02-28 11:46:48 -07:00
), () -> m_robotElevator.isL4Primed()),
2025-02-26 15:40:29 -07:00
// new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedFour), m_robotElevator),
// new GotoLastApril(m_robotSwerveDrive, m_vision, FieldConstants.L4_DISTANCE_2, Side.LEFT),
2025-02-25 11:33:46 -07:00
2025-02-18 19:39:01 -07:00
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-02-24 17:10:12 -07:00
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L4_DISTANCE_SCORE, Side.LEFT, true),
waitDebuger.asProxy(),
2025-03-06 19:55:26 -07:00
new LidarAlign(m_robotSwerveDrive, m_reefLidar),
2025-03-07 21:46:25 -07:00
waitDebuger.asProxy(),
2025-02-25 11:33:46 -07:00
2025-02-18 19:39:01 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.ScoringFour), m_robotElevator),
2025-02-25 11:33:46 -07:00
2025-02-18 19:39:01 -07:00
new waitEndefectorRefrence(m_robotElevator),
2025-02-25 11:33:46 -07:00
2025-03-03 16:32:27 -07:00
2025-02-18 19:39:01 -07:00
new MoveForTimeCommand(m_robotSwerveDrive,
2025-02-28 11:46:48 -07:00
new Translation2d(0,1), new Translation2d(), AutoConstants.L4_DRIVE_TIME, true),
2025-02-25 11:33:46 -07:00
2025-03-03 16:32:27 -07:00
new ConditionalCommand(
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedFour), m_robotElevator),
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.Waiting), m_robotElevator),
() -> m_robotElevator.hasCoral()),
2025-02-25 11:33:46 -07:00
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-02-01 15:52:06 -07:00
);
2025-02-19 21:28:28 -07:00
private Command AprilLidarAlignL3Left = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-02-28 11:46:48 -07:00
new ConditionalCommand(Commands.none(), new SequentialCommandGroup(
2025-02-27 19:45:18 -07:00
// new IfCommand(() -> m_robotElevator.isL3Primed(), new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedThree), m_robotElevator),
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L3_DISTANCE_PREP, Side.LEFT, true)
2025-02-28 11:46:48 -07:00
), () -> m_robotElevator.isL3Primed()),
2025-02-26 15:40:29 -07:00
2025-02-19 21:28:28 -07:00
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-02-26 15:40:29 -07:00
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L3_DISTANCE_SCORE, Side.LEFT, true),
waitDebuger.asProxy(),
2025-03-06 19:55:26 -07:00
new LidarAlign(m_robotSwerveDrive, m_reefLidar),
2025-03-07 21:46:25 -07:00
waitDebuger.asProxy(),
2025-02-19 21:28:28 -07:00
// new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.ScoringThree), m_robotElevator),
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
// new MoveForTimeCommand(m_robotSwerveDrive,
// new Translation2d(0,1), new Translation2d(), 500, true),
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.Waiting), m_robotElevator),
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-02-19 21:28:28 -07:00
);
2025-02-21 21:14:12 -07:00
private Command AprilLidarAlignL3Right = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-02-28 11:46:48 -07:00
new ConditionalCommand(Commands.none(), new SequentialCommandGroup(
2025-02-27 19:45:18 -07:00
// new IfCommand(() -> m_robotElevator.isL3Primed(), new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedThree), m_robotElevator),
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L3_DISTANCE_PREP, Side.RIGHT, true)
2025-02-28 11:46:48 -07:00
),() -> m_robotElevator.isL3Primed()),
2025-02-26 15:40:29 -07:00
2025-02-28 11:46:48 -07:00
// new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedThree), m_robotElevator),
// new GotoLastApril(m_robotSwerveDrive, m_vision, FieldConstants.L3_DISTANCE_2, Side.RIGHT),
2025-02-19 21:28:28 -07:00
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L3_DISTANCE_SCORE, Side.RIGHT, true),
waitDebuger.asProxy(),
2025-02-19 21:28:28 -07:00
2025-03-06 19:55:26 -07:00
new LidarAlign(m_robotSwerveDrive, m_reefLidar),
2025-03-07 21:46:25 -07:00
waitDebuger.asProxy(),
2025-02-19 21:28:28 -07:00
// new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.ScoringThree), m_robotElevator),
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
// new MoveForTimeCommand(m_robotSwerveDrive,
// new Translation2d(0,1), new Translation2d(), 500, true),
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.Waiting), m_robotElevator),
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-02-19 21:28:28 -07:00
);
2025-02-21 21:14:12 -07:00
private Command AprilLidarAlignL2Left = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L2_PREP_DISTANCE, Side.LEFT, true),
waitDebuger.asProxy(),
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L2_SCORE_DISTANCE, Side.LEFT, true),
waitDebuger.asProxy(),
2025-02-21 21:14:12 -07:00
2025-03-06 19:55:26 -07:00
new LidarAlign(m_robotSwerveDrive, m_reefLidar),
2025-03-07 21:46:25 -07:00
waitDebuger.asProxy(),
2025-02-21 21:14:12 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.L2Score);}, m_robotElevator),
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-03-08 17:11:56 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.L2ScoreLeave);}, m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-02-21 21:14:12 -07:00
new MoveForTimeCommand(m_robotSwerveDrive,
2025-02-28 11:46:48 -07:00
new Translation2d(0,1), new Translation2d(), AutoConstants.L2_DRIVE_TIME, true),
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.Waiting);}, m_robotElevator),
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-02-19 21:28:28 -07:00
2025-01-30 19:28:46 -07:00
);
2025-02-21 21:14:12 -07:00
private Command AprilLidarAlignL2Right = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-03-07 21:46:25 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L2_PREP_DISTANCE, Side.RIGHT, true),
waitDebuger.asProxy(),
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.L2_SCORE_DISTANCE, Side.RIGHT, true),
waitDebuger.asProxy(),
2025-02-28 11:46:48 -07:00
2025-03-06 19:55:26 -07:00
new LidarAlign(m_robotSwerveDrive, m_reefLidar),
2025-03-07 21:46:25 -07:00
waitDebuger.asProxy(),
2025-02-21 21:14:12 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.L2Score);}, m_robotElevator),
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-03-08 17:11:56 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.L2ScoreLeave);}, m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-02-21 21:14:12 -07:00
new MoveForTimeCommand(m_robotSwerveDrive,
2025-02-28 11:46:48 -07:00
new Translation2d(0,1), new Translation2d(), AutoConstants.L2_DRIVE_TIME, true),
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.Waiting);}, m_robotElevator),
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-01-30 19:28:46 -07:00
);
2025-01-24 20:41:09 -07:00
2025-03-08 13:22:14 -07:00
// private Command leftAlgaeRemove = new SequentialCommandGroup(
// new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL2Primed);}, m_robotElevator),
// new waitEndefectorRefrence(m_robotElevator),
// new waitElevatorRefrence(m_robotElevator),
// new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.ALGAE_REMOVAL_DISTANCE, Side.LEFT, false),
// new LidarAlign(m_robotSwerveDrive, m_reefLidar),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL2Go);}, m_robotElevator),
// new MoveForTimeCommand(m_robotSwerveDrive,
// new Translation2d(0,1), new Translation2d(), AutoConstants.ALGAE_DRIVE_TIME, true),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.Waiting);}, m_robotElevator),
// new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
// );
private Command lowerAlgaeRemove = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-02-21 21:14:12 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL2Primed);}, m_robotElevator),
2025-03-08 13:22:14 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.ALGAE_REMOVAL_DISTANCE + Units.inchesToMeters(8), Side.FAR_LEFT, true),
2025-02-21 21:14:12 -07:00
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-03-08 13:22:14 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.ALGAE_REMOVAL_DISTANCE, Side.FAR_LEFT, true),
waitDebuger.asProxy(),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL2Go);}, m_robotElevator),
2025-02-21 21:14:12 -07:00
new MoveForTimeCommand(m_robotSwerveDrive,
2025-03-08 13:22:14 -07:00
new Translation2d(1,0), new Translation2d(0, 0), AutoConstants.ALGAE_DRIVE_TIME / 2, true),
new MoveForTimeCommand(m_robotSwerveDrive,
new Translation2d(1,1), new Translation2d(0, 0), AutoConstants.ALGAE_DRIVE_TIME * 2, true),
2025-03-08 17:11:56 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.Waiting);}, m_robotElevator),
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-02-21 21:14:12 -07:00
);
2025-03-08 13:22:14 -07:00
// private Command rightAlgaeRemove = new SequentialCommandGroup(
// new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL3Primed);}, m_robotElevator),
// new waitEndefectorRefrence(m_robotElevator),
// new waitElevatorRefrence(m_robotElevator),
// new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.ALGAE_REMOVAL_DISTANCE, Side.LEFT, false),
// new LidarAlign(m_robotSwerveDrive, m_reefLidar),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL3Go);}, m_robotElevator),
// new MoveForTimeCommand(m_robotSwerveDrive,
// new Translation2d(1,1), new Translation2d(), AutoConstants.ALGAE_DRIVE_TIME, true),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.Waiting);}, m_robotElevator),
// new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
// );
private Command upperAlgaeRemove = new SequentialCommandGroup(
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.startSlowPeriod();}),
2025-02-21 21:14:12 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL3Primed);}, m_robotElevator),
2025-03-08 13:22:14 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.ALGAE_REMOVAL_DISTANCE + Units.inchesToMeters(8), Side.FAR_LEFT, true),
2025-02-21 21:14:12 -07:00
new waitEndefectorRefrence(m_robotElevator),
new waitElevatorRefrence(m_robotElevator),
2025-03-08 13:22:14 -07:00
new GotoLastApril(m_robotSwerveDrive, m_vision, AutoConstants.ALGAE_REMOVAL_DISTANCE, Side.FAR_LEFT, true),
waitDebuger.asProxy(),
// new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.BallRemoverL2Go);}, m_robotElevator),
2025-02-21 21:14:12 -07:00
new MoveForTimeCommand(m_robotSwerveDrive,
2025-03-08 13:22:14 -07:00
new Translation2d(1,1), new Translation2d(0, 0), AutoConstants.ALGAE_DRIVE_TIME, true),
2025-03-08 17:11:56 -07:00
new InstantCommand(() -> {m_robotElevator.transitionState(CoordinationState.Waiting);}, m_robotElevator),
2025-02-26 15:40:29 -07:00
new InstantCommand(() -> {m_robotSwerveDrive.endSlowPeriod();})
2025-02-21 21:14:12 -07:00
);
2025-02-27 19:47:21 -07:00
private Command thrustIntake = new SequentialCommandGroup(
2025-03-03 16:32:27 -07:00
new InstantCommand(() -> m_robotSwerveDrive.startTurboPeriod(), m_robotSwerveDrive),
new MoveForTimeCommand(m_robotSwerveDrive, new Translation2d(0,-1), new Translation2d(), 300, true),
new InstantCommand(() -> m_robotSwerveDrive.softStop(), m_robotSwerveDrive),
new InstantCommand(() -> m_robotSwerveDrive.endSlowPeriod(), m_robotSwerveDrive)
2025-02-27 19:47:21 -07:00
);
private Boolean operatorManualMode = false;
2025-01-04 16:09:10 -07:00
2025-03-05 19:42:36 -07:00
// public Command LoopAprilLidarAlignL4Left = new WhileTrueCommand(AprilLidarAlignL4Left.asProxy(), () -> !m_robotElevator.hasCoral());
// public Command LoopAprilLidarAlignL4Right = new WhileTrueCommand(AprilLidarAlignL4Right.asProxy(), () -> !m_robotElevator.hasCoral());
// public Command LoopAprilLidarAlignL3Left = new WhileTrueCommand(AprilLidarAlignL3Left.asProxy(), () -> !m_robotElevator.hasCoral());
// public Command LoopAprilLidarAlignL3Right = new WhileTrueCommand(AprilLidarAlignL3Right.asProxy(), () -> !m_robotElevator.hasCoral());
// public Command LoopAprilLidarAlignL2Left = new WhileTrueCommand(AprilLidarAlignL2Left.asProxy(), () -> !m_robotElevator.hasCoral());
// public Command LoopAprilLidarAlignL2Right = new WhileTrueCommand(AprilLidarAlignL2Right.asProxy(), () -> !m_robotElevator.hasCoral());
// public Command LoopAprilLidarAlignL4Left = new SequentialCommandGroup(AprilLidarAlignL4Left.asProxy(), new ConditionalCommand(AprilLidarAlignL4Left.asProxy(), Commands.none(), () -> !m_robotElevator.hasCoral()));
// public Command LoopAprilLidarAlignL4Right = new SequentialCommandGroup(AprilLidarAlignL4Right.asProxy(), new ConditionalCommand(AprilLidarAlignL4Right.asProxy(), Commands.none(), () -> !m_robotElevator.hasCoral()));
// public Command LoopAprilLidarAlignL3Left = new SequentialCommandGroup(AprilLidarAlignL3Left.asProxy(), new ConditionalCommand(AprilLidarAlignL3Left.asProxy(), Commands.none(), () -> m_robotElevator.hasCoral()));
// public Command LoopAprilLidarAlignL3Right = new SequentialCommandGroup(AprilLidarAlignL3Right.asProxy(), new ConditionalCommand(AprilLidarAlignL3Right.asProxy(), Commands.none(), () -> m_robotElevator.hasCoral()));
// public Command LoopAprilLidarAlignL2Left = new SequentialCommandGroup(AprilLidarAlignL2Left.asProxy(), new ConditionalCommand(AprilLidarAlignL2Left.asProxy(), Commands.none(), () -> m_robotElevator.hasCoral()));
// public Command LoopAprilLidarAlignL2Right = new SequentialCommandGroup(AprilLidarAlignL2Right.asProxy(), new ConditionalCommand(AprilLidarAlignL2Right.asProxy(), Commands.none(), () -> m_robotElevator.hasCoral()));
2025-01-04 16:09:10 -07:00
/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer() {
2025-03-13 07:19:15 -06:00
NamedCommands.registerCommand("taxi", new SequentialCommandGroup(
new MoveForTimeCommand(m_robotSwerveDrive,
new Translation2d(0, -1),
new Translation2d(), 1000, true
), new InstantCommand(()-> {m_robotSwerveDrive.softStop();} , m_robotSwerveDrive)));
2025-02-28 18:46:30 -07:00
2025-03-03 17:49:06 -07:00
NamedCommands.registerCommand("grab-coral", waitFeedStation.asProxy());
NamedCommands.registerCommand("await-coral", new waitFeedCoral(m_robotElevator));
2025-03-06 19:55:26 -07:00
NamedCommands.registerCommand("feed-driveback", new DriveUntilLiDAR(m_robotSwerveDrive,
new Translation2d(-1,0), new Translation2d(), m_reverseLidar, LiDARConstants.HUMAN_PLAYER_STATION_DISTANCE, true));
// NamedCommands.registerCommand("feed-driveback", Commands.none());
2025-03-06 17:34:16 -07:00
NamedCommands.registerCommand("stop", new waitSupplier(() -> m_robotSwerveDrive.lastOdomSpeed < AutoConstants.STOP_VELOCITY));
2025-02-28 18:46:30 -07:00
NamedCommands.registerCommand("align-feed", new SequentialCommandGroup(
new MoveForTimeCommand(m_robotSwerveDrive,
new Translation2d(0, 1),
2025-03-05 19:42:36 -07:00
new Translation2d(), 300, true
2025-02-28 18:46:30 -07:00
), new InstantCommand(()-> {m_robotSwerveDrive.softStop();} , m_robotSwerveDrive)));
2025-01-15 17:55:24 -07:00
2025-03-05 19:42:36 -07:00
NamedCommands.registerCommand("place-coral-left-l4", AprilLidarAlignL4Left);
NamedCommands.registerCommand("place-coral-right-l4", AprilLidarAlignL4Right);
NamedCommands.registerCommand("place-coral-left-l3", AprilLidarAlignL3Left);
NamedCommands.registerCommand("place-coral-right-l3", AprilLidarAlignL3Right);
NamedCommands.registerCommand("place-coral-left-l2", AprilLidarAlignL2Left);
NamedCommands.registerCommand("place-coral-right-l2", AprilLidarAlignL2Right);
2025-02-24 17:10:12 -07:00
2025-03-03 17:49:06 -07:00
NamedCommands.registerCommand("prepare-l4", new InstantCommand(() -> {
m_robotElevator.transitionState(CoordinationState.PrimedFour);
2025-03-03 16:40:33 -07:00
}));
2025-02-24 17:10:12 -07:00
2025-01-04 16:09:10 -07:00
configureButtonBindings();
configureVirtualButtonBindings();
2025-02-25 19:49:10 -07:00
new DeferredBlock(() -> { // Called on first robot enable
2025-02-24 17:59:44 -07:00
m_robotSwerveDrive.resetGyro();
});
2025-02-25 19:49:10 -07:00
new DeferredBlockMulti(() -> { // Called on every robot enable
TimesNegativeOne.update();
});
2025-01-04 16:09:10 -07:00
DriverStation.silenceJoystickConnectionWarning(true);
// CameraServer.startAutomaticCapture();
/* Default Commands */
// ! Swerve Drive Default Command (Regular Rotation)
// drives the robot with a two-axis input from the driver controller
m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> {
m_robotSwerveDrive.driveWithInput(getDeadbandedDriverController().getLeft(),
2025-02-15 09:24:56 -07:00
// m_robotSwerveDrive.driveWithInput(new Translation2d(.4, 0),
2025-01-04 16:09:10 -07:00
getDeadbandedDriverController().getRight(),
2025-01-14 17:26:32 -07:00
true);
2025-01-04 16:09:10 -07:00
}, m_robotSwerveDrive)
.withName("SwerveDrive DefaultCommand"));
m_robotSwerveDrive.setToSlow();
2025-02-17 15:45:59 -07:00
2025-02-27 19:47:21 -07:00
m_robotElevator.setDefaultCommand(new RunCommand(() -> {
m_robotElevator.manualEndeffectorVel(getDeadbandedOperatorController().getLeftY());
m_robotElevator.manualElevatorVel(getDeadbandedOperatorController().getRightY());
}, m_robotElevator)
.withName("Default Manual Controls"));
2025-02-17 15:45:59 -07:00
2025-02-10 19:38:43 -07:00
makeAutoChooser();
2025-01-23 19:32:12 -07:00
SmartDashboard.putData("Auto Chooser", autoChooser);
2025-01-04 16:09:10 -07:00
// this.subsystems.add(m_robotSwerveDrive);
// this.subsystems.add(m_robotMap.leftFront);
// this.subsystems.add(m_robotMap.rightFront);
// this.subsystems.add(m_robotMap.rightBack);
// this.subsystems.add(m_robotMap.leftBack);
// ! Swerve Drive One Module Test
// m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> {
// m_robotMap.rightFront.go(getDeadbandedDriverController().getLeft());
// }
// ! Swerve Drive Default Command (Orientation Rotation)
// m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> {
// m_robotSwerveDrive.driveWithInputOrientation(getDeadbandedDriverController().getLeft(),
// getDeadbandedDriverController().getRightX(),
// getDeadbandedDriverController().getRightY(),
// true);
// }, m_robotSwerveDrive))
// .withName("SwerveDrive OrientationCommand"));
// continually sends updates to the Blinkin LED controller to keep the lights on
// m_robotLED.setDefaultCommand(new RunCommand(() -> m_robotLED.updateLED(), m_robotLED));
// m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> {
// m_robotSwerveDrive.driveWithInput(
// getDeadbandedDriverController().getLeft(),
// getDeadbandedDriverController().getRight(),
// true);
// }, m_robotSwerveDrive));
}
/**
* Use this method to define your button->command mappings. Buttons can be
* created by instantiating a {@link GenericHID} or one of its subclasses
* ({@link edu.wpi.first.wpilibj.Joystick} or {@link XboxController}), and then
* passing it to a {@link edu.wpi.first.wpilibj2.command.button.JoystickButton}.
*/
private void configureButtonBindings() {
2025-02-10 16:16:50 -07:00
// ? /* Driver Buttons */
2025-01-16 19:41:05 -07:00
2025-02-27 19:47:21 -07:00
DualJoystickButton(getDeadbandedDriverController(), getVirtualDriverController(), XboxController.A_BUTTON)
.onTrue(new InstantCommand(() -> m_robotSwerveDrive.resetGyro()));
2025-02-21 20:22:07 -07:00
2025-02-27 19:47:21 -07:00
// ! /* Speed */
new JoystickButton(getDeadbandedDriverController(), XboxController.RIGHT_BUMPER_BUTTON)
.onTrue(new InstantCommand(() -> m_robotSwerveDrive.shiftUp()));
new JoystickButton(getDeadbandedDriverController(), XboxController.LEFT_BUMPER_BUTTON)
.onTrue(new InstantCommand(() -> m_robotSwerveDrive.shiftDown()));
2025-02-21 20:22:07 -07:00
2025-02-27 19:47:21 -07:00
new JoystickButton(getDeadbandedDriverController(), XboxController.START_BUTTON)
.onTrue(new InstantCommand(() -> m_robotSwerveDrive.activateLuigiMode()));
new JoystickButton(getDeadbandedDriverController(), XboxController.BACK_BUTTON)
.onTrue(new InstantCommand(() -> m_robotSwerveDrive.deactivateLuigiMode()));
2025-02-21 20:22:07 -07:00
2025-02-27 19:47:21 -07:00
// While Left Trigger Pressed: Trims
new Trigger(() -> getDeadbandedDriverController().getPOV() == 0 && getDeadbandedDriverController().getLeftTriggerAxis() > 0.8)
.onTrue(new InstantCommand(() -> AutoConstants.Y_OFFSET_TRIM.stepUp()));
2025-02-21 21:14:12 -07:00
2025-02-27 19:47:21 -07:00
new Trigger(() -> getDeadbandedDriverController().getPOV() == 180 && getDeadbandedDriverController().getLeftTriggerAxis() > 0.8)
.onTrue(new InstantCommand(() -> AutoConstants.Y_OFFSET_TRIM.stepDown()));
2025-02-21 21:14:12 -07:00
2025-02-27 19:47:21 -07:00
new Trigger(() -> getDeadbandedDriverController().getPOV() == 90 && getDeadbandedDriverController().getLeftTriggerAxis() > 0.8)
.onTrue(new InstantCommand(() -> AutoConstants.X_OFFSET_TRIM.stepUp()));
2025-02-18 19:39:01 -07:00
2025-02-27 19:47:21 -07:00
new Trigger(() -> getDeadbandedDriverController().getPOV() == 270 && getDeadbandedDriverController().getLeftTriggerAxis() > 0.8)
.onTrue(new InstantCommand(() -> AutoConstants.X_OFFSET_TRIM.stepDown()));
2025-03-03 16:32:27 -07:00
new Trigger(() ->getDeadbandedDriverController().getRightTriggerAxis() > 0.8)
.onTrue(new InstantCommand(() -> m_robotSwerveDrive.startTurboPeriod()))
.onFalse(new InstantCommand(() -> m_robotSwerveDrive.endSlowPeriod()));
2025-02-27 19:47:21 -07:00
// While Left Trigger NOT Pressed: Fine Alignment
new Trigger(() -> getDeadbandedDriverController().getPOV() != -1 && !(getDeadbandedDriverController().getLeftTriggerAxis() > 0.8))
.whileTrue(new RunCommand(
() -> m_robotSwerveDrive.driveFine(
2025-02-27 19:47:21 -07:00
new Translation2d(
1,
Rotation2d.fromDegrees(getDeadbandedDriverController().getPOV())
2025-02-27 19:47:21 -07:00
),
2025-03-03 16:32:27 -07:00
getDeadbandedDriverController().getRight(), 0.30
2025-02-27 19:47:21 -07:00
), m_robotSwerveDrive))
.onFalse(new InstantCommand(() -> m_robotSwerveDrive.softStop(), m_robotSwerveDrive));
new JoystickButton(getDeadbandedDriverController(), XboxController.Y_BUTTON)
.onTrue(new DriveUntilLiDAR(m_robotSwerveDrive,
new Translation2d(-1,0), new Translation2d(), m_reverseLidar, LiDARConstants.HUMAN_PLAYER_STATION_DISTANCE, true));
2025-03-06 19:55:26 -07:00
2025-02-27 19:47:21 -07:00
new JoystickButton(getDeadbandedDriverController(), XboxController.X_BUTTON)
.onTrue(thrustIntake.asProxy());
2025-01-04 16:09:10 -07:00
2025-02-27 19:47:21 -07:00
new JoystickButton(getDeadbandedDriverController(), XboxController.B_BUTTON)
2025-03-06 19:55:26 -07:00
.onTrue(new InstantCommand(() -> {}, m_robotSwerveDrive, m_reefLidar));
2025-01-13 19:43:35 -07:00
2025-02-25 16:41:28 -07:00
2025-02-27 19:47:21 -07:00
// ? /* Operator Buttons */
DualJoystickButton(getDeadbandedOperatorController(), getVirtualOperatorController(), XboxController.B_BUTTON)
.onTrue(new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.Waiting), m_robotElevator));
DualJoystickButton(getDeadbandedOperatorController(), getVirtualOperatorController(), XboxController.A_BUTTON)
.onTrue(new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.Ready), m_robotElevator));
// Button box
2025-02-18 19:39:01 -07:00
2025-02-27 19:47:21 -07:00
new JoystickButton(getButtonBox(), ButtonBox.Five)
.onTrue(AprilLidarAlignL4Left);
new JoystickButton(getButtonBox(), ButtonBox.One)
.onTrue(AprilLidarAlignL4Right);
2025-02-24 17:10:12 -07:00
2025-02-27 19:47:21 -07:00
new JoystickButton(getButtonBox(), ButtonBox.Six)
.onTrue(AprilLidarAlignL3Left);
new JoystickButton(getButtonBox(), ButtonBox.Two)
.onTrue(AprilLidarAlignL3Right);
new JoystickButton(getButtonBox(), ButtonBox.Seven)
.onTrue(AprilLidarAlignL2Left);
new JoystickButton(getButtonBox(), ButtonBox.Three)
.onTrue(AprilLidarAlignL2Right);
// Lower algae removal
new JoystickButton(getButtonBox(), ButtonBox.Eight)
2025-03-08 13:22:14 -07:00
.onTrue(lowerAlgaeRemove);
2025-02-27 19:47:21 -07:00
// Upper algae removal
new JoystickButton(getButtonBox(), ButtonBox.Four)
2025-03-08 13:22:14 -07:00
.onTrue(upperAlgaeRemove);
2025-02-21 21:14:12 -07:00
2025-02-24 17:10:12 -07:00
// Cancel button
2025-02-21 21:14:12 -07:00
new JoystickButton(getButtonBox(), ButtonBox.White)
2025-02-26 15:40:29 -07:00
.onTrue(new InstantCommand(() -> {
m_robotElevator.elevatorStop();
2025-02-26 17:14:17 -07:00
m_robotElevator.endeffectorStop();
2025-02-26 15:40:29 -07:00
m_robotSwerveDrive.endSlowPeriod();
}, m_robotElevator));
2025-02-21 20:22:07 -07:00
2025-02-27 19:47:21 -07:00
// Manual Mode Buttons
new Trigger(() -> (getDeadbandedOperatorController().getLeftTriggerAxis() >= 0.8 || getDeadbandedOperatorController().getRightTriggerAxis() >= 0.8) && operatorManualMode)
.onTrue (new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedFour), m_robotElevator))
.onFalse(new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.ScoringFour), m_robotElevator));
2025-02-25 16:41:28 -07:00
2025-02-27 19:47:21 -07:00
new Trigger(() -> (getDeadbandedOperatorController().getLeftBumperButton() || getDeadbandedOperatorController().getRightBumperButton()) && operatorManualMode)
.onTrue (new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.PrimedThree), m_robotElevator))
.onFalse(new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.ScoringThree), m_robotElevator));
new Trigger(() -> (getDeadbandedOperatorController().getXButton() || getDeadbandedOperatorController().getYButton()) && operatorManualMode)
.onTrue (new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.L2Score), m_robotElevator));
new Trigger(() -> getDeadbandedOperatorController().getPOV() == 180 && operatorManualMode)
.onTrue (new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.BallRemoverL2Primed), m_robotElevator))
.onFalse(new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.BallRemoverL2Go), m_robotElevator));
new Trigger(() -> getDeadbandedOperatorController().getPOV() == 0 && operatorManualMode)
.onTrue (new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.BallRemoverL3Primed), m_robotElevator))
.onFalse(new InstantCommand(() -> m_robotElevator.transitionState(CoordinationState.BallRemoverL3Go), m_robotElevator));
2025-03-03 16:32:27 -07:00
new JoystickButton(getDeadbandedOperatorController(), XboxController.BACK_BUTTON)
2025-02-27 19:47:21 -07:00
.onTrue(new InstantCommand(() -> {operatorManualMode = !operatorManualMode;}));
2025-03-08 13:22:14 -07:00
// new JoystickButton(getDeadbandedOperatorController(), XboxController.START_BUTTON)
// .onTrue(new InstantCommand(() -> m_robotElevator.togggleAutoIntaking()));
2025-02-21 20:22:07 -07:00
2025-02-27 19:47:21 -07:00
// Auto Scoring
new Trigger(() -> getDeadbandedOperatorController().getLeftTriggerAxis() >= 0.8 && !operatorManualMode)
.onTrue(AprilLidarAlignL4Left);
new Trigger(() -> getDeadbandedOperatorController().getRightTriggerAxis() >= 0.8 && !operatorManualMode)
.onTrue(AprilLidarAlignL4Right);
2025-02-21 20:22:07 -07:00
2025-02-27 19:47:21 -07:00
new Trigger(() -> getDeadbandedOperatorController().getLeftBumperButton() && !operatorManualMode)
.onTrue(AprilLidarAlignL3Left);
new Trigger(() -> getDeadbandedOperatorController().getRightBumperButton() && !operatorManualMode)
.onTrue(AprilLidarAlignL3Right);
new Trigger(() -> getDeadbandedOperatorController().getXButton() && !operatorManualMode)
.onTrue(AprilLidarAlignL2Left);
new Trigger(() -> getDeadbandedOperatorController().getYButton() && !operatorManualMode)
.onTrue(AprilLidarAlignL2Right);
2025-02-24 17:10:12 -07:00
2025-02-27 19:47:21 -07:00
//Controller Lower Algae Removal
new Trigger(() -> getDeadbandedOperatorController().getPOV() == 180 && !operatorManualMode)
2025-03-08 13:22:14 -07:00
.onTrue(lowerAlgaeRemove);
2025-02-24 17:10:12 -07:00
2025-02-27 19:47:21 -07:00
//Controller Upper Algae Removal
new Trigger(() -> getDeadbandedOperatorController().getPOV() == 0 && !operatorManualMode)
2025-03-08 13:22:14 -07:00
.onTrue(upperAlgaeRemove);
2025-02-25 16:41:28 -07:00
2025-01-04 16:09:10 -07:00
// ? /* Programer Buttons (Controller 3)*/
// * /* Auto Recording */
2025-02-10 19:38:43 -07:00
// new JoystickButton(m_autoRecorderXbox, XboxController.LEFT_BUMPER_BUTTON)
// .whileTrue(new neoJoystickRecorder(m_robotSwerveDrive,
// new DeadbandedXboxController[]{getDeadbandedDriverController(), getDeadbandedOperatorController()},
// () -> autoplaybackName.get()))
// .onFalse(new InstantCommand());
2025-01-04 16:09:10 -07:00
2025-02-10 19:38:43 -07:00
// new JoystickButton(m_autoRecorderXbox, XboxController.RIGHT_BUMPER_BUTTON)
// .onTrue(new neoJoystickPlayback(m_robotSwerveDrive,
// () -> autoplaybackName.get(),
// new VirtualController[]{getVirtualDriverController(), getVirtualOperatorController()},
// true, false))
// .onFalse(new InstantCommand());
2025-01-17 19:53:14 -07:00
2025-01-04 16:09:10 -07:00
}
/**
* This method is used to replcate {@link Trigger Triggers} for {@link VirtualController Virtual Controllers}. <p/>
* Please use {@link RobotContainer#DualJoystickButton} in {@link RobotContainer#configureButtonBindings} for standard buttons.
*/
private void configureVirtualButtonBindings() {
// ? /* Driver Buttons */
/* Notice: the following buttons have not been replicated
* Swerve Drive Slow and Fast mode Gear Shifts : Fast mode is known to cause drift, so we disable that feature in Autoplayback
* Swerve Drive Rotation Gear Shifts : Same reason as Slow and Fast mode.
* Auto Recording controls : We don't want an Null Ouroboros for an auto.
*/
// ? /* Operator Buttons */
/* Notice: the following buttons have not been replicated
* Override Intake Position Encoder : It's an emergancy overide, for when the position of intake when the robot boots, the intake is not inside the robot.
* We don't need it in an auto.
* Climbing controls : We don't need to climb in auto.
*/
// ? Notice: the Programer Buttons are not to be replicated because they are designed for debuging the robot, and do not need to be replicated in auto.
}
/**
* Use this to pass the autonomous command to the main {@link Robot} class.
*
* @return the command to run in autonomous
*/
public Command getAutonomousCommand() {
2025-01-23 19:32:12 -07:00
2025-02-24 17:10:12 -07:00
2025-01-14 17:26:32 -07:00
//return autoPlayback;
2025-01-23 19:32:12 -07:00
//return new GotoPositionCommand(m_robotSwerveDrive, m_vision)
2025-01-28 17:05:10 -07:00
//return autoChooser.getSelected();
2025-01-23 19:32:12 -07:00
// try{
2025-02-24 17:10:12 -07:00
// // // Load the path you want to follow using its name in the GUI
// return autoCommand;
2025-01-23 19:32:12 -07:00
// } catch (Exception e) {
// DriverStation.reportError("Path planner error: " + e.getMessage(), e.getStackTrace());
2025-02-28 18:46:30 -07:00
return autoCommand;
2025-01-23 19:32:12 -07:00
// }
2025-02-28 18:46:30 -07:00
// return new PathPlannerAuto("Line-up-no-arm");
2025-01-14 17:28:01 -07:00
// zach told me to do the below comment
//return new GotoPositionCommand(m_robotSwerveDrive, m_vision);
2025-01-15 17:37:18 -07:00
// return new GotoPositionCommand(m_robotSwerveDrive, m_vision, AutoConstants.targetpos);
2025-01-04 16:09:10 -07:00
}
2025-02-10 19:38:43 -07:00
public void makeAutoChooser() {
autoChooser = new SendableChooser<String>();
File dir = new File("/home/lvuser/deploy/pathplanner/autos/");
// File dir = new File("C:\\Users\\Ridgebotics\\Documents\\GitHub\\2025RidgeScape\\src\\main\\deploy\\pathplanner\\autos\\");
String[] autos = dir.list();
2025-03-05 13:07:28 -07:00
if(autos == null) return;
2025-02-10 19:38:43 -07:00
for (String auto : autos) {
if (auto.endsWith(".auto"))
2025-02-28 18:46:30 -07:00
autoChooser.addOption(auto.replaceAll(".auto", ""), auto.replaceAll(".auto", ""));
// System.out.println(auto);
2025-02-10 19:38:43 -07:00
}
2025-01-14 17:26:32 -07:00
2025-02-10 19:38:43 -07:00
autoChooser.onChange((filename) -> {
autoCommand = new PathPlannerAuto(filename);
2025-02-25 11:33:46 -07:00
System.out.println("Robot Auto Changed " + filename);
2025-02-10 19:38:43 -07:00
});
2025-02-25 11:33:46 -07:00
// SmartDashboard.putData(autoChooser);
2025-02-10 19:38:43 -07:00
}
2025-01-14 17:26:32 -07:00
2025-01-04 16:09:10 -07:00
/**
* A button binding for two controllers, preferably an {@link DeadbandedXboxController Xbox Controller} and {@link VirtualController Virtual Xbox Controller}
* @param joystickA A controller
* @param joystickB A controller
* @param buttonNumber The button to bind to
*/
public Trigger DualJoystickButton(GenericHID joystickA, GenericHID joystickB, int buttonNumber) {
return new Trigger(() -> (joystickA.getRawButton(buttonNumber) || joystickB.getRawButton(buttonNumber)));
}
public DeadbandedXboxController getDeadbandedDriverController() {
return this.m_driverXbox;
}
public DeadbandedXboxController getDeadbandedOperatorController() {
return this.m_operatorXbox;
}
2025-02-10 16:16:50 -07:00
public ButtonBox getButtonBox() {
return this.m_buttonBox;
}
2025-01-04 16:09:10 -07:00
public VirtualController getVirtualDriverController() {
return m_virtualDriver;
}
public VirtualController getVirtualOperatorController() {
return m_virtualOperator;
}
}