mirror of
https://github.com/Team4388/2019-Hit-or-Miss.git
synced 2026-06-09 00:28:05 -06:00
Add limit switches to code
Encoder position will zero out whenever the arm hits the bottom limit switch. The Digital Output ids still need to be configured.
This commit is contained in:
@@ -21,6 +21,7 @@ import com.ctre.phoenix.motorcontrol.NeutralMode;
|
||||
import com.ctre.phoenix.motorcontrol.SensorCollection;
|
||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
|
||||
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj.Solenoid;
|
||||
import edu.wpi.first.wpilibj.command.Subsystem;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
@@ -93,6 +94,9 @@ public class Arm extends Subsystem implements ControlLoopable
|
||||
private PIDParams armPIDParams = new PIDParams(P_Value, I_Value, D_Value, KF_DOWN); // KF gets updated later
|
||||
public static final double PID_ERROR_INCHES = 5.0;
|
||||
LimitSwitchSource limitSwitchSource;
|
||||
DigitalInput forwardLimitSwitch = new DigitalInput(1);
|
||||
DigitalInput reverseLimitSwitch = new DigitalInput(2);
|
||||
|
||||
// Pneumatics
|
||||
private Solenoid speedShift;
|
||||
|
||||
@@ -270,6 +274,10 @@ public class Arm extends Subsystem implements ControlLoopable
|
||||
}
|
||||
lastControlLoopUpdateTimestamp = currentTimestamp;
|
||||
|
||||
if (reverseLimitSwitch.get()){
|
||||
motor1.setPosition(0);
|
||||
}
|
||||
|
||||
// Do the update
|
||||
if (armControlMode == ArmControlMode.JOYSTICK_MANUAL) {
|
||||
controlManualWithJoystick();
|
||||
|
||||
Reference in New Issue
Block a user