How can i get distance from Sniffer mode?

All discussions related to the Loco Positioning system
Post Reply
cmh0818
Beginner
Posts: 4
Joined: Thu Apr 01, 2021 1:25 pm

How can i get distance from Sniffer mode?

Post by cmh0818 »

Hi all
Before i begin, i apologize my low Eng level. plz understand me :)
Well... i'm trying to use node as tag. And i already used the node as TWR tag. But i have to make 2 or moreover drones... So i can't use TWR because of packet collision. So i tried using node as Sniffer mode. and i got long value.
So i saw the TDOA protocol V2(i set Anchor node as TDOA2)
---------------------------------------------------------------------------------------------
typedef struct rangePacket_s {
uint8_t type;
uint8_t seqs[8]; // Packet sequence number of the timestamps
uint32_t timestamps[8]; // Relevant time for anchors
uint16_t distances[8];
} __attribute__((packed)) rangePacket_t;
---------------------------------------------------------------------------------------------

After saw this, i thought there was distance values in the very long value.
and i also saw the code in the lps node firmware - uwb_sniffer.c

---------------------------------------------------------------------------------------------
for (int i=0; i<(dataLength - MAC802154_HEADER_LENGTH); i++) {
printf("%02x", rxPacket.payload);
}
---------------------------------------------------------------------------------------------

In conclusion, i realized that i can get distance when rxPacket.payload[41]~[56] (41 <= i <= 56)
So after changing the code, i got value like this

---------------------------------------------------------------------------------------------
From 01 to ff @b0 !! 974e09ce: 02 81 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @b0 !! cf4d86e3: 00 00 #0e 81 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
---------------------------------------------------------------------------------------------

i think 02 81 is Diff_distance 00 and 01 node and 0e 81 is also Diff_distance 00 and 01.
but i have no idea How to change this value into meter or mm.
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: How can i get distance from Sniffer mode?

Post by kristoffer »

Hi!

Yes, in the TDoA modes the anchors are essentially doing TWR with each other, and as a "side effect" Tags can extract TDoA data by listening to the packets. You can use either TDoA2 or TDoA3, I would personally use TDoA3 since it is more robust but both should work.

There is some documentation in the node repository, but I can see that we have not documented the TDoA2 protocol very well. The TDoA3 protocol is slightly better documented and can be found here https://www.bitcraze.io/documentation/r ... _protocol/

As you noted the distances to other anchors is included in the packets sent by the anchors. In TDoA2 it is an array, while the TDoA3 format is slightly more dynamic (and complex). The distance is measured as the time it takes for a packet to go from one anchor to another and the unit is ticks of the clock in the UWB radio. The clock runs at 499.2e6*128 Hz.
There is also a delay when the radio waves propagate through the antennas which is corresponding to 154.6 meters and this has to be removed from the measurement.

So what you have to do to convert the large distance number to meters is to multiply with the speed of light, divide with the clock frequency and remove the antenna delay.
cmh0818
Beginner
Posts: 4
Joined: Thu Apr 01, 2021 1:25 pm

Re: How can i get distance from Sniffer mode?

Post by cmh0818 »

Thanks for your help!
And i want to check what i understand.

you means 02 81 is tick.
And i think this value is Hex and reversed. So i converted this value like this 02 81 -> 81 02 -> 33026.
and 33026 * speed of light / clock frequency - 154.6[m] = 33026 * 299792458[m/s] / (499.2e6*128)[Hz] - 154.6(m)
than i can get the value 0.35(m)
and this 0.35m is the value Difference distance between anchor 0 and anchor 1 right?
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: How can i get distance from Sniffer mode?

Post by kristoffer »

Yes, that looks OK :-)
Was the distance between anchor 0 and 1 about 0.35m when you did the measurement?

Note that that this is the measured distance between the anchors. From your data you can see that anchor 1 is reporting that the distance to anchor 0 is 02 81 => 33026 => 0.35 m
while anchor 0 is reporting that the distance to anchor 1 is 0e 81 => 33038 => 0.41 m
Both anchors are measuring the distance to other anchors but get slightly different results.

From 01 to ff @b0 !! 974e09ce: 02 81 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @b0 !! cf4d86e3: 00 00 #0e 81 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: How can i get distance from Sniffer mode?

Post by kristoffer »

This is posted on behalf of cmh0818. Due to some technical issues posting did not work.
--------


Well... Actually i forgot the measurement sry....
So i did this experiment again.
and this time, i measured the distance between anchors and Tag.
anchor 0 and Tag distance was 3.825m
anchor 1 and Tag distance was 1.025m

And i got values like this
----------------------------------------------------------------------------------------------------------------------------------
From 00 to ff @66 !! db7266f9: 00 00 #49 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @66 !! e372ea36: 49 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! 1b726e73: 00 00 #4a 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! 2372f0c0: 4a 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! 5b7275ce: 00 00 #51 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! 6372f97d: 51 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! 9b727d34: 00 00 #48 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! a373000b: 46 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! db728494: 00 00 #3d 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! e37306bb: 3c 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @68 !! 1b728bef: 00 00 #45 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @68 !! 23730f59: 46 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @68 !! 5b729342: 00 00 #43 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @68 !! 63731600: 43 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @68 !! 9b729ab1: 00 00 #43 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @68 !! a3731e95: 43 88 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
----------------------------------------------------------------------------------------------------------------------------------

and i converted this value into meter

-----------------------------------------------------------------------------------------------------------------------------------
From 00 to ff @66 !! db7266f9: 00 00 #9.091 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @66 !! e372ea36: 9.091 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! 1b726e73: 00 00 #9.096 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! 2372f0c0: 9.096 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! 5b7275ce: 00 00 #9.128 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! 6372f97d: 9.128 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! 9b727d34: 00 00 #9.086 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! a373000b: 9.07 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @67 !! db728494: 00 00 #9.035 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @67 !! e37306bb: 9.03 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @68 !! 1b728bef: 00 00 #9.072 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @68 !! 23730f59: 9.07 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @68 !! 5b729342: 00 00 #9.063 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @68 !! 63731600: 9.063 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 00 to ff @68 !! 9b729ab1: 00 00 #9.063#00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
From 01 to ff @68 !! a3731e95: 9.063 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #00 00 #
-----------------------------------------------------------------------------------------------------------------------------------

i got the average value 9.0778m
But as i mentioned,
anchor 0 and Tag distance was 3.825m
anchor 1 and Tag distance was 1.025m
So the Diff_distance is 2.8m
Error is 6.2778m!!! this is so weird...
kristoffer
Bitcraze
Posts: 479
Joined: Tue Jun 30, 2015 7:47 am

Re: How can i get distance from Sniffer mode?

Post by kristoffer »

I think there is a misunderstanding, I will try to clear it up.

In TDoA the anchors are actually doing Two Way Ranging with each other. This is not obvious, but if you look at the third diagram in the TDoA description here https://www.bitcraze.io/documentation/r ... ating-tdoa you can see that the three red lines is the same thing that is explained for TWR here https://www.bitcraze.io/documentation/r ... -protocol/. The end result is that the anchors are measuring the distance to the other anchors using TWR. The measured distance to the other anchors is what is included in the transmitted packets that you are looking at, not the difference in distance that you are looking for.

The difference in distance to two anchors (AKA the TDoA value) that you are looking for in your latest post, can be calculated by a Tag by listening to the packets sent by the anchors. This process is described by the other diagrams in the link above. To calculate the TDoA you need to three consecutive packets from two anchors.

So in your example in the post, it looks like the two anchors agree that the distance to the other anchor is around 9.1 meters.

It is a bit weird though since with the numbers you give it is not possible that the anchors are that far (9 meters) apart as far as I can understand. Not sure what that is?
cmh0818
Beginner
Posts: 4
Joined: Thu Apr 01, 2021 1:25 pm

Re: How can i get distance from Sniffer mode?

Post by cmh0818 »

Okay now i understand!
Thanks for your help :)

And the value 9.1meter that was weird thing was came out because LPS node was so close to something metal materials.(and there was a guy ,me, between the anchors.)
After i clean up that. distance values was became more steady.

Please accept my deepest thanks :)
And
Hope you have a great day!
Post Reply