Work record: , 4 minute read

The depth-sign flip that sent a simulated hull to +20 metres

Running the board's depth-control code against a dynamics model exposed a sign mismatch. The completed simulation is useful evidence; it is not the missing water validation.

The standing gap at this host-integration checkpoint was the board’s automatic depth loop under this stack and hull. A forward-motion primitive could depend on it even when the requested action sounded purely horizontal. An in-air check near zero depth did not exercise that dependency meaningfully.

The September experiment ran the board’s depth-control code against a Fossen dynamics model. This made the feedback path inspectable without arming hardware. It should not be called the first feedback run in the firmware’s entire history: the later status correction records the firmware team’s August 2026 DEPTH_HOLD water tests on an older hull. Those are separate from the still-unvalidated AUTO path described here.

What crosses the cable

The boundary in question is one USB-C cable between the Pi, which thinks, and the control board, which acts. Everything the Pi says crosses it as MAVLink 2 frames, and the frame for the most ordinary thing the vehicle is ever asked to do is small enough to read byte by byte. There’s no thrust in it: no motor, no angle, no depth. It says what the Pi wants; how the hull achieves it is the board’s business.

fig 1move_forward, as it leaves the Pidrag the seconds and the gain

Loading the diagram. It needs JavaScript; the text around it says the same thing in words.

One COMMAND_LONG frame, packed the way pymavlink packs it: little-endian, trailing zeros truncated, an X.25 checksum seeded with the message's own crc_extra. At 3 s and gain 40 it reproduces Mongla's published frame exactly: 44 bytes, CRC 0x1EFD.

That’s the good news about a boundary like this: it’s narrow enough to be inspected. The bad news is below.

Two correct conventions, read together, wrong

Three attempts flew the simulated hull to +20 metres (above the water, in a pool 1.6 m deep) before the cause surfaced.

Inside the firmware, depth is positive metres down: 1.5 means 1.5 metres below the surface. The telemetry channel reports depth negative below the surface: minus 1.5. Passing one straight into a consumer that expects the other turns 1.5 metres deep into 1.5 metres above the water.surface, 0 mfirmware: +1.5positive is downtelemetry: −1.5negative is belowwhat the controller heard
Neither function was wrong on its own. The bug lived in the handshake between them.

Inside the firmware, depth is positive metres down: the setpoint is clamped non-negative, and a SURFACE command sets it to zero. But the telemetry channel reports depth as negative below the surface. Both internally correct. Passing one straight into a caller that expected the other read as the vehicle is above the water, to a controller that then tried hard to make that true.

Every boundary between two correct pieces of code is a place to write down which way is up.

After the conversion, in the plant

steady-state depth error after the fix, three setpoints0.5 m17 mm1.5 m17 mm3.0 m16 mm
Archived simulated final residuals, not physical in-water depth accuracy. The 3 m target is numerical coverage, not a claimed dive in the 1.6 m venue.

The integral term earns its place in the constant-buoyancy experiment. With a configured ±2 N standing bias, the simulated loop settled at 1.500 m with error reported as 0.000 m at three-decimal precision. That is not proof of exact zero physical error. Without an integral or suitable feedforward term, a proportional controller generally needs a standing error to supply the balancing command. Integral action still needs a stable loop and sufficient actuator authority; it does not remove saturation or hardware faults. The gimbal bench illustrates the related disturbance-rejection question.

Overshoot behaves like a physical system should, recorded as numbers rather than shapes: target 0.5 m gave 0.202 m of overshoot at a peak descent of 0.42 m/s; target 1.0 m gave 0.307 m.

The Mongla site's PID panel: a response curve with overshoot and the three gain controls
The control-loop explainer on the Mongla site: P, I, D, a current that pushes sideways, and the loop rate.Open image to inspect at full size.

The useful result is an exercised software boundary: positive-down input to the depth controller must not be confused with negative-below-surface telemetry. The plant’s drag, thrust and buoyancy assumptions still need physical identification. The roadmap therefore keeps the AUTO depth-loop checks as prerequisites for real automatic motion; this simulation does not close them. For the other frame convention in the same stack, read constructing estimator truth.