<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[onecolumn,letterpaper,11pt]{article}

%===================================================================
\input{common_latex/common_latex_packages}
\input{common_latex/common_latex_definitions}
\input{common_latex/common_latex_help_format}
%===================================================================

\begin{document}

\begin{labcover}
\labtitle{Help Topic: Poking the MOOSDB}
\vspace{0.1in}
\labdate{Spring 2020}
\vspace{0.1in}
\labauth{Michael Benjamin, mikerb@mit.edu}
\labauth{Department of Mechanical Engineering}
\labauth{MIT, Cambridge MA 02139}
\labline
\end{labcover}

\wikidoc{file=Help.MIPPoking}
\wikidoc{auth=mikerb@mit.edu}

%====================================================================
\section*{Poking the MOOSDB}
%====================================================================

Poking refers to the idea of publishing a variable-value pair to
the \app{MOOSDB}. Many apps publish to the \app{MOOSDB} during the
course of normal operation. Poking implies a publication that perhaps
was not planned, or outside the normal mode of business. It is often
very useful for debugging. Here we describe the \app{uPokeDB} tool.

\pskip
\noindent
Where to get more information:

\begin{packed_itemize}[0]
\item \app{uPokeDB}: \urlx{http://oceanai.mit.edu/ivpman/apps/uPokeDB}
\end{packed_itemize}

\noindent
Or simply:

\vspace{0.1in}
\begin{consoleverb}
$ uPokeDB --web
\end{consoleverb}

%=====================================================================
\subsection*{Poking the MOOSDB with uPokeDB}

\app{uPokeDB} is a command-line tool for poking the \app{MOOSDB} with
one or more variable-value pairs. Poking the \app{MOOSDB} requires
knowing where the \app{MOOSDB} is running in terms of its IP address,
(\pvar{ServerHost} parameter), and port number, (\pvar{ServerPort}
parameter). These may be specified on the command line to
\app{uPokeDB}, but for our purposes here we assume the existence of a
mission file, \var{alpha.moos} with this information:

\vspace{0.15in}
\begin{fileverb}
 // (wget http://oceanai.mit.edu/2.680/examples/alpha.moos)
 ServerHost = localhost
 ServerPort = 9000
 Community  = alpha
\end{fileverb}
\vspace{0.15in}

\noindent
Your goals in this part are:

\begin{packed_enumerate}[3]
\item Open two terminal windows and launch the \app{MOOSDB} and \app{uXMS} as done
  previously:

\begin{consoleverb}
 $ MOOSDB alpha.moos 
 $ uXMS alpha.moos --all 
\end{consoleverb}
\vspace{0.1in}

\noindent
Now open a third terminal window for poking the \app{MOOSDB} as follows:

\begin{consoleverb}
 $ uPokeDB DEPLOY=true SPEED=2 alpha.moos
\end{consoleverb}
\vspace{0.1in}

\noindent
Note the two new variables, \var{DEPLOY} and \var{SPEED}, appearing in
the \app{uXMS} window. It should look something like:

\begin{consoleverb}
 ==============================================================
 uXMS_655                                              0/0(204)
 ==============================================================
 VarName     (S)  (T)  (C)  VarValue (SCOPING:EVENTS)
 ----------  ---  ---  ---  -------------------------
 DB_CLIENTS                 "uXMS_655,"
 DB_TIME                    1386249435.276804
 DB_UPTIME                  46.213629
 DEPLOY                     "true"
 SPEED                      2
\end{consoleverb}
\vspace{0.1in}

\item Note the variable values in \app{uXMS}. \mvar{DEPLOY} has the value
  \var{"true"} with double quotes, indicating that it is a string. The
  variable \mvar{SPEED} is of type double, indicated by the lack of
  quotes. The types were inferred by \app{uPokeDB} by heuristically
  checking whether the arguments are numerical or not. But sometimes
  you {\em do} want to publish a string with a numerical value. Try
  posting the variable \mvar{HEIGHT} with the string value of \var{"192"}, 
  noting the colon-equals instead of equals:

\begin{consoleverb}
 $ uPokeDB HEIGHT:=192 alpha.moos
\end{consoleverb}
\vspace{0.1in}

\noindent
Note the new variable, \mvar{HEIGHT}, appearing in the \app{uXMS}
window. It should look something like the below output, where in this case,
the \var{(S)ource} column is expanded to show the source of the
postings.

\begin{consoleverb}
==============================================================
uXMS_655                                              0/0(347)
==============================================================
VarName     (S)ource     (T)  (C)  VarValue (SCOPING:EVENTS)
----------  ---------    ---  ---  -------------------------
DB_CLIENTS  MOOSDB_alpha           "uXMS_655,"
DB_TIME     MOOSDB_alpha           1386250092.847527
DB_UPTIME   MOOSDB_alpha           703.784353
DEPLOY      uPokeDB                "true"
HEIGHT      uPokeDB                "192"
SPEED       uPokeDB                2
\end{consoleverb}
\vspace{0.1in}

\end{packed_enumerate}


%=====================================================================
\subsection*{Further things to try Using uPokeDB}

Here's some other things to consider and try:

\begin{packed_enumerate}[3]

%-----------------------
\item Trying poking the \mvar{DEPLOY} variable to the \app{MOOSDB} a second time, 
this time with:

\begin{consoleverb}
 $ uPokeDB DEPLOY=100 alpha.moos
\end{consoleverb}

\noindent
Does the value of \mvar{DEPLOY} change? If not, why not?

%-----------------------
\vspace{0.1in}
\item Create a simple script of pokes on the command line as follows:

\begin{consoleverb}
 $ uPokeDB APPLES=1 alpha.moos; sleep 5; uPokeDB APPLES=2 alpha.moos; 
\end{consoleverb}

\noindent
If you're new to the command line environment, the semicolon above
separates successful command line invocations. The \cmd{sleep} command
is a common shell utilitity that will simply pause a given number of
seconds before completing.

%-----------------------
\vspace{0.1in}
\item
Another way to execute the same simple script as above is to store the
above three commands in a file named, for example, \var{myscript}:

\begin{fileverb}
 uPokeDB APPLES=1 alpha.moos
 sleep 5
 uPokeDB APPLES=2 alpha.moos   
\end{fileverb}
\vspace{0.1in}

\noindent 
With the above file you can make the two successive pokes to the \app{MOOSDB},
with five seconds in between, with:

\begin{consoleverb}
 $ source myscript
\end{consoleverb}
\vspace{0.1in}

\end{packed_enumerate}

\noindent
There are many other ways of poking the \app{MOOSDB}. All MOOS apps that publish
anything are examples. Of course many MOOS applications publish a fixed set of
variables that are not easily changeable without re-coding. But certain apps like
\app{uTimerScript} and \app{pMarineViewer} have built-in configuration file
parameters for poking the \app{MOOSDB} in user configurable ways. 

\end{document}

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