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

Added outaking Triggers and OutakeShooter Command #142

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ public static class ShooterConstants {
public static final double RADIUS_UPPER_HUB = 0.61; // in m
public static final double SHOOTER_HEIGHT = 0.51; // in m
public static final double UPPER_HUB_AIMING_HEIGHT = 2.725427; // in m
public static final double SHOOTER_SLOW_PERCENT = 0.10;


// Tuning Section
public static final double DELTA_AIM_HEIGHT_FACTOR = 0.0; // TODO: Set delta aim height factor from tuning
Expand Down
20 changes: 19 additions & 1 deletion src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import frc.robot.commands.shooter.*;
import frc.robot.commands.transfer.TransferIndexForward;
import frc.robot.commands.transfer.TransferManualReverse;
import frc.robot.commands.transfer.TransferOff;
import frc.robot.hardware.Limelight;
import frc.robot.helper.ControllerUtil;
import frc.robot.helper.DPadButton;
Expand Down Expand Up @@ -218,6 +219,14 @@ private void configureShooter() {
// Vibrations
if (TRANSFER) {
new Button(() -> transferSubsystem.getCurrentBallCount() >= MAX_BALL_COUNT).whenPressed(new WaitAndVibrateCommand(driverController, 0.1, 0.1));

new Trigger(()-> transferSubsystem.shouldOuttake(1))
.whileActiveContinuous(
new ParallelCommandGroup(
new OutakeShooter(shooterSubsystem),
new TransferIndexForward(transferSubsystem)
)
);
}

// Flywheel Vibration from the SetShooterPIDVelocityFromStateCommand
Expand All @@ -240,13 +249,22 @@ private void configureIntake() {

driverRightBumper.whenHeld(new IntakeOn(intakeSubsystem)); // TODO: bad

if (TRANSFER)
if (TRANSFER) {
operatorBButton.whenHeld(
new ParallelCommandGroup(
new IntakeReverse(intakeSubsystem),
new TransferManualReverse(transferSubsystem)
)
);
new Trigger(()-> transferSubsystem.shouldOuttake(0))
.whileActiveContinuous(
new ParallelCommandGroup(
new IntakeReverse(intakeSubsystem),
new TransferManualReverse(transferSubsystem)
)
);
}




Expand Down
30 changes: 30 additions & 0 deletions src/main/java/frc/robot/commands/shooter/OutakeShooter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package frc.robot.commands.shooter;

import edu.wpi.first.wpilibj2.command.CommandBase;
import frc.robot.subsystems.ShooterSubsystem;

public class OutakeShooter extends CommandBase {
private ShooterSubsystem flywheelSubsystem;

public OutakeShooter(ShooterSubsystem flywheelSubsystem) {
this.flywheelSubsystem = flywheelSubsystem;

addRequirements(flywheelSubsystem);
}

@Override
public void initialize() {
flywheelSubsystem.slowFlywheel();
}

// Called once the command ends or is interrupted.
@Override
public void end(boolean interrupted) {
flywheelSubsystem.stopFlywheel();
}

@Override
public boolean isFinished() {
return true;
Copy link
Member

Choose a reason for hiding this comment

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

If this is true the command wont run, should prolly add a condition to see if the ball has left and then stop the flywheel

Copy link
Member Author

Choose a reason for hiding this comment

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

I think I resolved this

}
}
4 changes: 4 additions & 0 deletions src/main/java/frc/robot/subsystems/ShooterSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ public boolean isHoodLimitSwitchPressed(){
/**
* Disables powers to flywheel motor, motors change to neutral/coast mode
*/
public void slowFlywheel(){
setPercentSpeed(SHOOTER_SLOW_PERCENT);
}

public void stopFlywheel() {
masterLeftShooterMotor.neutralOutput();
}
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/frc/robot/subsystems/TransferSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import edu.wpi.first.wpilibj2.command.InstantCommand;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj2.command.button.Trigger;
import frc.robot.commands.intake.IntakeOn;
import frc.robot.hardware.MuxedColorSensor;
import frc.robot.hardware.TalonConfiguration;
import frc.robot.hardware.TalonFXFactory;
Expand All @@ -30,8 +31,7 @@
import static frc.robot.Constants.LEDConstants.BALL_PATTERN;
import static frc.robot.Constants.IDConstants;

import static frc.robot.Constants.SubsystemEnableFlags.BALL_COLOR_SENSOR;
import static frc.robot.Constants.SubsystemEnableFlags.IR_SENSORS;
import static frc.robot.Constants.SubsystemEnableFlags.*;
import static frc.robot.Constants.TransferConstants;
import static frc.robot.Constants.TransferConstants.*;

Expand All @@ -55,6 +55,7 @@ public class TransferSubsystem extends SubsystemBase {

// Linked list for FIFO queue
LinkedList<BallColor> ballColorIndex = new LinkedList<>();
BallColor wrongBallColor;

// For Tracking Ball RPM
public static ShooterSubsystem flywheelSubsystem;
Expand Down Expand Up @@ -146,6 +147,10 @@ public boolean isFull(){
return currentBallCount >= TransferConstants.MAX_BALL_COUNT;
}

public boolean shouldOuttake(int index){
return wrongBallColor == ballColorIndex.get(index);
}

public void transferIndexSetup(){

// If no IR Sensors, Disable all Sensors
Expand Down Expand Up @@ -208,6 +213,7 @@ private void ballIndexEnd(){
logger.warning("No Ball Detected in Index!");

else if (redColorCountVote == blueColorCountVote)

logger.warning("Blue and Red Ball Counts are the same!\nCount: " + redColorCountVote);

else if (redColorCountVote > blueColorCountVote) {
Expand Down Expand Up @@ -262,6 +268,7 @@ private void removeShotBallFromIndex(){
if (ballColorIndex.getLast() == BallColor.NONE)
logger.warning("No Ball Color At end of index!");


ballColorIndex.removeLast();
ballColorIndex.addFirst(BallColor.NONE);

Expand Down Expand Up @@ -292,11 +299,13 @@ private void updateBallLEDPattern(){
BALL_PATTERN.update(firstBallColor, secondBallColor);
}


private void wrongBallColorDetected(BallColor ballColorDetected){
logger.warning("Intaked Wrong Ball Color! " +
"(Alliance: " + alliance +
", Ball Color Intaken: " + ballColorDetected +
")");
wrongBallColor = ballColorDetected;
}

@Override
Expand Down