somidad / dw1000-positioning

43 stars 8 forks source link

Continues Ranging and update rate #3

Open metehanemlik opened 5 years ago

metehanemlik commented 5 years ago

I want to make continues ranging to make this:

ı changed

PRINTLN(F(" Ranging all anchors. Return to IDLE")); updateState(STATE_IDLE);

to

PRINTLN(F(" Ranging all anchors. Return to IDLE")); updateState(STATE_PONG);

and ı add some code to calculateRange function amd then received Continues Ranging like this:

123 , 158 , 182 , 93 , 96 31 , 158 , 185 , 93 , 96 31 , 158 , 185 , 85 , 96 30 , 158 , 185 , 85 , 100 123 , 153 , 185 , 85 , 100 31 , 153 , 194 , 85 , 100 31 , 153 , 194 , 88 , 100 30 , 153 , 194 , 88 , 99 121 , 150 , 194 , 88 , 99 31 , 150 , 172 , 88 , 99 31 , 150 , 172 , 93 , 99 30 , 150 , 172 , 93 , 99 123 , 151 , 172 , 93 , 99 31 , 151 , 170 , 93 , 99

the first row is delay time for every calculateRange(); others are anchors distance(cm)

as you can see sometimes there is a big delay like 120ms,

we can eliminate this delay?

whole code:

void calculateRange() { DW1000Time round1 = (timePollAckReceived - timePollSent).wrap(); DW1000Time reply1 = (timePollAckSent - timePollReceived).wrap(); DW1000Time round2 = (timeRangeReceived - timePollAckSent).wrap(); DW1000Time reply2 = (timeRangeSent - timePollAckReceived).wrap(); DW1000Time tof = (round1 round2 - reply1 reply2) / (round1 + round2 + reply1 + reply2); distance[idx_anchor] = tof.getAsMeters(); if(calHz == 0){ currentMillis = millis(); calHz = 1; Serial.print( millis() - currentMillis2); Serial.print(" , "); }else{ calHz = 0; currentMillis2 = millis(); Serial.print( millis() - currentMillis); Serial.print(" , "); } Serial.print(round(distance[0]100)); Serial.print(" , "); Serial.print(round(distance[1]100)); Serial.print(" , "); Serial.print(round(distance[2]100)); Serial.print(" , "); Serial.println(round(distance[3]100)); }

somidad commented 5 years ago

Any reason that you skipped STATE_SCAN state?

metehanemlik commented 5 years ago

Any reason that you skipped STATE_SCAN state?

STATE_SCAN is working on startup one time

somidad commented 5 years ago

Did you check side effect that you skip STATE_SCAN and go directly to STATE_PONG after ranging is completed? e.g.,

Currently, I don't have RPi, Arduino nor dwm1000. Hence, I can't guarantee there is no side effect. So please debug it.

metehanemlik commented 5 years ago

the code is working as a continuously but to complete ranging with 4 anchors Arduino needs 140ms.

I changed also to reduce delay 100 > 30

define PONG_TIMEOUT_MS 30

Also, some times there is noisy ranging. I need accurate and fast ranging.

Do you any advice for filter or fast ranging?

hknckr commented 5 years ago

Hi Metehan, I am also working with DWM1000 modules for a week. There is a method called TDOA(Time Difference of Arrival) But clock sync is needed for anchors in this method. It is not easy. I am working to find a way to achieve this. In TDOA tag is almost passive, just sends a blink message then everything is up to anchors. Anchors positions are known positions. So system calculates TDOAs. With this method you can have more faster ranging. I haven't used this library yet but I think tag blinks and then waits anchors to calcualte and send back some information so it cause delays.