From b2f6ec1379d382e35c850e325a46a4addcc0c6cb Mon Sep 17 00:00:00 2001
From: Paul Wieland
Date: Fri, 6 Dec 2024 14:40:34 -0500
Subject: [PATCH] high ceiling & day light sensor adjustments
Ceilings that are higher than the sensor capabilities result in out of range (-1) readings.
Daylight, water on the floor and other environment changes can also cause the sensor to read out of range. This change results in 30 readings of -1 to be VehicleDetected false.
---
components/ratgdo/ratgdo.h | 2 +-
components/ratgdo/sensor/ratgdo_sensor.cpp | 12 +++++-------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/components/ratgdo/ratgdo.h b/components/ratgdo/ratgdo.h
index 35a9b46..30a01bd 100644
--- a/components/ratgdo/ratgdo.h
+++ b/components/ratgdo/ratgdo.h
@@ -65,7 +65,7 @@ namespace ratgdo {
observable closing_delay { 0 };
observable target_distance_measurement { -1 };
- std::vector distance_measurement { std::vector(10, -1) }; // the length of this vector determines how many in-range readings are required for presence detection to change states
+ std::vector distance_measurement { std::vector(30, -1) }; // the length of this vector determines how many in-range readings are required for presence detection to change states
observable last_distance_measurement { 0 };
observable openings { 0 }; // number of times the door has been opened
diff --git a/components/ratgdo/sensor/ratgdo_sensor.cpp b/components/ratgdo/sensor/ratgdo_sensor.cpp
index e90017f..77cafab 100644
--- a/components/ratgdo/sensor/ratgdo_sensor.cpp
+++ b/components/ratgdo/sensor/ratgdo_sensor.cpp
@@ -88,15 +88,13 @@ namespace ratgdo {
objCount = pDistanceData->NumberOfObjectsFound;
maxDistance = objCount == 0 ? -1 : pDistanceData->RangeData[objCount - 1].RangeMilliMeter;
- /* if(maxDistance < 0) maxDistance = -1;
- * if the sensor is pointed at glass, there are many error readings which will fill the
+ /*
+ * if the sensor is pointed at glass, there are many error -1 readings which will fill the
* vector with out of range data. The sensor should be sensitive enough to detect the floor
- * in most situations, unless its mounted really far away.
- * If this doesn't work, then the vector size will have to increase substantially
+ * in most situations, but daylight and/or really high ceilings can cause long distance
+ * measurements to be out of range.
*/
- if (maxDistance > 0) {
- this->parent_->set_distance_measurement(maxDistance);
- }
+ this->parent_->set_distance_measurement(maxDistance);
// ESP_LOGD(TAG,"# obj found %d; distance %d",objCount, maxDistance);