Canon esp bowtie.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/Deprecated/Science/canon_esp_bowtie.xml:468:7
     | 
 464 | 
 465 | 
 466 |       # Configure sampling sequance
 467 | 
 468 |       assign in sequence Sample:SampleCANONSampler = SampleCANONSampler
     |       ^^^^^^
 469 | 
 470 |       assign in sequence Sample:CANONSamplerDelay = CANONSamplerDelay
 471 | 
 472 |       assign in sequence Sample:ESPCartridgeType = CartridgeType
     | 
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
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
mission canon_esp_bowtie {
  """
  This mission cycles through the CANON Bowtie waypoints in the order: SE
  - NW - NE - SW - SE 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.
  """

  arguments {
    # Almost every mission should start with an overall timeout and a NeedCommsTime.

    MissionTimeout = 14 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: SE (to start
      position) leg 2: SE - CSE leg 3: CSE - CNW leg 4: CNW - NW leg 5: NW - N
      leg 6: N - NE leg 7: NE - CNE leg 8: CNE - CSW leg 9: CSW - SW leg 10:
      SW - S leg 11: S - SE leg 12: SE - ? (spare wp)
      """

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

    SampleInterval = 2 hour
      """
      ESP sampling interval. Must be longer than the duration of a single ESP
      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.
      """

    StartWithASample = true
      """
      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.
      """

    Lat1 = 36.7755 degree
      """
      Latitude of waypoint 1 (default: SE).
      """

    Lon1 = -121.825 degree
      """
      Longitude of waypoint 1 (default: SE).
      """

    Lat2 = 36.787825 degree
      """
      Latitude of waypoint 2 (default: CSE).
      """

    Lon2 = -121.841121 degree
      """
      Longitude of waypoint 2 (default: CSE).
      """

    Lat3 = 36.804417 degree
      """
      Latitude of waypoint 3 (default: CNW).
      """

    Lon3 = -121.862712 degree
      """
      Longitude of waypoint 3 (default: CNW).
      """

    Lat4 = 36.8219 degree
      """
      Latitude of waypoint 4 (default: NW).
      """

    Lon4 = -121.8856 degree
      """
      Longitude of waypoint 4 (default: NW).
      """

    Lat5 = 36.829608 degree
      """
      Latitude of waypoint 5 (default: N).
      """

    Lon5 = -121.853778 degree
      """
      Longitude of waypoint 5 (default: N).
      """

    Lat6 = 36.8315 degree
      """
      Latitude of waypoint 6 (default: NE).
      """

    Lon6 = -121.8457 degree
      """
      Longitude of waypoint 6 (default: NE).
      """

    Lat7 = 36.812109 degree
      """
      Latitude of waypoint 7 (default: CNE).
      """

    Lon7 = -121.851505 degree
      """
      Longitude of waypoint 7 (default: CNE).
      """

    Lat8 = 36.785431 degree
      """
      Latitude of waypoint 8 (default: CSW).
      """

    Lon8 = -121.859331 degree
      """
      Longitude of waypoint 8 (default: CSW).
      """

    Lat9 = 36.766 degree
      """
      Latitude of waypoint 9 (default: SW).
      """

    Lon9 = -121.8649 degree
      """
      Longitude of waypoint 9 (default: SW).
      """

    Lat10 = 36.769648 degree
      """
      Latitude of waypoint 10 (default: S).
      """

    Lon10 = -121.848834 degree
      """
      Longitude of waypoint 10 (default: S).
      """

    Lat11 = 36.7755 degree
      """
      Latitude of waypoint 11 (default: SE).
      """

    Lon11 = -121.825 degree
      """
      Longitude of waypoint 11 (default: SE).
      """

    Lat12 = NaN degree
      """
      Latitude of waypoint 12 (spare).
      """

    Lon12 = NaN degree
      """
      Longitude of waypoint 12 (spare).
      """

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

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

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

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

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

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

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

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

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

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

    YoYoMaxDepth9 = 65 meter
      """
      Maximum YoYo depth during leg 9.
      """

    YoYoMaxDepth10 = 50 meter
      """
      Maximum YoYo depth during leg 10.
      """

    YoYoMaxDepth11 = 20 meter
      """
      Maximum YoYo depth during leg 11.
      """

    YoYoMaxDepth12 = 20 meter
      """
      Maximum YoYo depth during leg 12.
      """

    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.
      """
  }

  # Missions should almost always start with a timeout

  timeout duration=MissionTimeout

  insert Insert/Science.tl {
    """
    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.tl 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.tl


  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 Deprecated/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 (
      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 ESP 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 #<No-Units?>


      # 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="PreSampleComms" 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.tl 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.tl 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 Leg9 {
      run in sequence

      break if (
        leg <= 8 count
      )

      assign in sequence Lat8 = NaN degree

      assign in sequence Lon8 = NaN degree
    }

    aggregate Leg10 {
      run in sequence

      break if (
        leg <= 9 count
      )

      assign in sequence Lat9 = NaN degree

      assign in sequence Lon9 = NaN degree
    }

    aggregate Leg11 {
      run in sequence

      break if (
        leg <= 10 count
      )

      assign in sequence Lat10 = NaN degree

      assign in sequence Lon10 = 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

    syslog important "Lat[9] = "
         + Lat9 ~ degree
         + " Lon[9] = "
         + Lon9 ~ degree

    syslog important "Lat[10] = "
         + Lat10 ~ degree
         + " Lon[10] = "
         + Lon10 ~ degree

    syslog important "Lat[11] = "
         + Lat11 ~ degree
         + " Lon[11] = "
         + Lon11 ~ degree

    syslog important "Lat[12] = "
         + Lat12 ~ degree
         + " Lon[12] = "
         + Lon12 ~ degree

    aggregate SampleOnStart {
      run in sequence

      break if (
        not ( StartWithASample )
      )

      # Kick off the first ESP sample.

      assign in sequence SampleInProgress = 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 Wpt9 {
      run in sequence

      syslog important "Navigating to WP9. YoYoMaxDepth: "
           + YoYoMaxDepth9 ~ meter

      behavior Guidance:DepthEnvelope {
        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth9
      }

      behavior Guidance:Waypoint {
        run in sequence
        set Guidance:Waypoint.latitude = Lat9
        set Guidance:Waypoint.longitude = Lon9
      }
    }

    aggregate Wpt10 {
      run in sequence

      syslog important "Navigating to WP10. YoYoMaxDepth: "
           + YoYoMaxDepth10 ~ meter

      behavior Guidance:DepthEnvelope {
        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth10
      }

      behavior Guidance:Waypoint {
        run in sequence
        set Guidance:Waypoint.latitude = Lat10
        set Guidance:Waypoint.longitude = Lon10
      }
    }

    aggregate Wpt11 {
      run in sequence

      syslog important "Navigating to WP11. YoYoMaxDepth: "
           + YoYoMaxDepth11 ~ meter

      behavior Guidance:DepthEnvelope {
        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth11
      }

      behavior Guidance:Waypoint {
        run in sequence
        set Guidance:Waypoint.latitude = Lat11
        set Guidance:Waypoint.longitude = Lon11
      }
    }

    aggregate Wpt12 {
      run in sequence

      syslog important "Navigating to WP12. YoYoMaxDepth: "
           + YoYoMaxDepth12 ~ meter

      behavior Guidance:DepthEnvelope {
        set Guidance:DepthEnvelope.maxDepth = YoYoMaxDepth12
      }

      behavior Guidance:Waypoint {
        run in sequence
        set Guidance:Waypoint.latitude = Lat12
        set Guidance:Waypoint.longitude = Lon12
      }
    }
  }
}
  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
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
<?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:Guidance="Tethys/Guidance"
         xmlns:Science="Tethys/Science"
         xmlns:Universal="Tethys/Universal"
         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_bowtie">

    <Description>
        This mission cycles through the CANON Bowtie waypoints in the order: SE
        - NW - NE - SW - SE 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.
    </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>14</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: SE (to start
        position) leg 2: SE - CSE leg 3: CSE - CNW leg 4: CNW - NW leg 5: NW - N
        leg 6: N - NE leg 7: NE - CNE leg 8: CNE - CSW leg 9: CSW - SW leg 10:
        SW - S leg 11: S - SE leg 12: SE - ? (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="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="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="StartWithASample"><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><True/></DefineArg>

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

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

    <DefineArg Name="Lat2"><Description>
        Latitude of waypoint 2 (default: CSE).
    </Description><Units:degree/><Value>36.787825</Value></DefineArg>

    <DefineArg Name="Lon2"><Description>
        Longitude of waypoint 2 (default: CSE).
    </Description><Units:degree/><Value>-121.841121</Value></DefineArg>

    <DefineArg Name="Lat3"><Description>
        Latitude of waypoint 3 (default: CNW).
    </Description><Units:degree/><Value>36.804417</Value></DefineArg>

    <DefineArg Name="Lon3"><Description>
        Longitude of waypoint 3 (default: CNW).
    </Description><Units:degree/><Value>-121.862712</Value></DefineArg>

    <DefineArg Name="Lat4"><Description>
        Latitude of waypoint 4 (default: NW).
    </Description><Units:degree/><Value>36.8219</Value></DefineArg>

    <DefineArg Name="Lon4"><Description>
        Longitude of waypoint 4 (default: NW).
    </Description><Units:degree/><Value>-121.8856</Value></DefineArg>

    <DefineArg Name="Lat5"><Description>
        Latitude of waypoint 5 (default: N).
    </Description><Units:degree/><Value>36.829608</Value></DefineArg>

    <DefineArg Name="Lon5"><Description>
        Longitude of waypoint 5 (default: N).
    </Description><Units:degree/><Value>-121.853778</Value></DefineArg>

    <DefineArg Name="Lat6"><Description>
        Latitude of waypoint 6 (default: NE).
    </Description><Units:degree/><Value>36.8315</Value></DefineArg>

    <DefineArg Name="Lon6"><Description>
        Longitude of waypoint 6 (default: NE).
    </Description><Units:degree/><Value>-121.8457</Value></DefineArg>

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

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

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

    <DefineArg Name="Lon8"><Description>
        Longitude of waypoint 8 (default: CSW).
    </Description><Units:degree/><Value>-121.859331</Value></DefineArg>

    <DefineArg Name="Lat9"><Description>
        Latitude of waypoint 9 (default: SW).
    </Description><Units:degree/><Value>36.766</Value></DefineArg>

    <DefineArg Name="Lon9"><Description>
        Longitude of waypoint 9 (default: SW).
    </Description><Units:degree/><Value>-121.8649</Value></DefineArg>

    <DefineArg Name="Lat10"><Description>
        Latitude of waypoint 10 (default: S).
    </Description><Units:degree/><Value>36.769648</Value></DefineArg>

    <DefineArg Name="Lon10"><Description>
        Longitude of waypoint 10 (default: S).
    </Description><Units:degree/><Value>-121.848834</Value></DefineArg>

    <DefineArg Name="Lat11"><Description>
        Latitude of waypoint 11 (default: SE).
    </Description><Units:degree/><Value>36.7755</Value></DefineArg>

    <DefineArg Name="Lon11"><Description>
        Longitude of waypoint 11 (default: SE).
    </Description><Units:degree/><Value>-121.825</Value></DefineArg>

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

    <DefineArg Name="Lon12"><Description>
        Longitude of waypoint 12 (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>20</Value></DefineArg>

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

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

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

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

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

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

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

    <DefineArg Name="YoYoMaxDepth9"><Description>
        Maximum YoYo depth during leg 9.
    </Description><Units:meter/><Value>65</Value></DefineArg>

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

    <DefineArg Name="YoYoMaxDepth11"><Description>
        Maximum YoYo depth during leg 11.
    </Description><Units:meter/><Value>20</Value></DefineArg>

    <DefineArg Name="YoYoMaxDepth12"><Description>
        Maximum YoYo depth during leg 12.
    </Description><Units:meter/><Value>20</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>

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

    <Timeout Duration="MissionTimeout"/>

    <Insert Filename="Insert/Science.tl">
        <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.tl" 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.tl"/>

    <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="Deprecated/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="SampleInProgress"/>
            <Or><Elapsed><Arg Name="ElapsedSinceLastSampleStart"/></Elapsed><Gt><Arg Name="SampleInterval"/></Gt></Or>
        </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 ESP 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="PreSampleComms" 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.tl 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.tl 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 Id="Leg9">

            <Sequence/>

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

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

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

        </Aggregate>

        <Aggregate Id="Leg10">

            <Sequence/>

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

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

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

        </Aggregate>

        <Aggregate Id="Leg11">

            <Sequence/>

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

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

            <Assign><Sequence/><Arg Name="Lon10"/><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>

        <Syslog Severity="Important">Lat[9] = <Arg Name="Lat9"/><Units:degree/> Lon[9] = <Arg Name="Lon9"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[10] = <Arg Name="Lat10"/><Units:degree/> Lon[10] = <Arg Name="Lon10"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[11] = <Arg Name="Lat11"/><Units:degree/> Lon[11] = <Arg Name="Lon11"/><Units:degree/></Syslog>

        <Syslog Severity="Important">Lat[12] = <Arg Name="Lat12"/><Units:degree/> Lon[12] = <Arg Name="Lon12"/><Units:degree/></Syslog>

        <Aggregate Id="SampleOnStart">

            <Sequence/>

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

<!-- Kick off the first ESP sample. -->

            <Assign><Sequence/><Arg Name="SampleInProgress"/><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="Wpt9">

            <Sequence/>

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

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

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat9"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon9"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt10">

            <Sequence/>

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

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

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat10"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon10"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt11">

            <Sequence/>

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

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

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat11"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon11"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

        <Aggregate Id="Wpt12">

            <Sequence/>

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

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

            <Guidance:Waypoint>
                <Sequence/>
                <Setting><Guidance:Waypoint.latitude/><Arg Name="Lat12"/></Setting>
                <Setting><Guidance:Waypoint.longitude/><Arg Name="Lon12"/></Setting>
            </Guidance:Waypoint>

        </Aggregate>

    </Aggregate>

</Mission>