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-23 15:45:08 -06:00
|
|
|
import edu.wpi.first.wpilibj.Servo;
|
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-23 15:45:08 -06:00
|
|
|
// private final PWM m_leftMotor;
|
|
|
|
|
// private final PWM m_rightMotor;
|
|
|
|
|
private final Servo m_leftMotor;
|
|
|
|
|
private final Servo m_rightMotor;
|
2023-03-21 16:17:20 -06:00
|
|
|
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-23 15:45:08 -06:00
|
|
|
// public Claw(PWM leftMotor, PWM rightMotor, CANSparkMax spinnyspin) {
|
|
|
|
|
// m_leftMotor = leftMotor;
|
|
|
|
|
// m_rightMotor = rightMotor;
|
|
|
|
|
// m_spinnyspin = spinnyspin;
|
|
|
|
|
|
|
|
|
|
// setClaw(false);
|
|
|
|
|
// }
|
|
|
|
|
public Claw(Servo leftMotor, Servo rightMotor, CANSparkMax spinnyspin) {
|
2023-03-21 16:17:20 -06:00
|
|
|
m_leftMotor = leftMotor;
|
|
|
|
|
m_rightMotor = rightMotor;
|
|
|
|
|
m_spinnyspin = spinnyspin;
|
|
|
|
|
|
2023-03-23 18:18:58 -06:00
|
|
|
// setClaw(false);
|
2023-01-24 17:04:19 -07:00
|
|
|
}
|
2023-01-23 19:53:30 -07:00
|
|
|
|
2023-03-23 18:48:57 -06:00
|
|
|
public void setAngle(double angle) {
|
|
|
|
|
m_leftMotor.setAngle(angle);
|
|
|
|
|
m_leftMotor.setAngle(180 - angle);
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-24 17:04:19 -07:00
|
|
|
public void setClaw(boolean open) {
|
|
|
|
|
// Open claw
|
|
|
|
|
m_open = open;
|
2023-03-23 15:45:08 -06:00
|
|
|
|
2023-03-24 08:17:18 -06:00
|
|
|
// ! THIS IS FOR CONE
|
2023-03-23 18:48:57 -06:00
|
|
|
// m_leftMotor.setAngle(m_open ? 0 : 180);
|
|
|
|
|
// m_rightMotor.setAngle(m_open ? 180 : 0);
|
2023-03-24 08:17:18 -06:00
|
|
|
|
|
|
|
|
// ! THIS IS FOR CUBE
|
2023-03-23 18:48:57 -06:00
|
|
|
m_leftMotor.setAngle(m_open ? 90 : 180);
|
|
|
|
|
m_rightMotor.setAngle(m_open ? 90 : 0);
|
2023-03-23 15:45:08 -06:00
|
|
|
|
2023-03-23 18:18:58 -06:00
|
|
|
// if (m_open)
|
|
|
|
|
// m_spinnyspin.set(0.2);
|
|
|
|
|
// else
|
|
|
|
|
// 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-23 19:02:59 -06:00
|
|
|
public void intake() {
|
2023-03-21 16:17:20 -06:00
|
|
|
m_spinnyspin.set(0.2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void nospinnyspin() {
|
|
|
|
|
m_spinnyspin.set(0);
|
|
|
|
|
}
|
2023-03-22 22:44:31 -06:00
|
|
|
|
2023-03-23 19:02:59 -06:00
|
|
|
public void outtake() {
|
2023-03-22 22:44:31 -06:00
|
|
|
m_spinnyspin.set(-0.2);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-14 15:27:53 -06:00
|
|
|
}
|