TECS: Correctly handle Home altitude change #28675
Merged
+67
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
In case where the Home altitude is changed, TECS will now not reset, but offset the relevant attributes instead.
Background
Recently one of our partners flying a quadplane reported that while doing a ship landing, their plane would continuously lose altitude.
Details
The reason is that the most minute home altitude changes trigger a TECS reset. This behaviour is about 1 year old.
In the meantime, the ship landing lua script continuously updates the home location.
This code is ~2years old.
The combination results in the TECS constantly switching into a state of rest and becoming effectively paralyzed.
Solution
I added a new method
AP_TECS::offset_altitude(const float alt_offset)
where TECS is made aware of the change in home altitude and offsets all internal attributes accordingly.This is a pretty wide-reaching change, so all comments and test proposals are welcome.
Testing
An autotest was created for Plane (
SetHomeAltChange2
) that, once the plane comes to altitude, it wiggles the home altitude over 10s.The MAVLink command is set at 10Hz, but it seems to get parsed only at 2Hz.
Still, the results are conclusive:
Before:
After:
Alternatives
An alternative would be to just not reset TECS as often in case of home altitude change. But what is a "good" interval? Are we happy with TECS resetting every 10s? 20s?
Another alternative would be to just not allow the user to update home while TECS is running, but that sounds a bit silly to me.