mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Rename DoubleSolenoid.Value constants to all caps
This commit is contained in:
@@ -23,11 +23,11 @@ class HatchSubsystem(commands2.Subsystem):
|
||||
def grabHatch(self) -> commands2.Command:
|
||||
"""Grabs the hatch"""
|
||||
return commands2.cmd.runOnce(
|
||||
lambda: self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.kForward), self
|
||||
lambda: self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.FORWARD), self
|
||||
)
|
||||
|
||||
def releaseHatch(self) -> commands2.Command:
|
||||
"""Releases the hatch"""
|
||||
return commands2.cmd.runOnce(
|
||||
lambda: self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.kReverse), self
|
||||
lambda: self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.REVERSE), self
|
||||
)
|
||||
|
||||
@@ -21,8 +21,8 @@ class HatchSubsystem(commands2.Subsystem):
|
||||
|
||||
def grabHatch(self) -> None:
|
||||
"""Grabs the hatch"""
|
||||
self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.kForward)
|
||||
self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.FORWARD)
|
||||
|
||||
def releaseHatch(self) -> None:
|
||||
"""Releases the hatch"""
|
||||
self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.kReverse)
|
||||
self.hatchSolenoid.set(wpilib.DoubleSolenoid.Value.REVERSE)
|
||||
|
||||
@@ -28,7 +28,7 @@ class Intake(Subsystem):
|
||||
indefinitely.
|
||||
"""
|
||||
return (
|
||||
self.runOnce(lambda: self.pistons.set(wpilib.DoubleSolenoid.Value.kForward))
|
||||
self.runOnce(lambda: self.pistons.set(wpilib.DoubleSolenoid.Value.FORWARD))
|
||||
.andThen(self.run(lambda: self.motor.set(1.0)))
|
||||
.withName("Intake")
|
||||
)
|
||||
@@ -38,6 +38,6 @@ class Intake(Subsystem):
|
||||
return self.runOnce(
|
||||
lambda: (
|
||||
self.motor.disable(),
|
||||
self.pistons.set(wpilib.DoubleSolenoid.Value.kReverse),
|
||||
self.pistons.set(wpilib.DoubleSolenoid.Value.REVERSE),
|
||||
)
|
||||
).withName("Retract")
|
||||
|
||||
@@ -86,9 +86,9 @@ class MyRobot(wpilib.TimedRobot):
|
||||
# If a button is pressed, set the solenoid to the respective channel.
|
||||
|
||||
if self.joystick.getRawButtonPressed(kDoubleSolenoidForwardButton):
|
||||
self.doubleSolenoid.set(wpilib.DoubleSolenoid.Value.kForward)
|
||||
self.doubleSolenoid.set(wpilib.DoubleSolenoid.Value.FORWARD)
|
||||
elif self.joystick.getRawButtonPressed(kDoubleSolenoidReverseButton):
|
||||
self.doubleSolenoid.set(wpilib.DoubleSolenoid.Value.kReverse)
|
||||
self.doubleSolenoid.set(wpilib.DoubleSolenoid.Value.REVERSE)
|
||||
|
||||
# On button press, toggle the compressor.
|
||||
if self.joystick.getRawButtonPressed(kCompressorButton):
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
|
||||
|
||||
class IntakeConstants:
|
||||
kMotorPort = 1
|
||||
MOTOR_PORT = 1
|
||||
|
||||
kPistonFwdChannel = 0
|
||||
kPistonRevChannel = 1
|
||||
kIntakeVelocity = 0.5
|
||||
PISTON_FWD_CHANNEL = 0
|
||||
PISTON_REV_CHANNEL = 1
|
||||
INTAKE_VELOCITY = 0.5
|
||||
|
||||
|
||||
kJoystickIndex = 0
|
||||
JOYSTICK_INDEX = 0
|
||||
|
||||
@@ -21,13 +21,13 @@ class MyRobot(wpilib.TimedRobot):
|
||||
def __init__(self) -> None:
|
||||
super().__init__()
|
||||
self.intake = Intake()
|
||||
self.joystick = wpilib.Joystick(constants.kJoystickIndex)
|
||||
self.joystick = wpilib.Joystick(constants.JOYSTICK_INDEX)
|
||||
|
||||
def teleopPeriodic(self) -> None:
|
||||
"""This function is called periodically during operator control."""
|
||||
# Activate the intake while the trigger is held
|
||||
if self.joystick.getTrigger():
|
||||
self.intake.activate(constants.IntakeConstants.kIntakeVelocity)
|
||||
self.intake.activate(constants.IntakeConstants.INTAKE_VELOCITY)
|
||||
else:
|
||||
self.intake.activate(0)
|
||||
|
||||
|
||||
@@ -11,19 +11,19 @@ from constants import IntakeConstants
|
||||
|
||||
class Intake:
|
||||
def __init__(self) -> None:
|
||||
self.motor = wpilib.PWMSparkMax(IntakeConstants.kMotorPort)
|
||||
self.motor = wpilib.PWMSparkMax(IntakeConstants.MOTOR_PORT)
|
||||
self.piston = wpilib.DoubleSolenoid(
|
||||
0,
|
||||
wpilib.PneumaticsModuleType.CTREPCM,
|
||||
IntakeConstants.kPistonFwdChannel,
|
||||
IntakeConstants.kPistonRevChannel,
|
||||
IntakeConstants.PISTON_FWD_CHANNEL,
|
||||
IntakeConstants.PISTON_REV_CHANNEL,
|
||||
)
|
||||
|
||||
def deploy(self) -> None:
|
||||
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.kForward)
|
||||
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.FORWARD)
|
||||
|
||||
def retract(self) -> None:
|
||||
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.kReverse)
|
||||
self.piston.setDutyCycle(wpilib.DoubleSolenoid.Value.REVERSE)
|
||||
self.motor.setDutyCycle(0) # turn off the motor
|
||||
|
||||
def activate(self, velocity: float) -> None:
|
||||
@@ -33,4 +33,4 @@ class Intake:
|
||||
self.motor.setDutyCycle(0)
|
||||
|
||||
def isDeployed(self) -> bool:
|
||||
return self.piston.get() == wpilib.DoubleSolenoid.Value.kForward
|
||||
return self.piston.get() == wpilib.DoubleSolenoid.Value.FORWARD
|
||||
|
||||
Reference in New Issue
Block a user