Skip to content

Commit 4a6126e

Browse files
check for intaking state machines and ballistics not operating before engaging
1 parent b082864 commit 4a6126e

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

controllers/algae_shooter.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
from components.shooter import ShooterComponent
99
from components.wrist import WristComponent
1010
from controllers.algae_measurement import AlgaeMeasurement
11+
from controllers.floor_intake import FloorIntake
12+
from controllers.reef_intake import ReefIntake
1113

1214

1315
class AlgaeShooter(StateMachine):
@@ -17,6 +19,8 @@ class AlgaeShooter(StateMachine):
1719
chassis: ChassisComponent
1820
wrist: WristComponent
1921
algae_measurement: AlgaeMeasurement
22+
floor_intake: FloorIntake
23+
reef_intake: ReefIntake
2024

2125
SHOOT_ANGLE = tunable(-50.0)
2226
TOP_SHOOT_SPEED = tunable(60.0)
@@ -27,20 +31,21 @@ def __init__(self) -> None:
2731
pass
2832

2933
def shoot(self) -> None:
34+
if self.floor_intake.is_executing:
35+
return
36+
if self.reef_intake.is_executing:
37+
return
38+
if (
39+
self.use_ballistics
40+
and not self.ballistics_component.is_in_range()
41+
or not self.ballistics_component.is_aligned()
42+
):
43+
return
3044
self.engage()
3145

3246
@state(first=True, must_finish=True)
33-
def preparing(self, initial_call: bool):
34-
if self.algae_measurement.is_executing:
35-
self.done()
36-
return
47+
def preparing(self):
3748
if self.use_ballistics:
38-
if initial_call and (
39-
not self.ballistics_component.is_in_range()
40-
or not self.ballistics_component.is_aligned()
41-
):
42-
self.done()
43-
return
4449
solution = self.ballistics_component.current_solution()
4550
self.wrist.tilt_to(solution.inclination)
4651
self.shooter_component.spin_flywheels(

0 commit comments

Comments
 (0)