mirror of
https://github.com/Team4388/2022NoWayHome.git
synced 2026-06-09 00:38:05 -06:00
updated deprecated class
This commit is contained in:
@@ -114,8 +114,6 @@ public final class Constants {
|
||||
public static final class HooksConstants {
|
||||
public static final int LEFT_HOOK_ID = -1;
|
||||
public static final int RIGHT_HOOK_ID = -1;
|
||||
public static final int LEFT_LIMIT_ID = -1;
|
||||
public static final int RIGHT_LIMIT_ID = -1;
|
||||
|
||||
public static final double OPEN_POSITION = 0;
|
||||
public static final double CLOSE_POSITION = 0;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RobotContainer {
|
||||
|
||||
private final Climber m_robotClimber = new Climber(m_robotMap.shoulder, m_robotMap.elbow, m_robotMap.gyro, false);
|
||||
|
||||
private final Hooks m_hooks = new Hooks(m_robotMap.leftHook, m_robotMap.rightHook, m_robotMap.leftHookLimit, m_robotMap.rightHookLimit);
|
||||
private final Hooks m_hooks = new Hooks(m_robotMap.leftHook, m_robotMap.rightHook);
|
||||
|
||||
/* Controllers */
|
||||
private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID);
|
||||
|
||||
@@ -109,7 +109,4 @@ public class RobotMap {
|
||||
/* Hooks Subsystem */
|
||||
public final CANSparkMax leftHook = new CANSparkMax(HooksConstants.LEFT_HOOK_ID, MotorType.kBrushless);
|
||||
public final CANSparkMax rightHook = new CANSparkMax(HooksConstants.RIGHT_HOOK_ID, MotorType.kBrushless);
|
||||
|
||||
public final DigitalInput leftHookLimit = new DigitalInput(HooksConstants.LEFT_LIMIT_ID);
|
||||
public final DigitalInput rightHookLimit = new DigitalInput(HooksConstants.RIGHT_LIMIT_ID);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package frc4388.robot.subsystems;
|
||||
|
||||
import com.ctre.phoenix.motorcontrol.LimitSwitchNormal;
|
||||
import com.revrobotics.CANSparkMax;
|
||||
import com.revrobotics.SparkMaxLimitSwitch;
|
||||
|
||||
import edu.wpi.first.wpilibj.DigitalInput;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
@@ -11,20 +12,22 @@ public class Hooks extends SubsystemBase {
|
||||
private CANSparkMax m_leftHook;
|
||||
private CANSparkMax m_rightHook;
|
||||
|
||||
private DigitalInput m_leftLimitSwitch;
|
||||
private DigitalInput m_rightLimitSwitch;
|
||||
private SparkMaxLimitSwitch m_leftLimitSwitch;
|
||||
private SparkMaxLimitSwitch m_rightLimitSwitch;
|
||||
|
||||
private double m_leftOffset;
|
||||
private double m_rightOffset;
|
||||
|
||||
private boolean m_open;
|
||||
|
||||
public Hooks(CANSparkMax leftHook, CANSparkMax rightHook, DigitalInput leftLimitSwitch, DigitalInput rightLimitSwitch) {
|
||||
public Hooks(CANSparkMax leftHook, CANSparkMax rightHook) {
|
||||
m_leftHook = leftHook;
|
||||
m_rightHook = rightHook;
|
||||
|
||||
m_leftLimitSwitch = leftLimitSwitch;
|
||||
m_rightLimitSwitch = rightLimitSwitch;
|
||||
m_leftLimitSwitch = m_leftHook.getForwardLimitSwitch(SparkMaxLimitSwitch.Type.kNormallyOpen);
|
||||
m_rightLimitSwitch = m_rightHook.getForwardLimitSwitch(SparkMaxLimitSwitch.Type.kNormallyOpen);
|
||||
m_leftLimitSwitch.enableLimitSwitch(true);
|
||||
m_rightLimitSwitch.enableLimitSwitch(true);
|
||||
|
||||
m_open = false;
|
||||
|
||||
@@ -50,10 +53,10 @@ public class Hooks extends SubsystemBase {
|
||||
|
||||
@Override
|
||||
public void periodic() {
|
||||
if(m_leftLimitSwitch.get())
|
||||
if(m_leftLimitSwitch.isPressed())
|
||||
m_leftOffset = m_leftHook.getEncoder().getPosition();
|
||||
|
||||
if(m_rightLimitSwitch.get())
|
||||
if(m_rightLimitSwitch.isPressed())
|
||||
m_rightOffset = m_rightHook.getEncoder().getPosition();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user