-
Notifications
You must be signed in to change notification settings - Fork 6
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
Measurement quality #9
Conversation
Added range_status() function to get the measurement validity of the current measurement.
Added sigma() function to get the estimated noise for the latest reported distance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be good to define named constants for range_status
and refer to those instead of simple integers.
adafruit_vl53l4cd.py
Outdated
_VL53L4CD_RANGE_VALID = const(0x00) | ||
_VL53L4CD_RANGE_WARN_SIGMA_ABOVE_THRESHOLD = const(0x01) | ||
_VL53L4CD_RANGE_WARN_SIGMA_BELOW_THRESHOLD = const(0x02) | ||
_VL53L4CD_RANGE_ERROR_DISTANCE_BELOW_DETECTION_THRESHOLD = const(0x03) | ||
_VL53L4CD_RANGE_ERROR_INVALID_PHASE = const(0x04) | ||
_VL53L4CD_RANGE_ERROR_HW_FAIL = const(0x05) | ||
_VL53L4CD_RANGE_WARN_NO_WRAP_AROUND_CHECK = const(0x06) | ||
_VL53L4CD_RANGE_ERROR_WRAPPED_TARGET_PHASE_MISMATCH = const(0x07) | ||
_VL53L4CD_RANGE_ERROR_PROCESSING_FAIL = const(0x08) | ||
_VL53L4CD_RANGE_ERROR_CROSSTALK_FAIL = const(0x09) | ||
_VL53L4CD_RANGE_ERROR_INTERRUPT = const(0x0A) | ||
_VL53L4CD_RANGE_ERROR_MERGED_TARGET = const(0x0B) | ||
_VL53L4CD_RANGE_ERROR_SIGNAL_TOO_WEAK = const(0x0C) | ||
_VL53L4CD_RANGE_ERROR_OTHER = const(0xFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these are _
const()
, they will not be available for the user code to use. They are discarded when imported. Could you choose shorter names and declare them globally without the _
? Or maybe range_status
could be range_valid
and just return a boolean? Are you using these error values in your own code?
I added a new commit that renames those constants to use shorter names and remove the leading underscore. The changes look good to me. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADXL37x to 1.1.9 from 1.1.8: > Merge pull request adafruit/Adafruit_CircuitPython_ADXL37x#5 from FoamyGuy/fix_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI to 7.0.0 from 6.1.3: > Merge pull request adafruit/Adafruit_CircuitPython_ESP32SPI#188 from justmobilize/remove-set-socket Updating https://github.com/adafruit/Adafruit_CircuitPython_GUVX_I2C to 1.0.7 from 1.0.6: > Merge pull request adafruit/Adafruit_CircuitPython_GUVX_I2C#5 from FoamyGuy/fix_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_OV5640 to 1.1.16 from 1.1.15: > Merge pull request adafruit/Adafruit_CircuitPython_OV5640#30 from FoamyGuy/fix_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8574 to 1.0.9 from 1.0.8: > Merge pull request adafruit/Adafruit_CircuitPython_PCF8574#8 from FoamyGuy/fix_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_PCF8575 to 1.0.5 from 1.0.4: > Merge pull request adafruit/Adafruit_CircuitPython_PCF8575#7 from FoamyGuy/fix_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_SPD1656 to 0.9.0 from 0.8.6: > Merge pull request adafruit/Adafruit_CircuitPython_SPD1656#7 from prcutler/root-group-fix Updating https://github.com/adafruit/Adafruit_CircuitPython_ST7735 to 1.2.13 from 1.2.12: > Merge pull request adafruit/Adafruit_CircuitPython_ST7735#19 from prcutler/root-group-fix Updating https://github.com/adafruit/Adafruit_CircuitPython_UC8151D to 1.3.3 from 1.3.2: > Merge pull request adafruit/Adafruit_CircuitPython_UC8151D#13 from FoamyGuy/fix_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_VEML7700 to 2.0.0 from 1.1.22: > Merge pull request adafruit/Adafruit_CircuitPython_VEML7700#26 from standsi/SetInitialLightGain Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X to 1.1.14 from 1.1.13: > Merge pull request adafruit/Adafruit_CircuitPython_VL53L1X#16 from analogic/patch-1 Updating https://github.com/adafruit/Adafruit_CircuitPython_VL53L4CD to 1.2.0 from 1.1.7: > Merge pull request adafruit/Adafruit_CircuitPython_VL53L4CD#9 from markkamp/measurement_quality Updating https://github.com/adafruit/Adafruit_CircuitPython_BLE_Beacon to 1.0.5 from 1.0.4: > Merge pull request adafruit/Adafruit_CircuitPython_BLE_Beacon#3 from FoamyGuy/fix_circup_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_PortalBase to 2.0.0 from 1.16.1: > Merge pull request adafruit/Adafruit_CircuitPython_PortalBase#100 from justmobilize/remove-set-socket Updating https://github.com/adafruit/Adafruit_CircuitPython_Radial_Controller to 1.0.12 from 1.0.11: > Merge pull request adafruit/Adafruit_CircuitPython_Radial_Controller#3 from FoamyGuy/fix_readme Updating https://github.com/adafruit/Adafruit_CircuitPython_Requests to 3.0.0 from 2.0.5: > Merge pull request adafruit/Adafruit_CircuitPython_Requests#151 from justmobilize/connection-manager Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA: > Updated download stats for the libraries
Added functions to check measurement quality. This helps determine if the value read is actually usable.
Tested with example vl53l4cd_simpletest.py replacing line:
print("Distance: {} cm".format(vl53.distance))
by:
print("Status: {:3d} Distance: {:6.2f}cm, Estimated noise: {:6.2f}cm".format(vl53.range_status, vl53.distance, vl53.sigma))