<?xml version="1.0" encoding="utf-8"?>
<Mission xmlns="Tethys"
        xmlns:Control="Tethys/Control"
        xmlns:Derivation="Tethys/Derivation"
        xmlns:Estimation="Tethys/Estimation"
        xmlns:Guidance="Tethys/Guidance" 
        xmlns:Navigation="Tethys/Navigation" 
		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/Control http://okeanids.mbari.org/tethys/Xml/Control.xsd
                            Tethys/Derivation http://okeanids.mbari.org/tethys/Xml/Derivation.xsd
                            Tethys/Estimation http://okeanids.mbari.org/tethys/Xml/Estimation.xsd
                            Tethys/Guidance http://okeanids.mbari.org/tethys/Xml/Guidance.xsd                            
                            Tethys/Navigation http://okeanids.mbari.org/tethys/Xml/Navigation.xsd                            
                            Tethys/Units http://okeanids.mbari.org/tethys/Xml/Units.xsd
                            Tethys/Universal http://okeanids.mbari.org/tethys/Xml/Universal.xsd" 
        Id="transit">

    <Description>
        Vehicle plans a path using surface currents forecast by compact model,
        then transits to desired waypoint. Can be commanded to use/hold mass or
        buoyancy.
    </Description>

    <DefineArg Name="Depth"><Description>
        Depth of flat and level flight during the mission.
    </Description><Units:meter /><Value>5</Value></DefineArg>

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

    <DefineArg Name="Wpt1Lat"><Description>
        Latitude of waypoint to seek. If set to NaN, uses latitude at mission
        initialization.
    </Description><Units:degree/><Value>NaN</Value></DefineArg>

    <DefineArg Name="Wpt1Lon"><Description>
        Longitude of waypoint to seek. If set to NaN, uses longitude at mission
        initialization.
    </Description><Units:degree/><Value>NaN</Value></DefineArg>

    <DefineArg Name="Northings"><Description>
        Northward distance of the waypoint to seek. If combined with Latitude
        and/or Longitude, this is an offset from the specified Latitude and/or
        Longitude.
    </Description><Units:meter/><Value>0</Value></DefineArg>

    <DefineArg Name="Eastings"><Description>
        Eastward distance of the waypoint to seek. If combined with Latitude
        and/or Longitude, this is an offset from the specified Latitude and/or
        Longitude.
    </Description><Units:meter/><Value>0</Value></DefineArg>

    <DefineArg Name="Speed"><Description>
        Speed of vehicle (relative to water) during the mission.
    </Description><Units:meter_per_second/><Value>0.75</Value></DefineArg>

    <DefineArg Name="MassHold"><Description>
        Set to True in order to hold mass at user defined position, False to
        allow mass to run on its own.
    </Description><True/></DefineArg>

    <DefineArg Name="BuoyancyHold"><Description>
        Set to True in order to hold buoyancy at neutral position, False to
        allow buoyancy to run on its own.
    </Description><True/></DefineArg>

    <DefineArg Name="BuoyancyNeutral"><Description>
        Buoyancy bladder position while performing the transit. Defaults to
        buoyancyNeutral setting in the Config/Control.cfg file.
    </Description><Control:VerticalControl.buoyancyNeutral/></DefineArg>

    <DefineArg Name="MassDefault"><Description>
        Static setting for mass during the mission.
    </Description><Control:VerticalControl.massDefault/></DefineArg>

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

    <DefineArg Name="NeedCommsTime"><Description>
        Elapsed time after previous surface communications when vehicle will
        begin to ascend for additional surface communications
    </Description><Units:minute/><Value>60</Value></DefineArg>

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

    <DefineArg Name="TimeoutDuration"><Description>
        Maximum length of mission
    </Description><Units:hour/><Value>12</Value></DefineArg>

    <DefineArg Name="HFRadarModelGridDivide"><Description>
        If UseHFRadarModel is true, when calculating fine grid, divide coarse
        grid by this number along each axis
    </Description><Units:count/><Value>16</Value></DefineArg>

    <Timeout Duration="TimeoutDuration"/>

    <Guidance:AltitudeEnvelope>
        <Parallel/>
        <Setting><Guidance:AltitudeEnvelope.minAltitude/><Arg Name="MinAltitude"/></Setting>
    </Guidance:AltitudeEnvelope>

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

    <Guidance:OffshoreEnvelope>
        <Parallel/>
        <Setting><Guidance:OffshoreEnvelope.minOffshore/><Arg Name="MinOffshore"/></Setting>
    </Guidance:OffshoreEnvelope>

<!-- The assigns that follow are temporary equivalents to:
configSet HFRCMSurfaceCurrentAtVehicleLocation.velocityAccuracy 0.0001 m/s;
configSet DeadReckonUsingCompactModelForecast.accuracyPremultiplier 0.01 none;
configSet DeadReckonWithRespectToWater.accuracyPremultiplier 1000000 none;
configSet DeadReckonWithRespectToSeafloor.accuracyPremultiplier 1000000 none;
configSet DeadReckonUsingDVLWaterTrack.accuracyPremultiplier 1000000 none;
configSet DeadReckonUsingMultipleVelocitySources.accuracyPremultiplier 1000000 none;
configSet SpeedCalculator.speedAccuracy 0.0000001 m/s;
 -->

<!--    <Assign><Parallel/><Estimation:HFRCMSurfaceCurrentAtVehicleLocation.velocityAccuracy/><Units:meter_per_second/><Value>0.0001</Value></Assign> -->

    <Assign><Parallel/><Estimation:HFRadarModelCalc.velocityAccuracy/><Units:meter_per_second/><Value>0.0001</Value></Assign>

    <Assign><Parallel/><Navigation:DeadReckonUsingCompactModelForecast.accuracyPremultiplier/><Units:none/><Value>0.01</Value></Assign>

    <Assign><Parallel/><Navigation:DeadReckonWithRespectToWater.accuracyPremultiplier/><Units:none/><Value>1000000</Value></Assign>

    <Assign><Parallel/><Navigation:DeadReckonWithRespectToSeafloor.accuracyPremultiplier/><Units:none/><Value>1000000</Value></Assign>

    <Assign><Parallel/><Navigation:DeadReckonUsingDVLWaterTrack.accuracyPremultiplier/><Units:none/><Value>1000000</Value></Assign>

    <Assign><Parallel/><Navigation:DeadReckonUsingMultipleVelocitySources.accuracyPremultiplier/><Units:none/><Value>1000000</Value></Assign>

    <Assign><Parallel/><Derivation:SpeedCalculator.speedAccuracy/><Units:meter_per_second/><Value>0.0000001</Value></Assign>

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

<!-- NOTE: The <Assign> clause below will not take effect until you actually run the mission. RedefineArg will not work in this case if you use a "set" after loading the mission. -->

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

<!-- Use the default NeedComms:SurfaceSpeed of 1 m/s, regardless of the commanded speed during the mission. -->

    <Guidance:Buoyancy Id="BuoyancyHold">
        <While>
            <Arg Name="BuoyancyHold"/>
        </While>
        <Setting><Guidance:Buoyancy.position /><Arg Name="BuoyancyNeutral"/></Setting>
    </Guidance:Buoyancy>

    <Guidance:Pitch Id="MassHold">
        <While>
            <Arg Name="MassHold"/>
        </While>
        <Setting><Guidance:Pitch.massPosition/><Arg Name="MassDefault"/></Setting>
    </Guidance:Pitch>

    <Aggregate Id="WaypointOne">

        <Sequence/>

<!-- Go to Wpt1 -->

        <Guidance:Pitch>
            <Parallel/>
            <Setting><Guidance:Pitch.depth/><Arg Name="Depth"/></Setting>
        </Guidance:Pitch>

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

        <Estimation:HFRadarModelPoint Id="HFRadarModelPointW1">
            <Sequence/>
            <Setting><Estimation:HFRadarModelPoint.latitude/><Arg Name="Wpt1Lat"/></Setting>
            <Setting><Estimation:HFRadarModelPoint.longitude/><Arg Name="Wpt1Lon"/></Setting>
            <Setting><Estimation:HFRadarModelPoint.northingsDelta/><Arg Name="Northings"/></Setting>
            <Setting><Estimation:HFRadarModelPoint.eastingsDelta/><Arg Name="Eastings"/></Setting>
            <Setting><Estimation:HFRadarModelPoint.speed/><Arg Name="Speed"/></Setting>
            <Setting><Estimation:HFRadarModelPoint.gridDivide/><Arg Name="HFRadarModelGridDivide"/></Setting>
        </Estimation:HFRadarModelPoint>

    </Aggregate>

</Mission>
<!-- Unless otherwise directed, vehicle will enter Default mission and go to the surface to call home. -->
