ardupilot icon indicating copy to clipboard operation
ardupilot copied to clipboard

Start Surface Distance Library

Open MattKear opened this issue 9 months ago • 7 comments

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.

MattKear avatar Apr 30 '24 18:04 MattKear

This is looking good! Let's call the new library "AP_SurfaceDistance" because we will likely use it in Plane as well.

rmackay9 avatar May 01 '24 03:05 rmackay9

maybe a SURF log message? with instance number

tridge avatar May 01 '24 07:05 tridge

Key things to test are:

  • Behaviour with rangefinder out of range
  • Behaviour with rangefinder enable/disable on RC switch

MattKear avatar May 01 '24 08:05 MattKear

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.

MattKear avatar May 01 '24 12:05 MattKear

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!

timtuxworth avatar May 01 '24 15:05 timtuxworth

This is great work! I would love to see sub use this in a future PR.

clydemcqueen avatar May 02 '24 13:05 clydemcqueen

I have flight tested this code (git hash: 426c9485) All appears to working as before.

Here is a break down of the test: image

log file here: https://drive.google.com/file/d/1myPkiXPjzz0Ay9KEJwMSnXHhpa4FlaGW/view?usp=sharing

MattKear avatar May 13 '24 10:05 MattKear

image 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.

MattKear avatar May 22 '24 09:05 MattKear

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.

MattKear avatar May 27 '24 15:05 MattKear