Accessing Depth Information

I am using the Bar30 sensor on the Navigator Controller. QGroundControl and BlueOS’s cockpit are able to show the depth readings.
However, MAVROS does not publish the depth in metres anywhere. I could not get it to publish SCALED_PRESSURE2 either.
I am using PyMavLink to get the SCALED_PRESSURE2 values. However, I am not able to figure out the formula to convert that hPa value to depth in metres. Could someone help?

Hi, I have been working with MAVROS and have obtained many MAVROS topics. I am trying to determine which one corresponds to the Bar30 sensor. Would /mavros/vfr_hud be the correct topic, or is there another one I should check? Thank you!

It is supposed to be the correct one. However, the altitude value is always 0.0.

Hi @jalansubham, welcome to the forum :slight_smile:

Is the AHRS2 message available? Cockpit and QGC use AHRS2.altitude, as the filtered output from the autopilot’s internal state.

I’m not familiar with MAVROS, but if the same message is available with Pymavlink then presumably this is a MAVROS issue rather than an autopilot issue.

Converting from a pressure measurement to a distance (e.g. relative altitude/depth) requires knowing (or estimating)

  1. the density of the fluid creating the pressure
  2. the atmospheric pressure at the surface, to use as an offset
  3. the static conversion factor for the units being used

The altitude calculation in ArduSub is done using:

where _specific_gravity is determined by the BARO_SPEC_GRAV parameter (as a proxy for the density of the water being operated in), and the ground_pressure is set when the barometer is calibrated at the surface, and stored in the BARO2_GND_PRESS parameter.[1]

I’m not sure why VFR_HUD isn’t returning correct values - that’s likely a bug in the firmware.


  1. There is a subsequent correction that can be applied by specifying BARO_ALT_OFFSET values, but that is rarely used. ↩︎