ardupilot
ardupilot copied to clipboard
Start Surface Distance Library
Following on from the discussion in this PR: https://github.com/ArduPilot/ardupilot/pull/26827, it was agreed that the best way forward was to move the copter rangefinder functionality into a library (we called it AP_HAGL then). This PR is the start of that process.
No functional change should result from this PR
As his way, @IamPete1 already had a branch for it! https://github.com/ArduPilot/ardupilot/pull/20535
I have rebased his original PR to get this. I will continue the work and do the testing.
This is looking good! Let's call the new library "AP_SurfaceDistance" because we will likely use it in Plane as well.
maybe a SURF log message? with instance number
Key things to test are:
- Behaviour with rangefinder out of range
- Behaviour with rangefinder enable/disable on RC switch
Renamed to AP_SurfaceDistance and added logging. For logging I have added a status bitmask which should make it easier to track various fault conditions.
This is looking good! Let's call the new library "AP_SurfaceDistance" because we will likely use it in Plane as well.
Definitely want this in Plane!
This is great work! I would love to see sub use this in a future PR.
I have flight tested this code (git hash: 426c9485) All appears to working as before.
Here is a break down of the test:
log file here: https://drive.google.com/file/d/1myPkiXPjzz0Ay9KEJwMSnXHhpa4FlaGW/view?usp=sharing
Made those changes and tested logging IRL in the office.
Only had a downward facing LiDaR fitted so only the first instance of SURF is populated with data in this test.
Apologies, I cannot make the call this evening, but this PR has been through a few reviews now and I am hopeful that it is good to go. As a reminder, since last review the following changes have been made:
- Rename RANGEFINDER_HEALTH_MAX to RANGEFINDER_HEALTH_MIN
- Logging has been changed to report in meters and fixed-up data types. This has been tested. See plot above.
- Semaphore added to avoid accessing last_healthy_ms out of sequence with millis() in data_stale() helper.