Skip to content

Commit

Permalink
Add a has_just_fired check that auto can poll
Browse files Browse the repository at this point in the history
  • Loading branch information
mlists committed Feb 2, 2024
1 parent ac2837e commit a5418e3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions controllers/shooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ class Shooter(StateMachine):
should_fire = will_reset_to(False)
SHOOTING_TIME_DURATION = 3

def __init__(self) -> None:
self.just_fired = False

def has_just_fired(self) -> bool:
return self.just_fired

def shoot(self) -> None:
"""Engage the state machine to attempt a shot, needs to be called repeatedly"""
self.should_fire = True
self.engage()

Expand All @@ -30,6 +37,7 @@ def update_ranging(self) -> None:
@default_state
def idle(self) -> None:
"""Run ranging whenever we are not doing anything else"""
self.just_fired = False
self.update_ranging()
if self.should_fire:
self.next_state("acquiring")
Expand Down Expand Up @@ -69,5 +77,6 @@ def shooting(self) -> None:

@state
def resetting(self) -> None:
self.just_fired = True
self.shooter_component.stop_injection()
self.done()

0 comments on commit a5418e3

Please sign in to comment.