Skip to content

Engineering/tritoncam_run_backseat_on_surface_circle_hotspot.tl

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#   Copyright (c) 2024 MBARI
#   MBARI Proprietary Information. Confidential. All Rights Reserved
#   Unauthorized copying or distribution of this file via any medium is strictly
#   prohibited.
#
#   WARNING - This file contains information whose export is restricted by the
#   Export Administration Act of 1979 (Title 50, U.S.C., App. 2401 et seq.), as
#   amended. Violations of these export laws are subject to severe civil and/or
#   criminal penalties.

# SURFACE BENCH TEST for the adaptive backseat (strategy 1 = circle_hotspot)

mission run_backseat_on_surface_circle_hotspot {
  arguments {
    ElapsedSinceMissionStarted = 0 minute

    # --- Backseat mission-driven config ---
    # Published to the slate as _.bs_* for the backseat to read once at startup
    PublishPeriod = 2 second
      """Re-publish period for the _.bs_* config below."""

    MinDepth = 10 meter
      """Absolute min of the frontseat-owned safety/search band. Published to the
         backseat as _.bs_min_depth_limit (cosmetic here — no diving on surface)."""

    MaxDepth = 60 meter
      """Absolute max of the frontseat-owned safety/search band. Published to the
         backseat as _.bs_max_depth_limit (cosmetic here — no diving on surface)."""

    Strategy = 1 count
      """Backseat strategy id (STRATEGY_IDS): 1=circle_hotspot."""

    BsSignalThreshold = 10 count
      """circle_hotspot signal_threshold: per-profile peak to mark a profile "high signal"."""

    BsThreshHighSignalCounts = 1 count
      """circle_hotspot thresh_high_signal_counts: consecutive high profiles -> enter circle."""

    BsThreshLowSignalCounts = 1 count
      """circle_hotspot thresh_low_signal_counts: consecutive low profiles -> back to transit."""

    BsMedianWindowSamples = 5 count
      """circle_hotspot median_window_samples: median-filter length."""

    BsMaWindowSeconds = 8 second
      """circle_hotspot ma_window_seconds: moving-average window."""
  }

  # Power the science payload.

  insert id="Science" Insert/Science.tl

  # Power the Backseat payload.

  insert Insert/BackseatDriver.tl

  assign in sequence BackseatDriver:EnableBackseat = true

  insert Insert/PowerOnly.tl

  # Run the backseat guidance so it processes on-surface.

  behavior Guidance:BackseatDriver {
    run in parallel
  }

  # --- Publish mission-driven config to the backseat (read once at startup) ---
  # Requires BackseatComponent. fullSlateAccess=1 on the frontseat.
  aggregate PublishBackseatParams {
    run when ( elapsed ( customUri "_.bs_strategy" ) > PublishPeriod )

    assign in sequence customUri "_.bs_strategy"                  = Strategy
    assign in sequence customUri "_.bs_min_depth_limit"           = MinDepth
    assign in sequence customUri "_.bs_max_depth_limit"           = MaxDepth
    assign in sequence customUri "_.bs_signal_threshold"          = BsSignalThreshold
    assign in sequence customUri "_.bs_thresh_high_signal_counts" = BsThreshHighSignalCounts
    assign in sequence customUri "_.bs_thresh_low_signal_counts"  = BsThreshLowSignalCounts
    assign in sequence customUri "_.bs_median_window_samples"     = BsMedianWindowSamples
    assign in sequence customUri "_.bs_ma_window_seconds"         = BsMaWindowSeconds
  }

  behavior Guidance:GoToSurface {
    run in progression
  }

  aggregate CheckIn {
    run in sequence repeat=288

    readDatum id="Read_GPS" {
      timeout duration=P5M

      Universal:time_fix
    }

    readDatum id="Read_Iridium" {
      timeout duration=P2H {
        behavior Guidance:Execute {
          run in sequence

          set command = "Burn on"
        }

        syslog critical "Dropped weight due to communications timeout."
      }

      Universal:platform_communications
    }

    behavior Guidance:Wait {
      run in sequence

      set duration = 5 minute
    }

    assign in sequence ElapsedSinceMissionStarted = elapsed ( Universal:mission_started )

    syslog important "run_backseat_on_surface mission has been running for "
         + ElapsedSinceMissionStarted~minute
  }

  syslog important "Restarting logs and run_backseat_on_surface_circle_hotspot mission."

  behavior Guidance:Execute {
    run in sequence

    set command = "restart logs"
  }
}