2022-01-11 11:05:52 -07:00
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
2021-11-15 16:26:16 -07:00
package frc4388.robot ;
2022-03-24 19:08:24 -06:00
import java.io.File ;
import java.nio.file.Files ;
import java.nio.file.StandardOpenOption ;
2022-02-10 21:18:00 -07:00
import java.util.ArrayList ;
2022-03-24 19:08:24 -06:00
import java.util.Arrays ;
2022-02-27 22:59:32 -07:00
import java.util.Objects ;
2022-02-15 11:05:59 -07:00
import java.util.logging.Logger ;
2022-01-21 16:50:26 -07:00
2022-03-24 19:08:24 -06:00
import com.diffplug.common.base.Errors ;
2022-01-29 14:39:46 -07:00
import com.pathplanner.lib.PathPlanner ;
2022-02-04 19:02:41 -07:00
import com.pathplanner.lib.PathPlannerTrajectory ;
2022-02-07 19:49:27 -07:00
import com.pathplanner.lib.PathPlannerTrajectory.PathPlannerState ;
2022-02-04 19:02:41 -07:00
import com.pathplanner.lib.commands.PPSwerveControllerCommand ;
2022-01-29 14:39:46 -07:00
import edu.wpi.first.math.controller.PIDController ;
import edu.wpi.first.math.controller.ProfiledPIDController ;
2022-01-22 15:55:04 -07:00
import edu.wpi.first.math.geometry.Pose2d ;
2022-01-29 14:39:46 -07:00
import edu.wpi.first.math.geometry.Rotation2d ;
2022-03-24 19:08:24 -06:00
import edu.wpi.first.util.sendable.Sendable ;
import edu.wpi.first.util.sendable.SendableBuilder ;
import edu.wpi.first.wpilibj.Filesystem ;
2022-02-11 18:53:13 -07:00
import edu.wpi.first.wpilibj.GenericHID ;
2022-01-29 01:16:58 -07:00
import edu.wpi.first.wpilibj.XboxController ;
2022-03-24 19:08:24 -06:00
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts ;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard ;
2022-03-24 13:59:59 -06:00
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser ;
2022-02-16 22:31:00 -07:00
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard ;
2021-11-15 16:26:16 -07:00
import edu.wpi.first.wpilibj2.command.Command ;
2022-04-07 15:13:24 -06:00
import edu.wpi.first.wpilibj2.command.CommandBase ;
2022-02-03 20:53:43 -07:00
import edu.wpi.first.wpilibj2.command.InstantCommand ;
2022-03-22 22:10:46 -06:00
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup ;
2022-04-04 17:22:52 -06:00
import edu.wpi.first.wpilibj2.command.ParallelDeadlineGroup ;
import edu.wpi.first.wpilibj2.command.ParallelRaceGroup ;
2021-11-15 16:26:16 -07:00
import edu.wpi.first.wpilibj2.command.RunCommand ;
2022-02-03 20:53:43 -07:00
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup ;
2021-11-15 16:26:16 -07:00
import edu.wpi.first.wpilibj2.command.button.JoystickButton ;
2022-02-11 18:53:13 -07:00
import frc4388.robot.Constants.OIConstants ;
2022-03-05 22:57:55 -07:00
import frc4388.robot.Constants.StorageConstants ;
2022-02-11 18:59:00 -07:00
import frc4388.robot.Constants.SwerveDriveConstants ;
2022-03-08 16:31:42 -07:00
import frc4388.robot.commands.PathRecorder ;
2022-03-22 22:10:46 -06:00
import frc4388.robot.commands.RunCommandForTime ;
2022-03-25 08:32:58 -06:00
import frc4388.robot.commands.ShooterTuner ;
2022-03-21 22:49:54 -06:00
import frc4388.robot.commands.DriveCommands.DriveWithInputForTime ;
2022-03-14 20:10:12 -06:00
import frc4388.robot.commands.ExtenderIntakeCommands.ExtenderIntakeGroup ;
import frc4388.robot.commands.ShooterCommands.TrackTarget ;
2022-01-20 18:08:05 -07:00
import frc4388.robot.subsystems.BoomBoom ;
2022-03-25 09:15:02 -06:00
import frc4388.robot.subsystems.Camera ;
2022-03-22 17:41:02 -06:00
import frc4388.robot.subsystems.Claws ;
2022-03-10 16:47:32 -07:00
import frc4388.robot.subsystems.Climber ;
2022-03-12 15:05:32 -07:00
import frc4388.robot.subsystems.Extender ;
2022-01-20 18:08:05 -07:00
import frc4388.robot.subsystems.Hood ;
2022-03-05 15:32:48 -07:00
import frc4388.robot.subsystems.Intake ;
2022-01-15 14:20:49 -07:00
import frc4388.robot.subsystems.Serializer ;
2022-02-26 15:41:54 -07:00
import frc4388.robot.subsystems.Storage ;
2021-12-02 17:51:06 -07:00
import frc4388.robot.subsystems.SwerveDrive ;
2022-01-20 18:08:05 -07:00
import frc4388.robot.subsystems.Turret ;
2022-03-05 11:29:40 -07:00
import frc4388.robot.subsystems.VisionOdometry ;
2022-03-24 00:30:25 -06:00
import frc4388.utility.Vector2D ;
2022-03-12 17:33:38 -07:00
import frc4388.utility.controller.ButtonBox ;
2022-03-22 19:48:40 -06:00
import frc4388.utility.controller.DeadbandedXboxController ;
2021-11-15 16:26:16 -07:00
/**
* 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 {
2022-02-25 01:33:32 -07:00
private static final Logger LOGGER = Logger . getLogger ( RobotContainer . class . getSimpleName ( ) ) ;
2022-03-14 20:10:12 -06:00
// RobotMap
2022-03-07 15:26:05 -07:00
public final RobotMap m_robotMap = new RobotMap ( ) ;
2022-01-11 11:05:52 -07:00
2022-03-11 23:25:05 -07:00
/* Subsystems */
2022-03-25 09:15:02 -06:00
public final Camera m_robotCamera = new Camera ( " driver " , 0 , 160 , 120 , 40 ) ;
2022-03-20 18:09:16 -06:00
public final Climber m_robotClimber = new Climber ( m_robotMap . elbow ) ;
2022-03-18 14:13:37 -06:00
public final Claws m_robotClaws = new Claws ( m_robotMap . leftClaw , m_robotMap . rightClaw ) ;
2022-03-05 15:32:48 -07:00
public final SwerveDrive m_robotSwerveDrive = new SwerveDrive ( m_robotMap . leftFront , m_robotMap . leftBack , m_robotMap . rightFront , m_robotMap . rightBack , m_robotMap . gyro ) ;
2022-03-07 15:26:05 -07:00
public final Serializer m_robotSerializer = new Serializer ( m_robotMap . serializerBelt , /*m_robotMap.serializerShooterBelt,*/ m_robotMap . serializerBeam ) ;
2022-03-14 20:10:12 -06:00
public final Intake m_robotIntake = new Intake ( m_robotMap . intakeMotor ) ;
2022-03-12 15:05:32 -07:00
public final Extender m_robotExtender = new Extender ( m_robotMap . extenderMotor ) ;
2022-03-05 22:57:55 -07:00
2022-03-07 15:26:05 -07:00
public final Storage m_robotStorage = new Storage ( m_robotMap . storageMotor ) ;
2022-03-25 09:15:02 -06:00
// private final LED m_robotLED = new LED(m_robotMap.LEDController); // ! no LED makes aarav sad
2022-03-07 15:26:05 -07:00
public final BoomBoom m_robotBoomBoom = new BoomBoom ( m_robotMap . shooterFalconLeft , m_robotMap . shooterFalconRight ) ;
public final Hood m_robotHood = new Hood ( m_robotMap . angleAdjusterMotor ) ;
public final Turret m_robotTurret = new Turret ( m_robotMap . shooterTurret ) ;
2022-03-13 19:59:55 -06:00
public final VisionOdometry m_robotVisionOdometry = new VisionOdometry ( m_robotSwerveDrive , m_robotTurret ) ;
2022-01-11 11:05:52 -07:00
2022-03-01 20:23:01 -07:00
/* Autonomous */
2022-03-08 16:31:42 -07:00
private final PathRecorder m_pathChooser = new PathRecorder ( m_robotSwerveDrive ) ;
2022-03-25 08:32:58 -06:00
private final ShooterTuner m_shooterTuner = new ShooterTuner ( m_robotBoomBoom ) ;
2022-03-14 20:10:12 -06:00
// Controllers
2022-04-04 13:37:20 -06:00
private final static DeadbandedXboxController m_driverXbox = new DeadbandedXboxController ( OIConstants . XBOX_DRIVER_ID ) ;
private final static DeadbandedXboxController m_operatorXbox = new DeadbandedXboxController ( OIConstants . XBOX_OPERATOR_ID ) ;
2022-03-12 19:02:37 -07:00
private final ButtonBox m_buttonBox = new ButtonBox ( OIConstants . BUTTON_BOX_ID ) ;
2022-03-12 17:43:17 -07:00
2022-03-12 22:19:42 -07:00
public static boolean softLimits = true ;
2022-03-18 17:18:39 -06:00
2022-03-18 17:39:06 -06:00
// control mode switching
2022-03-18 18:29:53 -06:00
public static enum ControlMode { SHOOTER , CLIMBER } ;
public static ControlMode currentControlMode = ControlMode . SHOOTER ;
2022-03-18 17:18:39 -06:00
2022-03-18 17:39:06 -06:00
// turret mode switching
private enum TurretMode { MANUAL , AUTONOMOUS } ;
private TurretMode currentTurretMode = TurretMode . MANUAL ;
// climber mode switching
2022-03-18 17:18:39 -06:00
private enum ClimberMode { MANUAL , AUTONOMOUS } ;
private ClimberMode currentClimberMode = ClimberMode . MANUAL ;
2022-02-16 22:31:00 -07:00
2022-03-25 10:29:17 -06:00
// drive on off mode switching
private enum DriveMode { ON , OFF } ;
private DriveMode currentDriveMode = DriveMode . ON ;
2022-04-07 15:13:24 -06:00
// private SendableChooser<SequentialCommandGroup> quickAutoChooser = new SendableChooser<>();
public SendableChooser < Command > autoChooser = new SendableChooser < Command > ( ) ;
2022-03-24 13:59:59 -06:00
2022-03-24 08:49:37 -06:00
/**
* SmartDash
* - Limelight cam X
* - Limit switches X
* - Shooter RPM X
* - Distance to target x
* - target locked
* - claws boolean
* - field
*/
2022-03-24 15:41:08 -06:00
// private SequentialCommandGroup makeTheWeirdGroup() {
// SequentialCommandGroup weirdAutoShootingGroup = new SequentialCommandGroup(new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry, true),
// new ParallelCommandGroup(
// new TrackTarget(m_robotTurret, m_robotBoomBoom, m_robotHood, m_robotVisionOdometry, true),
// new RunCommandForTime(new RunCommand(() -> m_robotStorage.runStorage(StorageConstants.STORAGE_SPEED), m_robotStorage), 2.0)
// )); // * weird way of shooting, i think we should make a new TrackTarget with built-in Storage control instead.
// return weirdAutoShootingGroup;
// }
2022-01-11 11:05:52 -07:00
/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer ( ) {
2022-04-07 15:13:24 -06:00
autoChooser . addOption ( " DriveOffLineAndShoot " , driveOffLineAndShoot ) ;
autoChooser . addOption ( " OneBallAuto " , oneBallAuto ) ;
autoChooser . setDefaultOption ( " TwoBallAuto " , twoBallAuto ) ;
autoChooser . addOption ( " ThreeBallAuto " , threeBallAuto ) ;
2022-03-24 13:59:59 -06:00
2022-04-07 15:13:24 -06:00
SmartDashboard . putData ( " AutoChooser " , autoChooser ) ;
2022-03-24 13:59:59 -06:00
2022-01-11 11:05:52 -07:00
configureButtonBindings ( ) ;
/* Default Commands */
2022-04-04 13:37:20 -06:00
// Swerve Drive with Input
m_robotSwerveDrive . setDefaultCommand (
2022-03-25 16:14:39 -06:00
new RunCommand ( ( ) - > {
2022-04-04 13:37:20 -06:00
if ( currentDriveMode = = DriveMode . ON ) {
m_robotSwerveDrive . driveWithInput ( getDriverController ( ) . getLeft ( ) ,
getDriverController ( ) . getRight ( ) , true ) ;
}
if ( currentDriveMode = = DriveMode . OFF ) {
m_robotSwerveDrive . driveWithInput ( 0 , 0 , 0 , 0 , false ) ;
}
} , m_robotSwerveDrive ) . withName ( " Swerve driveWithInput defaultCommand " ) ) ;
// Intake with Triggers
2022-03-05 22:57:55 -07:00
m_robotIntake . setDefaultCommand (
new RunCommand ( ( ) - > m_robotIntake . runWithTriggers (
2022-03-07 15:26:05 -07:00
getOperatorController ( ) . getLeftTriggerAxis ( ) ,
getOperatorController ( ) . getRightTriggerAxis ( ) ) ,
2022-03-05 22:57:55 -07:00
m_robotIntake ) . withName ( " Intake runWithTriggers defaultCommand " ) ) ;
2022-03-20 00:16:49 -06:00
m_robotBoomBoom . setDefaultCommand ( new RunCommand ( ( ) - > m_robotBoomBoom . runDrumShooter ( 0 . 0 ) , m_robotBoomBoom ) ) ;
2022-03-18 17:18:39 -06:00
2022-03-20 20:18:02 -06:00
// Serializer Manual
2022-03-08 16:14:34 -07:00
m_robotSerializer . setDefaultCommand (
2022-03-18 15:09:08 -06:00
new RunCommand ( ( ) - > m_robotSerializer . setSerializer ( getOperatorController ( ) . getLeftTriggerAxis ( ) * 0 . 8 ) , //m_robotSerializer.setSerializerStateWithBeam(),
2022-03-08 16:14:34 -07:00
m_robotSerializer ) . withName ( " Serializer setSerializerStateWithBeam defaultCommand " ) ) ;
2022-03-20 00:16:49 -06:00
2022-03-20 20:18:02 -06:00
// Turret Manual
2022-03-20 00:16:49 -06:00
m_robotTurret . setDefaultCommand (
new RunCommand ( ( ) - > {
2022-03-20 12:09:41 -06:00
if ( RobotContainer . currentControlMode . equals ( ControlMode . SHOOTER ) ) { m_robotTurret . runTurretWithInput ( getOperatorController ( ) . getLeftX ( ) ) ; }
if ( RobotContainer . currentControlMode . equals ( ControlMode . CLIMBER ) ) { m_robotTurret . runTurretWithInput ( 0 ) ; }
2022-03-20 00:16:49 -06:00
} , m_robotTurret ) ) ;
2022-03-18 23:56:01 -06:00
2022-03-20 20:18:02 -06:00
// Hood Manual
2022-03-18 23:56:01 -06:00
m_robotHood . setDefaultCommand (
new RunCommand ( ( ) - > {
2022-03-25 16:14:39 -06:00
if ( RobotContainer . currentControlMode . equals ( ControlMode . SHOOTER ) ) { m_robotHood . runHood ( getOperatorController ( ) . getLeftY ( ) ) ; }
2022-03-20 12:09:41 -06:00
if ( RobotContainer . currentControlMode . equals ( ControlMode . CLIMBER ) ) { m_robotHood . runHood ( 0 ) ; }
2022-03-18 23:56:01 -06:00
} , m_robotHood ) ) ;
2022-03-25 08:34:25 -06:00
// //Climber Manual
2022-03-20 00:16:49 -06:00
m_robotClimber . setDefaultCommand (
2022-03-20 20:18:02 -06:00
new RunCommand ( ( ) - > {
if ( RobotContainer . currentControlMode . equals ( ControlMode . SHOOTER ) ) { m_robotClimber . setMotors ( 0 . 0 ) ; }
2022-03-24 13:30:36 -06:00
if ( RobotContainer . currentControlMode . equals ( ControlMode . CLIMBER ) ) { m_robotClimber . setMotors ( - getOperatorController ( ) . getRightY ( ) ) ; }
2022-03-20 20:18:02 -06:00
} , m_robotClimber ) ) ;
2022-03-25 08:34:25 -06:00
// m_robotClimber.setDefaultCommand(
// new RunCommand(() -> m_robotClimber.setMotors(-getOperatorController().getRightY()), m_robotClimber));
2022-03-21 20:00:34 -06:00
m_robotBoomBoom . setDefaultCommand (
2022-03-22 17:07:06 -06:00
new RunCommand ( ( ) - > m_robotBoomBoom . runDrumShooter ( 0 . 45 ) , m_robotBoomBoom )
2022-03-21 20:00:34 -06:00
) ;
2022-03-22 17:41:02 -06:00
2022-03-25 08:32:58 -06:00
SmartDashboard . putData ( " Shooter Tuner " , m_shooterTuner ) ;
2022-01-11 11:05:52 -07:00
}
2022-01-15 11:31:15 -07:00
2022-01-11 11:05:52 -07:00
/**
* 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 ( ) {
2022-03-20 20:18:02 -06:00
//! Driver Buttons
2022-01-11 11:05:52 -07:00
2022-03-06 00:48:38 -07:00
// Start > Calibrate Odometry
2022-03-06 11:23:40 -07:00
new JoystickButton ( getDriverController ( ) , XboxController . Button . kBack . value )
2022-03-06 00:48:38 -07:00
. whenPressed ( ( ) - > resetOdometry ( new Pose2d ( 0 , 0 , new Rotation2d ( 0 ) ) ) ) ;
2022-03-20 20:18:02 -06:00
// Start > Calibrate Odometry
2022-03-06 11:23:40 -07:00
new JoystickButton ( getDriverController ( ) , XboxController . Button . kStart . value )
2022-03-20 20:18:02 -06:00
. whenPressed ( m_robotSwerveDrive : : resetGyro ) ;
2022-03-06 00:48:38 -07:00
// Left Bumper > Shift Down
2022-03-18 13:04:20 -06:00
new JoystickButton ( getDriverController ( ) , XboxController . Button . kLeftBumper . value )
. whenPressed ( ( ) - > m_robotSwerveDrive . highSpeed ( false ) ) ;
2022-03-20 20:18:02 -06:00
2022-03-18 13:04:20 -06:00
// Right Bumper > Shift Up
2022-03-18 23:11:30 -06:00
new JoystickButton ( getDriverController ( ) , XboxController . Button . kRightBumper . value )
. whenPressed ( ( ) - > m_robotSwerveDrive . highSpeed ( true ) ) ;
2022-03-25 16:26:14 -06:00
new JoystickButton ( getDriverController ( ) , XboxController . Button . kA . value )
2022-03-25 16:14:32 -06:00
. whenPressed ( new InstantCommand ( ( ) - > switchControlMode ( ) ) )
. whenReleased ( new InstantCommand ( ( ) - > switchControlMode ( ) ) ) ;
2022-03-20 18:09:16 -06:00
2022-03-25 16:26:14 -06:00
new JoystickButton ( getDriverController ( ) , XboxController . Button . kB . value )
2022-03-25 16:14:32 -06:00
. whenPressed ( new InstantCommand ( ( ) - > switchDriveMode ( ) ) )
. whenReleased ( new InstantCommand ( ( ) - > switchDriveMode ( ) ) ) ;
2022-03-20 16:22:11 -06:00
2022-03-20 20:18:02 -06:00
//! Operator Buttons
// Right Bumper > Storage Out
new JoystickButton ( getOperatorController ( ) , XboxController . Button . kRightBumper . value )
. whileHeld ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( - StorageConstants . STORAGE_SPEED ) ) )
. whenReleased ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( 0 . 0 ) ) ) ;
// Left Bumper > Storage In
new JoystickButton ( getOperatorController ( ) , XboxController . Button . kLeftBumper . value )
. whileHeld ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( StorageConstants . STORAGE_SPEED ) ) )
. whenReleased ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( 0 . 0 ) ) ) ;
// B > Toggle claws
2022-03-20 16:22:11 -06:00
new JoystickButton ( getOperatorController ( ) , XboxController . Button . kB . value )
2022-03-20 20:52:05 -06:00
. whenPressed ( new InstantCommand ( ( ) - > m_robotClaws . toggleClaws ( ) , m_robotClaws ) ) ;
2022-03-20 14:25:38 -06:00
2022-03-20 20:18:02 -06:00
// X > Toggles extender in and out
2022-03-21 20:00:34 -06:00
new JoystickButton ( getOperatorController ( ) , XboxController . Button . kX . value )
. whenPressed ( new ExtenderIntakeGroup ( m_robotIntake , m_robotExtender ) ) ;
2022-03-16 20:16:32 -06:00
2022-03-20 20:18:02 -06:00
// A > Spit Out Ball
new JoystickButton ( getOperatorController ( ) , XboxController . Button . kA . value )
2022-03-20 20:52:05 -06:00
. whileHeld ( new RunCommand ( ( ) - > m_robotTurret . gotoMidpoint ( ) , m_robotTurret ) )
2022-03-20 20:18:02 -06:00
. whileHeld ( new RunCommand ( ( ) - > m_robotBoomBoom . runDrumShooter ( 0 . 25 ) ) ) ;
// Y > Full aim command
2022-03-14 15:16:21 -06:00
// new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
2022-03-20 21:21:45 -06:00
// .whileHeld(new Seek(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood, m_robotVisionOdometry));
//! Test Buttons
2022-03-21 20:00:34 -06:00
// new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
// .whenPressed(new Shoot(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood, m_robotVisionOdometry, false, false));
2022-03-20 20:18:02 -06:00
2022-04-04 17:22:52 -06:00
// new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
// .whenPressed(new RunCommandForTime(new RunCommand(() -> m_robotTurret.runShooterRotatePID(-Math.atan2((219.25 / 2.00) - 10, (82.83 / 2.00) - 15.56)), m_robotTurret), 1.0));
2022-03-21 20:00:34 -06:00
new JoystickButton ( getOperatorController ( ) , XboxController . Button . kY . value )
2022-04-04 18:53:38 -06:00
. whileHeld ( new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry ) ) ; // * aim with turret to target);
2022-03-05 22:57:55 -07:00
2022-03-20 20:18:02 -06:00
// new JoystickButton(getOperatorController(), XboxController.Button.kY.value)
// .whileHeld(new RunCommand(() -> m_robotClaws.setOpen(true)));
2022-03-05 22:57:55 -07:00
2022-03-20 20:18:02 -06:00
// new JoystickButton(getOperatorController(), XboxController.Button.kB.value)
// .whileHeld(new RunCommand(() -> m_robotClaws.setOpen(false)));
2022-03-05 22:57:55 -07:00
2022-03-20 20:18:02 -06:00
// new JoystickButton(getOperatorController(), XboxController.Button.kA.value)
// .whenPressed(new Shoot(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood));
2022-03-13 17:57:36 -06:00
2022-03-20 20:18:02 -06:00
// new JoystickButton(getOperatorController(), XboxController.Button.kA.value)
// .whenPressed(new RunCommand(() -> m_robotBoomBoom.runDrumShooter(0.25)))
// .whenReleased(new RunCommand(() -> m_robotBoomBoom.runDrumShooter(0.0)));
2022-03-10 16:47:32 -07:00
2022-03-05 22:57:55 -07:00
2022-03-20 20:18:02 -06:00
//! Button Box Buttons
// Left Switch > Disables soft limits on press, release resets encoders (all for turret, hood, climber, and extender)
2022-03-25 16:14:32 -06:00
2022-03-26 10:47:22 -06:00
// SmartDashboard.putData("BB LEFT ON", new SequentialCommandGroup(
// new InstantCommand(() -> m_robotTurret.setTurretSoftLimits(false), m_robotTurret),
// new InstantCommand(() -> m_robotTurret.calibrationSpeed = 0.3, m_robotTurret),
2022-03-25 16:14:32 -06:00
2022-03-26 10:47:22 -06:00
// new InstantCommand(() -> m_robotHood.setHoodSoftLimits(false), m_robotHood),
// new InstantCommand(() -> m_robotHood.calibrationSpeed = 0.3, m_robotHood),
2022-03-25 16:14:32 -06:00
2022-03-26 10:47:22 -06:00
// new InstantCommand(() -> m_robotExtender.setExtenderSoftLimits(false), m_robotExtender)
// ));
2022-03-25 16:14:32 -06:00
2022-03-26 10:47:22 -06:00
// SmartDashboard.putData("BB LEFT OFF", new SequentialCommandGroup(
// new InstantCommand(() -> m_robotTurret.setTurretSoftLimits(true), m_robotTurret),
// new InstantCommand(() -> m_robotTurret.calibrationSpeed = 1.0, m_robotTurret),
2022-03-25 16:14:32 -06:00
2022-03-26 10:47:22 -06:00
// new InstantCommand(() -> m_robotHood.setHoodSoftLimits(true), m_robotHood),
// new InstantCommand(() -> m_robotHood.calibrationSpeed = 1.0, m_robotHood),
2022-03-25 16:14:32 -06:00
2022-03-26 10:47:22 -06:00
// new InstantCommand(() -> m_robotExtender.setExtenderSoftLimits(true), m_robotExtender),
2022-03-25 16:14:32 -06:00
2022-03-26 10:47:22 -06:00
// new InstantCommand(() -> m_robotTurret.m_boomBoomRotateEncoder.setPosition(0), m_robotTurret),
// new InstantCommand(() -> m_robotHood.m_angleEncoder.setPosition(0), m_robotHood),
// new InstantCommand(() -> m_robotExtender.setEncoder(0), m_robotExtender),
// new InstantCommand(() -> ExtenderIntakeGroup.setDirectionToOut(), m_robotIntake, m_robotExtender),
// new InstantCommand(() -> m_robotClimber.setEncoders(0), m_robotClimber)
// ));
2022-03-25 16:14:32 -06:00
2022-03-25 16:27:29 -06:00
// new JoystickButton(getButtonBox(), ButtonBox.Button.kLeftSwitch.value)
// .whenPressed(new InstantCommand(() -> m_robotTurret.setTurretSoftLimits(false), m_robotTurret))
// .whenPressed(new InstantCommand(() -> m_robotTurret.calibrationSpeed = 0.3, m_robotTurret))
2022-03-19 21:03:01 -06:00
2022-03-25 16:27:29 -06:00
// .whenPressed(new InstantCommand(() -> m_robotHood.setHoodSoftLimits(false), m_robotHood))
// .whenPressed(new InstantCommand(() -> m_robotHood.calibrationSpeed = 0.3, m_robotHood))
2022-03-19 21:03:01 -06:00
2022-03-25 16:27:29 -06:00
// .whenPressed(new InstantCommand(() -> m_robotExtender.setExtenderSoftLimits(false), m_robotExtender))
2022-03-19 21:03:01 -06:00
2022-03-25 16:27:29 -06:00
// .whenReleased(new InstantCommand(() -> m_robotTurret.setTurretSoftLimits(true), m_robotTurret))
// .whenReleased(new InstantCommand(() -> m_robotTurret.calibrationSpeed = 1.0, m_robotTurret))
2022-03-19 21:03:01 -06:00
2022-03-25 16:27:29 -06:00
// .whenReleased(new InstantCommand(() -> m_robotHood.setHoodSoftLimits(true), m_robotHood))
// .whenReleased(new InstantCommand(() -> m_robotHood.calibrationSpeed = 1.0, m_robotHood))
2022-03-19 21:03:01 -06:00
2022-03-25 16:27:29 -06:00
// .whenReleased(new InstantCommand(() -> m_robotExtender.setExtenderSoftLimits(true), m_robotExtender))
2022-03-06 00:24:51 -07:00
2022-03-25 16:27:29 -06:00
// .whenReleased(new InstantCommand(() -> m_robotTurret.m_boomBoomRotateEncoder.setPosition(0), m_robotTurret))
// .whenReleased(new InstantCommand(() -> m_robotHood.m_angleEncoder.setPosition(0), m_robotHood))
// .whenReleased(new InstantCommand(() -> m_robotExtender.setEncoder(0), m_robotExtender))
// .whenReleased(new InstantCommand(() -> ExtenderIntakeGroup.setDirectionToOut(), m_robotIntake, m_robotExtender))
// .whenReleased(new InstantCommand(() -> m_robotClimber.setEncoders(0), m_robotClimber));
2022-03-12 17:33:38 -07:00
2022-03-20 20:18:02 -06:00
// Middle Switch > Climber and Shooter mode switching
2022-03-25 16:27:29 -06:00
// new JoystickButton(getButtonBox(), ButtonBox.Button.kMiddleSwitch.value)
// .whenPressed(new InstantCommand(() -> currentControlMode = ControlMode.CLIMBER))
// .whenReleased(new InstantCommand(() -> currentControlMode = ControlMode.SHOOTER));
// // new JoystickButton(getButtonBox(), ButtonBox.Button.kRightSwitch.value)
// // .whenPressed(new InstantCommand(() -> currentControlMode = ControlMode.))
// // .whenReleased(new InstantCommand(() -> currentControlMode = ControlMode.SHOOTER));
2022-03-24 19:32:22 -06:00
2022-03-25 16:27:29 -06:00
// new JoystickButton(getButtonBox(), ButtonBox.Button.kRightSwitch.value)
// .whileHeld(new InstantCommand(() -> currentDriveMode = DriveMode.OFF))
// .whenReleased(new InstantCommand(() -> currentDriveMode = DriveMode.ON));
2022-03-18 15:09:08 -06:00
2022-03-26 10:47:22 -06:00
// // Left Button > Extender In
new JoystickButton ( getDriverController ( ) , XboxController . Button . kX . value )
2022-03-24 10:38:13 -06:00
. whileHeld ( new RunCommand ( ( ) - > m_robotExtender . runExtender ( 1 . 0 ) , m_robotExtender ) )
2022-03-20 20:18:02 -06:00
. whenReleased ( new RunCommand ( ( ) - > m_robotExtender . runExtender ( 0 . 0 ) , m_robotExtender ) ) ;
2022-03-12 17:33:38 -07:00
2022-03-26 10:47:22 -06:00
// Left Button > Extender Out
new JoystickButton ( getDriverController ( ) , XboxController . Button . kY . value )
2022-03-24 10:38:13 -06:00
. whileHeld ( new RunCommand ( ( ) - > m_robotExtender . runExtender ( - 1 . 0 ) , m_robotExtender ) )
2022-03-20 20:18:02 -06:00
. whenReleased ( new RunCommand ( ( ) - > m_robotExtender . runExtender ( 0 . 0 ) , m_robotExtender ) ) ;
2022-03-12 17:33:38 -07:00
}
2022-01-11 11:05:52 -07:00
2022-03-20 19:31:42 -06:00
/**
* Generate autonomous
* @param maxVel max velocity for the path (null to override default value of 5.0)
* @param maxAccel max acceleration for the path (null to override default value of 5.0)
* @param inputs strings (paths) or commands you want to run (in order)
* @return array of commands
*/
2022-04-04 17:22:52 -06:00
public SequentialCommandGroup buildAuto ( Double maxVel , Double maxAccel , Object . . . inputs ) {
2022-03-20 19:31:42 -06:00
maxVel = Objects . requireNonNullElse ( maxVel , SwerveDriveConstants . PATH_MAX_VELOCITY ) ;
maxAccel = Objects . requireNonNullElse ( maxAccel , SwerveDriveConstants . PATH_MAX_ACCELERATION ) ;
ArrayList < Command > commands = new ArrayList < Command > ( ) ;
2022-04-04 17:22:52 -06:00
// commands.add(new InstantCommand(() -> m_robotSwerveDrive.resetGyro(), m_robotSwerveDrive));
// commands.add(new InstantCommand(() -> m_robotSwerveDrive.m, m_robotSwerveDrive));
2022-03-20 19:31:42 -06:00
PIDController xController = SwerveDriveConstants . X_CONTROLLER ;
PIDController yController = SwerveDriveConstants . Y_CONTROLLER ;
ProfiledPIDController thetaController = SwerveDriveConstants . THETA_CONTROLLER ;
thetaController . enableContinuousInput ( - Math . PI , Math . PI ) ;
// parse input
for ( int i = 0 ; i < inputs . length ; i + + ) {
if ( inputs [ i ] instanceof String ) {
PathPlannerTrajectory traj = PathPlanner . loadPath ( inputs [ i ] . toString ( ) , maxVel , maxAccel ) ;
2022-03-21 22:49:54 -06:00
PathPlannerState initState = traj . getInitialState ( ) ;
Pose2d initPose = new Pose2d ( initState . poseMeters . getTranslation ( ) , initState . holonomicRotation ) ;
commands . add ( new InstantCommand ( ( ) - > m_robotSwerveDrive . resetOdometry ( initPose ) , m_robotSwerveDrive ) ) ;
2022-03-20 19:31:42 -06:00
commands . add ( new PPSwerveControllerCommand (
traj ,
m_robotSwerveDrive : : getOdometry ,
m_robotSwerveDrive . m_kinematics ,
xController ,
yController ,
thetaController ,
m_robotSwerveDrive : : setModuleStates ,
m_robotSwerveDrive ) ) ;
}
2022-03-21 22:49:54 -06:00
2022-03-20 19:31:42 -06:00
if ( inputs [ i ] instanceof Command ) {
commands . add ( ( Command ) inputs [ i ] ) ;
}
}
2022-04-04 17:22:52 -06:00
commands . add ( new InstantCommand ( ( ) - > m_robotSwerveDrive . stopModules ( ) , m_robotSwerveDrive ) ) ;
2022-03-20 19:31:42 -06:00
Command [ ] ret = new Command [ commands . size ( ) ] ;
ret = commands . toArray ( ret ) ;
2022-04-04 17:22:52 -06:00
SequentialCommandGroup seqCG = new SequentialCommandGroup ( ret ) ;
return seqCG ;
2022-01-11 11:05:52 -07:00
}
2022-04-07 15:13:24 -06:00
// ! ways to not coast
// // * 1. try zero joystick input: new InstantCommand(() -> m_robotSwerveDrive.driveWithInput(0.0, 0.0, 0.0, 0.0, false), m_robotSwerveDrive);
// * 2. try opposite joystick input: new InstantCommand(() -> m_robotSwerveDrive.driveWithInput(0.0, -1.0, 0.0, 0.0, false), m_robotSwerveDrive);
// * 3a. try permanently setting drive motors to brake, not coast, in RobotMap.java, and ask the driver how it feels.
// * 3b. try to only set the drive motors to brake if in auto mode.
// * 4. try new InstantCommand(() -> m_robotSwerveDrive.stopModules(), m_robotSwerveDrive);
// ? 1.0 input, 1 second: 134 inches
// ? 0.75 input, 1 second: 48 inches
// ! POSITIVE Y IS LEFT, POSITIVE X IS BACKWARDS
2022-03-24 16:58:29 -06:00
2022-04-07 15:13:24 -06:00
double turretDistanceFromFront = 10 . 0 ; // * distance of turret from the front of the robot in inches. might need to be somewhat accurate.
double distancePerSecond = 134 . 0 ; // * assuming emulated joystick input magnitude is 1.0
double offset = 10 . 0 ; // * distance (in inches) from ball that we actually want to stop
// ! ball positions are "unit tested"
Vector2D firstBallPosition = new Vector2D ( 15 . 56 - ( 82 . 83 / 2 . 00 ) , 11 . 21 - 162 . 00 ) ; // * position of first ball, relative to hub.
Vector2D secondBallPosition = new Vector2D ( - ( 40 . 44 * ( Math . sqrt ( 2 . 00 ) / 2 . 00 ) ) - ( ( 82 . 83 - 7 . 58 ) * ( Math . sqrt ( 2 . 00 ) / 2 . 00 ) ) - ( 82 . 83 / 2 . 00 ) , - ( 40 . 44 * ( Math . sqrt ( 2 . 00 ) / 2 . 00 ) ) + ( ( 82 . 83 - 7 . 58 ) * ( Math . sqrt ( 2 . 00 ) / 2 . 00 ) ) - ( 219 . 25 / 2 . 00 ) ) ; // * position of second ball, relative to hub.
Vector2D firstToSecond = Vector2D . subtract ( secondBallPosition , firstBallPosition ) ; // * vector from first ball to second ball, used to calculate emulated joystick inputs.
private SequentialCommandGroup shoot ( double storageRunTime ) {
return new SequentialCommandGroup (
new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
new ParallelCommandGroup (
new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( StorageConstants . STORAGE_SPEED ) , m_robotStorage ) , storageRunTime , true )
)
) ;
}
2022-03-24 16:58:29 -06:00
2022-04-07 15:13:24 -06:00
SequentialCommandGroup weirdAutoShootingGroup1 = new SequentialCommandGroup ( new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
2022-03-24 17:51:18 -06:00
new ParallelCommandGroup (
new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
2022-04-04 18:53:38 -06:00
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( StorageConstants . STORAGE_SPEED ) , m_robotStorage ) , 1 . 0 , true )
2022-04-04 17:22:52 -06:00
) ) ; // * weird way of shooting, i think we should make a new TrackTarget with built-in Storage control instead.
2022-04-07 15:13:24 -06:00
SequentialCommandGroup weirdAutoShootingGroup2 = new SequentialCommandGroup ( new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
new ParallelCommandGroup (
new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( StorageConstants . STORAGE_SPEED ) , m_robotStorage ) , 2 . 3 , true )
) ) ; // * weird way of shooting, i think we should make a new TrackTarget with built-in Storage control instead.
SequentialCommandGroup weirdAutoShootingGroup3 = new SequentialCommandGroup ( new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
new ParallelCommandGroup (
new TrackTarget ( m_robotTurret , m_robotBoomBoom , m_robotHood , m_robotVisionOdometry , true ) ,
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( StorageConstants . STORAGE_SPEED ) , m_robotStorage ) , 4 . 0 , true )
) ) ; // * weird way of shooting, i think we should make a new TrackTarget with built-in Storage control instead.
Command resetGyro = new InstantCommand ( ( ) - > m_robotSwerveDrive . resetGyro ( ) , m_robotSwerveDrive ) ;
Command brakeDrive = new InstantCommand ( ( ) - > m_robotSwerveDrive . stopModules ( ) , m_robotSwerveDrive ) ;
private Command brakeStorage ( double storageRunTime ) {
return new RunCommandForTime ( new RunCommand ( ( ) - > m_robotStorage . runStorage ( 0 . 0 ) , m_robotIntake ) , storageRunTime , true ) ;
}
SequentialCommandGroup extendThenAimTurret ( ) {
return new SequentialCommandGroup (
new ExtenderIntakeGroup ( m_robotIntake , m_robotExtender ) ,
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotTurret . runShooterRotatePID ( ( 180 . 0 / Math . PI ) * Math . atan2 ( - ( 82 . 83 / 2 . 00 ) + 15 . 56 , - ( 219 . 25 / 2 . 00 ) - 40 . 44 + 10 . 00 ) ) , m_robotTurret ) , 1 . 0 , true ) // TODO: optimize time
) ;
}
2022-03-24 19:47:12 -06:00
2022-04-07 15:13:24 -06:00
ParallelDeadlineGroup idleDrumUntilShootingFirstBall ( ) {
return new ParallelDeadlineGroup (
extendThenAimTurret ( ) ,
new RunCommand ( ( ) - > m_robotBoomBoom . runDrumShooterVelocityPID ( 8000 ) , m_robotBoomBoom )
) ;
}
private ParallelDeadlineGroup intakeWithPath1 ( double intakeRunTime ) {
return new ParallelDeadlineGroup (
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotIntake . runAtOutput ( - 1 . 0 ) , m_robotIntake ) , intakeRunTime , true ) , // TODO: optimize time
new RunCommand ( ( ) - > m_robotSerializer . setSerializer ( 0 . 8 ) , m_robotSerializer ) ,
buildAuto ( 3 . 0 , 3 . 0 , " JMove1 " ) // TODO: make faster?
) ;
}
private ParallelDeadlineGroup intakeWithPath2 ( double intakeRunTime ) {
return new ParallelDeadlineGroup (
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotIntake . runAtOutput ( - 1 . 0 ) , m_robotIntake ) , intakeRunTime , true ) , // TODO: optimize time
new RunCommand ( ( ) - > m_robotSerializer . setSerializer ( 0 . 8 ) , m_robotSerializer ) ,
buildAuto ( 3 . 0 , 3 . 0 , " JMove2 " ) // TODO: make faster?
) ;
}
2022-04-04 19:30:15 -06:00
2022-04-07 15:13:24 -06:00
ParallelCommandGroup intakeWithPathAndTrackTarget = new ParallelCommandGroup ( intakeWithPath1 ( 3 . 0 ) , weirdAutoShootingGroup2 ) ;
// ParallelCommandGroup intakeWithPath2AndTrackTarget = new ParallelCommandGroup(intakeWithPath2, weirdAutoShootingGroup3);
ParallelDeadlineGroup intakeWithPath2AndIdleShooterAndAimTurret = new ParallelDeadlineGroup (
intakeWithPath2 ( 4 . 2 ) ,
new RunCommand ( ( ) - > m_robotBoomBoom . runDrumShooterVelocityPID ( 8000 ) , m_robotBoomBoom ) ,
new RunCommandForTime ( new RunCommand ( ( ) - > m_robotTurret . runShooterRotatePID ( - 120 ) , m_robotTurret ) , 0 . 7 , true )
) ;
// ! DRIVE OFF LINE AND SHOOT (ASSUMES ROBOT IS FACING DIRECTLY TOWARDS THE TARGET)
SequentialCommandGroup driveOffLineAndShoot = new SequentialCommandGroup (
resetGyro ,
new DriveWithInputForTime ( m_robotSwerveDrive , new double [ ] { 1 . 0 , 0 . 0 , 0 . 0 , 0 . 0 } , ( 5 . 0 * 12 ) / distancePerSecond ) , // * go backwards five feet
brakeDrive ,
shoot ( 1 . 0 ) ,
brakeStorage ( 0 . 1 )
) ;
// ! ONE BALL AUTO (ASSUMES ROBOT IS FACING DIRECTLY TOWARDS THE TARGET)
SequentialCommandGroup oneBallAuto = new SequentialCommandGroup (
shoot ( 1 . 0 ) ,
brakeStorage ( 0 . 1 )
) ;
// ! TWO BALL AUTO (ASSUMES ROBOT IS FACING DIRECTLY TOWARDS THE FIRST BALL OUTSIDE THE TARMAC, BUMPERS FLUSH WITH THE EDGE)
SequentialCommandGroup twoBallAuto = new SequentialCommandGroup (
idleDrumUntilShootingFirstBall ( ) ,
shoot ( 1 . 0 ) , // TODO: optimize time
brakeStorage ( 0 . 1 ) ,
intakeWithPath1 ( 3 . 0 ) , // * this line and the one underneath it can be replaced with intakeWithPathAndTrackTarget
shoot ( 2 . 3 ) , // TODO: optimize time
brakeStorage ( 0 . 1 )
) ;
// ! THREE BALL AUTO (ASSUMES ROBOT IS FACING DIRECTLY TOWARDS THE FIRST BALL OUTSIDE THE TARMAC, BUMPERS FLUSH WITH THE EDGE)
SequentialCommandGroup threeBallAuto = new SequentialCommandGroup (
idleDrumUntilShootingFirstBall ( ) ,
shoot ( 1 . 0 ) , // TODO: optimize time
brakeStorage ( 0 . 1 ) ,
intakeWithPath1 ( 3 . 0 ) , // * this line and the one underneath it can be replaced with intakeWithPathAndTrackTarget
shoot ( 2 . 3 ) , // TODO: optimize time
brakeStorage ( 0 . 1 ) ,
intakeWithPath2AndIdleShooterAndAimTurret ,
shoot ( 4 . 0 ) , // TODO: optimize time
brakeStorage ( 0 . 1 )
) ;
2022-04-04 19:30:15 -06:00
2022-04-07 15:13:24 -06:00
/**
* Use this to pass the autonomous command to the main {@link Robot} class.
*
* @return the command to run in autonomous
*/
public Command getAutonomousCommand ( ) {
return autoChooser . getSelected ( ) ;
2022-04-04 17:22:52 -06:00
// return new SequentialCommandGroup(buildAuto(1.0, 1.0, "Move Forward"));
2022-04-07 15:13:24 -06:00
// return new SequentialCommandGroup(idleDrumUntilShootingFirstBall,
// //new RunCommandForTime(new RunCommand(() -> m_robotTurret.runShooterRotatePID((180.0 / Math.PI) * Math.atan2(-(82.83 / 2.00) + 15.56, -(219.25 / 2.00) - 40.44 + 10.00)), m_robotTurret), 1.0, true),
// // extendWhileTurretIsAiming,//new RunCommandForTime(new RunCommand(() -> m_robotTurret.runShooterRotatePID((180.0 / Math.PI) * Math.atan2(-(82.83 / 2.00) + 15.56, -(219.25 / 2.00) - 40.44 + 10.00)), m_robotTurret), 1.0, true), // * aim with turret to target
// weirdAutoShootingGroup, // * shoot
// // extendWhileTurretIsAiming,
// new RunCommandForTime(new RunCommand(() -> m_robotStorage.runStorage(0.0), m_robotStorage), 0.1, true),
// // new ExtenderIntakeGroup(m_robotIntake, m_robotExtender),
// intakeWithPathAndTrackTarget, // TODO: dont TrackTarget while driving. instead intakeWithPath, then weirdAutoShootingGroup2
// // intakeWithPath,
// // weirdAutoShootingGroup2,
// // new RunCommandForTime(new RunCommand(() -> m_robotTurret.runShooterRotatePID((180.0 / Math.PI) * Math.atan2(-(82.83 / 2.00) + 15.56, -(219.25 / 2.00) - 40.44 + 10.00)), m_robotTurret), 1.0, true)); // * aim with turret to target); // * shoot
// new RunCommandForTime(new RunCommand(() -> m_robotStorage.runStorage(0.0), m_robotStorage), 0.1, true),
// // intakeWithPath2,
// // new RunCommandForTime(new RunCommand(() -> m_robotTurret.runShooterRotatePID(-120), m_robotTurret), 1.0, true),
// // new RunCommandForTime(new RunCommand(() -> m_robotTurret.runShooterRotatePID(-120), m_robotTurret), 0.7, true),
// // intakeWithPath2AndTrackTarget,
// intakeWithPath2AndIdleShooterAndAimTurret,
// weirdAutoShootingGroup3,
// new RunCommandForTime(new RunCommand(() -> m_robotStorage.runStorage(0.0), m_robotStorage), 0.1, true));
2022-01-11 11:05:52 -07:00
}
2022-03-25 16:14:32 -06:00
public void switchControlMode ( ) {
if ( currentControlMode = = ControlMode . SHOOTER ) {
currentControlMode = ControlMode . CLIMBER ;
} else {
currentControlMode = ControlMode . SHOOTER ;
}
}
public void switchDriveMode ( ) {
if ( currentDriveMode = = DriveMode . ON ) {
currentDriveMode = DriveMode . OFF ;
} else {
currentDriveMode = DriveMode . ON ;
}
}
2022-04-04 13:37:20 -06:00
public static DeadbandedXboxController getDriverController ( ) {
2022-01-11 11:05:52 -07:00
return m_driverXbox ;
}
2022-04-04 13:37:20 -06:00
public static DeadbandedXboxController getOperatorController ( ) {
2022-03-21 12:29:03 -06:00
return m_operatorXbox ;
}
2022-03-12 19:02:37 -07:00
public ButtonBox getButtonBox ( ) {
return m_buttonBox ;
2022-03-12 17:33:38 -07:00
}
2022-03-12 22:19:42 -07:00
public static void setSoftLimits ( boolean set ) {
softLimits = set ;
}
2022-01-11 11:05:52 -07:00
/**
2022-02-17 19:52:05 -07:00
* Get odometry.
2022-03-05 11:12:33 -07:00
*
2022-02-17 19:52:05 -07:00
* @return Odometry
2022-01-11 11:05:52 -07:00
*/
2022-01-22 15:55:04 -07:00
public Pose2d getOdometry ( ) {
return m_robotSwerveDrive . getOdometry ( ) ;
}
2022-01-24 17:00:06 -07:00
2022-01-11 11:05:52 -07:00
/**
2022-02-17 19:52:05 -07:00
* Set odometry to given pose.
2022-03-05 11:12:33 -07:00
*
2022-02-17 19:52:05 -07:00
* @param pose Pose to set odometry to.
2022-01-11 11:05:52 -07:00
*/
2022-02-05 11:50:49 -07:00
public void resetOdometry ( Pose2d pose ) {
2022-01-29 14:39:46 -07:00
m_robotSwerveDrive . resetOdometry ( pose ) ;
2022-01-24 17:00:06 -07:00
}
2021-11-15 16:26:16 -07:00
}