Altitude Hold / Position confusion in guided mode

Flying in guided mode on 3.5.4

Launch the craft and command it to go to 5.0 meters. It does this and holds altitude well at this height.

However, the POS.RelHomeAlt value starts drifting upwards. Quickly it is reporting 7 meters. The craft has not actually moved upwards - just the POS.RelHomeAlt value.

I then issue a command to reposition the craft at the same altitude (5.0m) just slightly over to the right. The craft drops roughly 2m on this command. It is as if it used the RelHomeAlt when I gave it the position command, but once it is in position, it isn’t responding to drift in RelHomeAlt (which is actually good, because the craft isn’t really drifting).

I can see in the log that the CTUN.DAlt value is not the 5.0m I commanded, but it is offset by this drift amount.

I can recreate this using MissionPlanner and the “Fly to here” and “Fly to here alt” commands.

You can see this in the log at roughly 1:30. There are other examples in the log - this is just the most dramatic.

The weird thing is that the craft holds altitude very well - It is just the reported Relative Home Altitude that drifts - and anytime I give it a position command (SET_POSITION_TARGET…) it appears to use this bad value.

btw - the RelOriginAlt does not suffer from this drift/offset, only the RelHomeAlt.

Any ideas?


Log File

I had the same issue with you,and I had solve the prblem。
The reason of this problem is Original altitude drift beacuse of GPS altitude drift。THis is a code bug and you should comment “EKF_origin.alt -= (int)(100.0f * gain * innovation);” in “AP_NavEKF2_Measurements.cpp” file.Then compile your code and upload the firmware to your copter.

1 Like

Thank you!

I thought it was GPS drift but had not figured out where it was in the code yet.

Is this bug fixed in newer versions of ArduPilot?