Drone Swarming with HTC Vive

Topics related to the Lighthouse positioning system, configuration and use
skyfall
Beginner
Posts: 14
Joined: Thu Aug 06, 2020 8:04 am

Drone Swarming with HTC Vive

Post by skyfall »

Hi all,

I am a student currently doing my final year project. The objective of my final year project is to use the Crazyflie drones to do a simple drone swarming with the HTC Lighthouse positioning system. I was given 4 Crazyflie drones, 2 HTC Vive Lighthouse, the Lighthouse deck, as well as the Flow deck.

From the documentation that you have published on your website (https://www.bitcraze.io/documentation/r ... _overview/), I managed to get the get_bs_geometry.py to run and was able to get the positions of the base stations. However, I am stuck at the part where I need to copy and paste the last two lines into the lighthouse_position_est.c file. What should I do after I completing that portion? Where do I edit the codes to change the swarming sequence?

Also, how do I interpret the position data that was being generated after running get_bs_geometry.py? In the documentation, it states that the .origin part represents the position of each base station, and the .mat part is the orientation (rotation matrix). I am very confused with this portion too. Is it possible to show an illustration to explain the position coordinates?

Thank you for reading this post.
kimberly
Bitcraze
Posts: 523
Joined: Fri Jul 06, 2018 11:13 am

Re: Drone Swarming with HTC Vive

Post by kimberly »

Hi!

First things first: let's focus on just one crazyflie with the basestations and worry about the swarming later. It makes it easier for us to take it one step at a time. You need to replace these lines in the code of the crazyflie firmware. Then you would need to build the firmware according to the instructions of the readme of the crazyflie-firmware repository and flash it to the crazyflie after tuning it into bootloader mode.

Code: Select all

make clean
make all
make cload
If this is too complicated for you, you can also run the geometry script with --write:

Code: Select all

tools/lighthouse/get_bs_geometry.py --write --uri radio://0/80/2M
This means though, that you would need to do this every time you restart the crazyflie since it does not save these values when it restarts.

Since you just started working with the crazyflie, I highly suggest of starting from the beginning as well (. Since you have a flowdeck you can try out the step by step guides starting from logging and parameters: https://www.bitcraze.io/documentation/r ... on/master/. Once you finished the motion commander one, and managed to get that one to work with your lighthouse basestations, with just one crazyflie, then we can start discussing the swarming part.
skyfall
Beginner
Posts: 14
Joined: Thu Aug 06, 2020 8:04 am

Re: Drone Swarming with HTC Vive

Post by skyfall »

I managed to go get the motion_commander_demo.py from the example file running and was able to flash the code to the Crazyflie. Moving on to the lighthouse positioning, what will happen after I replace the lines in the code in lighthouse_position_est.c? What is the expected result I will get after flashing the new firmware into the Crazyflie?
kimberly
Bitcraze
Posts: 523
Joined: Fri Jul 06, 2018 11:13 am

Re: Drone Swarming with HTC Vive

Post by kimberly »

Currently the lines in the lighthouse_position_est.c are the exact position and orientation of the basestations in our own flightlab. You need this information in order to calculate from the sweepangles (what the lighthouse deck detects) to the position of the crazyflie. If these positions and orientations of the basestations are set in wrong, it will calculate the position based on wrong assumptions of where the basestations are. Pretty much, if you flash the crazyflie with the firmware, without changing the basestation position to the right one in your setup or using the --write flag on the script, it will fly away and crash.

by the way:
.orgin is the actual x,y,z position of the basestation. .mat is the rotation matrix that depicts the orientation of the basestation (where it is facing towards)
skyfall
Beginner
Posts: 14
Joined: Thu Aug 06, 2020 8:04 am

Re: Drone Swarming with HTC Vive

Post by skyfall »

Oh, that is interesting. This means that I have to stick to the same exact same position at where I calibrated the coordinates right?

Moving on, I have actually tested the lighthouse positioning system by placing the drone at certain positions within the play area to see the changes it does to the .origin coordinate. For that part, I was able to interpret since it only involves the XYZ axis. For the .matrix portion, I am still currently in the midst of understanding it. Is there any illustrations or diagram that I can refer to for better visualization?

Also, what should I be doing for the next step for drone swarming after understanding the principle behind the coordinates?
kimberly
Bitcraze
Posts: 523
Joined: Fri Jul 06, 2018 11:13 am

Re: Drone Swarming with HTC Vive

Post by kimberly »

There is no illustration or diagram for the rotation matrix representation. Best thing is to look into the get_bs_geometry.py script.

Have you managed to fly just one crazyflie based on a python script with the cflib library already? That is necessary before moving towards multiple crazyflies.
skyfall
Beginner
Posts: 14
Joined: Thu Aug 06, 2020 8:04 am

Re: Drone Swarming with HTC Vive

Post by skyfall »

Yes. I manage to execute the example codes under the /home/bitcraze/Desktop/projects/crazyflie-lib-python/examples/ in the virtual machine. Motion_commander_demo.py and flowsequenceSync.py is the code that I run to test it.
kimberly
Bitcraze
Posts: 523
Joined: Fri Jul 06, 2018 11:13 am

Re: Drone Swarming with HTC Vive

Post by kimberly »

Good! Then you can look into the swarm folder of the example folder. I would recommend the swarmSequenceCircle.py, but first only try it with 2 and slowly increase it. Change the URIS to the crazyflies addresses (they must have different addresses, you can change that in the cfclient in connnect and configure ).

Once you managed to get this to work with several crazyflies, you can try out the hl-commander-swarm.py which uses the highlevel commander.
skyfall
Beginner
Posts: 14
Joined: Thu Aug 06, 2020 8:04 am

Re: Drone Swarming with HTC Vive

Post by skyfall »

For the swarmSequenceCircle.py, it states that it is the script for 5 Crazyflies. As such, I will need to comment the extra 3 URL/Params right let's say I am testing with 2 Crazyflies first?
kimberly
Bitcraze
Posts: 523
Joined: Fri Jul 06, 2018 11:13 am

Re: Drone Swarming with HTC Vive

Post by kimberly »

Yes you will need to do that in the uris struct, and you might need to comment out the unused uris in params as well.
Post Reply