Home        Store        Docs        Blog

Perfect Depth Hold Mode for AUV

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(

# Wait a heartbeat before sending commands

# ARM the Ardusub

# 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.target_system, master.target_component,
        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:

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.

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: https://www.ardusub.com/operators-manual/parameters.html

The way to get some sensor values is with mavlink messages: https://mavlink.io/en/messages/common.html#VFR_HUD

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.