Hey @rafael.lehmkuhl and @williangalvani !
Did you by any chance have the oppurtunity to look at the latest (The ones from the 7th of May) Cockpit MavLink Dumps and AHR2.alt error jumps, yet?
Thanks in advance!
Hey @rafael.lehmkuhl and @williangalvani !
Did you by any chance have the oppurtunity to look at the latest (The ones from the 7th of May) Cockpit MavLink Dumps and AHR2.alt error jumps, yet?
Thanks in advance!
Hey @sietse! I have took a look but forgot to answer.
The 3 Cockpit logs look normal to me. No jumps at all. Take a look below. Do those values make sense? I see no jumps at all. During those sessions, did you see the values jumping in the Cockpit widget?
Hey @rafael.lehmkuhl,
The Depth Indicator displayed 0 m throughout all three tests, which is already an issue on its own.
The second issue seems to be with AHR2.Alt. It shows unusual jumps, as visible in the screenshots I sent on May 6, especially the final screenshot of 00000238.bin. The same behavior is also visible in the third screenshot you just sent, right at the very start.
In that data, there is roughly a 7 m jump within about 0.1 seconds. Since my basin is only 1.2 m deep, these AHR2.Alt values cannot be the correct absolute depth values.
However, Baro[1].Alt appears to be reporting the correct absolute depth readings.
So my current understanding is:
The sudden jumps in the Depth Indicator are likely caused by unrealistic jumps in AHR2.Alt, which may be an ArduSub 4.5.7 issue.
The Depth Indicator sometimes showing 0m for a extended period of time seems to be a separate issue with the Cockpit Depth Indicator Widget, since valid depth values are still present in Baro[1].Alt.
Agree. It looks like we may have two different bugs. If the Depth Indicator was showing 0 during those moments, it indeed has some problem, and it is separated to the bug in ArduSub (which is causing the AHRS2.altitude to differ from the Baro).
I will investigate the Cockpit one. I would ask you to help me on confirming how the problem occurs by recording 3 things at the same time:
Try to record those all at the same time and make sure that they include the bug happening. This way we can more easily understand what is going on.
Thanks again for the detailed report and the patience on helping finding what is going on.
Hey @rafael.lehmkuhl!
I immediately peformed a test for you to grab the .bin file, the .jsonl file and a screen recording.
Here are the files (The screenrecording was too big to upload here directly):
Note that this time the cockpit widget viewed 0m from the start, and also watch the HUD widget give different values in the second half of the video! I watched the .bin files myself and I can confirm this AHR2.Alt shift is in there, while Baro[1].alt stays working properly. The only thing is that I could not get the change of the depth indicator going from something realistic to 0. Unfortunately…
No worries at all! I’m happy to work things out, together ![]()
Thanks again @sietse! I will analyze everything today!
I wanted to follow up on my depth estimate issues as well (@EliotBR )
In our last dive we experimented with adding a ferrite to the depth sensor, and eventually replaced our older Bar30 sensor with a new unit.
This reduced the spurious measurements and seems to fix the in situ calibration issue.
However, the depth reading in cockpit continued to be incorrect at ~-40m while on the surface. We examined the SCALED_PRESSURE2, VFR_HUD and GLOBAL_POSITION_INT altitudes in Mavlink and determined the depth was generally tracking to the vehicle motion, but had a large “offset” which seemed to change on an infrequent (~10-30s?) basis.
Last year, we added an integrated GPS receiver for localization when on the surface.
We discovered the depth problems were resolved when we disabled the GPS receiver (set SERIAL_PROTOCOL1 from GPS to None). On some investigation, it seems that EKF was getting an absolute altitude update from the GPS … the ~40m offset corresponded to our height above local geoid.
Getting GPS-derived position when on the surface works well for our missions, so I’d like to keep that functionality.
What’s the EKF’s expected behavior for handling altitudes from GPS? Can we get Ardupilot to ignore GPS altitude? Is it taking a “zero altitude” at any point or can we force it to do so?
What are your EKF3_SRCx_POSZ parameters set to?
Hmm, what about EK3_OGN_HGT_MASK?
Ok, I had a chat with Willian and have done some more digging. The current state of investigation:
AHRS2 MAVLink message is for the autopilot’s secondary estimator, and likely shouldn’t be used for indicators other than for debugging purposes
VFR_HUD messages without a horizontal position estimate, which has been fixed in 4.7 (currently in beta) and in the 4.5 branch, but is not in a stable release yet
This is important stuff to get right, and will require some more digging before we’ve established what exactly is wrong and how to fix it or work around it. There’s also a lot of other high priority work at the moment, so (aside from adding the Cockpit source selection option) we may have to hold off on the investigating for a week or two.
A longer pair of DataFlash (.bin) and MAVLink telemetry logs showing multiple jumps instead of just one origin change one may help to determine the source of that less clear issue.
@EliotBR thanks for that synthesis, and apologies for not posting binlogs. Here are two from recent testing:
00000016_without_gps.BIN (16.9 MB)
00000015_with_gps.BIN (4.8 MB)
The ROV is in a ~1m test tank. It is inside but near a large window, so the GPS positioning is inconsistent.
Here is the plot from _with_gps.BIN showing pressure (blue), GPS altitude (red) and canonical position (green)
In the plot you see us push the ROV down, and also hoist it “up” out of the water twice.
The two points I’d call out are the large DC offset in the canonical position ~43m, which we think we can attribute to the GPS altitude. And the “racheting” down of the depth throughout the trace.
There is a slight downward trend to the measured pressure which may have been actual drop in atmospheric pressure?
The _without_gps.BIN does not contain the POS entry, which may be a hint to what’s happening?
The pressure altitude is generally reasonable with one spurious outlier
Thanks @Eliot, that helps clarify the distinction between the two behaviours.
For my case, I think your interpretation matches what I have been seeing while re-analysing my .BIN logs. The main issue appears to be a large offset introduced when the GPS origin is set, rather than continuous jumping or ratcheting behaviour throughout the dive.
This does seem to point to an issue with how AHR2.Alt is being calculated or updated in relation to the GPS origin.
Like you already mentioned here above, AHRS2 isn’t what should be used for the exact Depth Indicator.
Disabling GPS appears to avoid the issue.
Do you have an estimate for when we might see a new ArduSub 4.5 stable release and/or a Cockpit release that includes the planned depth-source fixes?
Also, would there be any way to expose BARO[1].Alt as a DataLake variable and use that directly as the source for the depth indicator in Cockpit?
From what I have seen in our logs, BARO[1].Alt has been very reliable for us and has consistently shown the correct depth values, even when the other depth/altitude sources were affected by the GPS/origin offset issue. So being able to select that directly in Cockpit would be very useful, at least as a workaround or configurable option.
If you’d like to have more logs or details for me that would make things easier for you, let me know!
Thanks!
@sietse we are going to make a Cockpit release this week that includes the ability to change the source of your depth widgets. In the ArduSub front, @EliotBR will have a better estimate.
In the meantime, if you just need the mini-widget indicator (and not the HUD), you can add a Very Generic Indicator widget and point it to the /mavlink/1/1/VFR_HUD/alt variable. This will show the same value as is being shown on QGC.
Hey @rafael.lehmkuhl!
I’m looking forward to the new Cockpit release.
Does this mean that the generic indicator will use the same data source that the HUD depth widget normally displays?
If that is the case, I am wondering whether this would actually solve the problem, since we observed the following:
In the video I uploaded to Google Drive, the Depth indicator shows 0m, while the HUD Depth shows around -11m to -12 m.
The test basin was only about 1m deep, so there was still an approximately 11m offset in the HUD Depth widget as well. Wouldn’t that suggest that the HUD Depth widget was also using AHR2.Alt instead of Baro[1].Alt? Or atleast VFR_HUD/alt is based on the AHR2.alt value rather than the Baro[1].alt value?
I’m currently selecting this one for my generic indicator, but I was wondering what the difference is between the /mavlink/1/1/VFR_HUD/alt and the VFR_HUD/alt.

Thanks! ![]()
Actually both the Depth Indicator (the mini-widget) and the Depth HUD (the regular widget) consume from the same place (AHRS2.altitude), so they should show the same value. If they are showing different values for you, this can indicate a bug in the widget. I will take a look.
I’m not sure if @EliotBR and @williangalvani have decided yet how exactly this will be implemented in ArduSub, but I believe they will try to expose something around what is being shown in the Baro[…].alt.
About VFR_HUD/alt vs /mavlink/1/1/VFR_HUD/alt, the first one is a legacy variable, while the new one with the /mavlink/x/y prefix was created to allow multi-vehicle/multi-components support in Cockpit. For a single vehicle operation, they will show you the same value, but try to always use the new one. In the future we are going to migrate everyone to the newer type and stop exposing the legacy one.
Let us know how the VFR_HUD.alt works for you.
Out of curiosity, could you try the latest beta ArduSub and see if the issue is still there?
I have a change in mind that would stop using the EKF origin for the altitude when it’s set to use the baro as its source, but Willian mentioned he tried the latest state and couldn’t replicate the issue to start with. I’m not aware of any code changes that would have fixed that, but it doesn’t hurt to confirm ![]()
Thanks - I’ll try to take a look late this week ![]()
ArduPilot is nearing the stable combined release of 4.7 - currently estimated in ~1 month. If you can confirm the origin issue isn’t already fixed in the latest 4.7 beta then we should be able to make this a priority to fix as part of that. That said, please check all 3 of VFR_HUD.alt, GLOBAL_POSITION_INT.alt, and GLOBAL_POSITION_INT.relative_alt - I believe the last one never includes an origin offset (though be aware that if you set a home position with a non-zero altitude, it will adjust to be relative to that).
Given the proximity of 4.7 I’m unsure whether we’ll make another Sub-4.5 stable. We could push one out with the current state of the branch, but I’m not in control of that process, and there’s lots of ongoing release testing and some feature developments that that would be taking time away from. Is it important to you that 4.5 gets that additional stable release?
I’m unsure if there are any CI issues with 4.5 now (which would make another release of it extra unlikely), but I was at least able to build the latest branch state without issues if you want to try that version too:
ardusub_4-5_latest_navigator.elf (2.2 MB)
That’s internal autopilot data that doesn’t currently get exposed directly over MAVLink. The closest thing would be to calculate it in Cockpit by reading the pressure data and adjusting it using the parameter values read from the autopilot. I’m wanting to make sending the baro altitude directly the expected behaviour when the EKF is set baro for PosZ, but that’s an unimplemented firmware change that will require discussion with others, and may have nuances I’m not thinking of that make it infeasible.
Hey @rafael.lehmkuhl and @EliotBR !
We concluded that AHR2.alt isn’t a proper value for depth. Therefore the Depth Indicator would give me strange values, since it’s using AHR2.alt.
We also concluded that the Depth Indicator stating 0m, is a cockpit bug. This has nothing to do with AHR2.alt giving odd values. This is because AHR2.alt never flatlined at exactly 0m.
During my dives in a 1m deep tank. The Depth Indicator and HUD indicator would work properly till a Set Origin occurs. When the Set Origin occurs, AHR2.alt (in a few tests) would jump from a 0 to 1m depth to a 11 to 12m depth. The Set Origin messing with the AHR2.alt value is a bug, therefore it should either be fixed, or AHR2.alt should just not be used for representing the actual Depth.
A different issue is that, while the Depth Indicator and Depth HUD are both using AHR2.alt, the Depth Indicator is displaying 0m, while the Depth HUD is displaying the actual AHR2.alt value, which is the jumped odd value, and not even the right Baro[1].alt value.
I’m assuming VFR_HUD/alt is also using AHR2.alt, instead of mirroring the Baro[1].alt value? Otherwise I wouldn’t get those weird 11m and 12m depth values on my Depth HUD, right?
So trying to use VFR_HUD.alt for the Generic Indicator, wouldn’t fix the issue, since it’s basically that same AHR2.alt value?
I’ve been testing ArduSub v4.7.0 Beta 5, your modified v4.5, and the regular v4.5.7.
Here is a Google Drive link where I uploaded the .BIN files for each ArduSub version, along with a screen recording of each test. In the recordings, I used the Plotter widget to plot AHRS2.altitude, VFR_HUD.alt, GLOBAL_POSITION_INT.alt, and GLOBAL_POSITION_INT.relative_alt.
Hope this helps! ![]()