Crazyflie assembly and test flight

What a week. Those who saw my last entry know that my Crazyflie arrived, and you probably guessed – correctly – that I’ve put it together by now. In the following days, I became more familiar with a soldering iron than ever before, assembled the Crazyflie, flashed the firmware, flew it around, fiddled with the firmware, flashed it again, flew around some more, and started doing some cosmetic changes to the PC client. In the meantime I’ve become enjoyed great support from the Crazyflie’s developers and had a slight disagreement with the manufacturers.

That sounds like a lot! But it’s actually not as hard as it sounds. Here’s how it worked out for me, and how it could work out for you if you want to start hacking around as well.

Assembling the Crazyflie

Assembling the Crazyflie sounded a lot more challenging than it actually was. The Crazyflie team has some great resources posted on their website and that made it pretty easy to put together. It was the first time that I’d had a soldering iron in my hand for a very long time, so I was understandably nervous about working on such a fine piece of electronics. Nonetheless, after some very tentative and careful prodding, the Crazyflie was assembled.

The assembled Crazyflie.

The assembled Crazyflie.

Not being an expert on any kind of physical electronics – I know, all electronics are physical, but I normally work on a much more abstract level – I have to say that I am nonetheless very impressed by how well designed the device is. Despite its small size, it seems fairly robust. I still touch it carefully and am very cautious while flying it, but when you hold it in your hand you notice that it’s not quite as fragile as you would think. If you would have watched me attach the propellors, you would have noticed that I handled them as if they were made out of porcelain. After removing them and putting them back again a couple of times I finally realized that all of the components are robust and nonetheless somewhat flexible, so that you can access all of the parts quite easily. If you want to swap out the propellors, it really helps to have a small screwdriver at hand, but it’s not absolutely necessary, which raised my hopes that I can run trials outside at some point.

Despite the complexity of the machine, it was understandable enough for a layperson like myself to put together and test to make sure everything was working alright. This was mainly due to the great directions on the page – the Crazyflie team has a nice video where you can see the assembly of another Crazyflie. Accompanying that is a nice storybook-style set of instructions on how to put it together if you just want to look things up or don’t feel like putting the thing together with the video running in parallel.

The team suggests flashing the Crazyflie by radio immediately after receiving it. They had great instructions on how to get the radio up and running in Linux, so after downloading the software I had both the PC client and the radio up and running inside of ten minutes. The instructions may not be so easy for non-Linux-savvy users, as you have to add a rule to `/etc/udev/rules.d`, but if you’re familiar enough with the command line to use `sudo`, you’ll be fine. The support for the PS3 controller that I currently use to pilot the Crazyflie is independent of the Crazyflie time itself, of course, but it’s also great: Plug and play. A friend of mine reportedly has difficulties in Windows 7, but hey, stop running Windows. No, seriously.

Sorry for being a snob. Naw, I’m not 😉

Test flights

So of course the most interesting thing is flying, and I’ve been practicing a lot. The first iteration of the Crazyflie that I built was pretty hard to stabilize. That was partly my own ineptitude, but partly it was – I believe – due to a faulty power management chip. That’s another story that I’ll talk about below. Anyway, after assembling a second Crazyflie I was able to immediately notice a difference in handling. I had learned in the meantime, but not enough to have it make that much of a difference. Plus, if I do say so myself, my flying ain’t so bad 😛

What’s so hard about flying the Crazyflie anyway? The main difficulty is in keeping the thing in one place. It stays level just fine all by itself, but because the device is so small, it’s always trying to go in one direction or another. You can hover, but it’s hard to find the right balance in thrust that keeps the Crazyflie from shooting up or falling down. Because you don’t have the thing balanced absolutely perfectly, it will be pulling in one direction or another. I expect that this changes, depending on how the wires connecting the motors to the power distributor happen to hang at takeoff. It’s not that bad, you can still keep it stable, but it would be a mistake to believe that you could just have the Crazyflie lift off and stay in one position without somebody behind the wheel balancing it manually.

The other difficulty is keeping your orientation. The commands that you give the Crazyflie are relative to the direction the Crazyflie is pointed in. This makes perfect sense and is really, really good from a piloting standpoint, but it can be rather difficult to wrap your head around the fact that when you tell the Crazyflie to fly forward and it’s facing to your left, that it flies to the left rather than forward from your perspective. Like I said, it makes perfect sense when you think about it, but when you’re flying the Crazyflie it’s hard to internalize to the point that you can “just fly it.” I’m getting there though.

The PC client gives you a lot of options, so what I started off with was reducing the maximum thrust, bank and yaw rates. It’s possible to completely turn off the yaw function, so that the Crazyflie is always facing in the same direction, and in my opinion this was the best way to start off using it. This has obvious advantages when you’re learning to fly the thing and with these electronic training wheels I was able to fly from the floor onto the table in my first flight test.

It was a big table.

After a while I was able to turn yaw on and by now I’m able to fly around pretty well, in my opinion – I’m at the point where I can have the Crazyflie lift off from my hand facing in any direction it likes. Then I spin it around and generally fly with it facing away from me. The bright LEDs help to maintain your orientation. After that I can either fly around and then have the Crazyflie land on my hand again, or I can land it pretty much anywhere I want. I feel very cool if I manage to land it on one of the two narrow stools I have standing in the kitchen, and normally I manage that as well. The drone is very responsive. The advantage of the PC client is that it’s possible to reduce the speed to the level that flying is just hard enough to help you climb the learning curve, or you can open up the throttle and fly around like a bee on

Custom firmware

As fun as flying around is, the real reason I bought the Crazyflie was so that I could use it for automated flight. There are some other people working on cool flight controls like a hover mode, and Apis already has some rather abstract methods to construct a line between given points that I hope to use for navigating in the future. For the moment, though, there’s just too much manual intervention necessary to focus on truly automated flight.

My first goal is to be able to reconstruct the Crazyflie’s flight properly, which is slightly more complicated than it sounds. When the Crazyflie pitches left, it actually tilts. It then flies to the left, at least when viewed externally. Intrinsically, the Crazyflie’s accelerometers see that it flies _upwards_ and then to the left. The vector, when converted to the extrensic coordinate system, is horizontal to the left (in theory), but the intrinsic coordinate system sees it differently. So I’ll have a little bit of work transforming accelerometer and gyroscope measurements to actual movements later on.

Before I can start with that, though, I have to access the accelerometer values from the Crazyflie itself. The PC client is quite large and I’m slowly familiarizing myself with it, but my main focus at the moment is on cosmetics, whereas getting into the actual inner workings of the library should come later. I’m really happy about having the sources, but I wish they were somewhat better documented. Another problem is that some of the examples on the Crazyflie wiki are, if I’m interpreting them correctly, deprecated. The Crazyflie team does a great job of compensating this by reacting very quickly in the forum. The code is also under rapid development and so all of these problems should be gone in the near future, but at the moment it’s still pretty difficult.

So I started off with exposing the accelerometer values that are taken on the Crazyflie itself. This involved adding a small code block to the firmware and then recompiling it. In order to do so, I also compiled the gcc-arm toolchain to be able to compile for the Crazyflie.

I’m no C coder, but this really wasn’t hard at all, and the Crazyflie team have made a great Makefile so that really all you have to do is modify the sources and then run `make` in the source root directory. That throws the firmware into the same directory you’re in, and with the PC client you can flash it.

Flashing is also very easy and takes five minutes at the most – you select the firmware binary in the PC client’s GUI, tell it to have the next Crazyflie it sees on the radio boot into the bootloader, and switch the Crazyflie on. Then you click the button to flash. Everything happens by radio and after about 40 seconds your firmware is flashed. Restart the Crazyflie and fly away! Mine is currently flying using the modified firmware and I can see that the accelerometer values are available in the logging table of contents, but I’m still having trouble getting them to log correctly. Thank goodness the Crazyflie team are so helpful, because if I weren’t able to turn to them and count on an answer, it would be a lot harder to get that up and running.

Current objective: Flight logging

As noted above, getting access to the flight log isn’t so easy, but that’s what I’m planning on doing. First I want to save the data to a file, then I want to make a few graphs of it to show my flight paths. These will be incorrect, but will give me hope as a kind of proof of concept. After that I plan to combine the accelerometer values with gyroscope measurements to figure out where the drone actually flew, and then I’ll drop the last errors by incorporating the roll and pitch values to translate the measurements into positions in an extrinsic coordinate system. Export to see results here.

Contact to designers and manufacturers

During this entire process, the Crazyflie designers have been very cooperative and helpful. They’ve made a great device that flies really, really well. As far as the code is concerned, I can’t really judge the C code in the firmware, but I’m quite impressed with the Python code that they’ve written, especially in light of the fact that they say that Python isn’t really their language. After noticing that quite a few spots in the code could be stylistically fixed up a bit – checking whether a variable is equal to None, rather than checking if it *is* None, etc. – I wrote to them and asked if they would mind if I did some stylistic reworks. They were happy over the contribution. Right now I’m really *only* focusing on bringing the code into accordance with the Python style guidelines, and afterwards I’m planning on introducing more Pythonic idiosyncracies. One after another, though – that makes it easier to merge. I’m very happy to be able to contribute.

The one problem I have at the moment is with Seeedstudio, although I have to say that I can somewhat understand it. The first Crazyflie that I built was always hard to handle, and at some point it simply died wihle charging. It’s never worked properly again, but because there were no crashes that could have caused it and the device was charging when it decided to kick the bucket, I believe that it’s probably a hardware problem. The Crazyflie team on the forum advised me to contact Seeedstudio and it’s been quite the ordeal with them so far. They still haven’t agreed to refund or exchange the Crazyflie so I’m testing with a borrowed device at the moment. I understand that, for them, it’s hard to tell whether I really have a hardware problem that was there from the beginning or whether it was caused by personal misuse, but I am of the opinion that it’s *not* my fault and that at the very least they should give me the benefit of the doubt. Hopefully that conflict will be solved soon. I really like and respect Seeedstudio and would much rather be on a more friendly basis with the people there.

What’s to come?

Expect updates on the logging project as I develop them! Soon I should be getting a camera that the Crazyflie can fly with, and I ohpe to use that, combined with the positional data, to start capturing 3D data using structure from motion. Lots of cool stuff to come!


My name’s Daniel Lee. I’m an enthusiast for open source and sharing. I grew up in the United States and did my doctorate in Germany. I've founded a company for planning solar power. I've worked on analog space suit interfaces, drones and a bunch of other things in my free time. I'm also involved in standards work for meteorological data. I worked for a while German Weather Service on improving forecasts for weather and renewable power production. I later led the team for data ingest there before I started my current job, engineering software and data formats at EUMETSAT.

Tagged with: , ,
Posted in Uncategorized
2 comments on “Crazyflie assembly and test flight
  1. Nigel says:

    hi daniel , i was hoping if you could help me with my project. im trying to implement the radio trasmitter/receiver function from the crazyradio quadcopter and i was hoping you would know the codes to it in C programming. do you have any clue ?


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

From the archive