Perfect Depth Hold Mode for AUV

Hello,
We are building an AUV where depth holding is very important.
I can perfectly go into DEPTH HOLD mode with PYMAVLINK → Python 3.6.
But the rover comes around 1 meter above and then again goes down. As Jacob said they are still working on it.

So, I thought to go into STABILIZE mode, read the depth every 1-second and throttle downward with python code. It’s like depth holding from the python code.

import time
from pymavlink import mavutil
import arduSub_pymavlink_methods as pixhawk

# Create the connection
# Need to provide the serial port and baudrate
master = mavutil.mavlink_connection(
            'COM5',
            baud=115200)

# Wait a heartbeat before sending commands
master.wait_heartbeat()
time.sleep(2)

# ARM the Ardusub
master.arducopter_arm()

# These are functions I wrote in another file and imported it to keep the code clean
pixhawk.change_mode(master, 'STABILIZE')

# Request SURFACE_DEPTH parameter
while True:
    master.mav.param_request_read_send(
        master.target_system, master.target_component,
        b'SURFACE_DEPTH',
        -1
    )
    time.sleep(1)
    try:
        message = master.recv_match(type='PARAM_VALUE', blocking=True).to_dict()
        print(message['param_id'].decode("utf-8"), message['param_value'])
    except Exception as e:
        print(e)
        exit(0)

How can I continuously get the depth of my AUV with 0.2m Precision?
The code above only returns -10 then I set on QGC.

Or suggest me a way to keep the AUV at a certain DEPTH. I don’t have any underwater GPS.

USING :
Pixhawk - PX4
Ardusub - 3.5.X (latest stable release)
Depth Sensor - Bar30
Platform - Windows10(For testing Purpose)
Python - 3.6
Library - Pymavlink
Frame Config - BLUE ROV2 (6 Motor)

I recommend you work on the depth hold mode in the firmware rather than this approach. There will be extra latency with the approach you are suggesting.

A ‘parameter’ is not a dynamic variable representing some system state. Check the documentation on a parameter: Redirecting...

The way to get some sensor values is with mavlink messages: Messages (common) · MAVLink Developer Guide

Thank you, Jacob
I will try to edit the firmware first. Though I am now in firmware editing. I hope I can figure out some way.