Skip to content

fix(sensors): propagate equal_value_threshold to dynamic DataValidators#27822

Open
ARYA-mgc wants to merge 1 commit into
PX4:mainfrom
ARYA-mgc:fix/data-validator-threshold-propagation
Open

fix(sensors): propagate equal_value_threshold to dynamic DataValidators#27822
ARYA-mgc wants to merge 1 commit into
PX4:mainfrom
ARYA-mgc:fix/data-validator-threshold-propagation

Conversation

@ARYA-mgc

@ARYA-mgc ARYA-mgc commented Jul 6, 2026

Copy link
Copy Markdown

Found this while comparing set_timeout() and set_equal_value_threshold() in DataValidatorGroup timeout stores _timeout_interval_us and applies it in add_new_validator(), but the threshold setter had no equivalent storage. Confirmed via the test file, which already had TODO comments flagging this exact gap and worked around it manually.

Added _equal_value_threshold member (mirrors _timeout_interval_us), applied it in add_new_validator(), removed the workaround + TODOs, added an assertion to lock in correct behavior.

This is my first PR to PX4 - happy to adjust based on any feedback.

When new DataValidators are dynamically added to a DataValidatorGroup
via add_new_validator(), they previously initialized with the hardcoded
default threshold. If the group had a custom equal_value_threshold set,
the new validator would silently ignore it, causing inconsistent sensor
failover behavior.

This commit:
- Stores the group's current threshold in an _equal_value_threshold member
- Applies the stored threshold immediately to newly added validators
- Adds a getter and test assertion to verify proper propagation
- Removes the related TODO workarounds in the test suite
@github-actions github-actions Bot added kind:bug Something is broken or behaving incorrectly. kind:test Adds or improves tests. scope:sensors Sensor pipeline, calibration, voting, or sensor validation. scope:testing Unit, integration, fuzzing, or test data. labels Jul 6, 2026
@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 8 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%      +8  +0.0%      +8    .text
     +12%      +6   +12%      +6    DataValidatorGroup::add_new_validator()
    +3.6%      +4  +3.6%      +4    DataValidatorGroup::DataValidatorGroup()
    +7.1%      +4  +7.1%      +4    sensors::VehicleOpticalFlow::ClearAccumulatedData()
     +17%      +2   +17%      +2    DataValidatorGroup::set_equal_value_threshold()
    -0.0%      -8  -0.0%      -8    [section .text]
  +0.0%     +77  [ = ]       0    .debug_abbrev
  +0.0%    +294  [ = ]       0    .debug_info
  +0.0%     +45  [ = ]       0    .debug_line
     +33%      +1  [ = ]       0    [Unmapped]
    +0.0%     +44  [ = ]       0    [section .debug_line]
  +0.0%     +29  [ = ]       0    .debug_loclists
  +0.0%     +12  [ = ]       0    .debug_rnglists
  +0.0%     +75  [ = ]       0    .debug_str
  -0.1%      -8  [ = ]       0    [Unmapped]
  +0.0%    +532  +0.0%      +8    TOTAL

px4_fmu-v6x [Total VM Diff: 24 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +24  +0.0%     +24    .text
    +0.0%     +12  +0.0%     +12    [section .text]
     +12%      +6   +12%      +6    DataValidatorGroup::add_new_validator()
    +3.6%      +4  +3.6%      +4    DataValidatorGroup::DataValidatorGroup()
     +44%      +4   +44%      +4    g_nullstring
     +17%      +2   +17%      +2    DataValidatorGroup::set_equal_value_threshold()
    -6.7%      -4  -6.7%      -4    sensors::VehicleOpticalFlow::ClearAccumulatedData()
  +0.0%     +77  [ = ]       0    .debug_abbrev
  +0.0%    +294  [ = ]       0    .debug_info
  +0.0%     +45  [ = ]       0    .debug_line
     +33%      +1  [ = ]       0    [Unmapped]
    +0.0%     +44  [ = ]       0    [section .debug_line]
  +0.0%     +17  [ = ]       0    .debug_loclists
  +0.0%     +12  [ = ]       0    .debug_rnglists
  +0.0%     +75  [ = ]       0    .debug_str
  -0.3%     -24  [ = ]       0    [Unmapped]
  +0.0%    +520  +0.0%     +24    TOTAL

Updated: 2026-07-06T17:40:25

@ARYA-mgc

Copy link
Copy Markdown
Author

Hi @mrpollo, sorry to tag you directly and add noise to your notifications - I wasn't sure who else to reach for this area.
This is a small, self-contained fix (sensors/testing) with a test added to lock in the behavior. All checks are passing. Would you be able to take a look when you have a moment, or point me to someone who covers this area? No rush at all - just following up
Thanks for your time!

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

Labels

kind:bug Something is broken or behaving incorrectly. kind:test Adds or improves tests. scope:sensors Sensor pipeline, calibration, voting, or sensor validation. scope:testing Unit, integration, fuzzing, or test data.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant