LPS node anchor question

Discussions about all things Bitcraze
Post Reply
doctorlu
Beginner
Posts: 23
Joined: Mon Dec 28, 2015 8:41 am

LPS node anchor question

Post by doctorlu »

Dear all,
I have a question about LPS node firmware. I saw that in the source code, it also implements the TAG relevant stuff, namely, in file 'uwb_twr_tag.c'. So I am just confused that why the anchor firmware has tag stuff integrated.
Besides, I compared it with 'lpstwrtag.c' in crazyflie-firmware. Found that the two instances are almost the same, except for some detailed coding style. Could anyone tell me what the tag stuff is used for in LPS node firmware?
doctorlu
Beginner
Posts: 23
Joined: Mon Dec 28, 2015 8:41 am

Re: LPS node anchor question

Post by doctorlu »

Come on. No one is answering??
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: LPS node anchor question

Post by arnaud »

Hi doctorlu,

Happy new year! I am usually answering post related to the LPS and have been a bit off the grid for the holidays.

The reason the LPS node is not called LPS anchor is because it can be used as anchor, tag or UWB sniffer (I think we wrote it in the product description). The code should be very similar between the Crazyflie and the node. So similar that we actually wanted to merge both in a common lib but it causes problems with the interfaces (in the copter the code pushes ranges in the kalman filter, in the node it is printed on the console). As of now it feels it is not worth the effort of merging the two codes.

/Arnaud
doctorlu
Beginner
Posts: 23
Joined: Mon Dec 28, 2015 8:41 am

Re: LPS node anchor question

Post by doctorlu »

Thanks for the clarification. I did see the description saying the LPS node could be served as a tag, but I did not see any example using it as a tag within Crazyflie framework. That's why I brought up this question. So we can configure the node as a tag to test the whole LPS system instead of using CF2, right?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: LPS node anchor question

Post by arnaud »

When setting up the node as an TWR tag you will get ranges to the anchors printed to the USB serial port. You will need to have some software on the back to do something with these ranges like plotting the raw ranges for test or calculating a position. CF2 has a Kalman filter that calculate a position estimate, this is not done by the node so if you want the same quality of position estimate as what CF2 is getting you would need to run a similar filter in your system.

We have been used the tag mode for testing the UWB ranging (things like stddev of the measurement). For that we just open the serial port and decode the lines with regular expression. If you are interested I have a couple of these test scripts lying around, I can share them.
doctorlu
Beginner
Posts: 23
Joined: Mon Dec 28, 2015 8:41 am

Re: LPS node anchor question

Post by doctorlu »

Dear Arnaud,
Thanks for the reply. I get it.
I have another question about the source code in the LPS node. I saw in uwb_twr_tag.c, there is a static variable called base_address:
static uint8_t base_address[] = {0,0,0,0,0,0,0xcf,0xbc};
I also saw this var is used to store, in its first element, the timed-out anchor the tag is communicating with. Does that mean it requires the ranging should be re-initialized from this timed-out anchor? Also, why the last two elements are set as oxcf and oxbc?
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: LPS node anchor question

Post by arnaud »

About time-out I am not sure to understand. The anchors are almost state-less and will just answer a pre-defined answer to each packet so if a ranging to one anchor times-out there is no need to reset anything, we can just try again the ranging sequence next time.

The array you are pointing out is the MAC address used to select which anchor we are talking to. 0xBC 0xCF are just arbitrary (not so) random numbers to set the address to something else than all 0. Nothing special about it.
doctorlu
Beginner
Posts: 23
Joined: Mon Dec 28, 2015 8:41 am

Re: LPS node anchor question

Post by doctorlu »

Arnaud,
Thanks for the reply. I still cannot understand the why we need base_address variable. Look at the code below:
void initiateRanging(dwDevice_t *dev)
{
//printf ("Interrogating anchor %d\r\n", config.anchors[curr_anchor]);
//led_on(LED_PC9);
base_address[0] = config.anchors[curr_anchor];
curr_anchor ++;
if (curr_anchor > config.anchorListSize-1) {
curr_anchor = 0; //change this for testing
}
dwIdle(dev);

txPacket.payload[TYPE] = POLL;
txPacket.payload[SEQ] = ++curr_seq;

memcpy(txPacket.sourceAddress, config.address, 8);
memcpy(txPacket.destAddress, base_address, 8);


It seems to me that only the first element, namely base_address[0], is in real use. Why do we need an array, init like that, to store the MAC address. Could you elaborate it in detail?
Another thing, I saw default_anchor_list in cfg.c starts from 1, can it start from 0? Why 1?
I tried to start it from 0, but got Anchor 0 cease to work. I cannot figure out why it happens, and speculate that there must be a reason that you guy make anchor list start from 1 instead of 0.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: LPS node anchor question

Post by arnaud »

Hi,
We are using IEEE802.15.4 header format with 8 bytes addresses. So Addresses are stored as an array of 8 bytes. The array here is used as a template to translate anchor ID (from 1 to 6) into IEEE802.15.4 MAC address.

The anchrors number and address starts by 1 for historical reason. This is going to change soon to start from 0 which will be better and less confusing. If you set both tag and anchor to address 0 it should work. We have setup the TDOA anchors and tag to start with address 0 and TWR will follow soon.
Post Reply