jremington / UWB-Indoor-Localization_Arduino

Open source Indoor localization using Arduino and ESP32_UWB tags + anchors
GNU General Public License v3.0
140 stars 35 forks source link

Error in ESP32_anchor_autocalibrate.ino #11

Closed jhoydich closed 1 year ago

jhoydich commented 1 year ago

First off thanks for all of the experimentation you have done with the uwb chips.

I was experimenting with your ESP32_anchor_autocalibrate.ino program and I believe there is an error in its implementation.

void newRange()
{
  static float last_delta = 0.0;
  Serial.print(DW1000Ranging.getDistantDevice()->getShortAddress(), DEC);

  float dist = 0;
  for (int i = 0; i < 100; i++) {
    // get and average 100 measurements
    dist += DW1000Ranging.getDistantDevice()->getRange();
  }

Since newRange() is a callback that is called when a new range is calculated, the for loop inside will return that same range 100 times. To get 100 different ranges, you need to wait for newRange() to be called 100 times. Making dist global as well as a global iter variable to track how many times newRange() has been called lead to some very repeatable calibration values in my testing.

jremington commented 1 year ago

You are correct. Someone else pointed out that silly mistake some time ago and I forgot to fix it. Will do!

jremington commented 1 year ago

Removed the nonfunctional code.