Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harry695/controller rumble when intake #169

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 47 additions & 31 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
import static frc.robot.Constants.ColorConstants.PINK;
import static frc.robot.Constants.ColorConstants.RED;

import java.util.Map;

import com.nrg948.preferences.RobotPreferences;
import com.nrg948.preferences.RobotPreferencesLayout;

import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.GenericHID.RumbleType;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.shuffleboard.BuiltInLayouts;
import edu.wpi.first.wpilibj.shuffleboard.Shuffleboard;
Expand All @@ -38,12 +42,14 @@
import frc.robot.subsystems.ShooterSubsystem;
import frc.robot.subsystems.StatusLEDSubsystem;
import frc.robot.subsystems.Subsystems;
import java.util.Map;

/**
* 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
* 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 trigger mappings) should be declared here.
*/
@RobotPreferencesLayout(groupName = "Preferences", column = 0, row = 0, width = 1, height = 1)
Expand All @@ -55,22 +61,26 @@ public class RobotContainer {
private final RobotAutonomous autonomous = new RobotAutonomous(subsystems);

// Replace with CommandPS4Controller or CommandJoystick if needed
private final CommandXboxController driverController =
new CommandXboxController(OperatorConstants.XboxControllerPort.DRIVER);
private final CommandXboxController operatorController =
new CommandXboxController(OperatorConstants.XboxControllerPort.MANIPULATOR);
private final CommandXboxController driverController = new CommandXboxController(
OperatorConstants.XboxControllerPort.DRIVER);
private final CommandXboxController operatorController = new CommandXboxController(
OperatorConstants.XboxControllerPort.MANIPULATOR);

private Timer coastModeTimer = new Timer();

/** The container for the robot. Contains subsystems, OI devices, and commands. */
/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer() {
DriverStation.silenceJoystickConnectionWarning(true);

subsystems.drivetrain.setDefaultCommand(new DriveUsingController(subsystems, driverController));
// subsystems.arm.setDefaultCommand(new ManualArmController(subsystems, operatorController));
// subsystems.arm.setDefaultCommand(new ManualArmController(subsystems,
// operatorController));
// subsystems.intake.setDefaultCommand(new IntakeUsingController(subsystems,
// operatorController));
// subsystems.shooter.setDefaultCommand(new ShootUsingController(subsystems.shooter,
// subsystems.shooter.setDefaultCommand(new
// ShootUsingController(subsystems.shooter,
// operatorController));

// Configure the trigger bindings
Expand All @@ -80,12 +90,17 @@ public RobotContainer() {
}

/**
* Use this method to define your trigger->command mappings. Triggers can be created via the
* {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary
* Use this method to define your trigger->command mappings. Triggers can be
* created via the
* {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with
* an arbitrary
* predicate, or via the named factories in {@link
* edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for {@link
* CommandXboxController Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller
* PS4} controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight
* edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for
* {@link
* CommandXboxController
* Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller
* PS4} controllers or
* {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight
* joysticks}.
*/
private void configureBindings() {
Expand All @@ -105,12 +120,12 @@ private void configureBindings() {
driverController.rightBumper().whileTrue(ClimberCommands.manualClimbDownChain(subsystems));

// operatorController
// .start()
// .onTrue(
// NoteCommands.prepareToShoot(
// subsystems,
// Autos.SPIKE_SHOT_RPM.getValue(),
// Math.toRadians(Autos.SPIKE_SHOT_ANGLE.getValue())));
// .start()
// .onTrue(
// NoteCommands.prepareToShoot(
// subsystems,
// Autos.SPIKE_SHOT_RPM.getValue(),
// Math.toRadians(Autos.SPIKE_SHOT_ANGLE.getValue())));
operatorController
.povUp()
.whileTrue(NoteCommands.shootAtCurrentRPM(subsystems).finallyDo(shooter::disable));
Expand All @@ -134,11 +149,13 @@ private void configureBindings() {

Trigger noteDetected = new Trigger(indexer::isNoteBreakingEitherBeam);
noteDetected.onTrue(
Commands.sequence(LEDs.flashColor(statusLED, GREEN), LEDs.fillColor(statusLED, GREEN)));
Commands.sequence(
Commands.parallel(LEDs.flashColor(statusLED, GREEN),
Commands.runOnce(() -> driverController.getHID().setRumble(RumbleType.kBothRumble, 1.0))),
LEDs.fillColor(statusLED, GREEN)));
noteDetected.onFalse(LEDs.fillColor(statusLED, RED));
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably stop rumbling when there's no note.


Trigger shooterSpinning =
new Trigger(() -> shooter.atGoalRPM() && indexer.isNoteBreakingEitherBeam());
Trigger shooterSpinning = new Trigger(() -> shooter.atGoalRPM() && indexer.isNoteBreakingEitherBeam());
shooterSpinning.onTrue(
Commands.sequence(LEDs.flashColor(statusLED, PINK), LEDs.fillColor(statusLED, PINK)));
}
Expand Down Expand Up @@ -188,12 +205,11 @@ public void initShuffleboard() {
ShuffleboardTab operatorTab = Shuffleboard.getTab("Operator");

autonomous.addShuffleboardLayout(operatorTab);
ShuffleboardLayout statusLayout =
operatorTab
.getLayout("Status", BuiltInLayouts.kGrid)
.withProperties(Map.of("Number of columns", 1, "Number of rows", 1))
.withPosition(6, 0)
.withSize(2, 2);
ShuffleboardLayout statusLayout = operatorTab
.getLayout("Status", BuiltInLayouts.kGrid)
.withProperties(Map.of("Number of columns", 1, "Number of rows", 1))
.withPosition(6, 0)
.withSize(2, 2);
statusLayout.addBoolean("Note Detected", subsystems.indexer::isNoteBreakingUpperBeam);

RobotPreferences.addShuffleBoardTab();
Expand Down