Skip to content

Conversation

@rmackay9
Copy link
Contributor

@rmackay9 rmackay9 commented May 12, 2025

This modifies the LD06/LD19 proximity library so that average distances are reported instead of the shortest distance.

This will hopefully resolve the, "LD19 average change makes it sensitive to sunlight" issue from the 4.6 issues list.

This is completely untested so I'd like help from @peterbarker and others to verify the code and test it. I believe there is a SITL simulator so perhaps I can use that for testing

Some references:

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR alters the LD06/LD19 proximity library to switch from reporting the shortest detected distance to reporting average distances per face, addressing sensitivity issues related to sunlight.

  • Updated internal structures to accumulate angle and distance readings for averaging.
  • Adjusted the logic in AP_Proximity_LD06.cpp for computing and reporting average distances and angles.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
libraries/AP_Proximity/AP_Proximity_LD06.h Introduced a new internal struct (_lastface) to aggregate angular and distance readings.
libraries/AP_Proximity/AP_Proximity_LD06.cpp Modified logic to collect and average distance readings over a 2° window, and to update face attributes accordingly.
Comments suppressed due to low confidence (2)

libraries/AP_Proximity/AP_Proximity_LD06.h:66

  • [nitpick] The struct member name 'angle_ref_deg' is used as the reference for averaging but could be clearer. Consider renaming it to 'base_angle_deg' to better convey its purpose as the fixed reference angle for accumulating deviations.
struct { AP_Proximity_Boundary_3D::Face face;    // last face requested

libraries/AP_Proximity/AP_Proximity_LD06.cpp:215

  • The averaging calculation uses the 2°‐rounded angle (_angle_2deg) rather than the original reading. Please verify that this design choice meets the precision requirements for averaging and that the intended behavior is clearly documented.
_lastface.angle_sum_deg += wrap_180(_angle_2deg - _lastface.angle_ref_deg);

@rmackay9 rmackay9 changed the title AP_Proximity: LD06 reports averages distances -- WIP AP_Proximity: LD06 reports averages distances May 13, 2025
@rmackay9 rmackay9 removed the WIP label May 13, 2025
@rmackay9 rmackay9 closed this May 23, 2025
@rmackay9 rmackay9 deleted the proximity-ld06-average branch May 23, 2025 06:34
@rmackay9
Copy link
Contributor Author

closed because the mode filter solution works better

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant