mirror of
https://github.com/Team4388/RiseOfRidgebotics2020.git
synced 2026-06-09 08:48:01 -06:00
Limit switches for extenders
Co-Authored-By: llamakingker <llamakingker@users.noreply.github.com> #janky
This commit is contained in:
@@ -22,14 +22,15 @@ import frc4388.robot.Constants.IntakeConstants;
|
||||
public class Intake extends SubsystemBase {
|
||||
CANSparkMax m_intakeMotor = new CANSparkMax(IntakeConstants.INTAKE_SPARK_ID, MotorType.kBrushless);
|
||||
CANSparkMax m_extenderMotor = new CANSparkMax(IntakeConstants.EXTENDER_SPARK_ID, MotorType.kBrushless);
|
||||
|
||||
CANDigitalInput m_extenderForwardLimit;
|
||||
CANDigitalInput m_extenderReverseLimit;
|
||||
boolean extended = false;
|
||||
|
||||
/**
|
||||
* Creates a new Intake.
|
||||
*/
|
||||
public Intake() {
|
||||
CANDigitalInput m_extenderForwardLimit;
|
||||
CANDigitalInput m_extenderReverseLimit;
|
||||
|
||||
|
||||
m_intakeMotor.restoreFactoryDefaults();
|
||||
m_extenderMotor.restoreFactoryDefaults();
|
||||
@@ -63,6 +64,18 @@ public class Intake extends SubsystemBase {
|
||||
* @param input the percent output to run motor at
|
||||
*/
|
||||
public void runExtender(final double input) {
|
||||
m_extenderMotor.set(input);
|
||||
if (m_extenderForwardLimit.get()) {
|
||||
extended = true;
|
||||
}
|
||||
if (m_extenderReverseLimit.get()) {
|
||||
extended = false;
|
||||
}
|
||||
|
||||
if (extended == false) {
|
||||
m_extenderMotor.set(0.5);
|
||||
}
|
||||
if (extended == true) {
|
||||
m_extenderMotor.set(-0.5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public void storageIntake(Intake intake) {
|
||||
m_storageMotor.set(0);
|
||||
}
|
||||
if (m_beamSensors[0].get()){
|
||||
m_intake.runExtender(-0.3);
|
||||
m_intake.runExtender(-0.3);
|
||||
m_storagePIDController.setReference(10, ControlType.kPosition);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user