Lh deck custom use

Topics related to the Lighthouse positioning system, configuration and use
Post Reply
Bostjan Nagode
Beginner
Posts: 7
Joined: Sat Jan 30, 2021 4:11 pm

Lh deck custom use

Post by Bostjan Nagode »

Dear, as first, great work there..

I need to make a position device that would tracking it's position in area covered with vive v1 lighthouse. I have managed to do it with crazyflie. Amazed.. Im littlebit scare to ask, but i have a question about LH deck booting.
On crazyflie itself, i can see the Uart0 and uart1 tx sending serial data as described..

LH deck It has uart 0, uart 1 and i2c. In documentation i have seen some commands for leds and boot (0xbc), tried but with no sucess (probably those commands are active after boot.
Can maybie someone explain boot proces for LH deck in few words, how it can be done without Crazyflie deck?

Thanks in advance,
Bostjan Nagode
Bostjan Nagode
Beginner
Posts: 7
Joined: Sat Jan 30, 2021 4:11 pm

Re: Lh deck custom use

Post by Bostjan Nagode »

Sending 0x00 via I2C bus did the trick and now i can see the serial data output from LH deck.
Btw, commands for turning leds should work on uart? Sending 0x01 and led status doesnt do anything. I guess we are at 115200, n, 8 ,1. Any tip apreciated..

Thanks,
Bostjan Nagode
Bostjan Nagode
Beginner
Posts: 7
Joined: Sat Jan 30, 2021 4:11 pm

Re: Lh deck custom use

Post by Bostjan Nagode »

Dear,
now Uart is alive and it is sending a bunch of data out of it. Is there anyone maybe that can assist anyhow in order to clarify what those numbers are? They are captured and are like in manual is written.

Code: Select all

Sens:1	Chan:14	 TimeS:16776960		 Width:7681	 Beamd:6	 C:15597450
Sens:1	Chan:0	 TimeS:16776960		 Width:16419	 Beamd:9	 C:14483332
Sens:1	Chan:0	 TimeS:10945023		 Width:19813	 Beamd:16711680	 C:1927
Sens:0	Chan:0	 TimeS:16776960		 Width:32138	 Beamd:8	 C:14876453
Sens:1	Chan:0	 TimeS:16776960		 Width:30006	 Beamd:9	 C:14417808
Sens:1	Chan:0	 TimeS:16776960		 Width:33401	 Beamd:12	 C:13172627
Sens:1	Chan:0	 TimeS:786684		 Width:36800	 Beamd:10067206	 C:130966
Sens:0	Chan:0	 TimeS:16776960		 Width:0	 Beamd:9	 C:13959167
Sens:1	Chan:0	 TimeS:258304		 Width:46993	 Beamd:11	 C:4259743
Sens:0	Chan:0	 TimeS:1908479		 Width:17414	 Beamd:10759424	 C:122785
Sens:0	Chan:0	 TimeS:16776960		 Width:0	 Beamd:6	 C:15400959
Sens:1	Chan:0	 TimeS:16776960		 Width:57181	 Beamd:9	 C:14090152
Sens:1	Chan:0	 TimeS:15073791		 Width:60579	 Beamd:16711680	 C:1963
Sens:3	Chan:3	 TimeS:16776960		 Width:32175	 Beamd:6	 C:15465509
Sens:1	Chan:0	 TimeS:16776960		 Width:5233	 Beamd:11	 C:13237429
Sens:1	Chan:0	 TimeS:16776960		 Width:8638	 Beamd:12	 C:12976056
Sens:1	Chan:0	 TimeS:516221		 Width:12025	 Beamd:12467274	 C:131003
Sens:0	Chan:0	 TimeS:16776960		 Width:0	 Beamd:11	 C:13238271
Sens:1	Chan:0	 TimeS:7471489		 Width:22221	 Beamd:16580608	 C:3012
Sens:3	Chan:12	 TimeS:9394		 Width:65221	 Beamd:16763156	 C:13566374
Sens:0	Chan:0	 TimeS:583678		 Width:1024	 Beamd:13467284	 C:130875
Sens:0	Chan:0	 TimeS:13238527		 Width:0	 Beamd:16711680	 C:2303
Sens:1	Chan:6	 TimeS:0		 Width:32208	 Beamd:1707006	 C:13877029
Sens:3	Chan:13	 TimeS:16776960		 Width:339	 Beamd:8	 C:14417702
Sens:1	Chan:0	 TimeS:16776960		 Width:45990	 Beamd:9	 C:14417881
Sens:1	Chan:0	 TimeS:16776960		 Width:49384	 Beamd:10	 C:14024668
Sens:1	Chan:0	 TimeS:8488714		 Width:52777	 Beamd:1670627	 C:88799
Sens:1	Chan:0	 TimeS:16776960		 Width:65535	 Beamd:11	 C:13565697
Sens:1	Chan:0	 TimeS:16776960		 Width:62971	 Beamd:10	 C:13696232
Sens:1	Chan:0	 TimeS:516988		 Width:827	 Beamd:15667329	 C:131052
Sens:3	Chan:0	 TimeS:722431		 Width:385	 Beamd:15877059	 C:131071
Sens:0	Chan:0	 TimeS:2042		 Width:0	 Beamd:0	 C:696575
Sens:2	Chan:13	 TimeS:11993439		 Width:63159	 Beamd:13041664	 C:7678
Sens:0	Chan:3	 TimeS:16776960		 Width:65017	 Beamd:8	 C:14745583
Sens:1	Chan:0	 TimeS:3025		 Width:21198	 Beamd:8192352	 C:2032126
Sens:0	Chan:0	 TimeS:5177855		 Width:65280	 Beamd:16711680	 C:2559
Sens:3	Chan:2	 TimeS:499849		 Width:32004	 Beamd:131071	 C:22
Sens:3	Chan:15	 TimeS:16776960		 Width:1773	 Beamd:9	 C:14089216
Sens:1	Chan:0	 TimeS:16776960		 Width:38202	 Beamd:10	 C:14024461
Sens:1	Chan:0	 TimeS:391549		 Width:41583	 Beamd:1290176	 C:130832
Sens:3	Chan:0	 TimeS:583806		 Width:385	 Beamd:1490171	 C:131071
Sens:3	Chan:0	 TimeS:65280		 Width:385	 Beamd:11	 C:5636095
Sens:1	Chan:0	 TimeS:6291967		 Width:22353	 Beamd:16711680	 C:2331
Sens:1	Chan:15	 TimeS:16776960		 Width:32028	 Beamd:8	 C:14221078
Sens:1	Chan:0	 TimeS:3017		 Width:61973	 Beamd:8201727	 C:7012642
Sens:0	Chan:0	 TimeS:7275007		 Width:65280	 Beamd:16711680	 C:2047
Sens:2	Chan:6	 TimeS:8488716		 Width:32041	 Beamd:687404	 C:4179237
Sens:1	Chan:0	 TimeS:16776960		 Width:65535	 Beamd:9	 C:14483201
Sens:1	Chan:0	 TimeS:16776960		 Width:13433	 Beamd:12	 C:13172530
I have partially used your code to capture 12 bits..

Code: Select all

		for (int i = 0; i < UART_FRAME_LENGTH; i++) {
			 datau[i] = Uart_2.read();
			if ((unsigned char)datau[i] == 0xff) {
				syncCounter += 1;
			}
		}

		memset(&frame_0, 0, sizeof(&frame_0));

		bool isSyncFrame = (syncCounter == UART_FRAME_LENGTH);

		frame_0.sensor = datau[0] & 0x03;
		frame_0.channelFound = (datau[0] & 0x80) == 0;
		frame_0.channel = (datau[0] >> 3) & 0x0f;
		frame_0.slowbit = (datau[0] >> 2) & 0x01;
		memcpy(&frame_0.width, &datau[1], 2);
		memcpy(&frame_0.offset, &datau[3], 3);
		memcpy(&frame_0.beamData, &datau[6], 3);
		memcpy(&frame_0.timestamp, &datau[9], 3);

Thanks for your answer,
Bostjan Nagode
Attachments
Capture.PNG
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Lh deck custom use

Post by arnaud »

That you had to send 0x00 is normal: the deck starts in bootloader mode and 0x00 is the command to start the firmware. The bootloader is documented there: https://www.bitcraze.io/documentation/r ... -protocol/

To set the leds it should be enough to send "0x01 <LED_STAUS>" over the UART. For example sending "0x01 0x01" should blink the red led slowly.

As for the pulses, the screenshot you took documents what the different values are. The FPGA is acquiring lighthouse pulse timing and, for lighthouse v2, beam-data, identity and beam-time-offset. The meaning of the pulse if documented in many documents on the internet, we have not centralized the information in any of our doc yet. For lighthouse v1 this is a good repos: https://github.com/nairol/LighthouseRed ... issions.md. For lighthouse V2 I explained a bit how it worked in this blog post: https://www.bitcraze.io/2020/02/crazyfl ... thouse-v2/. The code in the Crazyflie should be mostly architecture independent so if can be used to decode the angles.

With both lighthouse V1 and V2 you will end up with a couple of angles per base-station. The crazyflie firmware repos contains some doc on how we use these angles to feed the kalman filter to achieved positioning: https://www.bitcraze.io/documentation/r ... ighthouse/.
Bostjan Nagode
Beginner
Posts: 7
Joined: Sat Jan 30, 2021 4:11 pm

Re: Lh deck custom use

Post by Bostjan Nagode »

Dear Arnaud,
thanks for answer, may i have just one more? In folder print_frame.py there is a function

Code: Select all

def calculateAE(firstBeam, secondBeam):
, but i didnt see that is anywhere used. Is it possible to get somehow the source for that script that produce following result (in lighthouse fpga) :

Code: Select all

$ ./tools/print_frame.py /dev/ttyUSB0
Waiting for sync ...
Found sync!
Sensor: 1  TS:5431ed  Width: 13d  Mode: None  SyncTime:     0  BeamWord:128aa
Sensor: 0  TS:543291  Width: 141  Mode: 1(0)  SyncTime: 28992  BeamWord:1a639
Sensor: 3  TS:5436c4  Width: 147  Mode: 1(0)  SyncTime:     0  BeamWord:1f5dc
Sensor: 2  TS:543769  Width: 140  Mode: 1(0)  SyncTime:     0  BeamWord:026f3
Sensor: 0  TS:56bcd9  Width: 120  Mode: None  SyncTime:     0  BeamWord:1b903
Sensor: 1  TS:56be78  Width: 110  Mode: 1(0)  SyncTime: 70714  BeamWord:175a5   Azimuth: -30.285°, Elevation: 4.576°
Sensor: 2  TS:56c094  Width: 113  Mode: 1(0)  SyncTime:     0  BeamWord:05879
Sensor: 3  TS:56c21a  Width: 12a  Mode: 1(0)  SyncTime:     0  BeamWord:1c094
Sensor: 1  TS:5b82f5  Width: 13f  Mode: None  SyncTime:     0  BeamWord:0debe
Sensor: 0  TS:5b8395  Width: 144  Mode: 1(1)  SyncTime: 28992  BeamWord:11c42
Sensor: 3  TS:5b87c8  Width: 146  Mode: 1(1)  SyncTime:     0  BeamWord:194c5
Sensor: 2  TS:5b8870  Width: 144  Mode: 1(1)  SyncTime:     0  BeamWord:19e30
Sensor: 0  TS:5e0dcf  Width: 118  Mode: None  SyncTime:     0  BeamWord:19864
Sensor: 1  TS:5e0f71  Width: 119  Mode: 1(1)  SyncTime: 70711  BeamWord:1511f   Azimuth: -30.290°, Elevation: 4.568°
Sensor: 2  TS:5e1189  Width: 113  Mode: 1(1)  SyncTime:     0  BeamWord:0d239
Sensor: 3  TS:5e1314  Width: 127  Mode: 1(1)  SyncTime:     0  BeamWord:08c31
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Lh deck custom use

Post by arnaud »

Hi,

If you look in the git history you can find the version of the script that produced that input: https://github.com/bitcraze/lighthouse- ... t_frame.py

I would not necessarily trust that function though: we have had a lot of back-and-forth over time in the method used to estimate azimuth and elevation from the V2 beam. The formula in the code does not seems to math the last formula in this document which is not a good sign: https://www.bitcraze.io/documentation/r ... onversion/
Post Reply