This repository has been archived by the owner on Nov 19, 2024. It is now read-only.
generated from Shenzhen-Robotics-Alliance/Maple-Swerve-Skeleton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
completed intake and related commands
- Loading branch information
Showing
8 changed files
with
151 additions
and
26 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
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
26 changes: 26 additions & 0 deletions
26
src/main/java/frc/robot/commands/shooter/GrabNoteManual.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,26 @@ | ||
package frc.robot.commands.shooter; | ||
|
||
|
||
import edu.wpi.first.wpilibj2.command.Commands; | ||
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup; | ||
import frc.robot.subsystems.intake.Intake; | ||
import frc.robot.subsystems.shooter.Shooter; | ||
|
||
public class GrabNoteManual extends SequentialCommandGroup { | ||
private final Shooter shooter; | ||
private final Intake intake; | ||
|
||
public GrabNoteManual(Shooter shooter, Intake intake) { | ||
this.shooter = shooter; | ||
this.intake = intake; | ||
|
||
super.addRequirements(shooter, intake); | ||
|
||
super.addCommands( | ||
Commands.run(shooter::runIdle) | ||
.until(shooter::isPitchInPosition) | ||
); | ||
|
||
super.addCommands(intake.runIntakeUntilNoteDetected()); | ||
} | ||
} |
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,55 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.wpilibj.DriverStation; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.FunctionalCommand; | ||
import frc.robot.subsystems.MapleSubsystem; | ||
import org.littletonrobotics.junction.Logger; | ||
|
||
public class Intake extends MapleSubsystem { | ||
private final IntakeIO io; | ||
private final IntakeInputsAutoLogged inputs; | ||
|
||
private boolean beamBrakeAlwaysTrue = true; | ||
|
||
public Intake(IntakeIO io) { | ||
super("Intake"); | ||
this.io = io; | ||
this.inputs = new IntakeInputsAutoLogged(); | ||
} | ||
|
||
|
||
@Override | ||
public void onReset() { | ||
|
||
} | ||
|
||
@Override | ||
public void periodic(double dt, boolean enabled) { | ||
io.updateInputs(inputs); | ||
Logger.processInputs("Intake", inputs); | ||
beamBrakeAlwaysTrue &= inputs.beamBreakTriggered; | ||
if (beamBrakeAlwaysTrue) | ||
DriverStation.reportWarning("Intake beam breaker always blocked, check wiring!", false); | ||
} | ||
|
||
public Command runIntakeUntilNoteDetected() { | ||
return new FunctionalCommand( | ||
() -> {}, | ||
() -> io.runIntakeVoltage(12), | ||
interrupted ->io.runIntakeVoltage(0), | ||
() -> inputs.beamBreakTriggered, | ||
this | ||
); | ||
} | ||
|
||
public Command shootNoteUntilNoteGone() { | ||
return new FunctionalCommand( | ||
() -> {}, | ||
() -> io.runIntakeVoltage(8), | ||
interrupted ->io.runIntakeVoltage(0), | ||
() -> !inputs.beamBreakTriggered, | ||
this | ||
); | ||
} | ||
} |
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,14 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface IntakeIO { | ||
@AutoLog | ||
class IntakeInputs { | ||
boolean beamBreakTriggered = true; | ||
} | ||
|
||
void updateInputs(IntakeInputs inputs); | ||
|
||
default void runIntakeVoltage(double volts) {} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/frc/robot/subsystems/intake/IntakeIOReal.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,21 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import com.ctre.phoenix.motorcontrol.ControlMode; | ||
import com.ctre.phoenix.motorcontrol.can.TalonSRX; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
import edu.wpi.first.wpilibj.RobotController; | ||
|
||
public class IntakeIOReal implements IntakeIO { | ||
private final TalonSRX intakeMotor = new TalonSRX(9); | ||
private final DigitalInput beamBreak = new DigitalInput(3); | ||
@Override | ||
public void updateInputs(IntakeInputs inputs) { | ||
inputs.beamBreakTriggered = beamBreak.get(); | ||
} | ||
|
||
@Override | ||
public void runIntakeVoltage(double volts) { | ||
intakeMotor.set(ControlMode.PercentOutput, | ||
volts / RobotController.getBatteryVoltage()); | ||
} | ||
} |
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