Skip to content

Engineering/DefaultUnderway.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#   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.

mission DefaultUnderway {
  arguments {
    ElapsedSinceDefaultStarted = 0 minute

    Speed = 0.8 meter_per_second
      """
      Speed of the vehicle. Arg must change in mission script to be used as Default!
      """

    ElevatorHoldAngle = -3 degree
      """
      Elevator angle to hold when the vehicle is on the surface. Arg must change in mission script to be used as Default!
      """

    WaypointLat = 36.813 degree
      """
      Latitude of 'safe' waypoint to nav towards. Arg must change in mission script to be used as Default!
      """

    WaypointLon = -121.879 degree
      """
      Longitude of 'safe' waypoint to nav towards. Arg must change in mission script to be used as Default!
      """

    WptCircleRadius = 100 meter
      """
      Circle radius upon reaching 'safe' waypoint. Arg must change in mission script to be used as Default!
      """

    GPSInterval = 1 minute
      """
      How long to wait between GPS polls after each successful fix. Arg must change in mission script to be used as Default!
      """

    CommsInterval = 1 minute
      """
      How long to wait between comms cycles after each successful cycle. Arg must change in mission script to be used as Default!
      """

    CommsTimeout = 15 minute
      """
      Maximum time to wait for an Iridium comms cycle before retrying. Arg must change in mission script to be used as Default!
      """

    DefaultTimeout = 1 hour
      """
      Maximum duration of Default_underway before falling back to regular Default. Arg must change in mission script to be used as Default!
      """
  }

  timeout duration=DefaultTimeout {
    syslog fault "Default underway timed out after " + DefaultTimeout~minute
         + " minutes, falling back to normal Default"

    insert Default.tl
  }

  # Speed aggregate before the Wait because we'd really like to maintain way
  behavior Guidance:SetSpeed {
    run in parallel

    set speed = Speed
  }

  behavior Guidance:Wait {
    """
    Wait a moment to see if the scheduler starts a new mission before
    starting to actually run Default.
    """

    run in sequence

    set duration = 13 second
  }

  behavior Guidance:Circle {
    run in parallel

    set latitude = WaypointLat
    set longitude = WaypointLon
    set radius = WptCircleRadius
    set turnToPort = false
  }

  behavior Guidance:Pitch {
    run while (
      Universal:depth <= Control:VerticalControl.surfaceThreshold
    )

    set elevatorAngle = ElevatorHoldAngle
  }

  behavior Guidance:GoToSurface {
    run in progression
  }

  aggregate PollGPS {
    """
    Request a GPS fix periodically.
    """

    run in parallel

    aggregate {
      run in sequence repeat=9999

      readDatum id="Read_GPS" {
        timeout duration=P5M

        Universal:time_fix
      }

      behavior Guidance:Wait {
        run in sequence

        set duration = GPSInterval
      }
    }
  }

  aggregate PollComms {
    """
    Initiate an Iridium comms cycle periodically.
    """

    run in parallel

    aggregate {
      run in sequence repeat=9999

      assign in sequence ElapsedSinceDefaultStarted = elapsed ( Universal:mission_started )

      syslog important "Default underway has been running for " + ElapsedSinceDefaultStarted~minute

      readDatum id="Read_Iridium" {
        timeout duration=CommsTimeout

        Universal:platform_communications
      }

      behavior Guidance:Wait {
        run in sequence

        set duration = CommsInterval
      }
    }
  }

  behavior Guidance:Wait {
    run in sequence

    set duration = DefaultTimeout + CommsTimeout
  }
}