generated from StuyPulse/Phil
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 1/22 Co-authored-by: Edgar694 <[email protected]> Co-authored-by: Owen-Zeng <[email protected]> Co-authored-by: sixuanl <[email protected]> Co-authored-by: Weifen Chen <[email protected]> Co-authored-by: smiley-axolotl <[email protected]> * Wrote method signatures in IntakeImpl to help speed up tomorrow's session * Fix IR logic * Finished IntakeImpl, wrote commands Co-authored-by: Weifen Chen <[email protected]> Co-authored-by: smiley-axolotl <[email protected]> Co-authored-by: Zixi Feng <[email protected]> Co-authored-by: sixuanl <[email protected]> Co-authored-by: Edgar694 <[email protected]> Co-authored-by: emidudu <[email protected]> * Added IntakeAcquireButDontStore Co-authored-by: Weifen Chen <[email protected]> Co-authored-by: smiley-axolotl <[email protected]> Co-authored-by: Zixi Feng <[email protected]> Co-authored-by: sixuanl <[email protected]> Co-authored-by: Edgar694 <[email protected]> Co-authored-by: emidudu <[email protected]> * According to all known laws of aviation , there is no way a bee should fly. Its wings are too small to get its fat little body off the ground. Co-authored-by: Weifen Chen <[email protected]> Co-authored-by: smiley-axolotl <[email protected]> Co-authored-by: Zixi Feng <[email protected]> Co-authored-by: sixuanl <[email protected]> Co-authored-by: Edgar694 <[email protected]> Co-authored-by: emidudu <[email protected]> * The bee, of course, flies anyways because bees dont care what humans think is impossible * Yellow, black. Yellow, black. Yellow, black. Yellow, black. Ooh, black and yellow! * Let's shake it up a little. Barry! Breakfast is ready! Co-authored-by: Weifen Chen <[email protected]> Co-authored-by: sixuanl <[email protected]> Co-authored-by: vipook <[email protected]> * Coming! Hang on a second. Hello? Barry? Adam? Can you believe this is happening? * this was so unneccessary --------- Co-authored-by: Edgar694 <[email protected]> Co-authored-by: Owen-Zeng <[email protected]> Co-authored-by: sixuanl <[email protected]> Co-authored-by: Weifen Chen <[email protected]> Co-authored-by: smiley-axolotl <[email protected]> Co-authored-by: Zixi Feng <[email protected]> Co-authored-by: emidudu <[email protected]> Co-authored-by: WennieC <[email protected]> Co-authored-by: vipook <[email protected]> Co-authored-by: BenG49 <[email protected]>
- Loading branch information
1 parent
8f10ae0
commit 4449adf
Showing
10 changed files
with
210 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/com/stuypulse/robot/commands/intake/IntakeAcquire.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.stuypulse.robot.commands.intake; | ||
|
||
import com.stuypulse.robot.subsystems.intake.Intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.Command; | ||
|
||
public class IntakeAcquire extends Command{ | ||
|
||
private Intake intake; | ||
|
||
public IntakeAcquire() { | ||
intake = Intake.getInstance(); | ||
addRequirements(intake); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
intake.acquire(); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
intake.stop(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return intake.hasNote(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/stuypulse/robot/commands/intake/IntakeAcquireForever.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.stuypulse.robot.commands.intake; | ||
|
||
import com.stuypulse.robot.subsystems.intake.Intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
public class IntakeAcquireForever extends InstantCommand { | ||
|
||
private Intake intake; | ||
|
||
public IntakeAcquireForever() { | ||
intake = Intake.getInstance(); | ||
addRequirements(intake); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
intake.acquire(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/stuypulse/robot/commands/intake/IntakeDeacquire.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.stuypulse.robot.commands.intake; | ||
|
||
import com.stuypulse.robot.subsystems.intake.Intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
public class IntakeDeacquire extends InstantCommand { | ||
private Intake intake; | ||
|
||
public IntakeDeacquire() { | ||
intake = Intake.getInstance(); | ||
addRequirements(intake); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
intake.deacquire(); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/stuypulse/robot/commands/intake/IntakeStop.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.stuypulse.robot.commands.intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.InstantCommand; | ||
|
||
import com.stuypulse.robot.subsystems.intake.Intake; | ||
|
||
public class IntakeStop extends InstantCommand { | ||
|
||
private Intake intake; | ||
|
||
public IntakeStop() { | ||
intake = Intake.getInstance(); | ||
addRequirements(intake); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
intake.stop(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/com/stuypulse/robot/subsystems/intake/Intake.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.stuypulse.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
||
public abstract class Intake extends SubsystemBase { | ||
|
||
private static final Intake instance; | ||
|
||
static { | ||
instance = new IntakeImpl(); | ||
} | ||
|
||
public static Intake getInstance() { | ||
return instance; | ||
} | ||
|
||
public abstract void acquire(); | ||
public abstract void deacquire(); | ||
public abstract void stop(); | ||
|
||
public abstract boolean hasNote(); | ||
|
||
} |
76 changes: 76 additions & 0 deletions
76
src/main/java/com/stuypulse/robot/subsystems/intake/IntakeImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.stuypulse.robot.subsystems.intake; | ||
|
||
import com.stuypulse.robot.constants.Motors; | ||
import com.stuypulse.robot.constants.Ports; | ||
import com.stuypulse.robot.constants.Settings; | ||
import com.stuypulse.stuylib.streams.booleans.BStream; | ||
import com.stuypulse.stuylib.streams.booleans.filters.BDebounce; | ||
|
||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
|
||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
|
||
public class IntakeImpl extends Intake { | ||
|
||
private final CANSparkMax motor; | ||
private final DigitalInput sensor; | ||
|
||
private final BStream triggered; | ||
private final BStream stalling; | ||
|
||
public IntakeImpl() { | ||
motor = new CANSparkMax(Ports.Intake.MOTOR, MotorType.kBrushless); | ||
sensor = new DigitalInput(Ports.Intake.SENSOR); | ||
|
||
Motors.Intake.MOTOR_CONFIG.configure(motor); | ||
|
||
triggered = BStream.create(sensor).not().filtered(new BDebounce.Both(Settings.Intake.Detection.TRIGGER_TIME)); | ||
stalling = BStream.create(this::isMomentarilyStalling).filtered(new BDebounce.Both(Settings.Intake.Detection.STALL_TIME)); | ||
} | ||
|
||
@Override | ||
public void acquire() { | ||
motor.set(Settings.Intake.ACQUIRE_SPEED.getAsDouble()); | ||
} | ||
|
||
@Override | ||
public void deacquire() { | ||
motor.set(Settings.Intake.DEACQUIRE_SPEED.getAsDouble()); | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
motor.stopMotor(); | ||
} | ||
|
||
// Detection | ||
|
||
private boolean isMomentarilyStalling() { | ||
return motor.getOutputCurrent() > Settings.Intake.Detection.STALL_CURRENT.getAsDouble(); | ||
} | ||
|
||
private boolean isStalling() { | ||
return stalling.get(); | ||
} | ||
|
||
private boolean isTriggered() { | ||
return triggered.get(); | ||
} | ||
|
||
// Not using stall detection, but keeping it as an option | ||
@Override | ||
public boolean hasNote() { | ||
return isTriggered(); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
SmartDashboard.putNumber("Intake/Speed", motor.get()); | ||
SmartDashboard.putNumber("Intake/Current", motor.getOutputCurrent()); | ||
|
||
SmartDashboard.putBoolean("Intake/Is Stalling", isStalling()); | ||
SmartDashboard.putBoolean("Intake/IR is triggered", isTriggered()); | ||
} | ||
} |