Canon esp trianguloid.xml

Page auto-generated from XML file.

Failure

The generated TethysL source could not be parsed, likely due to source XML not being well-formed.

Below is the compile error at the TethysL level, as well as the source XML.

The TethysL file name shown below does not necessarily indicate the file exists, but hints about the actual corresponding .xml file.

Syntax error:
    --> lrauv-application/Missions/Science/canon_esp_trianguloid.xml:391:7
     | 
 387 | 
 388 |       assign in sequence  ElapsedSinceLastSampleStart = 0
 389 |       # Configure sampling sequance
 390 | 
 391 |       assign in sequence  Sample:SampleCANONSampler = SampleCANONSampler
     |       ^^^^^^
 392 |       assign in sequence  Sample:CANONSamplerDelay = CANONSamplerDelay
 393 |       assign in sequence  Sample:ESPCartridgeType = CartridgeType
 394 |       assign in sequence  Sample:SampleESP = SampleESP
 395 |       # Trigger sampling sequance
     | 
Unexpected: `assign`
Expecting: 'unit' <<<<
  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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
mission canon_esp_trianguloid {
  """
  This mission navigates to the CANON trianguloid waypoints and sets the
  max depth for each leg. The mission can (re)start at any point within
  this trajectory by adjusting the `leg` parameter as needed. Samples are
  triggered on a clock every SampleInterval.
  """
  # Almost every mission should start with an overall timeout and a NeedCommsTime.

  arguments {
    MissionTimeout = 42 hour
      """
      Maximum duration of mission
      """

    NeedCommsTime = 120 minute
      """
      How often to surface for commumications
      """

    # You probably need to change these.

    leg = 1 count
      """
      Leg to start at (default is start at leg 1). leg 1: C1, 40m leg 2: C1 -
      M1 Bypass 01, 50m leg 3: M1 Bypass 01 - Soquel Monterey Junction 01, 50m
      leg 4: Soquel Monterey Junction 01 - WG near MARS, 50m leg 5: WG near
      MARS - WG near Mid 1, 50m leg 6: WG near Mid 1 - M1 Bypass 01, 50m leg
      7: M1 Bypass 01 - C1, 50m leg 8: C1 - ?, 50m (spare wp)
      """

    SampleInterval = 2 hour
      """
      ESP sampling interval. Must be longer than the duration of a single ESP
      sample.
      """

    FirstSampleTimeOffset = 10 minute
      """
      When true, the mission will acquire and ESP sample at the start of the
      mission. When false, the mission will wait for the SampleInterval before
      acquiring the first sample.
      """

    SampleESP = true
      """
      When true, aqurie an ESP sample.
      """

    CartridgeType = -6 count
      """
      Specifies ESP cartridge type code (defaults to archive_bac: -6)
      """

    SampleCANONSampler = false
      """
      When true, aqurie a CANON Sampler water sample.
      """

    CANONSamplerDelay = 10 minute
      """
      How long to delay a CANON Sampler sample after an ESP sample is
      intiated.
      """

    SampleTimeout = 3 hour
      """
      Max time duration allowed for a single sample.
      """

    Lat1 = 36.797 degree
      """
      Latitude of waypoint 1 (default: C1).
      """

    Lon1 = -121.847 degree
      """
      Longitude of waypoint 1 (default: C1).
      """

    Lat2 = 36.754 degree
      """
      Latitude of waypoint 2 (default: M1 Bypass 01).
      """

    Lon2 = -122.0155 degree
      """
      Longitude of waypoint 2 (default: M1 Bypass 01).
      """

    Lat3 = 36.7825 degree
      """
      Latitude of waypoint 3 (default: Soquel Monterey Junction 01).
      """

    Lon3 = -122.018 degree
      """
      Longitude of waypoint 3 (default: Soquel Monterey Junction 01).
      """

    Lat4 = 36.7117 degree
      """
      Latitude of waypoint 4 (default: WG near MARS).
      """

    Lon4 = -122.1919 degree
      """
      Longitude of waypoint 4 (default: WG near MARS).
      """

    Lat5 = 36.6978 degree
      """
      Latitude of waypoint 5 (default: WG near Mid 1).
      """

    Lon5 = -122.0562 degree
      """
      Longitude of waypoint 5 (default: WG near Mid 1).
      """

    Lat6 = 36.754 degree
      """
      Latitude of waypoint 6 (default: M1 Bypass 01).
      """

    Lon6 = -122.0155 degree
      """
      Longitude of waypoint 6 (default: M1 Bypass 01).
      """

    Lat7 = 36.797 degree
      """
      Latitude of waypoint 7 (default: C1).
      """

    Lon7 = -121.847 degree
      """
      Longitude of waypoint 7 (default: C1).
      """

    Lat8 = NaN degree
      """
      Latitude of waypoint 8 (spare).
      """

    Lon8 = NaN degree
      """
      Longitude of waypoint 8 (spare).
      """

    Speed = 1 meter_per_second
      """
      Vehicle speed for the entire mission.
      """

    YoYoMinDepth = 5 meter
      """
      Minimum YoYo depth for the entire mission.
      """

    YoYoMaxDepth1 = 40 meter
      """
      Maximum YoYo depth during leg 1.
      """

    YoYoMaxDepth2 = 50 meter
      """
      Maximum YoYo depth during leg 2.
      """

    YoYoMaxDepth3 = 50 meter
      """
      Maximum YoYo depth during leg 3.
      """

    YoYoMaxDepth4 = 50 meter
      """
      Maximum YoYo depth during leg 4.
      """

    YoYoMaxDepth5 = 50 meter
      """
      Maximum YoYo depth during leg 5.
      """

    YoYoMaxDepth6 = 50 meter
      """
      Maximum YoYo depth during leg 6.
      """

    YoYoMaxDepth7 = 50 meter
      """
      Maximum YoYo depth during leg 7.
      """

    YoYoMaxDepth8 = 50 meter
      """
      Maximum YoYo depth during leg 8.
      """

    YoYoMinAltitude = 9 meter
      """
      Minimum altitude while performing the YoYo behavior (for
      bottom-terminated YoYos).
      """

    YoYoUpPitch = 20 degree
      """
      Vehicle up pitch while performing the YoYo behavior.
      """

    YoYoDownPitch = -20 degree
      """
      Vehicle down pitch while performing the YoYo behavior.
      """

    # You are even less likely to need to change these.

    CaptureRadius = NaN meter
      """
      Waypoint capture radiues.
      """

    MinAltitude = 5 meter
      """
      Minimum height above the sea floor for the entire mission.
      """

    MaxDepth = 110 meter
      """
      Maximum depth for the entire mission.
      """

    MinOffshore = 2 kilometer
      """
      Minimum offshore distance for the entire mission.
      """

  }

  output {
    ElapsedSinceLastSampleStart = 0 minute
      """
      Mission variable (don't change). The mission sets this variable to reset
      the ESP sample timer.
      """

    ElapsedTime = 0 hour
      """
      Mission variable (don't change). The mission sets this variable to reset
      the ESP sample timer.
      """

    SampleInProgress = false
      """
      Mission variable (don't change). The mission sets this variable to while
      sampling is in progress.
      """

    FirstSample = false
      """
      Mission variable (don't change). The mission sets this variable to when
      it's time to take the first sample.
      """

  }

  # Missions should almost always start with a timeout

  timeout duration=MissionTimeout
  insert Insert/Science.xml {

    """
    Most missions will run the science sensors. If you don't place this
    aggregate above NeedComms, science instruments get turned off on the
    last upcast and while floating on the surface.
    """

  }


  # Most missions should use the NeedComms aggregate.

  insert Insert/NeedComms.xml id="NeedComms"

  assign in sequence  NeedComms:DiveInterval = NeedCommsTime
  # Missions should almost always start with standard safety envelopes;
  #    most missions should not expose the parameters of these envelopes.

  insert Insert/StandardEnvelopes.xml

  assign in sequence  StandardEnvelopes:MinAltitude = MinAltitude
  assign in sequence  StandardEnvelopes:MaxDepth = MaxDepth
  assign in sequence  StandardEnvelopes:MinOffshore = MinOffshore
  assign in sequence  StandardEnvelopes:MaxDepth = MaxDepth
  assign in sequence  StandardEnvelopes:MinOffshore = MinOffshore
  # Sampling directives

  aggregate CheckSamplingSettings {
    run in sequence
    syslog info "Checking sampling settings."
    aggregate CheckESP {
      run when ( SampleESP and not ( Science:ESPComponent.loadAtStartup ) )
      syslog critical "Cannot service ESP sample request. ESPComponent is not loaded."
    }

    aggregate CheckCANONSampler {
      run when ( SampleCANONSampler and not ( Science:CANONSampler.loadAtStartup ) )
      syslog critical "Cannot service CANONSampler water sample request. CANONSampler component is not loaded."
    }

  }

  insert Insert/Sample.xml {

    redefineArg SampleTimeout = SampleTimeout

  }


  # Automatically cycle logs every 24 hours

  aggregate CycleLogs {
    run in parallel
    aggregate {
      run in sequence
      behavior Guidance:Wait  {

        run in sequence


        set Guidance:Wait.duration = 24 hour

      }


      syslog important "Restarting logs."
      behavior Guidance:Execute  {

        run in sequence


        set Guidance:Execute.command = "restart logs"

      }


    }

  }

  # Acquire ESP sample every SampleInterval

  aggregate SampleTimer {
    run while ( FirstSample and SampleInProgress or elapsed ( ElapsedSinceLastSampleStart ) > SampleInterval
    )
    aggregate AcquireSample {
      run in sequence
      assign in sequence  ElapsedTime = elapsed ( ElapsedSinceLastSampleStart )
      syslog important "Pre-sample comms. Elapsed time since last water sample: " + ElapsedTime~hour
      # Surface for comms before initiating the sample sequence

      call id="PreSampleComms" refId="NeedComms"
      # Set the surface comms interval to the sample timeout to avoid interruptions while sampling

      assign in sequence  NeedComms:DiveInterval = SampleTimeout
      aggregate WaitForDepth {
        run in sequence
        break if ( Universal:depth  >= YoYoMinDepth )
        syslog info "Waiting to achieve min depth of " + YoYoMinDepth~meter
        behavior Guidance:Wait  {

          run in sequence


          set Guidance:Wait.duration = SampleTimeout

        }


      }

      # Indicate a sample is in progress

      assign in sequence  SampleInProgress = true
      # This assignment restarts the sample timer

      assign in sequence  ElapsedSinceLastSampleStart = 0
      # Configure sampling sequance

      assign in sequence  Sample:SampleCANONSampler = SampleCANONSampler
      assign in sequence  Sample:CANONSamplerDelay = CANONSamplerDelay
      assign in sequence  Sample:ESPCartridgeType = CartridgeType
      assign in sequence  Sample:SampleESP = SampleESP
      # Trigger sampling sequance

      call id="TriggerSample" refId="Sample"
      # Surface for comms after the sampling sequence completes

      call id="PostSampleComms" refId="NeedComms"
      # Reinstate nominal surface comms interval

      assign in sequence  NeedComms:DiveInterval = NeedCommsTime
      assign in sequence  SampleInProgress = false
    }

  }

  call id="StartingMission" refId="NeedComms"
  # Many missions will keep mass position and buoyancy volume fixed at defaults.

  behavior Guidance:Pitch  {

    run in parallel


    set Guidance:Pitch.massPosition = Control:VerticalControl.massDefault

  }


  behavior Guidance:Buoyancy  {

    run in parallel


    set Guidance:Buoyancy.position = Control:VerticalControl.buoyancyNeutral

  }


  behavior Guidance:SetSpeed  {

    run in parallel


    set Guidance:SetSpeed.speed = Speed

  }


  behavior Guidance:DepthEnvelope  {
      """
    Another depth envelope for the YoYo behavior. This envelope should
    fall within the limits of the standard safety envelopes in
    Insert/StandardEnvelopes.xml in order to avoid commanding high pitch
    angles for depth-terminated YoYos.
    """
    run in parallel



    set Guidance:DepthEnvelope.minDepth = YoYoMinDepth

    set Guidance:DepthEnvelope.downPitch = YoYoDownPitch

    set Guidance:DepthEnvelope.upPitch = YoYoUpPitch

  }


  behavior Guidance:AltitudeEnvelope  {
      """
    Another altitude envelope for the YoYo behavior. This envelope
    should fall within the limits of the standard safety envelopes in
    Insert/StandardEnvelopes.xml in order to avoid commanding high pitch
    angles for bottom-terminated YoYos.
    """
    run in parallel



    set Guidance:AltitudeEnvelope.minAltitude = YoYoMinAltitude

    set Guidance:AltitudeEnvelope.upPitch = YoYoUpPitch

  }


  behavior Guidance:YoYo  {

    run in parallel


    set Guidance:YoYo.downPitch = YoYoDownPitch

    set Guidance:YoYo.upPitch = YoYoUpPitch

  }


  aggregate SetWaypointsPerLegParameter {
    """
    The following Leg2-5 aggregates adjust the Lat[] and Lon[] variables
    according to the `trajectory` parameter:
    """
    run in sequence
    aggregate Leg2 {
      run in sequence
      break if ( leg <= 1 count )
      assign in sequence  Lat1 = NaN degree
      assign in sequence  Lon1 = NaN degree
    }

    aggregate Leg3 {
      run in sequence
      break if ( leg <= 2 count )
      assign in sequence  Lat2 = NaN degree
      assign in sequence  Lon2 = NaN degree
    }

    aggregate Leg4 {
      run in sequence
      break if ( leg <= 3 count )
      assign in sequence  Lat3 = NaN degree
      assign in sequence  Lon3 = NaN degree
    }

    aggregate Leg5 {
      run in sequence
      break if ( leg <= 4 count )
      assign in sequence  Lat4 = NaN degree
      assign in sequence  Lon4 = NaN degree
    }

    aggregate Leg6 {
      run in sequence
      break if ( leg <= 5 count )
      assign in sequence  Lat5 = NaN degree
      assign in sequence  Lon5 = NaN degree
    }

    aggregate Leg7 {
      run in sequence
      break if ( leg <= 6 count )
      assign in sequence  Lat6 = NaN degree
      assign in sequence  Lon6 = NaN degree
    }

    aggregate Leg8 {
      run in sequence
      break if ( leg <= 7 count )
      assign in sequence  Lat7 = NaN degree
      assign in sequence  Lon7 = NaN degree
    }

  }

  aggregate Lap {
    run in sequence
    syslog important "Starting Lap"
    syslog important "Lat[1] = " + Lat1~degree + " Lon[1] = " + Lon1~degree
    syslog important "Lat[2] = " + Lat2~degree + " Lon[2] = " + Lon2~degree
    syslog important "Lat[3] = " + Lat3~degree + " Lon[3] = " + Lon3~degree
    syslog important "Lat[4] = " + Lat4~degree + " Lon[4] = " + Lon4~degree
    syslog important "Lat[5] = " + Lat5~degree + " Lon[5] = " + Lon5~degree
    syslog important "Lat[6] = " + Lat6~degree + " Lon[6] = " + Lon6~degree
    syslog important "Lat[7] = " + Lat7~degree + " Lon[7] = " + Lon7~degree
    syslog important "Lat[8] = " + Lat8~degree + " Lon[8] = " + Lon8~degree
    # Kick off the first ESP sample on mission start?

    aggregate SampleOnStart {
      run in sequence
      run when ( not ( FirstSample ) and elapsed ( ElapsedSinceLastSampleStart ) > FirstSampleTimeOffset )
      # Start the first ESP sample.

      syslog important "Acquiring first sample."
      assign in sequence  SampleInProgress = true
      assign in sequence  FirstSample = true
    }

    # The following aggregates dispatch the waypoints behaviors

    aggregate Wpt1 {
      run in sequence
      syslog important "Navigating to box start WP. YoYoMaxDepth:" + YoYoMaxDepth1~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth1

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat1

        set Guidance:Waypoint.longitude = Lon1

      }


    }

    aggregate Wpt2 {
      run in sequence
      syslog important "Navigating to WP2. YoYoMaxDepth: " + YoYoMaxDepth2~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth2

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat2

        set Guidance:Waypoint.longitude = Lon2

      }


    }

    aggregate Wpt3 {
      run in sequence
      syslog important "Navigating to WP3. YoYoMaxDepth: " + YoYoMaxDepth3~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth3

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat3

        set Guidance:Waypoint.longitude = Lon3

      }


    }

    aggregate Wpt4 {
      run in sequence
      syslog important "Navigating to WP4. YoYoMaxDepth: " + YoYoMaxDepth4~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth4

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat4

        set Guidance:Waypoint.longitude = Lon4

      }


    }

    aggregate Wpt5 {
      run in sequence
      syslog important "Navigating to WP5. YoYoMaxDepth:" + YoYoMaxDepth5~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth5

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat5

        set Guidance:Waypoint.longitude = Lon5

      }


    }

    aggregate Wpt6 {
      run in sequence
      syslog important "Navigating to WP6. YoYoMaxDepth:" + YoYoMaxDepth6~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth6

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat6

        set Guidance:Waypoint.longitude = Lon6

      }


    }

    aggregate Wpt7 {
      run in sequence
      syslog important "Navigating to WP7. YoYoMaxDepth: " + YoYoMaxDepth7~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth7

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat7

        set Guidance:Waypoint.longitude = Lon7

      }


    }

    aggregate Wpt8 {
      run in sequence
      syslog important "Navigating to WP8. YoYoMaxDepth: " + YoYoMaxDepth8~meter
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth8

      }


      behavior Guidance:Waypoint  {

        run in sequence


        set Guidance:Waypoint.latitude = Lat8

        set Guidance:Waypoint.longitude = Lon8

      }


    }

    aggregate CircleWpt8 {
      run in sequence
      break if ( not ( SampleInProgress ) )
      syslog important "Circling at WP8 until sample is finished."
      behavior Guidance:DepthEnvelope  {



        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth8

      }


      aggregate CircleWrapper {
        run in sequence repeat=4096
        assign in parallel Control:HorizontalControl.kwpHeading = 0.010 radian_per_meter
        behavior Guidance:Circle  {

          run in sequence


          set Guidance:Circle.latitude = Lat8

          set Guidance:Circle.longitude = Lon8

          set Guidance:Circle.radius = 100 meter

          set Guidance:Circle.maxError = 10 meter

          set Guidance:Circle.turnToPort = false

        }


      }

    }

  }

}
  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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
<?xml version="1.0" encoding="UTF-8"?>
<Mission xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="Tethys"
    xmlns:Units="Tethys/Units"
    xmlns:Control="Tethys/Control"
    xmlns:Science="Tethys/Science"
    xmlns:Universal="Tethys/Universal"
    xmlns:Guidance="Tethys/Guidance"
    xsi:schemaLocation="Tethys http://okeanids.mbari.org/tethys/Xml/Tethys.xsd
                        Tethys/Units http://okeanids.mbari.org/tethys/Xml/Units.xsd
                        Tethys/Control http://okeanids.mbari.org/tethys/Xml/Control.xsd
                        Tethys/Science http://okeanids.mbari.org/tethys/Xml/Science.xsd
                        Tethys/Universal http://okeanids.mbari.org/tethys/Xml/Universal.xsd
                        Tethys/Guidance http://okeanids.mbari.org/tethys/Xml/Guidance.xsd"
    Id="canon_esp_trianguloid">

    <Description>
        This mission navigates to the CANON trianguloid waypoints and sets the
        max depth for each leg. The mission can (re)start at any point within
        this trajectory by adjusting the `leg` parameter as needed. Samples are
        triggered on a clock every SampleInterval.
    </Description>

<!-- Almost every mission should start with an overall timeout and a NeedCommsTime. -->

    <DefineArg Name="MissionTimeout"><Description>
        Maximum duration of mission
    </Description><Units:hour/><Value>42</Value></DefineArg>

    <DefineArg Name="NeedCommsTime"><Description>
        How often to surface for commumications
    </Description><Units:minute/><Value>120</Value></DefineArg>

<!-- You probably need to change these. -->

    <DefineArg Name="leg"><Description>
        Leg to start at (default is start at leg 1). leg 1: C1, 40m leg 2: C1 -
        M1 Bypass 01, 50m leg 3: M1 Bypass 01 - Soquel Monterey Junction 01, 50m
        leg 4: Soquel Monterey Junction 01 - WG near MARS, 50m leg 5: WG near
        MARS - WG near Mid 1, 50m leg 6: WG near Mid 1 - M1 Bypass 01, 50m leg
        7: M1 Bypass 01 - C1, 50m leg 8: C1 - ?, 50m (spare wp)
    </Description><Units:count/><Value>1</Value></DefineArg>

    <DefineArg Name="SampleInterval"><Description>
        ESP sampling interval. Must be longer than the duration of a single ESP
        sample.
    </Description><Units:hour/><Value>2</Value></DefineArg>

    <DefineArg Name="FirstSampleTimeOffset"><Description>
        When true, the mission will acquire and ESP sample at the start of the
        mission. When false, the mission will wait for the SampleInterval before
        acquiring the first sample.
    </Description><Units:minute/><Value>10</Value></DefineArg>

    <DefineArg Name="SampleESP"><Description>
        When true, aqurie an ESP sample.
    </Description><True/></DefineArg>

    <DefineArg Name="CartridgeType"><Description>
        Specifies ESP cartridge type code (defaults to archive_bac: -6)
    </Description><Units:count/><Value>-6</Value></DefineArg>

    <DefineArg Name="SampleCANONSampler"><Description>
        When true, aqurie a CANON Sampler water sample.
    </Description><False/></DefineArg>

    <DefineArg Name="CANONSamplerDelay"><Description>
        How long to delay a CANON Sampler sample after an ESP sample is
        intiated.
    </Description><Units:minute/><Value>10</Value></DefineArg>

    <DefineArg Name="SampleTimeout"><Description>
        Max time duration allowed for a single sample.
    </Description><Units:hour/><Value>3</Value></DefineArg>

    <DefineArg Name="Lat1"><Description>
        Latitude of waypoint 1 (default: C1).
    </Description><Units:degree/><Value>36.797</Value></DefineArg>

    <DefineArg Name="Lon1"><Description>
        Longitude of waypoint 1 (default: C1).
    </Description><Units:degree/><Value>-121.847</Value></DefineArg>

    <DefineArg Name="Lat2"><Description>
        Latitude of waypoint 2 (default: M1 Bypass 01).
    </Description><Units:degree/><Value>36.754</Value></DefineArg>

    <DefineArg Name="Lon2"><Description>
        Longitude of waypoint 2 (default: M1 Bypass 01).
    </Description><Units:degree/><Value>-122.0155</Value></DefineArg>

    <DefineArg Name="Lat3"><Description>
        Latitude of waypoint 3 (default: Soquel Monterey Junction 01).
    </Description><Units:degree/><Value>36.7825</Value></DefineArg>

    <DefineArg Name="Lon3"><Description>
        Longitude of waypoint 3 (default: Soquel Monterey Junction 01).
    </Description><Units:degree/><Value>-122.018</Value></DefineArg>

    <DefineArg Name="Lat4"><Description>
        Latitude of waypoint 4 (default: WG near MARS).
    </Description><Units:degree/><Value>36.7117</Value></DefineArg>

    <DefineArg Name="Lon4"><Description>
        Longitude of waypoint 4 (default: WG near MARS).
    </Description><Units:degree/><Value>-122.1919</Value></DefineArg>

    <DefineArg Name="Lat5"><Description>
        Latitude of waypoint 5 (default: WG near Mid 1).
    </Description><Units:degree/><Value>36.6978</Value></DefineArg>

    <DefineArg Name="Lon5"><Description>
        Longitude of waypoint 5 (default: WG near Mid 1).
    </Description><Units:degree/><Value>-122.0562</Value></DefineArg>

    <DefineArg Name="Lat6"><Description>
        Latitude of waypoint 6 (default: M1 Bypass 01).
    </Description><Units:degree/><Value>36.754</Value></DefineArg>

    <DefineArg Name="Lon6"><Description>
        Longitude of waypoint 6 (default: M1 Bypass 01).
    </Description><Units:degree/><Value>-122.0155</Value></DefineArg>

    <DefineArg Name="Lat7"><Description>
        Latitude of waypoint 7 (default: C1).
    </Description><Units:degree/><Value>36.797</Value></DefineArg>

    <DefineArg Name="Lon7"><Description>
        Longitude of waypoint 7 (default: C1).
    </Description><Units:degree/><Value>-121.847</Value></DefineArg>

    <DefineArg Name="Lat8"><Description>
        Latitude of waypoint 8 (spare).
    </Description><Units:degree/><Value>NaN</Value></DefineArg>

    <DefineArg Name="Lon8"><Description>
        Longitude of waypoint 8 (spare).
    </Description><Units:degree/><Value>NaN</Value></DefineArg>

    <DefineArg Name="Speed"><Description>
        Vehicle speed for the entire mission.
    </Description><Units:meter_per_second/><Value>1</Value></DefineArg>

    <DefineArg Name="YoYoMinDepth"><Description>
        Minimum YoYo depth for the entire mission.
    </Description><Units:meter/><Value>5</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth1"><Description>
        Maximum YoYo depth during leg 1.
    </Description><Units:meter/><Value>40</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth2"><Description>
        Maximum YoYo depth during leg 2.
    </Description><Units:meter/><Value>50</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth3"><Description>
        Maximum YoYo depth during leg 3.
    </Description><Units:meter/><Value>50</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth4"><Description>
        Maximum YoYo depth during leg 4.
    </Description><Units:meter/><Value>50</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth5"><Description>
        Maximum YoYo depth during leg 5.
    </Description><Units:meter/><Value>50</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth6"><Description>
        Maximum YoYo depth during leg 6.
    </Description><Units:meter/><Value>50</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth7"><Description>
        Maximum YoYo depth during leg 7.
    </Description><Units:meter/><Value>50</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth8"><Description>
        Maximum YoYo depth during leg 8.
    </Description><Units:meter/><Value>50</Value></DefineArg>

    <DefineArg Name="YoYoMinAltitude"><Description>
        Minimum altitude while performing the YoYo behavior (for
        bottom-terminated YoYos).
    </Description><Units:meter/><Value>9</Value></DefineArg>

    <DefineArg Name="YoYoUpPitch"><Description>
        Vehicle up pitch while performing the YoYo behavior.
    </Description><Units:degree/><Value>20</Value></DefineArg>

    <DefineArg Name="YoYoDownPitch"><Description>
        Vehicle down pitch while performing the YoYo behavior.
    </Description><Units:degree/><Value>-20</Value></DefineArg>

<!-- You are even less likely to need to change these. -->

    <DefineArg Name="CaptureRadius"><Description>
        Waypoint capture radiues.
    </Description><Units:meter/><Value>NaN</Value></DefineArg>

    <DefineArg Name="MinAltitude"><Description>
        Minimum height above the sea floor for the entire mission.
    </Description><Units:meter/><Value>5</Value></DefineArg>

    <DefineArg Name="MaxDepth"><Description>
        Maximum depth for the entire mission.
    </Description><Units:meter/><Value>110</Value></DefineArg>

    <DefineArg Name="MinOffshore"><Description>
        Minimum offshore distance for the entire mission.
    </Description><Units:kilometer/><Value>2</Value></DefineArg>

    <DefineOutput Name="ElapsedSinceLastSampleStart"><Description>
        Mission variable (don't change). The mission sets this variable to reset
        the ESP sample timer.
    </Description><Units:minute/><Value>0</Value></DefineOutput>

    <DefineOutput Name="ElapsedTime"><Description>
        Mission variable (don't change). The mission sets this variable to reset
        the ESP sample timer.
    </Description><Units:hour/><Value>0</Value></DefineOutput>

    <DefineOutput Name="SampleInProgress"><Description>
        Mission variable (don't change). The mission sets this variable to while
        sampling is in progress.
    </Description><False/></DefineOutput>

    <DefineOutput Name="FirstSample"><Description>
        Mission variable (don't change). The mission sets this variable to when
        it's time to take the first sample.
    </Description><False/></DefineOutput>

<!-- Missions should almost always start with a timeout -->

    <Timeout Duration="MissionTimeout"/>

    <Insert Filename="Insert/Science.xml">
        <Description>
            Most missions will run the science sensors. If you don't place this
            aggregate above NeedComms, science instruments get turned off on the
            last upcast and while floating on the surface.
        </Description>
    </Insert>

<!-- Most missions should use the NeedComms aggregate. -->

    <Insert Filename="Insert/NeedComms.xml" Id="NeedComms"/>

    <Assign><Sequence/><Arg Name="NeedComms:DiveInterval"/><Arg Name="NeedCommsTime"/></Assign>

<!-- Missions should almost always start with standard safety envelopes;
    most missions should not expose the parameters of these envelopes.
    -->

    <Insert Filename="Insert/StandardEnvelopes.xml"/>

    <Assign><Sequence/><Arg Name="StandardEnvelopes:MinAltitude"/><Arg Name="MinAltitude"/></Assign>

    <Assign><Sequence/><Arg Name="StandardEnvelopes:MaxDepth"/><Arg Name="MaxDepth"/></Assign>

    <Assign><Sequence/><Arg Name="StandardEnvelopes:MinOffshore"/><Arg Name="MinOffshore"/></Assign>

    <Assign><Sequence/><Arg Name="StandardEnvelopes:MaxDepth"/><Arg Name="MaxDepth"/></Assign>

    <Assign><Sequence/><Arg Name="StandardEnvelopes:MinOffshore"/><Arg Name="MinOffshore"/></Assign>

<!-- Sampling directives -->

    <Aggregate Id="CheckSamplingSettings">

        <Sequence/>

        <Syslog Severity="Info">Checking sampling settings.</Syslog>

        <Aggregate Id="CheckESP">

            <When>
                <Arg Name="SampleESP"/>
                <And><Not><Science:ESPComponent.loadAtStartup/></Not></And>
            </When>

            <Syslog Severity="Critical">Cannot service ESP sample request. ESPComponent is not loaded.</Syslog>

        </Aggregate>

        <Aggregate Id="CheckCANONSampler">

            <When>
                <Arg Name="SampleCANONSampler"/>
                <And><Not><Science:CANONSampler.loadAtStartup/></Not></And>
            </When>

            <Syslog Severity="Critical">Cannot service CANONSampler water sample request. CANONSampler component is not loaded.</Syslog>

        </Aggregate>

    </Aggregate>

    <Insert Filename="Insert/Sample.xml">
        <RedefineArg Name="SampleTimeout"><Arg Name="SampleTimeout"/></RedefineArg>
    </Insert>

<!-- Automatically cycle logs every 24 hours -->

    <Aggregate Id="CycleLogs">

        <Parallel/>

        <Aggregate>

            <Sequence/>

            <Guidance:Wait>
                <Sequence/>
                <Setting><Guidance:Wait.duration/><Units:hour/><Value>24</Value></Setting>
            </Guidance:Wait>

            <Syslog Severity="Important">Restarting logs.</Syslog>

            <Guidance:Execute>
                <Sequence/>
                <Setting><Guidance:Execute.command/><String>restart logs</String></Setting>
            </Guidance:Execute>

        </Aggregate>

    </Aggregate>

<!-- Acquire ESP sample every SampleInterval -->

    <Aggregate Id="SampleTimer">

        <While>
            <Arg Name="FirstSample"/>
            <And>
                <Arg Name="SampleInProgress"/>
                <Or><Elapsed><Arg Name="ElapsedSinceLastSampleStart"/></Elapsed><Gt><Arg Name="SampleInterval"/></Gt></Or>
            </And>
        </While>

        <Aggregate Id="AcquireSample">

            <Sequence/>

            <Assign><Sequence/><Arg Name="ElapsedTime"/><Elapsed><Arg Name="ElapsedSinceLastSampleStart"/></Elapsed></Assign>

            <Syslog Severity="Important">Pre-sample comms. Elapsed time since last water sample: <Arg Name="ElapsedTime"/><Units:hour/></Syslog>

<!-- Surface for comms before initiating the sample sequence -->

            <Call Id="PreSampleComms" RefId="NeedComms"/>

<!-- Set the surface comms interval to the sample timeout to avoid interruptions while sampling -->

            <Assign><Sequence/><Arg Name="NeedComms:DiveInterval"/><Arg Name="SampleTimeout"/></Assign>

            <Aggregate Id="WaitForDepth">

                <Sequence/>

                <Break>
                    <Universal:depth/>
                    <Ge><Arg Name="YoYoMinDepth"/></Ge>
                </Break>

                <Syslog Severity="Info">Waiting to achieve min depth of <Arg Name="YoYoMinDepth"/><Units:meter/></Syslog>

                <Guidance:Wait>
                    <Sequence/>
                    <Setting><Guidance:Wait.duration/><Arg Name="SampleTimeout"/></Setting>
                </Guidance:Wait>

            </Aggregate>

<!-- Indicate a sample is in progress -->

            <Assign><Sequence/><Arg Name="SampleInProgress"/><True/></Assign>

<!-- This assignment restarts the sample timer -->

            <Assign><Sequence/><Arg Name="ElapsedSinceLastSampleStart"/><Value>0</Value></Assign>

<!-- Configure sampling sequance -->

            <Assign><Sequence/><Arg Name="Sample:SampleCANONSampler"/><Arg Name="SampleCANONSampler"/></Assign>

            <Assign><Sequence/><Arg Name="Sample:CANONSamplerDelay"/><Arg Name="CANONSamplerDelay"/></Assign>

            <Assign><Sequence/><Arg Name="Sample:ESPCartridgeType"/><Arg Name="CartridgeType"/></Assign>

            <Assign><Sequence/><Arg Name="Sample:SampleESP"/><Arg Name="SampleESP"/></Assign>

<!-- Trigger sampling sequance -->

            <Call Id="TriggerSample" RefId="Sample"/>

<!-- Surface for comms after the sampling sequence completes -->

            <Call Id="PostSampleComms" RefId="NeedComms"/>

<!-- Reinstate nominal surface comms interval -->

            <Assign><Sequence/><Arg Name="NeedComms:DiveInterval"/><Arg Name="NeedCommsTime"/></Assign>

            <Assign><Sequence/><Arg Name="SampleInProgress"/><False/></Assign>

        </Aggregate>

    </Aggregate>

    <Call Id="StartingMission" RefId="NeedComms"/>

<!-- Many missions will keep mass position and buoyancy volume fixed at defaults. -->

    <Guidance:Pitch>
        <Parallel/>
        <Setting><Guidance:Pitch.massPosition/><Control:VerticalControl.massDefault/></Setting>
    </Guidance:Pitch>

    <Guidance:Buoyancy>
        <Parallel/>
        <Setting><Guidance:Buoyancy.position/><Control:VerticalControl.buoyancyNeutral/></Setting>
    </Guidance:Buoyancy>

    <Guidance:SetSpeed>
        <Parallel/>
        <Setting><Guidance:SetSpeed.speed/><Arg Name="Speed"/></Setting>
    </Guidance:SetSpeed>

    <Guidance:DepthEnvelope>
        <Description>
            Another depth envelope for the YoYo behavior. This envelope should
            fall within the limits of the standard safety envelopes in
            Insert/StandardEnvelopes.xml in order to avoid commanding high pitch
            angles for depth-terminated YoYos.
        </Description>
        <Parallel/>
        <Setting><Guidance:DepthEnvelope.minDepth/><Arg Name="YoYoMinDepth"/></Setting>
        <Setting><Guidance:DepthEnvelope.downPitch/><Arg Name="YoYoDownPitch"/></Setting>
        <Setting><Guidance:DepthEnvelope.upPitch/><Arg Name="YoYoUpPitch"/></Setting>
    </Guidance:DepthEnvelope>

    <Guidance:AltitudeEnvelope>
        <Description>
            Another altitude envelope for the YoYo behavior. This envelope
            should fall within the limits of the standard safety envelopes in
            Insert/StandardEnvelopes.xml in order to avoid commanding high pitch
            angles for bottom-terminated YoYos.
        </Description>
        <Parallel/>
        <Setting><Guidance:AltitudeEnvelope.minAltitude/><Arg Name="YoYoMinAltitude"/></Setting>
        <Setting><Guidance:AltitudeEnvelope.upPitch/><Arg Name="YoYoUpPitch"/></Setting>
    </Guidance:AltitudeEnvelope>

    <Guidance:YoYo>
        <Parallel/>
        <Setting><Guidance:YoYo.downPitch/><Arg Name="YoYoDownPitch"/></Setting>
        <Setting><Guidance:YoYo.upPitch/><Arg Name="YoYoUpPitch"/></Setting>
    </Guidance:YoYo>

    <Aggregate Id="SetWaypointsPerLegParameter">

        <Description>
            The following Leg2-5 aggregates adjust the Lat[] and Lon[] variables
            according to the `trajectory` parameter:
        </Description>

        <Sequence/>

        <Aggregate Id="Leg2">

            <Sequence/>

            <Break><Arg Name="leg"/>
                <Le><Units:count/><Value>1</Value></Le>
            </Break>

            <Assign><Sequence/><Arg Name="Lat1"/><Units:degree/><Value>NaN</Value></Assign>

            <Assign><Sequence/><Arg Name="Lon1"/><Units:degree/><Value>NaN</Value></Assign>

        </Aggregate>

        <Aggregate Id="Leg3">

            <Sequence/>

            <Break><Arg Name="leg"/>
                <Le><Units:count/><Value>2</Value></Le>
            </Break>

            <Assign><Sequence/><Arg Name="Lat2"/><Units:degree/><Value>NaN</Value></Assign>

            <Assign><Sequence/><Arg Name="Lon2"/><Units:degree/><Value>NaN</Value></Assign>

        </Aggregate>

        <Aggregate Id="Leg4">

            <Sequence/>

            <Break><Arg Name="leg"/>
                <Le><Units:count/><Value>3</Value></Le>
            </Break>

            <Assign><Sequence/><Arg Name="Lat3"/><Units:degree/><Value>NaN</Value></Assign>

            <Assign><Sequence/><Arg Name="Lon3"/><Units:degree/><Value>NaN</Value></Assign>

        </Aggregate>

        <Aggregate Id="Leg5">

            <Sequence/>

            <Break><Arg Name="leg"/>
                <Le><Units:count/><Value>4</Value></Le>
            </Break>

            <Assign><Sequence/><Arg Name="Lat4"/><Units:degree/><Value>NaN</Value></Assign>

            <Assign><Sequence/><Arg Name="Lon4"/><Units:degree/><Value>NaN</Value></Assign>

        </Aggregate>

        <Aggregate Id="Leg6">

            <Sequence/>

            <Break><Arg Name="leg"/>
                <Le><Units:count/><Value>5</Value></Le>
            </Break>

            <Assign><Sequence/><Arg Name="Lat5"/><Units:degree/><Value>NaN</Value></Assign>

            <Assign><Sequence/><Arg Name="Lon5"/><Units:degree/><Value>NaN</Value></Assign>

        </Aggregate>

        <Aggregate Id="Leg7">

            <Sequence/>

            <Break><Arg Name="leg"/>
                <Le><Units:count/><Value>6</Value></Le>
            </Break>

            <Assign><Sequence/><Arg Name="Lat6"/><Units:degree/><Value>NaN</Value></Assign>

            <Assign><Sequence/><Arg Name="Lon6"/><Units:degree/><Value>NaN</Value></Assign>

        </Aggregate>

        <Aggregate Id="Leg8">

            <Sequence/>

            <Break><Arg Name="leg"/>
                <Le><Units:count/><Value>7</Value></Le>
            </Break>

            <Assign><Sequence/><Arg Name="Lat7"/><Units:degree/><Value>NaN</Value></Assign>

            <Assign><Sequence/><Arg Name="Lon7"/><Units:degree/><Value>NaN</Value></Assign>

        </Aggregate>

    </Aggregate>

    <Aggregate Id="Lap">

        <Sequence/>

        <Syslog Severity="Important">Starting Lap</Syslog>

        <Syslog Severity="Important">Lat[1] = <Arg Name="Lat1"/><Units:degree/> Lon[1] = <Arg Name="Lon1"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[2] = <Arg Name="Lat2"/><Units:degree/> Lon[2] = <Arg Name="Lon2"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[3] = <Arg Name="Lat3"/><Units:degree/> Lon[3] = <Arg Name="Lon3"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[4] = <Arg Name="Lat4"/><Units:degree/> Lon[4] = <Arg Name="Lon4"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[5] = <Arg Name="Lat5"/><Units:degree/> Lon[5] = <Arg Name="Lon5"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[6] = <Arg Name="Lat6"/><Units:degree/> Lon[6] = <Arg Name="Lon6"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[7] = <Arg Name="Lat7"/><Units:degree/> Lon[7] = <Arg Name="Lon7"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[8] = <Arg Name="Lat8"/><Units:degree/> Lon[8] = <Arg Name="Lon8"/><Units:degree/></Syslog>

<!-- Kick off the first ESP sample on mission start? -->

        <Aggregate Id="SampleOnStart">

            <Sequence/>

            <When>
                <Not><Arg Name="FirstSample"/></Not>
                <And>
                    <Elapsed><Arg Name="ElapsedSinceLastSampleStart"/></Elapsed><Gt><Arg Name="FirstSampleTimeOffset"/></Gt>
                </And>
            </When>

<!-- Start the first ESP sample. -->
            <Syslog Severity="Important">Acquiring first sample.</Syslog>

            <Assign><Sequence/><Arg Name="SampleInProgress"/><True/></Assign>

            <Assign><Sequence/><Arg Name="FirstSample"/><True/></Assign>

        </Aggregate>

<!-- The following aggregates dispatch the waypoints behaviors -->

        <Aggregate Id="Wpt1">

            <Sequence/>

            <Syslog Severity="Important">Navigating to box start WP. YoYoMaxDepth:<Arg Name="YoYoMaxDepth1"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth1"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat1"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon1"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt2">

            <Sequence/>

            <Syslog Severity="Important">Navigating to WP2. YoYoMaxDepth: <Arg Name="YoYoMaxDepth2"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth2"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat2"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon2"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt3">

            <Sequence/>

            <Syslog Severity="Important">Navigating to WP3. YoYoMaxDepth: <Arg Name="YoYoMaxDepth3"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth3"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat3"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon3"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt4">

            <Sequence/>

            <Syslog Severity="Important">Navigating to WP4. YoYoMaxDepth: <Arg Name="YoYoMaxDepth4"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth4"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat4"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon4"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt5">

            <Sequence/>

            <Syslog Severity="Important">Navigating to WP5. YoYoMaxDepth:<Arg Name="YoYoMaxDepth5"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth5"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat5"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon5"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt6">

            <Sequence/>

            <Syslog Severity="Important">Navigating to WP6. YoYoMaxDepth:<Arg Name="YoYoMaxDepth6"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth6"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat6"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon6"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt7">

            <Sequence/>

            <Syslog Severity="Important">Navigating to WP7. YoYoMaxDepth: <Arg Name="YoYoMaxDepth7"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth7"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat7"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon7"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt8">

            <Sequence/>

            <Syslog Severity="Important">Navigating to WP8. YoYoMaxDepth: <Arg Name="YoYoMaxDepth8"/><Units:meter/></Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth8"/></Setting>
            </Guidance:DepthEnvelope>

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat8"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon8"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="CircleWpt8">

            <Sequence/>

            <Break>
                <Not><Arg Name="SampleInProgress"/></Not>
            </Break>

            <Syslog Severity="Important">Circling at WP8 until sample is finished.</Syslog>

            <Guidance:DepthEnvelope>
                <Setting><Guidance:DepthEnvelope.maxDepth/><Arg Name="YoYoMaxDepth8"/></Setting>
            </Guidance:DepthEnvelope>

            <Aggregate Id="CircleWrapper">

                <Sequence Repeat="4096"/>

                <Assign><Parallel/><Control:HorizontalControl.kwpHeading/><Units:radian_per_meter/><Value>0.010</Value></Assign>

                <Guidance:Circle>
                    <Sequence/>
                    <Setting><Guidance:Circle.latitude/><Arg Name="Lat8"/></Setting>
                    <Setting><Guidance:Circle.longitude/><Arg Name="Lon8"/></Setting>
                    <Setting><Guidance:Circle.radius/><Units:meter/><Value>100</Value></Setting>
                    <Setting><Guidance:Circle.maxError/><Units:meter/><Value>10</Value></Setting>
                    <Setting><Guidance:Circle.turnToPort/><False/></Setting>
                </Guidance:Circle>

            </Aggregate>

        </Aggregate>

    </Aggregate>

</Mission>