-
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.
Signed-off-by: Jade Turner <[email protected]>
- Loading branch information
1 parent
2e09a1e
commit 4da4d41
Showing
9 changed files
with
70 additions
and
143 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
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
20 changes: 4 additions & 16 deletions
20
src/main/java/org/curtinfrc/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 |
---|---|---|
@@ -1,22 +1,10 @@ | ||
package org.curtinfrc.subsystems.intake; | ||
|
||
public class IntakeConstants { | ||
public static double intakeVolts = 6; | ||
public static double intakeVolts = 8; | ||
public static int intakeCurrentLimit = 40; | ||
public static double motorReduction = 1.0; | ||
public static double intakePort = 99; | ||
public static double intakeMaxVelocity = 550; | ||
public static double intakeTolerance = 0.01; | ||
// public static double goalRPM = 4000; | ||
public static double goalRPM = 500; | ||
public static double intakeLoopError = 0.1; | ||
|
||
public static double kP = 1; | ||
public static double kI = 0; | ||
public static double kD = 0; | ||
public static double kV = 473; | ||
|
||
public static double intakeID = 99; | ||
|
||
public enum intakeSetPoints {} | ||
public static int intakeMotorId = 99; | ||
public static int intakeFrontSensorPort = 99; | ||
public static int intakeBackSensorPort = 99; | ||
} |
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
15 changes: 0 additions & 15 deletions
15
src/main/java/org/curtinfrc/subsystems/intake/IntakeIOBeamBreak.java
This file was deleted.
Oops, something went wrong.
22 changes: 17 additions & 5 deletions
22
src/main/java/org/curtinfrc/subsystems/intake/IntakeIONEO.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 |
---|---|---|
@@ -1,19 +1,31 @@ | ||
package org.curtinfrc.subsystems.intake; | ||
|
||
import com.revrobotics.RelativeEncoder; | ||
import static org.curtinfrc.subsystems.intake.IntakeConstants.*; | ||
|
||
import com.revrobotics.spark.SparkLowLevel.MotorType; | ||
import com.revrobotics.spark.SparkMax; | ||
import edu.wpi.first.wpilibj.DigitalInput; | ||
|
||
public class IntakeIONEO implements IntakeIO { | ||
protected final SparkMax intakeNeo = new SparkMax(99, MotorType.kBrushless); | ||
protected final RelativeEncoder intakeEncoder = intakeNeo.getEncoder(); | ||
private final SparkMax intakeNeo = new SparkMax(intakeMotorId, MotorType.kBrushless); | ||
private final DigitalInput frontSensor = new DigitalInput(intakeFrontSensorPort); | ||
private final DigitalInput backSensor = new DigitalInput(intakeBackSensorPort); | ||
|
||
// TODO apply configs | ||
public IntakeIONEO() {} | ||
|
||
@Override | ||
public void updateInputs(IntakeIOInputs inputs) { | ||
inputs.encoderOutput = intakeEncoder.getVelocity(); | ||
// inputs.encoderOutput = intakeEncoder.getVelocity(); | ||
inputs.appliedVolts = intakeNeo.getBusVoltage() * intakeNeo.getAppliedOutput(); | ||
inputs.currentAmps = intakeNeo.getOutputCurrent(); | ||
inputs.positionRotations = intakeNeo.getEncoder().getPosition(); | ||
inputs.angularVelocityRotationsPerMinute = intakeNeo.getEncoder().getVelocity(); | ||
inputs.frontSensor = frontSensor.get(); | ||
inputs.backSensor = backSensor.get(); | ||
} | ||
|
||
@Override | ||
public void setVoltage(double volts) { | ||
intakeNeo.setVoltage(volts); | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
src/main/java/org/curtinfrc/subsystems/intake/IntakeIONeoMaxMotion.java
This file was deleted.
Oops, something went wrong.
46 changes: 24 additions & 22 deletions
46
src/main/java/org/curtinfrc/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 |
---|---|---|
@@ -1,47 +1,49 @@ | ||
package org.curtinfrc.subsystems.intake; | ||
|
||
import edu.wpi.first.math.MathUtil; | ||
import static org.curtinfrc.subsystems.intake.IntakeConstants.intakeBackSensorPort; | ||
import static org.curtinfrc.subsystems.intake.IntakeConstants.intakeFrontSensorPort; | ||
|
||
import edu.wpi.first.hal.SimBoolean; | ||
import edu.wpi.first.hal.SimDevice; | ||
import edu.wpi.first.hal.SimDevice.Direction; | ||
import edu.wpi.first.math.system.plant.DCMotor; | ||
import edu.wpi.first.math.system.plant.LinearSystemId; | ||
import edu.wpi.first.wpilibj.simulation.DCMotorSim; | ||
|
||
public class IntakeIOSim implements IntakeIO { | ||
|
||
private DCMotor intakeMotor = DCMotor.getNEO(1); | ||
private DCMotorSim intakeMotorSim; | ||
private SimDevice frontImpl; | ||
private SimBoolean frontSensor; | ||
private SimDevice backImpl; | ||
private SimBoolean backSensor; | ||
private double volts = 0; | ||
|
||
public IntakeIOSim() { | ||
intakeMotorSim = | ||
new DCMotorSim(LinearSystemId.createDCMotorSystem(intakeMotor, 0.025, 4.0), intakeMotor); | ||
} | ||
|
||
private double appliedVolts = 0.0; | ||
frontImpl = SimDevice.create("IntakeSensorFront", intakeFrontSensorPort); | ||
frontSensor = frontImpl.createBoolean("IsTriggered", Direction.kInput, false); | ||
backImpl = SimDevice.create("IntakeSensorBack", intakeBackSensorPort); | ||
backSensor = backImpl.createBoolean("IsTriggered", Direction.kInput, false); | ||
} | ||
|
||
@Override | ||
public void updateInputs(IntakeIOInputs inputs) { | ||
intakeMotorSim.setInputVoltage(appliedVolts); | ||
intakeMotorSim.setInputVoltage(volts); | ||
intakeMotorSim.update(0.02); | ||
// inputs.appliedVolts = appliedVolts; | ||
inputs.appliedVolts = intakeMotorSim.getInputVoltage(); | ||
// inputs.encoderOutput = intakeMotorSim.getAngularVelocity(); | ||
inputs.encoderOutput = intakeMotorSim.getAngularVelocityRadPerSec(); | ||
inputs.currentAmps = intakeMotorSim.getCurrentDrawAmps(); | ||
inputs.positionRotations = intakeMotorSim.getAngularPositionRotations(); | ||
inputs.angularVelocityRotationsPerMinute = intakeMotorSim.getAngularVelocityRPM(); | ||
inputs.frontSensor = frontSensor.get(); | ||
inputs.backSensor = backSensor.get(); | ||
} | ||
|
||
@Override | ||
public void setIntakeVolts(double volts) { | ||
appliedVolts = MathUtil.clamp(volts, -12.0, 12.0); | ||
public void setVoltage(double volts) { | ||
this.volts = volts; | ||
intakeMotorSim.setInputVoltage(volts); | ||
} | ||
|
||
@Override | ||
public void achieveRPM() { | ||
intakeMotorSim.setAngularVelocity(IntakeConstants.goalRPM); | ||
} | ||
|
||
@Override | ||
public boolean intakeAtRPM() { | ||
double angularVelocity = intakeMotorSim.getAngularVelocityRadPerSec(); | ||
return IntakeConstants.goalRPM - IntakeConstants.intakeTolerance < angularVelocity | ||
&& angularVelocity < IntakeConstants.goalRPM + IntakeConstants.intakeTolerance; | ||
} | ||
} |