Need help with broadcasting & swarm control

Discussions about autonomous flight in general, regardless of positioning method
Post Reply
MichaelNdu
Beginner
Posts: 6
Joined: Tue Apr 27, 2021 7:27 am

Need help with broadcasting & swarm control

Post by MichaelNdu »

Hello,

First, a bit of context on my project and what I'm attempting to do—I'm trying to build an app that discovers & controls a swarm of drones, with the capability to run synchronized trajectories that I've defined beforehand (via the high level commander). This is more or less exactly what the Crazyswarm project does, but for external reasons, my app has to be a Windows application, so unfortunately I can't actually use the Crazyswarm API directly, as my understanding is that it currently only supports Ubuntu Linux.

My initial plan of attack was use the crazyflie-lib-python to control the drones individually, but I ran into synchronization and bandwidth problems, and after doing some digging, I found out the Crazyswarm project works around these limitations by sending out broadcast packets for tighter control. I know the cflib Python library doesn't currently support this feature (though curiously, the high level commander in cflib does support groups/group masks 🤔), but I read through the source code for crazyswarm, crazyflie_ros, crazyflie_cpp, and crazyflie-firmware, and as far as I can tell, broadcasting involves 2 things:
  • Sending to special "broadcast address" 0xFFE7E7E7E7
  • Sending out 2 packets without waiting for an ack response, with this one being more for mitigating potential packet loss than anything else
With that understanding, what I was thinking of doing was using the cflib along with the new C++ link from crazyflie-link-cpp, and forking both the crazyflie-lib-python and crazyflie-link-cpp repositories, to expose the send2PacketsNoAck functionality through cflib. My first step was writing a small C++ test app that uses crazyflie-link-cpp directly to control a couple of drones, using send2PacketsNoAck, and attempts to broadcast to get them to take off and land simultaneously, and this is where I'm running into trouble.

My current testing setup is as follows:
  • I've got two crazyflie 2.X's configured on the same channel with different addresses, one at uri radio://0/55/2M/E7E7E7E7E7, and another at radio://0/55/2M/E7E7E7E7E8
  • I'm using a Crazyradio PA usb radio, with libusbK drivers, and I've built the latest crazyradio-firmware and flashed it to the dongle successfully
  • I've also flashed both crazyflies with the latest releases of crazyflie-firmware and crazyflie2-nrf-firmware
  • I'm sending high level commander takeoff/land packets (port 8, command 7/8), with group mask 0
  • I've enabled the high level commander on each of the drones individually, using the Crazyflie PC Client and setting the commander.enHighLevel parameter to 1
  • Not particularly relevant (since I'm only doing takeoff/land at the moment), but I have a Lighthouse deck attached to each of the drones and I'm using the lighthouse positioning system for autonomous flight of the trajectories
To try and broadcast to the drones, I'm manually creating a connection with uri radio://0/55/2M/FFE7E7E7E7, and sending the same high level commander packets I normally send individually. The behavior I'm seeing is that if I address each of the drones individually, I'm able to have them take off and land no issue, but if I try the broadcast address, the green LEDs on both drones turn on (same as when they have a unicast connection), but neither drone moves at all. The LED on the radio dongle itself also stays RED, unlike when creating a unicast connection. I also made some testing modifications to the library, and I'm currently sending all packets via send2PacketsNoAck, though the behavior is the same with or without that mod.

So it's very possible, and actually very likely that I have either an incomplete or misinformed understanding of what is involved in broadcast communication with the crazyflies, so I'd very much appreciate some pointers on whether what I'm attempting to do makes sense, and how I should be going about it.

Thanks!
Michael
MichaelNdu
Beginner
Posts: 6
Joined: Tue Apr 27, 2021 7:27 am

Re: Need help with broadcasting & swarm control

Post by MichaelNdu »

Bump—anyone have any thoughts on this? Would love any ideas or suggestions!
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Need help with broadcasting & swarm control

Post by arnaud »

Hi,

Interesting experiment, I would love to get some update when you have things working. Adding broadcast support to the python lib and the native link sounds interesting.

For your current problem: have you updated your Crazyradio with the Crazyswarm-provided firmware? The stock Crazyradio is not able to send broadcast packets and the fact that the radio light up the red LED tends to indicate that it is stock: a radio with broadcast support will lit Green when sending broadcast packets.

I also suggest you write a ticker of do a draft pull request to the cpplink git repos so that we can see your changes to support broadcast. There is a special command to setup the radio in noAck mode which I assume you are using.

Otherwise, the behavior on the Crazyflie side looks good: the green LED means that packets are received in the Crazyflie.

One last though: I do not think the proper way to handle broadcast is to open a "broadcast link", but I have never used it myself. I think github would be a good forum to discuss about it since we can then include @whoenig (the main author of the CPPlink and Crazyswarm) in the discussion.
MichaelNdu
Beginner
Posts: 6
Joined: Tue Apr 27, 2021 7:27 am

Re: Need help with broadcasting & swarm control

Post by MichaelNdu »

Hi arnaud,

Thanks for the response! I'll address some of your questions here, but I'll also open up a GitHub issue where can discuss this further.
For your current problem: have you updated your Crazyradio with the Crazyswarm-provided firmware?
I actually built a binary from the master branch of the crazyradio-firmware repository and flashed that to the radio, which I assumed should work—the crazyswarm repo references the crazyradio repo as a submodule, pinned at a much older commit, so I assume, that's what the prebuilt radio firmware was built from, and that a newer build of the firmware should be fine.
I also suggest you write a ticker of do a draft pull request to the cpplink git repos so that we can see your changes to support broadcast.
Going to open an issue like I mentioned, but would also be happy to draft up a pull request, once I have things in a working state and clean things up a bit!
There is a special command to setup the radio in noAck mode which I assume you are using.
I wasn't aware of this, and this is probably the missing link—I'm wondering if that's as simple as sending an ACK_ENABLE command to disable ack packets, or if there's something else. An example of this being used would be great to see.
One last though: I do not think the proper way to handle broadcast is to open a "broadcast link", but I have never used it myself.
Interesting—curious how those packets are sent out in that case, but we can discuss further on GitHub.
MichaelNdu
Beginner
Posts: 6
Joined: Tue Apr 27, 2021 7:27 am

Re: Need help with broadcasting & swarm control

Post by MichaelNdu »

Here's a link to the Github Issue, for anyone interested in following this discussion: https://github.com/bitcraze/crazyflie-link-cpp/issues/8
Post Reply