-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
182 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -246,4 +246,4 @@ eval "set -- $( | |
tr '\n' ' ' | ||
)" '"$@"' | ||
|
||
exec "$JAVACMD" "$@" | ||
exec "$JAVACMD" "$@" |
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 |
---|---|---|
|
@@ -89,4 +89,4 @@ exit /b %EXIT_CODE% | |
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
|
||
:omega | ||
:omega |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.wpilibj.Timer; | ||
import edu.wpi.first.wpilibj2.command.Command; | ||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
import org.littletonrobotics.junction.Logger; | ||
|
||
public class Intake extends SubsystemBase { | ||
private Timer noteTime = new Timer(); | ||
private IntakeIO io; | ||
private final IntakeIOInputsAutoLogged inputs = new IntakeIOInputsAutoLogged(); | ||
private static Intake instance; | ||
public double intakeSpeed; | ||
public static double time1 = 0; // static | ||
private double testamps = 0; | ||
public static boolean flag = false; | ||
|
||
private Intake(IntakeIO IO) { | ||
io = IO; | ||
} | ||
|
||
public static Intake getInstance() { | ||
return instance; | ||
} | ||
|
||
public static Intake initialize(IntakeIO io) { | ||
if (instance == null) { | ||
instance = new Intake(io); | ||
} | ||
return instance; | ||
} | ||
|
||
public void setIntakeSpeed(double speed) { | ||
intakeSpeed = speed; | ||
} | ||
|
||
public boolean noteNotInIntake() { // .. | ||
if (inputs.Amps < IntakeConstants.current) { | ||
noteTime.start(); | ||
flag = true; | ||
return inputs.Amps < IntakeConstants.current; | ||
} else { | ||
if (flag) { | ||
time1 = noteTime.get(); | ||
noteTime.stop(); | ||
noteTime.reset(); | ||
} | ||
return inputs.Amps < IntakeConstants.current; | ||
} | ||
} | ||
|
||
public Command intake() { | ||
return startEnd(() -> setIntakeSpeed(1), () -> setIntakeSpeed(0)) | ||
.onlyWhile(() -> noteNotInIntake()); | ||
// return (startEnd(() -> setIntakeSpeed(1), () -> setIntakeSpeed(0)).onlyWhile(() -> | ||
// noteNotInIntake())).alongWith(startEnd(() -> setIntakeSpeed(0.1), () -> | ||
// setIntakeSpeed(0)).onlyIf(() -> noteNotInIntake() == true).onlyWhile(() -> noteNotInIntake() | ||
// == true)); | ||
} | ||
/* | ||
public Command spike() { | ||
return startEnd(() -> testamps = 150, () -> testamps = 0); | ||
} | ||
*/ | ||
public Command reverse() { | ||
return startEnd(() -> setIntakeSpeed(-1), () -> setIntakeSpeed(0)); | ||
} | ||
|
||
@Override | ||
public void periodic() { | ||
Logger.recordOutput("Intake/testamps", testamps); | ||
io.setMotorSpeed(intakeSpeed); | ||
io.updateInputs(inputs); | ||
Logger.processInputs("Intake", inputs); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/frc/robot/subsystems/intake/IntakeConstants.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,7 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
public class IntakeConstants { | ||
public static final int CanID = 2; // .. | ||
public static final int currentLimit = 40; // vortex | ||
public static final int current = 10; // .. | ||
} |
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,18 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface IntakeIO { | ||
@AutoLog | ||
public static class IntakeIOInputs { | ||
public double angularVelocityRPM = 0.0; | ||
public double angularPositionRot = 0.0; | ||
public double Voltage = 0.0; // .. | ||
public double Amps = 0.0; | ||
public double noteTime = 0.0; | ||
} | ||
|
||
public default void updateInputs(IntakeIOInputs inputs) {} | ||
|
||
public default void setMotorSpeed(double speed) {} | ||
} |
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
package frc.robot.subsystems.intake; | ||
|
||
import com.revrobotics.CANSparkLowLevel.MotorType; | ||
import com.revrobotics.CANSparkMax; | ||
import com.revrobotics.RelativeEncoder; | ||
|
||
public class IntakeIOReal implements IntakeIO { | ||
private CANSparkMax IntakeMotor = new CANSparkMax(IntakeConstants.CanID, MotorType.kBrushless); | ||
private final RelativeEncoder IntakEncoder = IntakeMotor.getEncoder(); | ||
|
||
public IntakeIOReal() { | ||
IntakeMotor.setSmartCurrentLimit(IntakeConstants.currentLimit); | ||
IntakeMotor.burnFlash(); | ||
} | ||
|
||
@Override | ||
public void setMotorSpeed(double speed) { | ||
IntakeMotor.set(speed); | ||
} | ||
|
||
@Override | ||
public void updateInputs(IntakeIOInputs inputs) { | ||
inputs.angularVelocityRPM = IntakEncoder.getVelocity(); | ||
inputs.angularPositionRot = IntakEncoder.getPosition(); | ||
inputs.Voltage = IntakeMotor.getBusVoltage(); | ||
inputs.Amps = IntakeMotor.getOutputCurrent(); | ||
inputs.noteTime = Intake.time1; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/frc/robot/subsystems/intake/IntakeIOSim.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 frc.robot.subsystems.intake; | ||
|
||
import edu.wpi.first.math.system.plant.DCMotor; | ||
import edu.wpi.first.wpilibj.simulation.DCMotorSim; | ||
|
||
public class IntakeIOSim implements IntakeIO { | ||
private final DCMotorSim motor = new DCMotorSim(DCMotor.getNeoVortex(1), 1, 1); | ||
|
||
@Override | ||
public void updateInputs(IntakeIOInputs inputs) { | ||
motor.update(0.02); | ||
|
||
inputs.angularPositionRot = motor.getAngularPositionRotations(); | ||
inputs.angularVelocityRPM = motor.getAngularVelocityRPM(); | ||
inputs.Amps = motor.getCurrentDrawAmps(); | ||
inputs.noteTime = Intake.time1; | ||
} | ||
|
||
@Override | ||
public void setMotorSpeed(double speed) { | ||
motor.setInputVoltage(speed); | ||
} | ||
} |