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

The AvoidObstacleV24 behavior is designed to produce IvP functions for
avoiding a single convex polygon obstacle. It is typically configured
as a behavior {\em template} in the helm and works with an {\em
  obstacle manager} with the latter spawning new behavior instances
for each known obstacle when the vehicle is sufficiently close to the
obstacle.  In the example in Figure \ref{fig_avo_basic} below, two
behavior instances are spawned, one for each of the two shown
obstacles. Each instance starts exactly in the same way, evolving in
state differently as it maneuvers around its respective obstacle.
As an obstacle recedes behind the vehicle, its behavior at some point
is completed, deleted and forgotten. 

\vspace{0.1in}
\begin{figure}[H]
  \centering 
  \includegraphics[width=0.65\textwidth]{figures/obavd_basic.png}
  \caption{{\bf AvoidObstacleV24 Behavior}: The operation area}
  \label{fig_obavd_basic}
\gif{figures/obavd_basic.gif}
\end{figure}
\vspace{0.1in}





%=====================================================================
\subsection{Overview}
\label{sec_obsavd_overview}

The \var{AvoidObstacle} behavior acts upon a single obstacle given by
a convex polygon, Figure \ref{fig_obs_avoid}. When a robot has
multiple obstacles, multiple versions of the behavior are spawned, one
for each obstacle. During the course of a mission, it is expected that
multiple such behavior instances will be spawned and deleted.

\vspace{0.1in}
\noindent
The \var{AvoidObstacle} behavior is typically configured as a template
for spawning instances as obstacles emerge. In less common cases, one
or more static behaviors may be configured, instantiated at mission
launch time, with a obstacle of a known position and location. Both
use cases will be described. In the case of dynamically spawned
behaviors, the helm and the AvoidObstacle behavior work in
coordination with an obstacle manager which sits between the helm and
sensor processing applications to reason about obstacles and post
messages at the approprite time to the helm, for generating new
AvoidObstacle behaviors. The obstacle manager currently used is another
MOOS app called \app{pObstacleMgr} and is documented separately. The
interface that triggers AvoidObstacle instances will be described.


\vspace{0.1in}
\begin{figure}[H]
  \centering
  \includegraphics[width=0.9\textwidth]{figures/bhv_obs_avoid.png}
  \caption{{\bf The AvoidObstacle Behavior}: The behavior reasons
    about a single convex polygon obstacle. It uses an inner buffer
    and outer buffer, treating the inner buffer as essentially an
    extension of the obstacle, and the outer buffer as a region where
    it is preferred not to be in.}
  \label{fig_obs_avoid}
\end{figure}
\vspace{0.1in}


\vspace{0.1in}
\noindent
The AvoidObstacle behavior is not a path planner. It is a behavior
that works in conjuction with a planned path, typically being executed
by the Waypoint behavior. The AvoidObstacle behavior is typically used
for avoid locally sensed obstacles like buoys, stationary vessels, or
any other hazard that may be detected or known about beforehand. The
AvoidObstacle behavior, like any IvP Helm behavior, is capable of
accepting dynamic updates. This includes obstacle size and
location. So the AvoidObstacle behavior is capable of dealing with
moving obstacles including vessels. However, when a vessel is known to
be a vessel, and has a known position, heading, and speed, the
AvoidCollision or AvdColregs behaviors are more appropriate.

%=====================================================================
\subsection{The Nature and Origin of Obstacles}
\label{sec_obsavd_obstacles}

The AvoidObstacle behavior may be configured {\em statically} or {\em
  dynamically}. In a static behavior the obstacle is provided in the
mission configuration using the \bvar{polygon} configuration parameter.
For example:

\vspace{0.1in}
\bvar{polygon = 60,-40 : 60,-160 : 150,-160 : 180,-100 : 150,-40}

\vspace{0.1in}
\noindent
The vertices may also be specified indirectly using one more supported
patterns. For example an octogon polygon, perhaps for avoiding a 1 meter
sized buoy at a local coordinates \var{(45,90)} could be given as:

\vspace{0.1in}
\bvar{polygon = format=radial, x=45, y=90, radius=2, pts=8}

\vspace{0.1in}
\noindent
In a dynamic behavior, the polygon specification is typically provided
by an external source, typically the obstacle manager. In the mission
file this behavior leaves the \bvar{polygon} parameter unspecified, but does
specify a MOOS variable for receiving updates. For example:

\vspace{0.1in}
\bvar{templating = spawn}

\bvar{updates = OBSTACLE\_ALRERT}

\vspace{0.1in}
\noindent
A new AvoidObstacle behavior 

\vspace{0.1in}
\noindent
In both cases, they may be altered during run time.



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

\input{includes/bhv_all_properties}

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

  {\bf Parameter} &amp; {\bf Description} \\  
  
  \bvar{completed\_dist}: &amp; Range to contact outside of which the 
  behavior completes and dies. The default is 500 meters. \\  
  
  \bvar{max\_util\_cpa\_dist}: &amp; Range to contact outside which a
  considered maneuver will have max utility. Section
  \ref{sec_bhv_avdobs_cpa_params}. The default is 75 meters\\

  \bvar{min\_util\_cpa\_dist}: &amp; Range to contact within which a
  considered maneuver will have min utility. Section
  \ref{sec_bhv_avdobs_cpa_params}. The default is 10 meters. \\

  \bvar{pwt\_inner\_dist}: &amp; Range to contact within which the
  behavior has maximum priority weight. Section
  \ref{sec_bhv_avdobs_pwt_params}. The default is 50 meters. \\

  \bvar{pwt\_outer\_dist}: &amp; Range to contact outside which the
  behavior has zero priority weight. Section
  \ref{sec_bhv_avdobs_pwt_params}. The default is 200 meters. \\

  \bvar{use\_refinery}: &amp; If true, the behavior will produce an
  optimized objective function that is faster to produce, uses
  a smaller memory footprint, and contributes to faster helm solution
  time. The default is false, simply for continuity with prior
  releases, but there is no downside to enabling this feature. Section
  \ref{sec_bhv_avdobs_refinery}. \\

  \bvar{polygon}: &amp; A convex polygon representing the obstacle. Section
  \ref{sec_bhv_avdobs_poly}. \\

  \bvar{poly}: &amp; Same as \bvar{polygon}. \\

  \bvar{rng\_flag}: &amp; A flag to be posted on all iterations. It may be
  conditioned on a range threshold. Section \ref{sec_obsavd_rngflag}. \\

  \bvar{cpa\_flag}: &amp; A flag to be posted upon reaching the closest
  point of approach to the obstacle. Section \ref{sec_obsavd_cpaflag}. \\

  \bvar{visual\_hints}: &amp; A request to override the default visual
  parameters of the rendered obstacle or its buffer region. Section
  \ref{sec_obsavd_visual}. \\
  
  \bvar{allowable\_ttc}: &amp; The allowable time-to-collision, in
  seconds, within which a candidate trajectory will begin to be
  penalized. Section \ref{sec_obsavd_ttc}.  \bvar{id}: \\
  
\end{longtable}
\end{listing}
\normalsize


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

\begin{fileverb}
Behavior = BHV_AvoidObstacleV24
{
  // General Behavior Parameters
  // ---------------------------
  name       = avdob_
  pwt        = 300
  condition  = DEPLOY = true
  templating = spawn
  updates    = OBSTACLE_ALERT

  // Parameters specific to this behavior
  // ------------------------------------
       allowable_ttc = 20   // default
      pwt_outer_dist = 50   // default
      pwt_inner_dist = 10   // default
      completed_dist = 60   // default
   min_util_cpa_dist = 8    // default
   max_util_cpa_dist = 16   // default
        use_refinery = true // default is false

    visual_hints = obstacle_edge_color   = white     // default
    visual_hints = obstacle_vertex_color = gray60    // default is white
    visual_hints = obstacle_vertex_size  = 1         // default is white
    visual_hints = obstacle_fill_color   = gray60    // default
    visual_hints = obstacle_fill_transparency = 0.7  // default

    visual_hints = buffer_min_edge_color = gray60    // default
    visual_hints = buffer_min_vertex_color = blue    // default is dodger_blue
    visual_hints = buffer_min_vertex_size = 1        // default
    visual_hints = buffer_min_fill_color = gray70    // default
    visual_hints = buffer_min_fill_transparency = 0.25  // default

    visual_hints = buffer_max_edge_color = gray60         // default
    visual_hints = buffer_max_vertex_color = dodger_blue  // default
    visual_hints = buffer_max_vertex_size = 0             // default is 1
    visual_hints = buffer_max_fill_color = gray70         // default         
    visual_hints = buffer_max_fill_transparency = 0.1     // default
}
\end{fileverb}
\end{listing}

%----------------------------------------------------------------------
\subsection{Variables Published}

The below MOOS variables will be published by the behavior during
normal operation, in addition to any configured flags. A variable
published by any behavior may be supressed or changed to a different
variable name using the \bvar{post\_mapping} configuration parameter
described in Section \ref{sec_bhv_post_mapping}.

\begin{packed_itemize}[2]

\item \mvar{AVD\_OB\_SPAWN}: A request to the obstacle manager
  specifying the conditions for obstacle alerts.
    
\item \mvar{NOTED\_RESOLVED}: A posting made when the behavior notes
  an obstacle has been reported be resolved by the obstacle manager.

\item \mvar{VIEW\_POLYGON}: A polygon rendering of either the obstacle,
  inner, or outer buffer. 
\end{packed_itemize}

%=======================================================================
\subsection{Configuring and Using the AvoidObstacle Behavior}

The AvoidObstacle behavior produces an objective function based on
the relative position and trajectory between the vehicle and its
obstacle.

The objective function is based on applying a utility to the
calculated closest point of approach (CPA) for a candidate
maneuver. The user may configure a priority weight, but this weight is
typically degraded in proportion to increasing range to the
obstacle. The behavior may be configured for avoidance with respect to
an obstacle known prior to the start of the mission, or it may be
configured to spawn a new instance upon demand as obstacles become
known through the obstacle manager.

%=======================================================================
\subsection{Specifying the Behavior Priority Weight Policy}
\label{sec_bhv_avdobs_pwt_params}

The AvoidObstacle behavior may be configured to increase its priority
as it closes range to the obstacle. The priority weight specified
in its configuration represents the {\em maximum} possible priority
applied to the behavior, presumably in close range to the obstacle. The
range at which this maximum priority applies is specified in the
\bvar{pwt\_inner\_dist} parameter. Likewise, the
\bvar{pwt\_outer\_dist} parameter specifies a range to the obstacle
where the priority weight becomes zero, regardless of the priority
weight specified in the configuration file.

\vspace{0.1in}
\noindent
So the {\em current priority} will always be between zero and the maximum
priority set in the behavior \bvar{priority} configuration parmeter. To be
more precise:

\vspace{0.1in}
\noindent
Current Priority =

\begin{packed_itemize}
\item 0 if current range to obstacle is greater than or equal to
  \bvar{pwt\_outer\_dist}

\item 100 if current range to obstacle is less than or equal to
  \bvar{pwt\_inner\_dist}

\item otherwise ((\bvar{pwt\_outer\_dist} - current range) /
  (\bvar{pwt\_outer\_dist} - \bvar{pwt\_inner\_dist})) * priority

\end{packed_itemize}

\vspace{0.1in}
\noindent
This relationship is shown in Figure \ref{fig_avdobs_pwt}.

\vspace{0.15in}
\begin{figure}[H]
  \centering 
  \includegraphics[width=0.91\textwidth]{figures/bhv_obs_avoid_rng.png}
  \caption{{\bf Scaling priority weights based on ownship range to
      obstacle}: The range between the vehicle and the obstacle
    affects whether the behavior is spawned, is active and with what
    priority weight.  Beyond the range specified by
    \bvar{pwt\_outer\_dist} the behavior will have a zero priority
    weight, if it even exists.  Within the range of
    \bvar{pwt\_outer\_dist}, the behavior is active with a non-zero
    priority weight growing as the obstacle comes closer.  Within the
    range of \bvar{pwt\_inner\_dist}, the behavior is active with
    100\% of its configured priority weight.}
  \label{fig_avdobs_pwt}
\end{figure}
\vspace{0.15in}

\noindent
The example shown below in Figure \ref{fig_avdobs_pwt_effect} shows
the effect of the \bvar{pwt\_outer\_dist} parameter. The vehicle on
the left is proceeding east, oblivious to the two approaching
vessels. The two westbound vessels, \var{ben} and \var{cal} are
simulated exactly on top of one another. They are oblivious to one
another, but will use the collision avoidance behavior to avoid the
eastbound vessel, abe. The only difference between \var{ben} and
\var{cal} is that \var{cal} begins winding up its priority weight at
80 meters range to \var{abe}, as opposed to 30 meters for
\var{ben}. The short simulation shows the resulting difference in
trajectory.


\vspace{0.1in}
\begin{figure}[H]
  \centering 
  \includegraphics[width=0.99\textwidth]{figures/avdobs_01.png}
  \caption{A vehicle approaches an obstacle. The physical obstacle is shown
    by the inner polygon. The middle inner polygon represents a buffer
    region around the physical obstacle regarded with the same severity
    of consequence as hitting the physical obstacle. The outer polygon
    represents the all clear boundary. The buffer region of the outer
    polygon has a linearly scaled utility.}
  \label{fig_obsavoid_01}
  \urlvideo{https://vimeo.com/856588988}{0:15}
\end{figure}
\vspace{0.1in}

By default, the priority weight decreases linearly between the two
depicted ranges. The \bvar{pwt\_grade} parameter allows the
degradation from maximum priority to zero priority to fall more
steeply by setting \bvar{pwt\_grade}\bsvar{=quadratric}.

%\small
%\begin{align*}
%  pwt(r) &amp;= \begin{cases}
%    0        &amp; r \geq r^+,  \\
%    P_{max}   &amp; r \leq r^-,  \\
%    P_{max} (\frac{3}{4}) &amp; otherwise 
%  \end{cases} \\
%\end{align*}
%\normalsize

%--------------------------------------------------------------------
\subsubsection*{Visual Configuration Options}
\label{sec_avo_vhints}

The visual artifacts generated by the \var{AvoidCollisionV24} behavior
are related to the three polygon regions representing (a) the
obastacle, (b) the inner buffer, and (c) outer buffer polygons.  There
are also seven visual aspects for each polygon that may be modified:
(1) the vertex size, (2) the edge size, (3) the vertex color, (4) the
edge color, (5) the label color, (6) the polygon fill color, and (7)
polygon transparency.

\vspace{0.1in}
\noindent
By setting \bvar{edge\_color=green}, this sets the default edge color
for all three polygons. This can be overruled for say the outer buffer
polygon by setting \bvar{buff\_max\_edge\_color=white}. If the latter
is left unspecified, the default edge colore is used. In the example
lines below, the first group of lines are the default aspects for all
polygons. The second block of lines pertain to the obstacle polygon
and overrule the default aspects.  The third block of lines pertain to
the inner buffer polygon, and the final block of lines pertain ot the
outer buffer polygon.  All lines below represent the defaults used by
the \var{AvoidCollisionV24} behavior if no visual hints were provided
in the behavior configuration.

\vspace{0.1in}
\begin{fileverb}
  m_hints.setMeasure("vertex_size", 0);
  m_hints.setMeasure("edge_size", 1);
  m_hints.setColor("vertex_color", "gray50");
  m_hints.setColor("edge_color", "gray50");
  m_hints.setColor("fill_color", "off");
  m_hints.setColor("label_color", "white");

  m_hints.setColor("obst_edge_color", "white");
  m_hints.setColor("obst_vertex_color", "white");
  m_hints.setColor("obst_fill_color", "gray60");
  m_hints.setMeasure("obst_vertex_size", 1);
  m_hints.setMeasure("obst_fill_transparency", 0.7);
  
  m_hints.setColor("buff_min_edge_color", "gray60");
  m_hints.setColor("buff_min_vertex_color", "dodger_blue");
  m_hints.setColor("buff_min_fill_color", "gray70");
  m_hints.setColor("buff_min_label_color", "off");
  m_hints.setMeasure("buff_min_vertex_size", 1);
  m_hints.setMeasure("buff_min_fill_transparency", 0.25);
  
  m_hints.setColor("buff_max_edge_color", "gray60");
  m_hints.setColor("buff_max_vertex_color", "dodger_blue");
  m_hints.setColor("buff_max_fill_color", "gray70");
  m_hints.setColor("buff_max_label_color", "off");
  m_hints.setMeasure("buff_max_vertex_size", 1);
  m_hints.setMeasure("buff_max_fill_transparency", 0.1);
\end{fileverb}

\noindent
The posting of the inner and outer polygons can be disabled simply
with:

\vspace{0.1in}
\begin{fileverb}
  draw_buff_max_poly = false
  draw_buff_min_poly = false
\end{fileverb}

  


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


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