Time-of-flight in TWR protocol

All discussions related to the Loco Positioning system
Post Reply
alexpic
Beginner
Posts: 13
Joined: Thu Sep 28, 2017 9:04 am

Time-of-flight in TWR protocol

Post by alexpic »

Hi everybody :)
I'm studying the communication between Crazyflie and LPS Anchor; i'm studying the Crazyflie firmware, in particular the script lpsTwrTag.c; in this script, after studying the TWR protocol, i observe that t_prop (https://github.com/bitcraze/crazyflie-f ... #L177-L181), that i think is time_propagation,

Code: Select all

     tprop_ctn = ((tround1*tround2) - (treply1*treply2)) / (tround1 + tround2 + treply1 + treply2);
      tprop = tprop_ctn / LOCODECK_TS_FREQ;
      options->distance[current_anchor] = SPEED_OF_LIGHT * tprop;
has a different form compared to the time-of flight descripted in your wiki:
pic.jpg
So my questions are:
  • What is mean LOCODECK_TS_FREQ?
  • What is the difference between tprop_ctn and the theoretycal t_f?
  • Why tprop_ctn is calculated in that way?
  • Finally, Why, for calculate tprop, tprop_ctn is divided by LOCODECK_TS_FREQ?
Thanks a lot for your help and sorry for so much questions :D
Alex
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Time-of-flight in TWR protocol

Post by arnaud »

Hi,

For the formula, there is a typo in the wiki. I fixed it, thanks for reporting the discrepancy!

As for your questions:
  • LOCODECK_TS_FREQ is the frequency of the UWB radio timer, it is a 40bit timer that counts up at about 64GHz and that is sampled when a packet leaves or is received by the radio
  • tprop_ctn is t_f measured in UWB timer ticks
  • This way of calculating T_prop allows to calculate the time of flight in a 'virtual clock' that is between the clock of the sender and the receiver drift-wise, this is done to avoid most of the error related to clock drift. there is a white board demonstration in this thread: viewtopic.php?f=6&t=1944&p=9965#p9959.
  • tprop_ctn is a timer count, dividing it by the timer frequency gives us tprop in seconds (this is t_f).
If you can share your study when you are done I feel it would be a great addition to the documentation for the LPS :-D
alexpic
Beginner
Posts: 13
Joined: Thu Sep 28, 2017 9:04 am

Re: Time-of-flight in TWR protocol

Post by alexpic »

Hi Arnaud!
Thanks for your reply!! Now it's more clear!!
For the formula, there is a typo in the wiki. I fixed it, thanks for reporting the discrepancy!
You're welcome! It was a pleasure!
If you can share your study when you are done I feel it would be a great addition to the documentation for the LPS :-D
Of course! it'll be a pleasure to be helpful!

PS: Thanks for the analytical demostration, i was searching just that!!!!! :D
Post Reply