The software subdivision designs, implements, and maintains all programmable elements of the AUV. It strives to create a robust system that is capable of adapting to different conditions and performing complex actions. In order to complete this, the subdivision designs and improves algorithms to manage various aspects of the AUV’s operation, including mission planning, navigation, localization, machine vision, and signal processing.
To manage the complex software system with multiple collaborators, the team uses Git version control. Git allows the software team to work on the same files independently while keeping backups of previous versions of the code. Marlin’s software stack runs on the Debian OS (GNU/Linux). Dubbed Aquastorm, it consists of multiple processes that communicate over a shared mutex and named pipes. Each process works independently of the others, while the mutex ensures thread safety. Most software is written in C/C++ and Python.
Interface is the master program that starts each process on the software stack. Each process is run in a separate thread to increase the efficiency of our program. The threads run independently from each other, and read or write to a mutex when they need or receive data (e.g. images, the current state, the prediction model).
Our low-level controller runs on the ATMega2560 microcontroller. It connects to Aquastorm, the AHRS, and the thruster controllers via serial UART pins. It uses six PID filters, one for each bearing of the submarine. The resulting PID vector is multiplied by the thruster matrix, mapping the effect of each thruster on each element of the state, to produce the desired thruster power. The state consists of the (X, Y) position, computed by integrating the thrust vectors, the depth, determined from the analog pressure sensor, and the roll, pitch, and yaw from AHRS. Control sends the current state to the control process in Aquastorm, and receives the desired setpoint. It also activates the relays on command. Because of the simple serial protocol, Marlin can be controlled manually through a terminal for testing and debugging use. Furthermore, all configuration variables (e.g., PID gains and the thruster matrix) can be adjusted over serial communication to empirically tune the optimal values on the fly.
In order to robustly navigate obstacles and account for imprecise positioning and observations, Modeling localizes the sub to its environment. Our modeling algorithm uses Monte Carlo Localization, which initially constructs a uniform particle filter. Each particle represents a possible state of the sub. As the particle filter is first set to be mostly uniform, the sub has little knowledge about its surroundings. However, as the submarine moves around its environment, it is able to resample its particles with motor and sensor updates. Eventually, the particles converge upon the actual location of the submarine, leading to successful localization.
Each competition task is associated with a vision function within Aquastorm, that returns an observation based on what objects it detects. Most vision processes initially run preprocessing to generate more contrast in the image. Afterwards, they use a variation of machine learning, color mapping, edge, contour, and blob detection with the aid of the OpenCV library. Our machine learning algorithms utilize the Tensorflow Object Detection API to detect objects within an image.
Mission generates a list of goals to complete throughout the competition run. Each goal contains a set of instructions, location, and point value. Based on the location of both the sub and the goal, we can compute an estimated time to completion for each goal, and visit the goals in an optimal fashion, maximizing our point value. Once we select a goal to complete, mission tells the corresponding vision function to start returning observations.
Otolith, written using LabVIEW, runs on the FPGA and reads from the four hydrophones located outside the main hull. The analog-to-digital converter (ADC) receives amplified signals from the hydrophones at 500 thousand samples per second. Using each analog signal, Otolith applies a Butterworth low pass filter to remove extraneous noise, then looks for a ping of the designated frequency. The time at which the ping is detected is recorded for each hydrophone, then the time difference of arrival (TDOA) is computed and sent to the main computer for localization. On the main computer, a small C program receives the TDOAs and computes the location of the pinger using trigonometric ratios between the TDOAs; this method, while introducing a slight built-in error (which decreases as the sub points towards the pinger), is less susceptible to slight errors in physical measurements and ping detection when compared to multilateration (solving the system of hyperboloids), making it much more robust. It sends to Interface the corresponding Gaussian distribution.