<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\small
\begin{algorithmic}[1]
\label{alg_muster_rstate}
  \Procedure{OnRunState()}{}

  \State $V$ $\gets$ updatePositions() \Comment{Step 1: Section \ref{sec_bhv_muster_positions}}
  \State $P$ $\gets$ calculateVoronoiPartition($V$, $P_m$) \Comment{Step 2: Section \ref{sec_bhv_muster_voronoi}}
  \State $x_{sp}$, $y_{sp}$ $\gets$ calculateSetPoint($P_{os}$, $x_{os}$, $y_{os}$) \Comment{Step 3: Section \ref{sec_bhv_muster_setpt}}
  \State $mode(i)$ $\gets$ setMusterMode($x_{sp}$, $y_{sp}$, $x_{os}$, $y_{os}$, $mode(i-1)$) \Comment{Step 4: Section \ref{sec_bhv_muster_modes}}
  \If{$mode(i) \neq mode(i-1)$ and $mode(i)$ = captured}   \Comment{Step 5: Section \ref{sec_bhv_muster_modes}}
    \State postCaptureFlags()  \Comment{Step 6: Section \ref{sec_bhv_muster_capflags}}
  \EndIf
  \If{auto\_complete}   \Comment{Step 7: Section \ref{sec_bhv_muster_autocomp}}
     \State shareMusterMode($mode_{i}$) \Comment{Step 8: Section \ref{sec_bhv_muster_modeshare}}
     \State completed $\gets$ checkForCompletion() \Comment{Step 9: Section \ref{sec_bhv_muster_autocheck}}
     \If{completed}
        \State postRunFlags() \Comment{Step 10: Section \ref{sec_bhv_muster_autocomp}}
        \State postEndFlags() \Comment{Step 10: Section \ref{sec_bhv_muster_autocomp}}
        \State {\bf return} 0
     \EndIf
  \EndIf
  
  \If {(mode = captured) or (mode = holding)}    \Comment{Step 11: Section \ref{sec_bhv_muster_modes}}
     \State postRunFlags() \Comment{Step 12: Section \ref{sec_bhv_muster_modes}}
     \State {\bf return} 0
  \EndIf

  \State $\theta_{sp}$ $\gets$ $relbng(x_{os}, y_{os}, x_{sp}, y_{sp})$ \Comment{Step 13: Section \ref{sec_bhv_muster_setpt_bng}}
  \State $ipf$ $\gets$ buildIvPFunction($\theta_{sp}$)   \Comment{Step 14: Section \ref{sec_bhv_muster_ipf}}
     \State postRunFlags() \Comment{Step 15: Section \ref{sec_bhv_muster_postipf}}
     \State postActiveFlags() \Comment{Step 15: Section \ref{sec_bhv_muster_postipf}}
  \State {\bf return} $ipf$
  \EndProcedure
\end{algorithmic}

\label{alg_ptaskmgr}
\normalsize





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