<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}

%===================================================================
% Include common packages, environments, counters etc
\input{latex/common_latex_packages}
\input{latex/common_latex_lab_format}
\input{latex/common_latex_definitions}
%===================================================================
\setcounter{tocdepth}{2}
%===================================================================

\begin{document}
\wikidoc{file=Lab.2S01Horta}
\wikidoc{auth=supun@mit.edu}
\helplevelsubsec

%===================================================================
% Build the Cover Page in an environment style easy for wiki parsing
\begin{labcover}
\labtitle{Sea Beaver II Lab - Unit Testing and Simulations}
\vspace{0.2in}
\labcourse{2.S01 Azores: Introduction to Autonomous Underwater Vehicles}
\vspace{0.5in}
\labpng{0.6}{figures/computer_layout_w_sensors.png}
\vspace{0.25in}
\labdate{Summer 2024}
\vspace{0.23in}
\labauth{Supun Randeni, supun@mit.edu}
\labauth{Michael Benjamin, mikerb@mit.edu}
\labauth{Mike Sacarny, msacarny@mit.edu}
\labauth{Department of Mechanical Engineering}
\labauth{MIT, Cambridge MA 02139}
\labtoc{scriptsize}
\labtocdepth{2}
\end{labcover}

%===================================================================
% Add a blank page so first body page is on the right when doubleside
\blankpage

%===================================================================
% Begin the body of the text
%===================================================================
\section{Overview and Objectives}
%===================================================================

\begin{labinfo}
%\labinfoheader{Topics:}
\begin{packed_itemize}[2]
\item Goal - Learning how to log onto and off of the AUV
\item Goal - Learning what are the base sensors and actuators inside SeaBeaver II AUVs
\item Goal - Mastering how to login to the vehicle's embedded
  computers
\item Goal - Learning how to unit test individual sensors and actuators to ensure they are in working order
\item Goal - Learning how to run a purely software simulation  
\item Goal - Learning how to run a hardware-in-the-loop (HITL) simulation 
\item Goal - Learning how to run a "bench test" mission on actual AUV hardware 
\end{packed_itemize}
\end{labinfo}

%===================================================================
\section{How to login to SeaBeaver II -- Wireless}
%===================================================================

You can use the wireless approach when the AUV and you are both in
proximity to the \cmd{SeaBeaverNetwork} WiFi router. That is, you can
only complete this section when you are in the classroom or at the MIT
Sailing Pavilion. If you are doing this lab at home, please skip this
section to the next.

%----------------------------
\subsection{Connect to the \cmd{SeaBeaverNetwork} WiFi router}
%----------------------------

Connect your topside laptop to the \cmd{SeaBeaverNetwork} WiFi
access-point. The DHCP server in the router will assign you an IP
address in the range \cmd{192.168.0.100-200}. If you like, you can
check your IP address by using \cmd{ifconfig} command:

\vspace{0.1in}
\begin{consoleverb}
$ ifconfig


\end{consoleverb}
\vspace{0.1in}


%----------------------------
\subsection{SSH to the Raspberry Pi}
%----------------------------

The wireless interface of Seabeaver II Raspberry Pi computers are
configured with a unique static IP address in the range
\cmd{192.168.0.50-80}. The static IP address assigned for your
training kit will be clearly labeled on the side of the kit. If
otherwise, please ask the instructors. Now connect to the Raspberry Pi
via SSH:

\vspace{0.1in}
\begin{consoleverb}
$ ssh seabeaver-raspi@192.168.0.[last.digits.of.your.ip]
eg:
$ ssh seabeaver-raspi@192.168.0.51
\end{consoleverb}
\vspace{0.1in}

\noindent Now you will be asked to enter the password:

\vspace{0.1in}
\begin{consoleverb}
seabeaver-raspi@10.42.0.5's password: 
\end{consoleverb}
\vspace{0.1in}

\noindent
Enter the password (password will be provided to you by the
instructors).  Now you are successfully logged into the SeaBeaver's
Raspberry Pi.


%----------------------------
\subsection{Ensure that the Raspberry Pi has internet}
%----------------------------

You can check if the Raspberry Pi has internet access via the router by pinging google.com:

\vspace{0.1in}
\begin{consoleverb}
$ ping google.com 
\end{consoleverb}
\vspace{0.1in}

\noindent If you have internet access, you will see an output similar to this.

\vspace{0.1in}
\begin{consoleverb}
PING google.com (142.251.40.142) 56(84) bytes of data.
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=1 ttl=55 time=8.96 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=2 ttl=55 time=11.5 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=3 ttl=55 time=11.1 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=4 ttl=55 time=11.7 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=5 ttl=55 time=10.2 ms
\end{consoleverb}
\vspace{0.1in}

\noindent To exit from pinging, press ctrl+c.


%----------------------------
\subsection{SSH to the PocketBeagle}
%----------------------------

Once you have logged onto the RasPi, you can SSH into the PocketBeagle. The ip address is always the same:

\vspace{0.1in}
\begin{consoleverb}
$ ssh debian@192.168.7.2
\end{consoleverb}
\vspace{0.1in}

\noindent Now you will be asked to enter the password:

\vspace{0.1in}
\begin{consoleverb}
Debian GNU/Linux 10

BeagleBoard.org Debian Buster IoT Image 2020-04-06

Support: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]
\end{consoleverb}
\vspace{0.1in}

%----------------------------
\subsection{Ensure that the PocketBeagle has internet}
%----------------------------

Similar to the RasPi, you can ensure that the PocketBeagle has internet access via the RasPi by pinging google.com:

\vspace{0.1in}
\begin{consoleverb}
$ ping google.com 
\end{consoleverb}
\vspace{0.1in}

\noindent If you have internet access, you will see an output similar to this.

\vspace{0.1in}
\begin{consoleverb}
PING google.com (142.251.40.142) 56(84) bytes of data.
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=1 ttl=55 time=8.96 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=2 ttl=55 time=11.5 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=3 ttl=55 time=11.1 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=4 ttl=55 time=11.7 ms
64 bytes from lga25s80-in-f14.1e100.net (142.251.40.142): icmp_seq=5 ttl=55 time=10.2 ms
\end{consoleverb}
\vspace{0.1in}

\noindent To exit from pinging, press ctrl+c.

%===================================================================
\section{Unit testing sensors}
%===================================================================

As shown in Figure \ref{fig_sensor_layout}, the PocketBeagle serves as
a hub that interfaces with the sensors and actuators of the
vehicle. Throughout the AUV's life; that is, starting from the initial
breadboard design phase to printed circuit board (PCB) testing, pre
vehicle assembly, post vehicle assembly and during in-water
operations; it is necessary to check if individual sensor and actuator
components work as a single unit.  To support that, we have developed
a set of low-level programs to unit test individual components.


\vspace{0.1in}
\begin{figure}[H]
\centering
\includegraphics[width=0.98\textwidth]{figures/computer_layout_w_sensors.png}
\caption{Sensors and actuators of SeaBeaver II AUVs are connected to the PocketBeagle}
\label{fig_sensor_layout}
\end{figure}

\noindent In order to perform unit tests and other activities such as
simulations you will first need to SSH into the PocketBeagle, as
described in the previous section.

%===========================
\subsection{Depth sensor}
%===========================

The depth sensor of an AUV measures the vehicle's current depth, by
measuring the external hydrostatic water pressure and converting it to
depth, using the equation:

\vspace{0.16in}
\begin{twequation}
  \input{eq_depth}
\end{twequation}

\noindent
where $P$ is the measured hydrostatic pressure, $\rho$ is the density
of water, and $g$ is the gravitational acceleration). In SeaBeaver II
AUVs, we use a BlueRobotics Bar30 depth sensor:
\urlx{https://bluerobotics.com/store/sensors-cameras/sensors/bar30-sensor-r1/}

\vspace{0.1in}
\noindent
This sensor is connected to the PocketBeagle via the Inter-Integrated
Circuit (I2C) interface. When the depth sensor is plugged in to the
daughter board, you can run the \cmd{test\_br\_depth} program to test
if the depth sensor is connected to the PocketBeagle, and is in proper
working order:

\vspace{0.1in}
\begin{consoleverb}
$ test_br_depth
\end{consoleverb}
\vspace{0.1in}

\noindent If the depth sensor is working as expected, you will see an output similar to this:

\vspace{0.1in}
\begin{consoleverb}
debian@beaglebone:~$ test_br_depth 
Acquired PROM contents
crc_data: 28673, c1: 30169, c2: 29708, c3: 18186, c4: 18854, c5: 28659, c6: 26886
Raw temp: 7386608, raw pressure: 4304880
dT: 4716612, ti: 49904
Depth: -0.09 m, Pressure: 1004.10 mbar, Temperature: 21.59 C
Raw temp: 7387120, raw pressure: 4305392
dT: 4716612, ti: 50416
Depth: -0.06 m, Pressure: 1007.10 mbar, Temperature: 21.61 C
Raw temp: 7387632, raw pressure: 4305392
dT: 4716612, ti: 50928
Depth: -0.06 m, Pressure: 1007.10 mbar, Temperature: 21.63 C
Raw temp: 7387120, raw pressure: 4305392
dT: 4716612, ti: 50416
\end{consoleverb}
\vspace{0.1in}



\noindent
Press ctrl+c to exit. If the depth sensor is not properly connected or
faulty, you will see an output similar to this:

\vspace{0.1in}
\begin{consoleverb}
debian@beaglebone:~$ test_br_depth 
ERROR: in rc_i2c_send_bytes, system write returned -1, expected 1
ERROR: Can not send reset
\end{consoleverb}
\vspace{0.1in}

\noindent {\bf Troubleshooting}:
\begin{itemize}
    \item Make sure that the depth sensor is plugged into the J4
      connector of the daughter board.
    \item If you have a different depth sensor that you know that
      works (perhaps a depth sensor that has been tested by a
      classmate), try it. This will help isolate the problem.
    \item Talk to an instructor.
\end{itemize}


%===========================
\subsection{Barometer sensor}
%===========================

SeaBeaver II AUVs come with an internal barometer that measures the
pressure inside the pressure hull. As you will learn later in this
class, observing internal pressure is important to check if the
pressure hull has leaks (i.e. once you assembled the vehicle, you will
pull the air inside the pressure hull out to create a vacuum. If the
vacuum leaks out at a rate higher than what is acceptable, that means
your pressure hull has a leak somewhere!).

\vspace{0.1in}
\noindent
In SeaBeaver II, we have a MPL3115A2 barometric pressure sensor
(\urlx{https://cdn-shop.adafruit.com/datasheets/1893_datasheet.pdf})
connected to the PocketBeagle via I2C interface. You can unit test the
internal barometer using the \cmd{test\_barometer} program:

\vspace{0.1in}
\begin{consoleverb}
$ test_barometer
\end{consoleverb}
\vspace{0.1in}

\noindent
If the barometer functions as expected, you will see an output similar
to this:

\vspace{0.1in}
\begin{consoleverb}
debian@beaglebone:~$ test_barometer 
 Pressure: 100.227. Alt: 92. Temparature (C): 28.375
 Pressure: 100.228. Alt: 397537. Temparature (C): 28.375
 Pressure: 100.232. Alt: 397537. Temparature (C): 28.375
 Pressure: 100.228. Alt: 397538. Temparature (C): 28.375
\end{consoleverb}
\vspace{0.1in}

\noindent Press ctrl+c to exit. If you get an error, talk to an instructor to debug.

%===========================
\subsection{Attitude and heading reference system (AHRS)}
%===========================

The attitude and heading reference system (AHRS) is essentially an
Inertial Measurement Unit (IMU) with a fusion algorithm that outputs
the roll, pitch and heading angle of the vehicle. These are crucial
parameters for underwater navigation.

\vspace{0.1in}
\noindent
In Seabeaver II, we use a XSens MTi-3 Micro-Electro-Mechanical systems
(MEMS) AHRS

%(\urlx{https://www.xsens.com/hubfs/Downloads/Leaflets/MTi-3.pdf?__hstc=157421285.f5cd38348bc5bc52dd21d613318130a3.1702921081291.1711079802081.1711835258589.16&amp;__hssc=157421285.1.1711835258589&amp;__hsfp=875856448}).

\vspace{0.1in}
\noindent
\urlx{https://www.xsens.com/hubfs/Downloads/Leaflets/MTi-3.pdf}

\vspace{0.1in}
\noindent
The IMU is connected to the PocketBeagle using a universal
asynchronous receiver/transmitter (UART) interface. You can unit test
this sensor using the \cmd{test\_xsens\_mti3} program.

\vspace{0.1in}
\begin{consoleverb}
$ test_xsens_mti3
\end{consoleverb}
\vspace{0.1in}

\noindent
If the sensor is connected and is in the working order, you will be
asked to check if the latitude and longitude currently written in the
sensor's non-volatile memory is correct. (The MTi-3 AHRS corrects for
the magnetic declination; therefore, it is important that it knows our
approximate operational area):

\vspace{0.1in}
\begin{consoleverb}
debian@beaglebone:~$ test_xsens_mti3 
Testing the Xsens MTi-3 IMU
First scanning for USB devices...
No USB device found. Scanning: /dev/ttyO4 at baud rate: 115200
Found a device with ID: 038898CE @ port: /dev/ttyO4, baudrate: 115200
Opening port...
Device: MTi-3-8A7G6, with ID: 038898CE opened.
Putting device into configuration mode...
Configuring the device...

 Current Latitude: 52.2405 | Longtitude: 6.83822 | Altitude: 1.29442e-312
Do you want to change the position for magnetic declination? 
Enter Y to change Lat/Long. Any other input to keep them. 
\end{consoleverb}
\vspace{0.1in}

\noindent
In this example, latitude and longitude do not represent Horta
(latitude 38.5348, longitude -28.6300), and this will most likely be
the case for the AHRS in a brand new training-kit or one previously
configured at MIT. In this case, press \cmd{Y} and hit return:

\vspace{0.1in}
\begin{consoleverb}
 Current Latitude: 52.2405 | Longtitude: 6.83822 | Altitude: 1.29442e-312
Do you want to change the position for magnetic declination? 
Enter Y to change Lat/Long. Any other input to keep them. 
y
Enter the new Latitude.. 
\end{consoleverb}
\vspace{0.1in}

\noindent Then you will be asked to enter your latitude, so enter the
latitude of Horta (38.5348):

\vspace{0.1in}
\begin{consoleverb}
 Current Latitude: 52.2405 | Longtitude: 6.83822 | Altitude: 1.29442e-312
Do you want to change the position for magnetic declination? 
Enter Y to change Lat/Long. Any other input to keep them. 
y
Enter the new Latitude.. 
38.5348                                  
Enter the new Longitude..
\end{consoleverb}
\vspace{0.1in}

\noindent
Enter the longitude of Horta (-28.6300, {\bf note the minus!}) Then
  the sensor will start outputting raw data and you will see an output
  similar to this:

\vspace{0.1in}
\begin{consoleverb}
 New Latitude: 38.5348 | Longitude: -28.6300 | Altitude: 9.54898e-313
Putting device into measurement mode...

Reading data...
Acc X:1.06, Acc Y:-0.15, Acc Z:9.70 |Gyr X:0.01, Gyr Y:0.01, Gyr Z:-0.00 
|Mag X:0.09, Mag Y:0.36, Mag Z:-0.56 |Roll:-0.91, Pitch:-6.29, Yaw:37.35, Hdg:232.65
\end{consoleverb}
\vspace{0.1in}

\noindent
Stretch out the terminal window to get a whole line of IMU data, then
move the training-kit around and observe how the raw acceleration,
gyroscope and magnetometer readings, as well as fused roll, pitch and
heading angles vary. Press ctrl+c to exit.

%===========================
\subsection{Global Positioning System (GPS)}
%===========================

While GPS does not work underwater, AUVs use GPS to initialize the
position while on the water surface. SeaBeaver II vehicles use an
Adafruit Ultimate GPS Breakout V3 as the GPS module
(\urlx{https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps.pdf}). This
module is connected to the PocketBeagle via the UART interface.

You can unit test the GPS by using the linux minicom tool
(\urlx{https://linux.die.net/man/1/minicom}). Minicom will display the
NMEA strings that the GPS outputs.

\vspace{0.1in}
\begin{consoleverb}
$ minicom -D /dev/ttyO0 -b 9600 -w
\end{consoleverb}
\vspace{0.1in}

If the GPS is connected to the PocketBeagle properly, and is it
working order, you will see an output similar to this:

\vspace{0.1in}
\begin{consoleverb}
Welcome to minicom 2.7.1

OPTIONS: I18n 
Compiled on May  6 2018, 10:36:56.
Port /dev/ttyO0, 22:10:29

Press CTRL-A Z for help on special keys

$GPGGA,222359.000,4221.5879,N,07106.2830,W,1,06,1.24,3.5,M,-33.7,M,,*51
$GPGSA,A,3,06,12,05,11,25,19,,,,,,,1.56,1.24,0.95*04
$GPRMC,222359.000,A,4221.5879,N,07106.2830,W,0.40,139.56,300324,,,A*74
$GPGGA,222400.000,4221.5880,N,07106.2831,W,1,06,1.24,3.5,M,-33.7,M,,*5D
$GPGSA,A,3,06,12,05,11,25,19,,,,,,,1.56,1.24,0.95*04
$GPRMC,222400.000,A,4221.5880,N,07106.2831,W,0.41,139.56,300324,,,A*79
$GPGGA,222401.000,4221.5881,N,07106.2831,W,1,06,1.24,3.5,M,-33.7,M,,*5D
$GPGSA,A,3,06,12,05,11,25,19,,,,,,,1.56,1.24,0.95*04
$GPRMC,222401.000,A,4221.5881,N,07106.2831,W,0.45,139.56,300324,,,A*7D
\end{consoleverb}
\vspace{0.1in}

\noindent
Try to figure out what these data strings mean (hint: these are NMEA
sentences.) {\bf Note: The GPS may not be able to receive satellite
  signals inside!} To exit from minicom, press ctrl+A and then X.

%\end{itemize}


%===================================================================
\section{Unit testing actuators}
%===================================================================

Now let's focus on unit testing the actuators.

%===========================
\subsection{Control surfaces}
%===========================

The servo motors that actuates the control surfaces of the SeaBeaver
II AUVs are driven by Pulse-Width Modulation (PWM) commands provided
by the PocketBeagle. The signal lines of the servo motors are
connected to certain Programmable Real-time Unit (PRU) output pins of
the PocketBeagle that are configured to generate necessary PWM
signals. Within the range, each PWM command corresponds to a certain
position/angle of the servo motor.

\vspace{0.1in}
\noindent
You can test the servo motors that run the control surfaces by running \cmd{test\_control\_surfaces} program:

\vspace{0.1in}
\begin{consoleverb}
$ test_control_surfaces
\end{consoleverb}
\vspace{0.1in}

\noindent If the servos are properly connected to the J6 pins of the
daughter board, you will observe the servos moving, one at a
time. Press ctrl+c to exit.

%===========================
\subsection{Main propulsion thruster}
%===========================

\noindent
{\bf WARNING: Always consider that the main thruster is live. Do NOT
  put fingers near the propeller while the thruster is plugged in!}

\vspace{0.1in}
\noindent
SeaBeaver II AUVs use a Blue Robotics T200 thrusters
(\urlx{https://bluerobotics.com/store/thrusters/t100-t200-thrusters/t200-thruster-r2-rp/})
as the main propulsion thruster. Similar to the servo motors, the main
thruster is driven by PWM signals signals. However, in this case, PWM
signals correspond to a speed value of the thruster.  You can test the
main thruster by running \cmd{test\_br\_thruster} program:

\vspace{0.1in}
\begin{consoleverb}
$ test_br_thruster
\end{consoleverb}
\vspace{0.1in}

\noindent Now you will be asked to provide a thruster percentage
value. If you are testing the actual Blue Robotics T200 thruster,
please do not provide a value beyond 50\%. 20\% is a good value to
test the Blue Robotics T200 thrusters.

\vspace{0.1in}
\begin{consoleverb}
debian@beaglebone:~$ test_br_thruster 
Enter thruster percentage between 100 and -100. ctrl-c to exit: 20
\end{consoleverb}
\vspace{0.1in}

\noindent If everything is in proper order, you will now see the
propeller turning.  {\color{red} Note: Please do not run the Blue
  Robotics T200 thruster in air for more than 10 seconds as it will
  overheat.} You may run the mockup main motor provided in your
training-kit as long as you like.

%===========================
\subsection{Light Emitting Diode (LED) indicators}
%===========================

While the LED indicators are not crucial for SeaBeaver II AUVs, they
can make the vehicle operators' lives easier by indicating the current
status of the vehicle, increasing the mission success rate. They are
connected to the PocketBeagle using the general purpose input/output
(GPIO) pins.  You can test them by running the \cmd{test\_leds}
program:

\vspace{0.1in}
\begin{consoleverb}
$ test_leds
\end{consoleverb}
\vspace{0.1in}

\noindent If everything is working as expected, the LEDs should now start blinking, one at a time. Press ctrl+c to exit. 

%===================================================================
\section{Software-in-the-loop (SITL) simulations}
%===================================================================

The \cmd{missions-seabeaver} launch framework is designed in a way
that we are able to simulate the mission, either software-in-the-loop
(i.e. in the topside laptop) or hardware-in-the-loop (i.e. on the
vehicle itself) fashion; and deploy the same mission in the field in
runtime mode. This way we can ensure that the mission has been setup
correctly and the hardware is working properly, before deploying a
vehicle in the field. In SITL simulations, as shown in Figure
\ref{fig_sitl}, the frontseat, backseat and VECTORS MOOS communities
are all launched in the topside computer.

\vspace{0.1in}
\begin{figure}[H]
\centering
\includegraphics[width=1\textwidth]{figures/SITL.png}
\caption{In software-in-the-loop simulations, frontseat, backseat and VECTORS MOOS communities are all launched on the topside computer}
\label{fig_sitl}
\end{figure}

\noindent Before launching a mission using  \cmd{missions-seabeaver}, you need to configure three things: 

\begin{enumerate}
    \item {\bf The vehicle architecture}: This is the vehicle
      class; SeaBeaver II in our case.
    \item {\bf The vehicle name}: Sometimes each vehicle
      has have slightly unique parameters. So we need to define what
      our vehicle is.
    \item {\bf The cruise (or mission)}: This is will tell the mission-specific parameters.
\end{enumerate}

\noindent
Configuring and launching is done in the \cmd{launch\_scripts}
directory {\bf on the topside computer }(class laptop.) So let's go
there:

\vspace{0.2in}
\noindent Open a new Terminal window {\bf on your class laptop}, then:

\begin{consoleverb}
$ cd ~/missions-seabeaver/launch_scripts/
\end{consoleverb}
\vspace{0.1in}

%===========================
\subsection{Defining the vehicle architecture}
%===========================

First, configure the vehicle architecture. Run the following command
to list all the available architectures, and you should get a similar
output:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_architecture.sh 
usage: ./architecture_config.sh {architecture-name}

current architecture is set to: 
(not set)

available architectures include: 
seabeaver_ii.def
template_architecture.def
\end{consoleverb}
\vspace{0.1in}

\noindent As you can see, there are two available architectures (1)
\cmd{seabeaver\_ii}, and (2) \cmd{template\_architecture}. Let's
select our vehicle architecture; i.e. \cmd{seabeaver\_ii}:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_architecture.sh seabeaver_ii
\end{consoleverb}
\vspace{0.1in}

\noindent note: make sure that you exclude the suffix [.def]. I.e. do
NOT configure like this: \cmd{./configure\_architecture.sh
  seabeaver\_ii.def}


%===========================
\subsection{Defining the vehicle}
%===========================

Now let's configure the vehicle name. Run the
\cmd{./configure\_vehicle.sh} script to list all the available
vehicles, and you should get a similar output:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_vehicle.sh
\end{consoleverb}
\vspace{0.1in}

\noindent It will give you an output similar to this:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_vehicle.sh 
usage: ./vehicle_config.sh {vehicle-name}

current vehicle is set to: 
(not set)

current sensor_config.txt is set to: 
(not set)

available vehicles include: 
sb2_alpha.def
template_uuv.def
\end{consoleverb}
\vspace{0.1in}

\noindent At a minimum, there will be two vehicles: (1)
\cmd{sb2\_alpha}, and (2) \cmd{template\_uuv}. In later sessions, you
will create a definition file for your own vehicle. But for now, let's
use the \cmd{sb2\_alpha} AUV's definition. Configure the vehicle:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_vehicle.sh sb2_alpha
\end{consoleverb}
\vspace{0.1in}


%===========================
\subsection{Defining the cruise}
%===========================

Finally, we will configure the cruise, or the mission, that we need to run. Run the \cmd{./configure\_cruise.sh} script to list all the available cruises:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_cruise.sh 
usage: ./cruiseconfig.sh {cruisename}

current cruise definition is set to: 
b_zigzag.def

current pMITFS_MissionScript plug is set to: 
b_zigzag_pMITFS_MissionScript.plug

available cruise names include: 
a_confidence.def
bench_test.def
b_zigzag.def
lab_4_do_nothing_log_data.def
shipwreck_search.def
template_cruise.def
\end{consoleverb}
\vspace{0.1in}

\noindent In this lab, we are going to simulate the \cmd{shipwreck\_search} mission. Let's select that:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_cruise.sh shipwreck_search
Successfully configured the cruise to shipwreck_search in sb-topside-4!
\end{consoleverb}
\vspace{0.1in}


%===========================
\subsection{Launching a software-in-the-loop simulated mission}
%===========================

Now we can launch the mission as a software-in-the-loop simulation by executing \cmd{launch\_simulation.sh} script on the {\bf topside computer} (class laptop):

\vspace{0.1in}
\begin{consoleverb}
$ ./launch_simulation.sh 
\end{consoleverb}
\vspace{0.1in}

\noindent On the terminal, you will see an output similar to this:

\vspace{0.1in}
\begin{consoleverb}
$ ./launch_simulation.sh 

Launching Frontseat-Backseat mode.. 
SITL launch in process..
Launching mode is: FRONTBACK_FRONT
Part 3: Assembling targ_ Frontseat .moos ... Done
Part 3: Assembling targ_ Frontseat .bhv ... Done
Launching Frontseat MOOS Community. WARP is 1
Done
SITL launch in process..
Launching mode is: FRONTBACK_BACK
Part 3: Assembling targ_ Backseat .moos ... Done
Part 3: Assembling targ_ Backseat .bhv ... Done
Part 3: Assembling targ_ VECTORS .moos ... Done
Launching Backseat MOOS Community. WARP is 1
Done
Launching VECTORS MOOS Community. WARP is 1
Done
uMAC launching as uMAC_5881

uMAC_5881 thread spawned
starting uMAC_5881 thread
1713245491.3322 140123404248832-                           disabling nagle

-------------- moos connect ----------------------
  contacting a MOOS server localhost:9250 -  try 00001 
  Handshaking as uMAC_5881              [ok]
  DB reports async support is           [on]
  DB is running on                      sb-topside-4
  Timing skew estimation is             [off] (not needed)
--------------------------------------------------

uMAC_5881 is Running:
 |-Baseline AppTick   @ 5.0 Hz
 |--Comms is Full Duplex and Asynchronous
 -Iterate Mode 0 :
   |-Regular iterate and message delivery at 5 Hz

==================================================
uMAC_5881:  Nodes (0)                   (1) EVENTS
==================================================
AppCasts Recd: 0

ID  Node  HMode  Recd  CWarns  RWarns
--  ----  -----  ----  ------  ------

==================================================
uMAC_5881:  Nodes (1)                   (2) EVENTS
==================================================

\end{consoleverb}
\vspace{0.1in}

\noindent The \cmd{pMarineViewer} window will come up shortly. The
mission will automatically start after 30 seconds, and will run for 7
minutes total. The mission is to go to the middle of the river,
conduct a short zig-zag pattern search mission, and loiter until the 7
minute runtime is complete. Observe the followings:

\begin{itemize}
    \item You will see two vehicle icons; one with the name
      \cmd{SB2\_ALPHA}, and the other \cmd{SB2\_ALPHA\_GT}. The two
      vehicles will start at the same location, and then diverge. GT
      stands for the {\em ground truth}; that is, the actual position
      of the simulated vehicle. The \cmd{SB2\_ALPHA} is the navigation
      solution computed by onboard navigation system;
      i.e. \cmd{pMITFS\_HydroMANLite} application. During our
      underwater navigation session, we discuss the reasons for this
      divergence, and how to minimize it.

    \item You will also note that the vehicle is not able to conduct a
      clear zig-zag pattern, and it wiggles. During our controls
      session, we will discuss the reasons for this, and how to
      minimize it.

    \item Observe the heading, speed and depth values of the vehicle
      displayed on the bottom-side on the \cmd{pMarineViewer} window.
\end{itemize}

\vspace{0.1in}
\begin{figure}[H]
\centering
\includegraphics[width=1\textwidth]{figures/search.png}
\caption{\cmd{pMarineViewer} window for the \cmd{shipwreck\_search} mission}
\label{fig_pMV}
\end{figure}

The software-in-the-loop simulations can be sped-up by time
warping. That is, we can simulate missions faster than real time by
appending the time warp factor at the end of
\cmd{./launch\_simulation.sh} command. For example, if you want to run
the simulation 5 times faster than real time:

\vspace{0.1in}
\begin{consoleverb}
$ ./launch_simulation.sh 5
\end{consoleverb}
\vspace{0.1in}

\noindent {\bf Please do NOT time warp hardware-in-the-loop
  simulations since the servo motors and the thruster can be damaged.}

%===========================
\subsection{Killing the mission}
%===========================

You can press ctrl+c on the terminal to kill the mission. To be safe,
you can also use \cmd{ktm} command (kill-the-moos) and kill all the
MOOS processes.


%===================================================================
\section{Hardware-in-the-loop (HITL) simulations}
%===================================================================

Hardware-in-the-loop simulations allow us to test the majority of
software and hardware components at a lower cost, minimizing the
required in-water testing time and the risk of expensive failures. In
SeaBeaver HITL simulations, we try to run the software in the
respective computers where they are supposed to run during in-water
operation to minimize any deviations. That is:

\begin{itemize}
 \item The Frontseat MOOS community runs in the PocketBeagle.
 \item The Backseat MOOS community runs in the Raspberry Pi.
 \item The Topside MOOS community runs in the topside computer.
 \item The VECTORS MOOS community (simulating the ocean environment)
   runs in the Raspberry Pi. This is the only case where software is
   running that is not running during an actual mission.
\end{itemize}

\vspace{0.1in}
\begin{figure}[H]
\centering
\includegraphics[width=1\textwidth]{figures/HITL.png}
\caption{Four MOOS communities are launched during hardware-in-the-loop simulations}
\label{fig_HITL}
\end{figure}


%===========================
\subsection{Defining the architecture, vehicle and cruise}
%===========================

As in SITL simulation, we need to configure the architecture, vehicle,
and cruise on the Topside computer. We also need to configure the
mission on the Raspberry Pi and PocketBeagle. However, when run on the
Raspberry Pi, the configuration scripts will automatically apply the
same configuration to the PocketBeagle using remote SSH commands, so
we do not have to do that. Let's try it.

\vspace{0.1in}
\noindent Please log {\bf into the Raspberry Pi} and change
directory to \cmd{missions-seabeaver}.

\vspace{0.1in}
\begin{consoleverb}
$ cd ~/missions-seabeaver
\end{consoleverb}
\vspace{0.1in}

\noindent On {\bf the Raspberry Pi}, configure the architecture to
\cmd{seabeaver\_ii} by using the following command:

\vspace{0.1in}
\begin{consoleverb}
$ cd launch_scripts/
$ ./configure_architecture.sh seabeaver_ii
Successfully configured the architecture to seabeaver_ii in seabeaver-raspi!
Configuring the architecture on the PocketBeagle. Architecture name: seabeaver_ii
Debian GNU/Linux 10

BeagleBoard.org Debian Buster IoT Image 2020-04-06

Support: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]

Successfully configured the architecture to seabeaver_ii in debian!
\end{consoleverb}
\vspace{0.1in}

\noindent Similarly, configure the vehicle to \cmd{sb2\_alpha} and cruise to \cmd{shipwreck\_search} on the Raspberry Pi:

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_vehicle.sh sb2_alpha
Successfully configured the vehicle to sb2_alpha in seabeaver-raspi!
Configuring the vehicle on the PocketBeagle. Vehicle name: sb2_alpha
Debian GNU/Linux 10

BeagleBoard.org Debian Buster IoT Image 2020-04-06

Support: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]

Successfully configured the vehicle to sb2_alpha in debian!

$ ./configure_cruise.sh shipwreck_search
Successfully configured the cruise to shipwreck_search in seabeaver-raspi!
Configuring the cruise on the PocketBeagle. Cruise name: shipwreck_search
Debian GNU/Linux 10

BeagleBoard.org Debian Buster IoT Image 2020-04-06

Support: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

default username:password is [debian:temppwd]

Successfully configured the cruise to shipwreck_search in debian!
\end{consoleverb}
\vspace{0.1in}


%===========================
\subsection{Launching the topside}
%===========================

We typically launch the topside MOOS community before launching the
backseat or frontseat MOOS communities. Before launching the topside,
we need to configure the architecture, vehicle, and cruise on the
{\bf topside computer} as well:

\vspace{0.1in}
\begin{consoleverb}
$ cd ~/missions-seabeaver/launch_scripts/
$ ./configure_architecture.sh seabeaver_ii
\end{consoleverb}
\vspace{0.1in}

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_vehicle.sh sb2_alpha
\end{consoleverb}
\vspace{0.1in}

\vspace{0.1in}
\begin{consoleverb}
$ ./configure_cruise.sh shipwreck_search
\end{consoleverb}
\vspace{0.1in}

\noindent We are almost ready to launch the topside, but first run
{\bf ifconfig} and get the ip address of the topside:

\vspace{0.1in}
\begin{consoleverb}
$ ifconfig

lo: flags=73&lt;UP,LOOPBACK,RUNNING&gt;  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10&lt;host&gt;
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 379469  bytes 59747567 (59.7 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 379469  bytes 59747567 (59.7 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlp0s20f3: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
        inet HERE IS THE IP! &gt;&gt;&gt; 192.168.0.102 netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::731f:7b8e:2326:8e73  prefixlen 64  scopeid 0x20&lt;link&gt;
        ether 14:75:5b:b9:db:42  txqueuelen 1000  (Ethernet)
        RX packets 4784758  bytes 5668111410 (5.6 GB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1548473  bytes 575385379 (575.3 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
\end{consoleverb}

\vspace{0.1in}

\noindent In this case, the ip address is 192.168.0.102. Remember this!
\vspace{0.1in}
\noindent Finally we are ready to launch the topside:

\vspace{0.1in}
\begin{consoleverb}
$ ./launch_topside.sh
\end{consoleverb}
\vspace{0.1in}

\noindent The \cmd{pMarineViewer} window should open. However, you
will not see any vehicles until you launch the backseat and frontseat.

%===========================
\subsection{Launching the hardware-in-the-loop simulation mission}
%===========================

Similar to the configurations, if you launch the mission {\bf on
  the Raspberry Pi }(i.e. backseat), it will automatically launch the
frontseat on the PocketBeagle. We can use the \cmd{./launch\_hitl.sh}
script to launch the mission. However, we do need to let the backseat
MOOS community know the IP address of the designated topside laptop by
using \cmd{--topside=} flag; for example, run this on the Raspberry
Pi:

\vspace{0.1in}
\begin{consoleverb}
$ ./launch_hitl.sh --topside=192.168.0.102
\end{consoleverb}
\vspace{0.1in}

Now the two vehicle icons (i.e., \cmd{SB2\_ALPHA}, and
\cmd{SB2\_ALPHA\_GT}) should appear, and they should start the same
\cmd{shipwreck\_search} mission that we can in SITL mode. However,
this time the mock-up control surfaces and thruster on your
training-kit should move.

Observe the following:

\begin{itemize}
    \item Movement of the rudder with heading changes.
    \item Movement of the elevators with heading changes.
    \item Movement of the elevators with depth (note that the mission
      expects to run the vehicle at 1m depth).
\end{itemize}

\noindent {\bf Please do NOT time warp hardware-in-the-loop
  simulations since the servo motors and the thruster can be damaged.}


%===========================
\subsection{Killing the mission}
%===========================

You can press ctrl+c on the Raspberry Pi terminal to kill both the
frontseat and the backseat. However, if the servo motors did not stop,
please log into the PocketBeagle and use \cmd{ktm} command
(kill-the-moos) and kill all the MOOS processes. Press ctrl+c on the
topside terminal to kill the topside MOOS community.


%===================================================================
\section{Running "in real life" (unsimulated)}
%===================================================================

Although we will not be running the Training Kit in water, it behaves
like the actual AUV, and we can use it to learn the launch procedures
and see how the AUV would respond to changes in heading or pitch, for
example. We will now run a very short and simple mission as the
initial deployment, named \cmd{a\_confidence}.

\noindent In this mission, the propeller will start to spin 10 seconds
after you launched the mission. It will end (i.e. mission completion)
at 120 seconds (i.e. one minute of flight time).

\noindent There is only one constant course mission in the mission
profile, which will command the vehicle to go at a heading of 150
degree, depth of 1 m and a speed of 0.8 m/s.

\noindent Configure the vehicle using following commands on the Raspberry Pi:

\vspace{0.1in}
\begin{consoleverb}
$ cd missions-seabeaver/launch_scripts
$ ./configure_architecture.sh seabeaver_ii
$ ./configure_vehicle.sh sb2_alpha
$ ./configure_cruise.sh a_confidence
\end{consoleverb}
\vspace{0.1in}

\noindent Launch the mission {\bf on the Raspberry Pi} using the
following command (no need to run the topside!)

\vspace{0.1in}
\begin{consoleverb}
$ launch_runtime.sh
\end{consoleverb}
\vspace{0.1in}

\noindent The mission will start in 10 seconds. The white LED
indicator will start to blink faster 10 seconds before the propeller
starts to spin.

\vspace{0.1in}
\noindent Try the following:
\begin{itemize}
\item Vary the heading (yaw.) What happens to the rudder? Can you
      find the heading that is called for by the mission?
    \item Vary the pitch of the Kit? Do the actions of the elevons make sense?
    \item Slowly roll the Kit? Do the actions of the fins make sense?
\end{itemize}


%---------------------------
\subsection{Killing the mission}
%---------------------------

After the mission, you can enter ctrl+c to kill the mission.


%\end{itemize}

%\end{enumerate}

\end{document}

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