We want to develop the control software for the glider in a way that will allow testing. In theory, with an accurate glider model, this allows you to develop the software independent of hardware, reducing the cost/time of PID optimisation.
The control software sets the buoyancy and trim and requests the angle and depth. Therefore, the Arduino code is written so that it either controls real or simulated hardware. A compiler flag is used to switch between real or simulated hardware.
Using Unity3d I created a simulation of the glider ascending/descending. The movement through the "water" is modelled using the buoyancy engine, Realistic Water Physics. The glider is modelled as a number of elements, the main body, a volume at the front that changes buoyancy and a mass that moves on the underside of the body that trims the angle.
Unity provides an Arduino with depth/gyroscope readings which are then used by the Arduino to calculate motor movements and these are passed back to Unity. Using these motor movements, Unity models the simulated glider.
The below GIF shows a screen capture of the glider simulation ascending and then descending.
Over the coming weeks I will optimise the simulation model to accurately reflect experimental data from the glider.