2023-01-24 17:04:19 -07:00
|
|
|
package frc4388.robot.subsystems;
|
2023-03-22 19:38:18 -06:00
|
|
|
|
2023-03-21 16:17:20 -06:00
|
|
|
import java.util.Timer;
|
|
|
|
|
import java.util.TimerTask;
|
|
|
|
|
|
|
|
|
|
import com.revrobotics.CANSparkMax;
|
|
|
|
|
|
2023-01-24 17:04:19 -07:00
|
|
|
import edu.wpi.first.wpilibj.PWM;
|
2023-03-06 18:36:32 -07:00
|
|
|
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
2023-01-24 17:04:19 -07:00
|
|
|
|
2023-03-06 18:36:32 -07:00
|
|
|
public class Claw extends SubsystemBase {
|
2023-03-22 19:38:18 -06:00
|
|
|
|
2023-03-21 16:17:20 -06:00
|
|
|
private final PWM m_leftMotor;
|
|
|
|
|
private final PWM m_rightMotor;
|
|
|
|
|
private final CANSparkMax m_spinnyspin;
|
|
|
|
|
|
|
|
|
|
private boolean m_open = false;
|
2023-01-24 17:04:19 -07:00
|
|
|
|
2023-01-23 19:53:30 -07:00
|
|
|
// Opens claw
|
2023-03-21 16:17:20 -06:00
|
|
|
public Claw(PWM leftMotor, PWM rightMotor, CANSparkMax spinnyspin) {
|
|
|
|
|
m_leftMotor = leftMotor;
|
|
|
|
|
m_rightMotor = rightMotor;
|
|
|
|
|
m_spinnyspin = spinnyspin;
|
|
|
|
|
|
|
|
|
|
setClaw(true);
|
2023-01-24 17:04:19 -07:00
|
|
|
}
|
2023-01-23 19:53:30 -07:00
|
|
|
|
2023-01-24 17:04:19 -07:00
|
|
|
public void setClaw(boolean open) {
|
|
|
|
|
// Open claw
|
|
|
|
|
m_open = open;
|
2023-03-21 16:17:20 -06:00
|
|
|
m_leftMotor.setRaw(m_open ? 1000 : 2000);
|
|
|
|
|
m_rightMotor.setRaw(m_open ? 2000 : 1000);
|
|
|
|
|
|
|
|
|
|
if (!m_open) {
|
|
|
|
|
m_spinnyspin.set(-0.2);
|
|
|
|
|
|
|
|
|
|
new Timer().schedule(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
nospinnyspin();
|
|
|
|
|
}
|
|
|
|
|
}, 750);
|
|
|
|
|
}
|
2023-01-23 19:53:30 -07:00
|
|
|
}
|
|
|
|
|
|
2023-03-06 19:40:50 -07:00
|
|
|
public void toggle() {
|
|
|
|
|
setClaw(!m_open);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-24 17:04:19 -07:00
|
|
|
public boolean isClawOpen() {
|
|
|
|
|
return m_open;
|
|
|
|
|
}
|
2023-03-11 14:03:36 -07:00
|
|
|
|
2023-03-21 16:17:20 -06:00
|
|
|
public void yesspinnyspin() {
|
|
|
|
|
m_spinnyspin.set(0.2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void nospinnyspin() {
|
|
|
|
|
m_spinnyspin.set(0);
|
|
|
|
|
}
|
2023-03-22 22:44:31 -06:00
|
|
|
|
|
|
|
|
public void reversespinnyspin() {
|
|
|
|
|
m_spinnyspin.set(-0.2);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-14 15:27:53 -06:00
|
|
|
}
|