<?xml version="1.0" encoding="UTF-8"?>
<Aggregate xmlns="Tethys"
       xmlns:Guidance="Tethys/Guidance" 
       xmlns:Units="Tethys/Units"
       xmlns:Universal="Tethys/Universal"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="Tethys http://okeanids.mbari.org/tethys/Xml/Tethys.xsd
                           Tethys/Guidance http://okeanids.mbari.org/tethys/Xml/Guidance.xsd
                           Tethys/Units http://okeanids.mbari.org/tethys/Xml/Units.xsd
                           Tethys/Universal http://okeanids.mbari.org/tethys/Xml/Universal.xsd"
       Id="NeedGPS">

    <DefineArg Name="GPSTimeout"><Description>
        Maximum amount of time to spend on the surface trying to get a GPS fix
        before giving up and diving again.
    </Description><Units:minute/><Value>3</Value></DefineArg>

    <DefineArg Name="DiveInterval"><Description>
        Elapsed time after most recent GPS fix when vehicle will begin to ascend
        to the surface again.
    </Description><Units:hour/><Value>3</Value></DefineArg>

    <DefineArg Name="WaitForPitchUp"><Description>
        Extra time to wait for the vehicle to pitch up (avoid truncating a yo).
    </Description><Units:minute/><Value>10</Value></DefineArg>

    <DefineArg Name="SurfacePitch"><Units:degree/><Value>20</Value></DefineArg>

    <DefineArg Name="SurfaceSpeed"><Description>
        Standard speed during surfacing. Don't reduce this too much below 1 m/s
        -- the elevators can stall. (At 0.5 m/s, we have observed evidence of
        stall in the past.)
    </Description><Units:meter_per_second/><Value>1</Value></DefineArg>

    <When>
        <Called/>
        <Or><Elapsed><Universal:time_fix/></Elapsed><Gt><Arg Name="DiveInterval"/><Add><Arg Name="WaitForPitchUp"/></Add></Gt></Or>
        <Or><Elapsed><Universal:time_fix/></Elapsed><Gt><Arg Name="DiveInterval"/></Gt><And><Universal:platform_pitch_angle/><Gt><Units:degree/><Value>0</Value></Gt></And></Or>
    </When>

    <Guidance:GoToSurface>
        <Progression/>
        <Setting><Guidance:GoToSurface.pitch/><Arg Name="SurfacePitch"/></Setting>
        <Setting><Guidance:GoToSurface.speed/><Arg Name="SurfaceSpeed"/></Setting>
    </Guidance:GoToSurface>

    <ReadDatum>
        <Universal:time_fix/>
    </ReadDatum>

</Aggregate>
