<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">%=====================================================================
\section{The LegRun Behavior}
%=====================================================================
\label{sec_bhv_waypoint}

The {\em LegRun} behavior is enables a vehicle to repeatedly traverse
back and forth over a {\em legrun trackline} prescribed by two
vertices. After reaching the end of the trackline, the vehicle
switches into a Williamson turn mode to ensure the vehicle aligns with
the trackline when starting in the other direction. The idea is shown
in Figure \ref{fig_bhv_legrun}.

\vspace{0.1in}
\begin{figure}[H]
  \centering 
  \includegraphics[width=0.75\textwidth]{figures/bhv_legrun.png}
  \caption{{\bf The LegRun Behavior:} A vehicle traverses back and forth along
    a trackline given by two vertices. At each end the vehicle performs
    a Williamson Turn to be aligned with the trackline at the very beginning
    of the trackline.}
  \label{fig_bhv_legrun}
\end{figure}
\vspace{0.1in}

\noindent
The behavior may be configured with a single vehicle speed, or a
schedule of speeds, changing on each legrun. As with any other helm
behavior, configuration parameters may be changed dynamically through
its \bvar{updates} variable. As such, this behavior support several
configuration parameters for changing the length and orientation of
the legrun trackline while the behavior is running.  Dynamic
in-mission modifications to the turn characteristics are also
supported. The support for in-mission adjustments is to allow an
operator to gauge a mission for safety or other metrics during a mission
and adjust as needed without needing to halt and restart the vehicle
mission, thereby saving valuable test range time.

%=====================================================================
\section{Intended Mission Use}
\label{sec_lrun_use}

The \var{LegRun} behavior generally is used for structuring a set of
vehicle performance tests. If the performance tests involved first
putting the vehicle on a straight course, then performing and
measuring a maneuver, the \var{LegRun} behavior can be used to
repeatedly set up the vehicle on the straight line. The basic
trajectory created by the behavior without any test, is shown
in Figure \ref{fig_lr_pavlab}:

\vspace{0.1in}
\begin{figure}[H]
  \centering
  \includegraphics[width=0.75\textwidth]{figures/lr_pavlab.png}
  \caption{{\bf LegRun Behavior}: The vehicle traverses a trackline
    given by two points, and conducts a Williamson turn at the end
    of each trackline to ensure it is aligned with the trackline
    when it resumes in the other direction.}
  \label{fig_lr_pavlab}
\gif{figures/lr_pavlab.gif}
\end{figure}
\vspace{0.1in}

\noindent
The behavior can be configured to post a user-specified flag at some
user-specified mid-point of each leg. This flag can be used to (a)
switch the \var{LegRun} behavior into idle mode and (b) cue another
behavior to begin. Presumably the other behavior will utilize an end
flag that will result in the resumption of the \var{LegRun} behavior.
In Figure \ref{fig_lr_fixturn}, a \var{FixedTurn} behavior is triggered
in the middle of a leg, completes its turn, and resumes the original
leg. 

\vspace{0.1in}
\begin{figure}[H]
  \centering
  \includegraphics[width=0.75\textwidth]{figures/lr_fixturn.png}
  \caption{{\bf LegRun Behavior with Turn Test}: During the trackline
    portion of the LegRun behavior, the behavior posts a flag to
    trigger a FixedTurn behavior to conduct a full turn, measuring the
    turn radius, and then resumes the trackline portion of the LegRun
    behavior.}
  \label{fig_lr_fixturn}
\gif{figures/lr_fixturn.gif}
\end{figure}
\vspace{0.1in}

\noindent
Other types of "shake-out" behavior used with a \var{LegRun} behavior
include the \var{FullStop} behavior, and the \var{ZigZag} behavior. 


%=====================================================================
\subsection{The Core Algorithm}
\label{sec_lrun_core}

The \var{LegRun} behavior is comprised of (a) a leg between two vertices,
(b) two Williamson turns at either end of the leg. The vehicle initially
will traverse to a point on the leg, and then proceed indefinitely through
each turn, ideally beginning each leg closely aligned with the leg angle
at the start of the turn. When or if the behavior is interupted and
enters the idle state, the resumption of the behavior will return to
whichever leg it was on when it entered the idle state. If the behavior
becomes idle when turning, it will re-enter the init state when it resumes
running.

\vspace{0.1in}
\begin{figure}[ht]
  \centering 
  \includegraphics[width=0.65\textwidth]{figures/lr_modes.png}
  \caption{{\bf LegRun Modes:} The behavior will initially begin in
    the init mode to find an initial leg, and then will transition
    between the modes as indicated as it proceeds through each stage.}
  \label{fig_lr_modes}
\end{figure}


%=====================================================================
\subsection{The OnRunState() Loop}
\label{sec_bhv_legrun_runstate}

The \var{onRunState()} function is executed by the behavior on each
iteration of the helm when the behavior is not idle. In this section
the key steps of this function are reviewed. Details of certain steps
will be discussed in separate sections.

\vspace{0.1in}
\noindent
As the step 1, the behavior obtains the current position of ownship
denoted by:

\vspace{0.15in}
\noindent
$\{x_{os}, y_{os}\}$

\vspace{0.1in}
\begin{figure}[ht]
  \centering
  \includegraphics[width=0.9\textwidth]{figures/legrun_flowchart.png}
  \caption{{\bf LegRun Behavior Loop Flow Chart:} Each iteration of
    the LegRun behavior will proceed through the steps shown, with
    branching determined by sensed events and the behavior
    configuration. Details of each step are discuss in their own
    sections as indicated.}
  \label{fig_bhv_legrun_flowchart}
\end{figure}
\vspace{0.1in}



%=====================================================================
\subsection{Construction of the IvP Objective Function}
\label{sec_bhv_legrun_ipf}

external to the LegRun behavior.

%=====================================================================
\subsection{Active Participation of the LegRun Behavior}
\label{sec_bhv_legrun_postipf}

In step 15, the LegRun behavior will actively participate in the Helm
decision stage by producing IvP function. When a running behavior does
indeed produce an objective function, this behavior is said to be in
the active state. Both the run flags and active flags will be posted
if the user has configured any.  Again, the only unique components of
these flag postings for the LegRun behavior are the macros supported
for solely for the LegRun behavior described in Section N.

%\ref{sec_bhv_muster_macros}.

%=====================================================================
\subsection*{Performance Metrics}


%=======================================================================
\subsection{Configuration Parameters}
\label{sec_bhv_legrun_params}

Certain configuration parameters available to LegRun behavior are are
unique to the LegRun behavior and others are inherited from the
\var{IvPBehavior} superclass.  Here parameters unique to the LegRun
behavior are presented.

\vspace{0.1in}
\noindent
The set of configuration parameters is long, and split into two
groups.  The first group deals mainly with the shape of the leg,
including position, angle, length and nature of the Williamson
turn. The LegRun behavior maintains an instance of a LegRun C++ class,
and these parameters are essentially passed directly to that class.
The remainder of the configuration parameters relate to the operation
of the behavior. 

\vspace{0.15in}
\begin{listing}{Configuration Parameters for the LegRun Behavior (Leg Shape)}
\label{lst_bhv_legrun}
\small \renewcommand{\arraystretch}{1.15}
\begin{longtable}{rp{0.76\textwidth}} 

  {\bf Parameter} &amp; {\bf Description} \\  
  
  \bvar{p1}: &amp; The location of one end of the primary leg. 
  Section \ref{sec_bhv_legrun_vertices}. \\

  \bvar{p2}: &amp; The location of the other end of the primary leg.
  Section \ref{sec_bhv_legrun_vertices}. \\

  % leg segment ------

  \bvar{leg}: &amp; A specification of the leg given by the leg center
  point, the angle and the length (rather than the two end points
  explicitly with the \bvar{p1} and \bvar{p2} parameters. \\

  \bvar{leg\_len}: &amp; The {\em length} of the primary legrun track
  line may be dynamically set to the given value. The center and
  orientation of the legrun track will be retained, but new locations
  for the two vertices will be calculated. \\

  \bvar{leg\_len\_mod}: &amp; The length of the primary legrun track
  line may be dynamically modified by the given value. The center and
  orientation of the legrun track will be retained, but new locations
  for the two vertices will be calculated. The new length of the leg
  cannot be lower than the value set by \bvar{leg\_length\_min}. \\

  \bvar{leg\_len\_min}: &amp; A minimum leg length is enforced when
  dynamically adjusting the leg length with the
  \bvar{leg\_length\_mod} parameter. This min length is 50
  meters. This can be changed with this parameter, but cannot be set
  lower than 5 meters. \\
  
  \bvar{leg\_ang}: &amp; The {\em angle} of the primary legrun track
  line may be dynamically set to the given value. The center and
  length of the legrun track line will be retained, but new locations
  for the two vertices will be calculated. \\

  \bvar{leg\_ang\_mod}: &amp; The {\em angle} of the primary legrun
  track line may be dynamically {\em modified} by the given value. The
  center and length of the legrun track line will be retained, but new
  locations for the two vertices will be calculated. \\
  
  \bvar{shift\_pt}: &amp; A location in the x-y plane. If provided, it
  will override the \bvar{p1} and \bvar{p2} parameters and move the
  primary leg to be centered at the \bvar{shift\_pt}, keeping the
  original primary leg length and angle. \\

  % turn bias ------
  
  \bvar{turn\_bias} &amp; The bias value, $[-100,100]$, may be adjusted
  with this parameter affecting the turn shape at {\em both}
  vertices. A value of $-100$ will result in a Williamson turn with
  its longest end aligned with the legrun track line
  (recommended). The default value is 0. \\

  \bvar{turn1\_bias} &amp; The bias value, $[-100,100]$, may be adjusted
  with this parameter affecting the turn shape at vertex 1. A value of
  $-100$ will result in a Williamson turn with its longest end aligned
  with the legrun track line (recommended). The default value is 0. \\

  \bvar{turn2\_bias} &amp; The bias value, $[-100,100]$, may be adjusted
  with this parameter affecting the turn shape at vertex 2. A value of
  $-100$ will result in a Williamson turn with its longest end aligned
  with the legrun track line (recommended). The default value is 0. \\

  \bvar{turn1\_bias\_mod} &amp; The bias value for the turn as vertex 1,
  may be dynamically adjusted with this parameter, during run time,
  affecting the turn shape at vertex 1. The given value will be added
  to the existing value. The resulting value will be clipped to the
  range $[-100,100]$. \\

  \bvar{turn2\_bias\_mod} &amp; The bias value for the turn as vertex 1,
  may be dynamically adjusted with this parameter, during run time,
  affecting the turn shape at vertex 2. The given value will be added
  to the existing value. The resulting value will be clipped to the
  range $[-100,100]$. \\

  \bvar{turn\_bias\_mod} &amp; The bias value for the turn as vertex 1,
  may be dynamically adjusted with this parameter, during run time,
  affecting the turn shape at {\em both} vertices. The given value
  will be added to the existing value. The resulting value will be
  clipped to the range $[-100,100]$. \\

  % turn dir ------
  
  \bvar{turn\_dir}: &amp; The turn direction, \var{"port"} or
  \var{"starboard"}, the vehicle will turn around {\em both} vertices.
  Acceptable parameter values are \var{"port"}, \var{"starboard"},
  \var{"star"}, or \var{"toggle"}. The default is \var{"star"}. \\

  \bvar{turn1\_dir}: &amp; The turn direction, \var{"port"} or
  \var{"starboard"}, the vehicle will turn around the first vertex.
  Acceptable parameter values are \var{"port"}, \var{"starboard"},
  \var{"star"}, or \var{"toggle"}. The default is \var{"star"}. \\

  \bvar{turn2\_dir}: &amp; The turn direction, \var{"port"} or
  \var{"starboard"}, the vehicle will turn around the second vertex.
  Acceptable parameter values are \var{"port"}, \var{"starboard"},
  \var{"star"}, or \var{"toggle"}. The default is \var{"star"}. \\

  % turn ext ------

  \bvar{turn1\_ext} &amp; An additional distance, applied beyond the
  distance of the track leg on turn 1, before the vehicle begins its
  turn. See Section \ref{sec_lr_legext}.  The default value is 0. \\

  \bvar{turn2\_ext} &amp; An additional distance, applied beyond the
  distance of the track leg on turn 2, before the vehicle begins its
  turn. See Section \ref{sec_lr_legext}.  The default value is 0. \\

  \bvar{turn\_ext} &amp; An additional distance, applied beyond the
  distance of the track leg on both ends, before the vehicle begins
  its turn. See Section \ref{sec_lr_legext}.  The default value is
  0. \\

  \bvar{turn1\_ext\_mod} &amp; Modify the turn 1 extent, an additional
  distance, applied beyond the distance of the track leg on turn 1,
  before the vehicle begins its turn. See Section \ref{sec_lr_legext}.
  The default value is 0. \\

  \bvar{turn2\_ext\_mod} &amp; Modify the turn 2 extent, an additional
  distance, applied beyond the distance of the track leg on turn 2,
  before the vehicle begins its turn. See Section \ref{sec_lr_legext}.
  The default value is 0. \\

  \bvar{turn\_ext\_mod} &amp; For both turns, modify the turn extent, an
  additional distance, applied beyond the distance of the track leg on
  both ends, before the vehicle begins its turn. See Section
  \ref{sec_lr_legext}.  The default value is 0. \\
  
  % turn rad ------
  
  \bvar{tur1\_rad} &amp; The turn radius of the turn following vertex
  1. Any positive value is allowed (yes, any, be carefull), and the
  default is 15 meters. \\

  \bvar{turn2\_rad} &amp; The turn radius of the turn following vertex
  2. Any positive value is allowed (yes, any, be carefull), and the
  default is 15 meters. \\

  \bvar{turn\_rad} &amp; The turn radius of the turn following {\em both}
  vertices. Any positive value is allowed (yes, any, be carefull), and
  the default is 15 meters. \\

  \bvar{turn\_rad\_min} &amp; A minimum turn radius is enforced when
  dynamically adjusting the turn radius with the
  \bvar{turn*\_rad\_mod} parameters. This min radius is 5 meters. This
  can be changed with this parameter, but cannot be set lower than 2
  meters. \\

  \bvar{turn1\_rad\_mod} &amp; The turn radius of the turn at vertex 1 may
  be modified with this parameter. It cannot be set lower than the
  value of \bvar{turn\_rad\_min}. \\

  \bvar{turn2\_rad\_mod} &amp; The turn radius of the turn at vertex 2 may
  be modified with this parameter. It cannot be set lower than the
  value of \bvar{turn\_rad\_min}. \\

  \bvar{turn\_rad\_mod} &amp; The turn radius of the turn at both
  vertices may be modified with this parameter. It cannot be set lower
  than the value of \bvar{turn\_rad\_min}. \\


  \bvar{turn\_pt\_gap}: &amp; The distance between points comprising the
  Williamson turns on both ends. The default is 25 meters. Section
  \ref{sec_lr_ptgap}. \\
  
\end{longtable}
\end{listing}
\normalsize

  
%===================================================================
% Behavior Parameters
%===================================================================
  
\vspace{0.15in}
\begin{listing}{Configuration Parameters for the LegRun Behavior (Leg Shape)}
\label{lst_bhv_legrun}
\small \renewcommand{\arraystretch}{1.15}
\begin{longtable}{rp{0.76\textwidth}} 

 
  {\bf Parameter} &amp; {\bf Description} \\  
  
  \bvar{capture\_line}: &amp; When set to true, the behavior will regard a
  vertex as captured, if it crosses the line at the vertex
  perpendicular to the trackline. The default is false. \\

  \bvar{capture\_radius}: &amp; The radius to the target vertex within
  which the vehicle must arrive for a vertex to considered reached, or
  captured. The default value is 3 meters. \\

  \bvar{init\_leg\_mode}: &amp; tbd. \\

  \bvar{lead}: &amp; For trackline following during the legrun phase of
  this behavior, this parameter affects the severity of adjustment
  back to the trackline when there is a trackline error. The default
  value is 0, meaning no trackline error adjustment will be made. \\

  \bvar{lead\_damper}: &amp; When adjusting for trackine errors, this
  parameter will automatically reduce the trackline adjustments the
  closer the vehicle gets to the trackline. The default value is 0. \\
  
  \bvar{leg\_spds}: &amp; A schedule of speeds in m/s to be executed on
  each successive leg run.  \\

  \bvar{leg\_spds\_onturn}: &amp; If set, use this speed, in m/s on turns
  at the end of each leg run. \\

  \bvar{leg\_spds\_repeat}: &amp; If true, and a schedule of speeds is
  provided with the \bvar{leg\_spds} parameter, then repeat the
  schedule once it has been exhausted. \\

  \bvar{leg\_flag}: &amp; A flag to be published on each helm interation
  while the behavior is the mode of traversing either direction
  of teh leg. Section \ref{sec_lrun_tbd}. \\

  \bvar{leg\_endflag}: &amp; A flag to be published at the end of each
  leg as the behavior transitions from either the \var{leg1} mode into
  the \var{turn1} mode, or from the \var{leg2} mode into the \var{turn2}
  mode. Section \ref{sec_lrun_tbd}. \\

  \bvar{leg1\_endflag}: &amp; A flag to be published as the behavior
  transitions from the \var{leg1} mode into the \var{turn1} mode.
  Section \ref{sec_lrun_tbd}. \\

  \bvar{leg2\_endflag}: &amp; A flag to be published as the behavior
  transitions from the \var{leg2} mode into the \var{turn2} mode.
  Section \ref{sec_lrun_tbd}. \\

  \bvar{mid\_leg\_flag}: &amp; A flag to be published at a mid point
  position during the leg. The location of the mid point is determined
  by the \var{mid\_leg\_pct} parameter. \\

  \bvar{mid\_leg\_pct}: &amp; The percentage $[0,100]$ of the primary leg,
  at which the behavior after first exceeding this point, will post
  any configured \bhv{mid\_leg\_flag} postings. \\

  \bvar{mid\_turn\_flag}: &amp; A flag to be published at a mid point
  position during a turn. The location of the mid point is determined
  by the \var{mid\_turn\_pct} parameter. \\

  \bvar{mid\_turn\_pct}: &amp; The percentage $[0,100]$ of turn, at which
  the behavior will post any configured \bhv{mid\_turn\_flag}
  postings. \\

  \bvar{patience}: &amp; A patience parameter in the range of $[1,99]$ may
  be set to adust the relative weight between adjusting speed while
  maintaining course, or adjusting course while maintaining
  speed. The default value is 50. \\

  \bvar{slip\_radius}: &amp; A radius to the target vertex within which
  the vehicle will declare arrival as soon as the distance to the
  vertex begins to grow larger. The default value is 15 meters. \\

  \bvar{speed}: &amp; The default speed in m/s if no schedule of speed is
  provided with the \bvar{leg\_spds} parameter, or when the speed
  schedule has been exhausted with no \bvar{leg\_spds\_repeat}
  enabled. \\

  \bvar{wpt\_status\_var}: &amp; The name of a MOOS variable to publish a
  status report. \\

  \bvar{repeat}: &amp; The number of times the trackline leg will be
  repeated before this behavior completes. The default values is 0,
  meaning it will repeat endlessly. (check this) \\

  \bvar{turn\_endflag}: &amp; A flag to be published at the end of each
  leg as the behavior transitions from either the \var{turn1} mode
  into the \var{leg2} mode, or from the \var{turn2} mode into the
  \var{leg1} mode. Section \ref{sec_lrun_tbd}. \\

  \bvar{turn1\_endflag}: &amp; A flag to be published as the behavior
  transitions from the \var{turn1} mode into the \var{leg2} mode.
  Section \ref{sec_lrun_tbd}. \\

  \bvar{turn2\_endflag}: &amp; A flag to be published as the behavior
  transitions from the \var{turn2} mode into the \var{leg1} mode.
  Section \ref{sec_lrun_tbd}. \\

  \bvar{visual\_hints}: &amp; Settings for the posted visual artifacts
  of this behavior, includeing edge and vertex colors and sizes. See
  the example configuration block for supported parameters. \\

\end{longtable}
\end{listing}
\normalsize


\vspace{0.15in}
\begin{listing}{Example Configuration Block}
\label{lst_bhv_trail_ex}

\begin{fileverb}
Behavior = BHV_LegRun
{
  name      = legs
  pwt       = 100
  condition = DEPLOY = true
  endflag   = RETURN = true

  updates    = LEG_UPDATE
  perpetual  = true

            lead = 5
     lead_damper = 1
           speed = 4.0   // meters per second                                                
    capture_line = true
  capture_radius = 2
     slip_radius = 15

              p1 = 70, -35
              p2 = -35, -85
          repeat = 1

       turn1_dir = port
       turn2_dir = star
       turn1_rad = 20
       turn2_rad = 20
      turn1_bias = 100
      turn2_bias = 100

     mid_leg_pct = 10
    mid_leg_flag = ZIGGING=true 

    visual_hints = nextpt_color=yellow
    visual_hints = nextpt_vertex_size=8
    visual_hints = nextpt_lcolor=gray70
    visual_hints = vertex_color=dodger_blue, edge_color=white
    visual_hints = vertex_size=6, edge_size=1
    visual_hints = turn_edge_color=white
    visual_hints = turn_vertext_color=green
    visual_hints = turn_label_color=off
}
\end{fileverb}
\end{listing}

%=====================================================================
\subsection{Publications}


\vspace{0.15in}
\begin{listing}{Configuration Parameters for the LegRun Behavior}
\label{lst_bhv_legrun}
\small
\renewcommand{\arraystretch}{1.15}
\begin{longtable}{rp{0.76\textwidth}} 

  {\bf Variable} &amp; {\bf Description} \\  
  
  \mvar{LR\_MODE}: &amp; The current mode, \var{leg1}, \var{leg2}, ,
  \var{turn1}, \var{turn2}.  Section \ref{TBD}. \\

  \mvar{LR\_MODE\_REPORT}: &amp; The current mode, vehicle name, and timestamp,
  to be sent to other vehicles for coordination. \\

  \mvar{LR\_TCOORD\_SPD}: &amp; The speed currently the target speed for the
  behavior based on its relative position to other vehicles. Only relevant
  when turn coordination is enabled between multiple vehicles. \\
  
  \mvar{LR\_NOW\_SPD}: &amp; The speed currently the target speed for the
  behavior based on its relative position to other vehicles. \\

  \mvar{LR\_OS\_DEGS}: &amp; The position of ownship, in degrees, on the reference
  circle used when multi-vehicle coordinatio is enabled. \\

  
  
\end{longtable}
\end{listing}
\normalsize




%=====================================================================
\section{The Waypoint Engine }
%=====================================================================
%=====================================================================

A {\em WaypointEngine} is a C++ utility for behaviors reasoning about waypoints.
This capability is isolated in its own utility class so it can be easily put
to use in a uniform manner by at least the following behaviors. 

\vspace{0.1in}
\begin{packed_itemize}
\item The Waypoint Behavior
\item The LegRun Behavior
\item The AndersonTurn Behavior
\item The WilliamsonTurn Behavior
\end{packed_itemize}
\vspace{0.1in}


%=====================================================================
\subsection*{Core Data Structure and State}

The primary data held by the WaypointEngine is simply an ordered list of waypoints,
stored in local x-y coordinates:

\vspace{0.1in}
\begin{twequation}
  \input{eq_lrun_waypts}
\end{twequation}

\vspace{0.15in}
\begin{figure}[H]
  \centering 
  \includegraphics[width=0.65\textwidth]{figures/wpt_engine_pts.png}
  \caption{{\bf Ordered Set of Waypoints:} The primary data of the WaypointEngine
    is an ordered list of points}
  \label{fig_wpt_engine_pts}
\end{figure}
\vspace{0.15in}

\noindent
The WaypointEngine keeps track of which waypoint is next, which
presumably is the waypoint that ownship will be aspiring to
reach. Since the WaypointEngine is agnostic to how it may be used
within a behavior, or even if the behavior is actively participating
in the helm, the notion of the "next" waypoint may or may not reflect
the observable trajectory of the vehicle. This value is given by:

\vspace{0.1in}
\noindent

\begin{align}
E_I \; \text{ = Index of waypoint currently aspiring toward}
\end{align}

%======================================================================
\subsection*{Updating the Waypoint Engine}

The waypoint engine is periodically updated with a new position of ownship, presumably
as ownship is moving toward the next waypoint. This operation is:

\begin{align}
E(x_{os}, y_{os}) \text{: Operation to update engine given new ownship position}
\end{align}

\vspace{0.1in}
\noindent
This operation will evaluate ownship position relative to the next waypoint, $E_I$, and
determine if this point has been reached. If so, it will increment $E_i$. If the
reached waypoint was the final waypoint, then $E_i$ is reset to zero.

\vspace{0.1in}
\noindent
After each update, the waypoint engine will calculate three new states
based on the new ownship positions.  The first state reflects whether
a waypoint has been reached upon the most recent update of ownship
position. This is true simply if the index $E_I$ has advanced:

\begin{align}
  E_{adv} =
  \begin{cases}
    true &amp;  E_I(t) \ne  E_I(t-1) \\[0.1in]
    false &amp; otherwise \\
  \end{cases} 
\end{align}

\vspace{0.1in}
\noindent
The next state reflects whether a waypoint has been reached upon the
most recent update of ownship position, and if the reached waypoint was
the final waypoint, $E_{n-1}$

\begin{align}
  E_{cyc} =
  \begin{cases}
    true &amp;  E_I(t) \ne  E_I(t-1),  E_I(t) = 0) \\[0.1in]
    false &amp; otherwise \\
  \end{cases} 
\end{align}

\vspace{0.1in}
\noindent
Note in the case where $E_{cyc}$ is true, this means that ownship has
reached the final waypoint, and $E_I$ has been reset to zero. The
waypoint engine can be configured to treat the arrival at the last
point as final, or simply a cue to begin proceeding back around to
the first point. If it is final, then we say that $E_{comp}$ is true.

%======================================================================
\subsection*{The Waypoint Steering Point}


$E_{np} = x_{np}, y_{np}$ = $p_{E_I}$

$E_{sp} = x_{sp}, y_{sp}$



$E(P)$ Initializes the Waypoint Engine with new points

$E(PSTR)$ Initializes the Waypoint Engine with new given by a string


$E_d$, $E_d(x_{os}, y_{os})$ Distance of ownship to the next waypoint

$E_{d'}$ Previous distancd of ownship to the next waypoint, reset to -1 when
a waypoint is advanced.
         


%======================================================================
\subsection{Flags and Macros}


%=======================================================================
\subsection{Flags and Macros}
\label{sec_opr_fmac}

The \var{LegRun} behavior supports the below set of event flags in
addition to the standard behavior flags, e.g., endflags,
runflags. These are:

\vspace{0.1in}
\begin{packed_itemize}

\item \bvar{leg\_end\_flag}: Posted when the vehicle reaches the end
  of the leg, regardless of the direction.
\item \bvar{leg1\_end\_flag}: Posted when the vehicle reaches the end
  of leg1, i.e., the leg traversing from \var{P2} to \var{P1}.
\item \bvar{leg2\_end\_flag}: Posted when the vehicle reaches the end
  of leg2, i.e., the leg traversing from \var{P1} to \var{P2}.

\item \bvar{mid\_leg\_flag}: Posted when the vehicle has partially
  traversed the main leg, in either direction. The point where it is
  posted is determined by the \bvar{mid\_leg\_pct} parameter.
\item \bvar{mid\_turn\_flag}: Posted when the vehicle has partially
  traversed a turn, in either direction. The point where it is posted
  is determined by the \bvar{mid\_turn\_pct} parameter.

\item \bvar{turn\_end\_flag}: Posted when the vehicle reaches the end
  of a turn, regardless of the direction.
\item \bvar{tur1\_end\_flag}: Posted when the vehicle reaches the end
  of turn1, i.e., the turn traversing from \var{P1} to \var{P2}.
\item \bvar{turn2\_end\_flag}: Posted when the vehicle reaches the end
  of turn2, i.e., the turn traversing from \var{P2} to \var{P1}.

\end{packed_itemize}

\vspace{0.1in}
\noindent
The following macros are supported in the \var{LegRun} behavior. These
macros will be expanded in any event flag, including event flags
defined for all IvP behaviors as well as event flags defined only for
the \var{OpRegionV24} behavior.


\vspace{0.1in}
\begin{packed_itemize}

\item \pvar{\$[CORE\_POLY]}: The specification of the polygon representing
  the core operation area. 
\item \pvar{\$[SAVE\_POLY]}: The specification of the polygon
  representing the operation area, outside which the vehicle will
  actively attempt to return to.
\item \pvar{\$[HALT\_POLY]}: The specification of the polygon
  representing the halt area, outside which the vehicle will
  post an emergency all-stop message.
  
\end{packed_itemize}







</pre></body></html>