flying multiple crazyflies at the same time

Discussions about all things Bitcraze
Post Reply
curiousstudent
Beginner
Posts: 18
Joined: Sun Jan 05, 2020 6:52 pm

flying multiple crazyflies at the same time

Post by curiousstudent »

HI!

So this might be a really stupid question. But for the longest time I have been searching for a code example on flying multiple drones at the same time.
But I have not been able to find anything. Does anyone have a example? I can do 1 crazyflie perfectly but I would like to fly more than that at the same time.
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: flying multiple crazyflies at the same time

Post by kimberly »

Tried out the examples yet on the crazyflie-lib-python repo ? https://github.com/bitcraze/crazyflie-l ... ples/swarm
curiousstudent
Beginner
Posts: 18
Joined: Sun Jan 05, 2020 6:52 pm

Re: flying multiple crazyflies at the same time

Post by curiousstudent »

Thank you for your reply. But I forgot to specify. In the stem ranger example code you can control the drone using velocity. But does something similar exist for the multiple drones flying?

I am curiuos cause the stem ranger code is different than the multiple flying code repository. Is there a way to use it with multiple drones?
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: flying multiple crazyflies at the same time

Post by kimberly »

Ah oke, so you want to do the push demo with multiple drones at the same time?

So this one https://github.com/bitcraze/crazyflie-l ... eCircle.py is using setpoints and velocity from the commander but you can check if you can put the part starting from with MotionCommander from the push demo in the run_sequence. Never tried this before but would be interesting to see if it works at all.

The problem is though, that there is two way information travel. The drone needs to constantly know what the multiranger status is (which it gets from the pc) and what the corresponding setpoint is. Communication might be the bottle neck here if you want the drones to react on sensor input...

So eventually if I where you, if you need to make something that constantly reacts on sensor input, is to work on the firmware of the crazyflie directly. In this blogpost we explained that you can do the push demo directly on the drone itself: https://www.bitcraze.io/2019/10/app-lay ... unication/. So you won't need a computer in between at all and therefore flying with multiple is much easier. However, you might want to make a script that connect to the swarm and sets parameters like 'start flying' and 'land' to make it all manageable.
curiousstudent
Beginner
Posts: 18
Joined: Sun Jan 05, 2020 6:52 pm

Re: flying multiple crazyflies at the same time

Post by curiousstudent »

Hi!

Thank you for your reply!

1)
So for the method to implement the motioncommander from the push demo but now for multiple drones at the same time: How would the program differentiate between the different drones to give specific commands to each ones? I would set up a list of URIs that I understand but the rest I am a bit confused. I also see how it could work if all the drones were operating on the same commands and directions but with different commands for each one I don't see it.

2)
To make the drones work in this manner with direct control on their firmware how would you suggest to make the script controlling the parameters? I think I see how to change the firmware. But would the general control program be in the same manner as the swarm programs(I know a lot would be different but as a vague outline would that be how I set it up with the URIs list and the rest)?
kimberly
Bitcraze
Posts: 1050
Joined: Fri Jul 06, 2018 11:13 am

Re: flying multiple crazyflies at the same time

Post by kimberly »

1) The run sequence will be initiated separately for each drone in a thread which runs in parallel in eachtoher. So it will not be the same commands and directions. But to truly understand it, you would need to dive deep into how python threads work... and that is a bit tricky. But easiest is just to give this a try with two of them and let us know if it works!

2) First of all, you would need to write a simple statemachine in C (so adding that to the applayer example in here https://www.bitcraze.io/2019/10/app-lay ... unication/) , which makes the crazyflie take off or land based on a parameter. This documentation explains how to setup a parameter in the firmware and this documentation under parameters explains how to set this up from the python side, but you can look at the swarmSequenceCircle.py examples how it is done there (the kalman filter is instructed to reinitialize from there through the parameter framework).

Especially the latter would require a bit of elbow grease to get this to work though, as it is not an easy thing to fix. If you want to checkout an highlevel example, check out the applayer functionality explained here: https://www.bitcraze.io/2019/10/enablin ... ploration/. It actually does not even use parameters but a peer to peer message in broadcast in order to have multiple drones be able to fly at the same time. It is highly complex but maybe just to check out what it can be used for,. It also has a take off state machine based on a parameter example: https://github.com/tudelft/SGBA_CF2_App ... ine.c#L341.
Post Reply