mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 00:38:05 -06:00
manual and normal button box switching
This commit is contained in:
@@ -269,15 +269,7 @@ public class Robot extends TimedRobot {
|
||||
* This function is called periodically during operator control.
|
||||
*/
|
||||
@Override
|
||||
public void teleopPeriodic() {
|
||||
boolean robotManual = m_robotContainer.manual;
|
||||
|
||||
if (robotManual) {
|
||||
m_robotContainer.configureManualButtonBindings();
|
||||
} else {
|
||||
m_robotContainer.configureAutomaticButtonBindings();
|
||||
}
|
||||
}
|
||||
public void teleopPeriodic() {}
|
||||
|
||||
@Override
|
||||
public void testInit() {
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.stream.Collectors;
|
||||
import com.ctre.phoenix.motorcontrol.NeutralMode;
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX;
|
||||
import com.diffplug.common.base.Errors;
|
||||
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor;
|
||||
import com.pathplanner.lib.PathPlanner;
|
||||
import com.pathplanner.lib.PathPlannerTrajectory;
|
||||
import com.pathplanner.lib.PathPlannerTrajectory.PathPlannerState;
|
||||
@@ -51,6 +52,7 @@ import edu.wpi.first.wpilibj.Filesystem;
|
||||
import edu.wpi.first.wpilibj.GenericHID;
|
||||
import edu.wpi.first.wpilibj.RobotBase;
|
||||
import edu.wpi.first.wpilibj.XboxController;
|
||||
import edu.wpi.first.wpilibj.PS4Controller.Button;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import edu.wpi.first.wpilibj2.command.Command;
|
||||
import edu.wpi.first.wpilibj2.command.InstantCommand;
|
||||
@@ -63,6 +65,7 @@ import frc4388.robot.Constants.OIConstants;
|
||||
import frc4388.robot.Constants.StorageConstants;
|
||||
import frc4388.robot.Constants.SwerveDriveConstants;
|
||||
import frc4388.robot.commands.AimToCenter;
|
||||
import frc4388.robot.commands.RunMiddleSwitch;
|
||||
import frc4388.robot.commands.Shoot;
|
||||
import frc4388.robot.commands.TrackTarget;
|
||||
import frc4388.robot.subsystems.BoomBoom;
|
||||
@@ -226,11 +229,6 @@ public class RobotContainer {
|
||||
// .whenPressed(() -> m_robotMap.leftBack.reset())
|
||||
// .whenPressed(() -> m_robotMap.rightBack.reset());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* Operator Buttons */
|
||||
|
||||
// X > Extend Intake
|
||||
@@ -263,7 +261,7 @@ public class RobotContainer {
|
||||
// .whenReleased(new RunCommand(() -> m_robotBoomBoom.runDrumShooter(0.0)));
|
||||
|
||||
new JoystickButton(getOperatorController(), XboxController.Button.kLeftBumper.value)
|
||||
.whileHeld(new RunCommand(() -> m_robotStorage.runStorage(-0.9), m_robotStorage))
|
||||
.whenPressed(new RunCommand(() -> m_robotStorage.runStorage(-0.9), m_robotStorage))
|
||||
.whenReleased(new RunCommand(() -> m_robotStorage.runStorage(0.0), m_robotStorage));
|
||||
|
||||
new JoystickButton(getOperatorController(), XboxController.Button.kRightBumper.value)
|
||||
@@ -286,7 +284,6 @@ public class RobotContainer {
|
||||
// .whileHeld(new RunCommand(() -> m_robotStorage.runStorage(-StorageConstants.STORAGE_SPEED)))
|
||||
// .whenReleased(new RunCommand(() -> m_robotStorage.runStorage(0.0)));
|
||||
|
||||
|
||||
// A > Shoot with Odo
|
||||
/*new JoystickButton(getOperatorController(), XboxController.Button.kA.value)
|
||||
.whenPressed(new Shoot(m_robotSwerveDrive, m_robotBoomBoom, m_robotTurret, m_robotHood));*/
|
||||
@@ -297,11 +294,11 @@ public class RobotContainer {
|
||||
|
||||
/* Button Box Buttons */
|
||||
new JoystickButton(getButtonFox(), ButtonBox.Button.kLeftSwitch.value)
|
||||
.whenPressed(new RunCommand(() -> setManual(true)))
|
||||
.whenReleased(new RunCommand(() -> setManual(false)));
|
||||
.whileHeld(new RunCommand(() -> RunMiddleSwitch.setManual(true)))
|
||||
.whenReleased(new RunCommand(() -> RunMiddleSwitch.setManual(false)));
|
||||
|
||||
// new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value)
|
||||
// .whileHeld(new RunCommand(() -> System.out.println("MiddleSwitch")));
|
||||
new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value)
|
||||
.whileHeld(new RunMiddleSwitch());
|
||||
|
||||
new JoystickButton(getButtonFox(), ButtonBox.Button.kRightSwitch.value)
|
||||
.whileHeld(new RunCommand(() -> System.out.println("RightSwitch")));
|
||||
@@ -313,20 +310,6 @@ public class RobotContainer {
|
||||
.whileHeld(new RunCommand(() -> System.out.println("RightButton")));
|
||||
}
|
||||
|
||||
public void configureManualButtonBindings() {
|
||||
|
||||
new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value)
|
||||
.whileHeld(new RunCommand(() -> System.out.println("MANUAL")));
|
||||
|
||||
}
|
||||
|
||||
public void configureAutomaticButtonBindings() {
|
||||
|
||||
new JoystickButton(getButtonFox(), ButtonBox.Button.kMiddleSwitch.value)
|
||||
.whileHeld(new RunCommand(() -> System.out.println("AUTOMATIC")));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Use this to pass the autonomous command to the main {@link Robot} class.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// 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.
|
||||
|
||||
package frc4388.robot.commands;
|
||||
|
||||
import edu.wpi.first.wpilibj2.command.CommandBase;
|
||||
|
||||
public class RunMiddleSwitch extends CommandBase {
|
||||
|
||||
private static boolean manual = false;
|
||||
private boolean newManual = false;
|
||||
private boolean changes = false;
|
||||
|
||||
/** Creates a new RunMiddleSwitch. */
|
||||
public RunMiddleSwitch() {
|
||||
// Use addRequirements() here to declare subsystem dependencies.
|
||||
}
|
||||
|
||||
// Called when the command is initially scheduled.
|
||||
@Override
|
||||
public void initialize() {}
|
||||
|
||||
// Called every time the scheduler runs while the command is scheduled.
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
changes = (newManual == manual);
|
||||
|
||||
if (manual) {
|
||||
printManual();
|
||||
} else {
|
||||
printNormal();
|
||||
}
|
||||
|
||||
newManual = manual;
|
||||
}
|
||||
|
||||
public void printNormal(){
|
||||
System.out.println("Normal");
|
||||
}
|
||||
|
||||
public void printManual(){
|
||||
System.out.println("Manual");
|
||||
}
|
||||
|
||||
public static void setManual(boolean set)
|
||||
{
|
||||
manual = set;
|
||||
}
|
||||
|
||||
// Called once the command ends or is interrupted.
|
||||
@Override
|
||||
public void end(boolean interrupted) {}
|
||||
|
||||
// Returns true when the command should end.
|
||||
@Override
|
||||
public boolean isFinished() {
|
||||
return changes;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user