Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AP_RangeFinder: Notify different alerts #26596

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

muramura
Copy link
Contributor

Multiple alert notifications.
Currently notifies the same alerts as last time.
It would be better to notify alerts that are not originally notified.

@peterbarker
Copy link
Contributor

This looks like an important change.

How was this tested?

@peterbarker peterbarker self-assigned this Sep 27, 2024
@peterbarker peterbarker force-pushed the AP_Notify_different_alerts branch from 26180e4 to 827ec2f Compare January 1, 2025 23:53
@peterbarker
Copy link
Contributor

I've pushed up an additional patch here which saves a few bytes and makes things a little clearer (IMO).

I've tested this in SITL using the simulated LR-D1 and this patch:

diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_Ainstein_LR_D1.cpp b/libraries/AP_RangeFinder/AP_RangeFinder_Ainstein_LR_D1.cpp
index 775a004268a..214cc3778ad 100644
--- a/libraries/AP_RangeFinder/AP_RangeFinder_Ainstein_LR_D1.cpp
+++ b/libraries/AP_RangeFinder/AP_RangeFinder_Ainstein_LR_D1.cpp
@@ -67,10 +67,17 @@ bool AP_RangeFinder_Ainstein_LR_D1::get_reading(float &reading_m)
             continue;
         }
 
-        const uint8_t malfunction_alert = buffer[1];
+        uint8_t malfunction_alert = buffer[1];
         reading_m = UINT16_VALUE(buffer[3], buffer[4]) * 0.01;
         const uint8_t snr = buffer[5];
 
+        const uint32_t nowx_ms = AP_HAL::millis();
+        static uint32_t last_error_ms = 0;
+        if (nowx_ms - last_error_ms > 5000) {
+            last_error_ms = nowx_ms;
+            malfunction_alert = 0x1;
+        }
+

@peterbarker
Copy link
Contributor

The net effect of these patches is that if the device is currently reporting a temperature error and then you get a voltage error you will not be notified of the temperature error again. On master you will be warned of the temperature error twice and the voltage error once.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

2 participants