ALTH and Loiter - Altitude Parameter?

Hello,

When the pilot is flying in ALTH or Loiter mode, my understanding is that the autopilot attempts to maintain the altitude using some sensor source set with EK3_SRCx_POSZ. So, presumably that altitude value is stored somewhere. Is there a way to get, and preferably, set that saved altitude value via script?

General code being something like:

– get altitude
local pilot_des_alt = ahrs:get_alt()

– set altitude
ahrs:set_alt(new_alt)

Thank you

Hi @tdempsey,

In general Lua scripts can only control the motion of a vehicle while it is in Guided mode similar to how the vehicle is controlled from a companion computer using mavlink.

The reason AP does it this way is that it means the pilot can always retake control from Lua scripts.

Recently it’s become possible to write a new flight mode completely in Lua. This is included in 4.6 but I must admit that I haven’t tried it yet.

3 Likes

Thanks, I will look into those links!

1 Like