commands.ball_transport

Ball transport commands — intake roller, hopper, and feed coordination.

These commands manage the ball path from intake through hopper and feed into the shooter.

 1"""Ball transport commands — intake roller, hopper, and feed coordination.
 2
 3These commands manage the ball path from intake through hopper and feed
 4into the shooter.
 5"""
 6
 7import commands2
 8
 9import constants.swerve_constants as consts
10
11
12def run_roller_while_held(intake_roller):
13    """Return a startEnd command that runs the intake roller while held."""
14    return commands2.cmd.startEnd(
15        lambda: intake_roller.setPower(consts.IntakeRollerConstants.defaultPower),
16        intake_roller.stop,
17        intake_roller,
18    )
19
20
21def run_hopper_while_active(hopper):
22    """Return a startEnd command that runs the hopper while the trigger is active."""
23    return commands2.cmd.startEnd(
24        lambda: hopper.setPower(consts.HopperConstants.defaultPower),
25        hopper.stop,
26        hopper,
27    )
28
29
30def run_hopper_and_feed(hopper, feed):
31    """Return a command that runs hopper at 50% and feed at 60% while held."""
32    def _start():
33        hopper.setPower(consts.HopperConstants.defaultPower)
34        feed.setPower(0.8)
35
36    def _end():
37        hopper.stop()
38        feed.stop()
39
40    return commands2.cmd.startEnd(_start, _end, hopper, feed)
def run_roller_while_held(intake_roller):
13def run_roller_while_held(intake_roller):
14    """Return a startEnd command that runs the intake roller while held."""
15    return commands2.cmd.startEnd(
16        lambda: intake_roller.setPower(consts.IntakeRollerConstants.defaultPower),
17        intake_roller.stop,
18        intake_roller,
19    )

Return a startEnd command that runs the intake roller while held.

def run_hopper_while_active(hopper):
22def run_hopper_while_active(hopper):
23    """Return a startEnd command that runs the hopper while the trigger is active."""
24    return commands2.cmd.startEnd(
25        lambda: hopper.setPower(consts.HopperConstants.defaultPower),
26        hopper.stop,
27        hopper,
28    )

Return a startEnd command that runs the hopper while the trigger is active.

def run_hopper_and_feed(hopper, feed):
31def run_hopper_and_feed(hopper, feed):
32    """Return a command that runs hopper at 50% and feed at 60% while held."""
33    def _start():
34        hopper.setPower(consts.HopperConstants.defaultPower)
35        feed.setPower(0.8)
36
37    def _end():
38        hopper.stop()
39        feed.stop()
40
41    return commands2.cmd.startEnd(_start, _end, hopper, feed)

Return a command that runs hopper at 50% and feed at 60% while held.