Skip to content

Commit

Permalink
feat: Schedule clean cycle independently of bead runs
Browse files Browse the repository at this point in the history
  • Loading branch information
figuernd committed Jul 3, 2024
1 parent e760383 commit c65027f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion configs/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ arm_ifcb:
ifcb_maintenance:
# Interval at which we run a cartridge debubble, necessary when IFCB on its side
cartridge_debubble_interval: 0 # minutes, 0 = never
# Interval at which we run a bead sample for maintenance
# Interval at which we run a biocide and bleach
clean_interval: 1440 # minutes, 0 = never
# Interval at which we run a debubble and bead sample. Make this a multiple of
# the clean interval if you want a clean after each bead sample.
bead_interval: 1440 # minutes, 0 = never

ctd_topic: '/arm_ifcb/ctd/depth'
Expand Down
11 changes: 10 additions & 1 deletion src/phyto_arm/src/ifcb_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class IFCBState:

last_cart_debub_time = None
last_bead_time = None
last_clean_time = None

state = IFCBState()

Expand Down Expand Up @@ -108,9 +109,16 @@ def run_sample_routines(goal):
rospy.loginfo('Will run beads this round')
playlist.append((ConductorStates.IFCB_DEBUBBLE, 'debubble'))
playlist.append((ConductorStates.IFCB_BEADS, 'beads'))
state.last_bead_time = rospy.Time.now()

# Determine if it's time to run a clean
clean_interval = rospy.Duration(60*rospy.get_param('ifcb_maintenance/clean_interval'))
run_clean = not math.isclose(clean_interval.to_sec(), 0.0) # disabled
if run_clean and rospy.Time.now() - state.last_clean_time > clean_interval:
rospy.loginfo('Will run biocide and bleach this round')
playlist.append((ConductorStates.IFCB_BIOCIDE, 'biocide'))
playlist.append((ConductorStates.IFCB_BLEACH, 'bleach'))
state.last_bead_time = rospy.Time.now()
state.last_clean_time = rospy.Time.now()

# Always run a debubble and sample
playlist.append((ConductorStates.IFCB_DEBUBBLE, 'debubble'))
Expand Down Expand Up @@ -164,6 +172,7 @@ def main():
# we don't run it every startup and potentially waste time or bead supply.
state.last_cart_debub_time = rospy.Time.now()
state.last_bead_time = rospy.Time.now()
state.last_clean_time = rospy.Time.now()

rospy.spin()

Expand Down

0 comments on commit c65027f

Please sign in to comment.