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:
|
2026-03-17 17:10:58 -07:00
|
|
|
self.motor = wpilib.PWMSparkMax(IntakeConstants.MOTOR_PORT)
|
2026-02-20 18:30:35 -05:00
|
|
|
self.piston = wpilib.DoubleSolenoid(
|
|
|
|
|
0,
|
2026-03-19 21:32:48 -07:00
|
|
|
wpilib.PneumaticsModuleType.CTRE_PCM,
|
2026-03-17 17:10:58 -07:00
|
|
|
IntakeConstants.PISTON_FWD_CHANNEL,
|
|
|
|
|
IntakeConstants.PISTON_REV_CHANNEL,
|
2026-02-20 18:30:35 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def deploy(self) -> None:
|
2026-04-09 22:28:01 -07:00
|
|
|
self.piston.setThrottle(wpilib.DoubleSolenoid.Value.FORWARD)
|
2026-02-20 18:30:35 -05:00
|
|
|
|
|
|
|
|
def retract(self) -> None:
|
2026-04-09 22:28:01 -07:00
|
|
|
self.piston.setThrottle(wpilib.DoubleSolenoid.Value.REVERSE)
|
|
|
|
|
self.motor.setThrottle(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-04-09 22:28:01 -07:00
|
|
|
self.motor.setThrottle(velocity)
|
2026-02-20 18:30:35 -05:00
|
|
|
else: # if piston isn't open, do nothing
|
2026-04-09 22:28:01 -07:00
|
|
|
self.motor.setThrottle(0)
|
2026-02-20 18:30:35 -05:00
|
|
|
|
|
|
|
|
def isDeployed(self) -> bool:
|
2026-03-17 17:10:58 -07:00
|
|
|
return self.piston.get() == wpilib.DoubleSolenoid.Value.FORWARD
|