Skip to content

Commit 7956a1c

Browse files
committed
add cycle counter var to start getting loggable timings for cycle breakdown
1 parent aaf30b9 commit 7956a1c

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

components/injector.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class InjectorComponent:
1919
INJECTOR_RPS_TOLERANCE = 0.5
2020
INJECTOR_MAX_ACCEL = 0.5
2121

22+
cycle_counter = tunable(0)
23+
cycle_segment = tunable("intaking")
24+
2225
def __init__(self) -> None:
2326
self.algae_limit_switch = DigitalInput(DioChannel.ALGAE_INTAKE_SWITCH)
2427

@@ -55,6 +58,14 @@ def __init__(self) -> None:
5558

5659
def on_enable(self) -> None:
5760
self.has_seen_algae = False
61+
self.cycle_counter = 0
62+
63+
def increment_segment(self) -> None:
64+
if self.cycle_segment == "intaking":
65+
self.cycle_segment = "shooting"
66+
else:
67+
self.cycle_segment = "intaking"
68+
self.cycle_counter += 1
5869

5970
@feedback
6071
def _algae_limit_switch_pressed(self) -> bool:

controllers/algae_shooter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ def preparing(self):
6767
self.next_state(self.shooting)
6868

6969
@timed_state(duration=0.2, must_finish=True)
70-
def shooting(self) -> None:
70+
def shooting(self, initial_call: bool) -> None:
71+
if initial_call:
72+
self.injector_component.increment_segment()
73+
7174
if self.use_ballistics:
7275
solution = self.ballistics_component.current_solution()
7376
self.shooter_component.spin_flywheels(

controllers/floor_intake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ def intake(self) -> None:
2828
@state(first=True, must_finish=True)
2929
def intaking(self):
3030
if self.injector_component.has_algae():
31+
self.injector_component.increment_segment()
3132
self.done()
3233
return
3334

controllers/reef_intake.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def safing(self, initial_call: bool):
113113
self.chassis.limit_to_positive_longitudinal_velocity()
114114

115115
if distance >= self.RETREAT_DISTANCE:
116+
self.injector_component.increment_segment()
116117
self.done()
117118

118119
def done(self) -> None:

0 commit comments

Comments
 (0)