2026-02-20 18:30:35 -05:00
|
|
|
#
|
|
|
|
|
# Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
# Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
# the WPILib BSD license file in the root directory of this project.
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
import wpilib
|
|
|
|
|
|
|
|
|
|
from constants import IntakeConstants
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Intake:
|
|
|
|
|
def __init__(self) -> None:
|
|
|
|
|
self.motor = wpilib.PWMSparkMax(IntakeConstants.kMotorPort)
|
|
|
|
|
self.piston = wpilib.DoubleSolenoid(
|
|
|
|
|
0,
|
|
|
|
|
wpilib.PneumaticsModuleType.CTREPCM,
|
|
|
|
|
IntakeConstants.kPistonFwdChannel,
|
|
|
|
|
IntakeConstants.kPistonRevChannel,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def deploy(self) -> None:
|
2026-03-07 00:21:43 -05:00
|
|
|
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.kForward)
|
2026-02-20 18:30:35 -05:00
|
|
|
|
|
|
|
|
def retract(self) -> None:
|
2026-03-07 00:21:43 -05:00
|
|
|
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.kReverse)
|
|
|
|
|
self.motor.setDutyCycle(0) # turn off the motor
|
2026-02-20 18:30:35 -05:00
|
|
|
|
2026-03-06 14:19:15 -08:00
|
|
|
def activate(self, velocity: float) -> None:
|
2026-02-20 18:30:35 -05:00
|
|
|
if self.isDeployed():
|
2026-03-07 00:21:43 -05:00
|
|
|
self.motor.setDutyCycle(velocity)
|
2026-02-20 18:30:35 -05:00
|
|
|
else: # if piston isn't open, do nothing
|
2026-03-07 00:21:43 -05:00
|
|
|
self.motor.setDutyCycle(0)
|
2026-02-20 18:30:35 -05:00
|
|
|
|
|
|
|
|
def isDeployed(self) -> bool:
|
|
|
|
|
return self.piston.get() == wpilib.DoubleSolenoid.Value.kForward
|