Do some interactions/feedbacks between three crazyflies

Discussions about autonomous flight in general, regardless of positioning method
Post Reply
pimpam
Beginner
Posts: 19
Joined: Fri Aug 07, 2020 8:07 am

Do some interactions/feedbacks between three crazyflies

Post by pimpam »

Hi everyone,

Currently I have three Crazyflies, but two of them are motorless (cuz I just want to hold them in each of my hand and move them by following another (with motor) Crazyflie). In my system, I use the LPS with TDOA2 mode (8 anchors), which means I have attached the loco decks on each Crazyflie. I also attached the LED-ring on one (with motor) Crazyflie. Regarding this, I would like to fly this Crazyflie and maybe hovering at any absolute height, while the others two that are held in my hand will also being moved to follow this Crazyflie. When these two Crazyflies in my hand can reach that hovering point, then the LED-ring on the first crazyflie, which is hovering now, will change the status/color.

So far, I have tried to use the Swarm to run all of the Crazyflies in parallel so that I can get the position of each Crazyflie at the same time, and then I can do the Realtime action as I mentioned above (changing the LED status). Now, I can get the position of each crazyflie. However, I'm still getting stuck on the Swarm thread. The crazyflie can fly as normal and I can also print out the positions of each, but I cannot do the Realtime feedback task that I want.

So I would like to ask whether I'm still in the right direction (I mean using the Swarm library to do so) or is there any other easier way to perform?

I would be appreciated for all suggestions.
kristoffer
Bitcraze
Posts: 464
Joined: Tue Jun 30, 2015 7:47 am

Re: Do some interactions/feedbacks between three crazyflies

Post by kristoffer »

Hi!

As always there are many ways to implement functionality and they all have their pros and cons :-)

The Swarm class is mainly intended to make it easy to connect to multiple Crazyflies, which matches your use case. The design (which I did and I'm not completely happy with) makes it fairly easy when all Crazyflies are doing similar things, like flying the same trajectory with an offset, but a bit harder to understand when you want you want different behaviour. I think it will be possible to use it in your case, but you will have to find a way to communicate between the threads. Either you use a global variable or pass a reference to a shared object when you start your work (in the args_dict param of parallel())

Another approach is to skip the Swarm class and set up the Crazyflie objects your self, connect callbacks and handle everything that way. You will have to manage all the callbacks which is a bit messy, but there are no threads and no hidden functionality.

A third option is to use the SyncCrazyflie class to connect to the Crazyflies (you can nest them) and set up the logging with callbacks (not using SyncLoggger)
pimpam
Beginner
Posts: 19
Joined: Fri Aug 07, 2020 8:07 am

Re: Do some interactions/feedbacks between three crazyflies

Post by pimpam »

Hi Kristoffer!

Thank you for your suggestions. I'll try and let's see whether which one will work for me :D
pimpam
Beginner
Posts: 19
Joined: Fri Aug 07, 2020 8:07 am

Re: Do some interactions/feedbacks between three crazyflies

Post by pimpam »

I haven't updated for a while.
I did solved my problems using SyncCrazyflie and nesting them together, then using threading.Event() to do the LED feedback part.

Thank you so much for your suggestions. However, I'm still facing with a link connection while using CrazyBolt. I'll ask in another forum.

Regards,
Pim
kristoffer
Bitcraze
Posts: 464
Joined: Tue Jun 30, 2015 7:47 am

Re: Do some interactions/feedbacks between three crazyflies

Post by kristoffer »

Great!
Post Reply