Skip to content

Conversation

@rmackay9
Copy link
Contributor

@rmackay9 rmackay9 commented May 19, 2025

This alternative to PR #30050 adds a mode filter to try and remove the noise from the sensor readings when used outdoors

This PR also includes these fixes:

  1. comments are slightly improved
  2. fix to the distances pushed to the OA database. Previously a distance was pushed for each 2 deg sector but this distance was the shortest distance for the "face" (the "face" is the larger 45 degree sector into which the smaller 2 deg sector falls)
  3. constify a local variable
  4. improve some definitions (add a confidence definition, remove some unused definitions)

This has not yet been tested on real hardware nor in the simulator

The relevant 4.6.0-beta discussion is here

@rmackay9 rmackay9 requested review from Copilot and peterbarker May 19, 2025 04:13
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 adds a mode filter for sensor readings to help reduce noise when operating outdoors while also addressing fixes related to distance reporting and minor comment improvements.

  • Introduces a mode filter template specialization for uint16_t values.
  • Updates the AP_Proximity LD06 header to include the mode filter and adds a new filter member variable.
  • Modifies the distance processing logic in the LD06 source file to apply the filter and pushes corrected distance values to the database.

Reviewed Changes

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

File Description
libraries/Filter/ModeFilter.cpp Added template instantiation for ModeFilter<uint16_t,3>.
libraries/AP_Proximity/AP_Proximity_LD06.h Added include and a new mode filter member; potential type mismatch.
libraries/AP_Proximity/AP_Proximity_LD06.cpp Updated distance processing to use the mode filter and improved the use of the confidence threshold.

@rmackay9 rmackay9 force-pushed the proximity-ld06-modefilter branch from 5ae87d3 to 33724b4 Compare May 19, 2025 04:18
@rmackay9 rmackay9 requested a review from Copilot May 19, 2025 04:19
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 introduces a mode filter to reduce noise in sensor readings for the LD06 sensor while also addressing miscellaneous fixes related to distance reporting and code improvements.

  • Added a new ModeFilter instantiation for uint16_t in the filter library.
  • Updated AP_Proximity LD06 sensor processing to apply the mode filter and use confidence thresholds.
  • Adjusted the values pushed to the OA database and refined comments and variable definitions.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
libraries/Filter/ModeFilter.cpp Added a new template instantiation for uint16_t filtering.
libraries/AP_Proximity/AP_Proximity_LD06.h Included the mode filter header and introduced the filter object.
libraries/AP_Proximity/AP_Proximity_LD06.cpp Modified distance conversion to use the filter; added confidence threshold check; updated database_push call.
Comments suppressed due to low confidence (1)

libraries/AP_Proximity/AP_Proximity_LD06.cpp:173

  • [nitpick] Verify that applying the mode filter to the raw sensor value (in mm) before converting to meters meets the intended measurement accuracy.
const float distance_m = _dist_filt_mm.apply(UINT16_VALUE(_response[i + 1], _response[i])) * 0.001;

@rmackay9 rmackay9 force-pushed the proximity-ld06-modefilter branch from 33724b4 to 1438aac Compare May 19, 2025 04:27
@rmackay9 rmackay9 force-pushed the proximity-ld06-modefilter branch 2 times, most recently from 31a87f5 to c33c754 Compare May 23, 2025 06:50
@rmackay9 rmackay9 force-pushed the proximity-ld06-modefilter branch from c33c754 to fde25e3 Compare May 23, 2025 10:50
@rmackay9
Copy link
Contributor Author

I've fixed up the autotest and rebased on master. Personally I think this is ready to merge now

@peterbarker peterbarker merged commit 044f1cc into ArduPilot:master May 27, 2025
102 checks passed
@rmackay9 rmackay9 deleted the proximity-ld06-modefilter branch May 27, 2025 01:44
@rmackay9 rmackay9 moved this to Pending in 4.6 Backports Jun 24, 2025
@rmackay9
Copy link
Contributor Author

This is included in 4.6.2-beta1

@rmackay9 rmackay9 moved this from Pending to 4.6.2-beta1 in 4.6 Backports Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: 4.6.2-beta1

Development

Successfully merging this pull request may close these issues.

3 participants