Tuning crazyflie for smooth, stable and responsive flight

Firmware/software/electronics/mechanics
theseankelly
Expert
Posts: 153
Joined: Mon Dec 28, 2015 3:23 pm
Contact:

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by theseankelly »

Hey all, it's been a while. Here's some updates for those who are curious: I've made some changes to how UART is handled that lets us reduce the syslink task priorty. However, I also determined that the massive 20ms+ spikes only happen when connected through USB instead of OTA, so it's less of a concern. I also prototyped using DMA, but haven't gotten around to finishing it. It's more of a nice-to-have since there's plenty of CPU available to handle UART interrupts on syslink.

Also made changes to synchronize the IMU data ready signal with the stabilization loop, which gets rid of that constant latency ramp. With both of these changes we're down below 100us of latency. Doesn't seem to make a ton of difference to flight performance though. The main thing I'm focused on eliminating is uncontrolled oscillations during throttle punch outs - seems to expose some instability that's probably related to other issues. I poked around at some ideas I had but didn't get anywhere yet.

I also played around with reducing the DLPF (adds quite a bit of latency), tuning the AHRS algorithm (but the problem happens in acro mode too, where errors in the attitude estimation wouldn't be relevant) and changing the software low pass filter. Nothing has really made a dent in the problem yet, so this is going to need some deeper investigation. Perhaps I'll need to dust off the SD card deck so I can get some data logs of what actually happens during a throttle punch out :)
http://www.thejumperwire.com
Tips, tutorials, and science about DIY electronics, drones, and embedded software.
tobias
Bitcraze
Posts: 2339
Joined: Mon Jan 28, 2013 7:17 pm
Location: Sweden

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by tobias »

You done a great investigation work Sean!

When you say throttle punch out what do you exactly mean and what is the behavior? Can it just be that we are reaching the physical limit?
theseankelly
Expert
Posts: 153
Joined: Mon Dec 28, 2015 3:23 pm
Contact:

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by theseankelly »

I mean rapid increases to max throttle. The behavior happens most commonly when you go immediately to 100% throttle at takeoff. I can also see it when you go from hover throttle to 100% immediately during flight.

The behavior is hard to describe, but it looks like an uncontrolled oscillation or destabilization of the system. The copter starts drifting off level at first and then very quickly inverts or spins out of control.

This particular usage scenario isn't a big deal, HOWEVER I've also experienced uncontrolled oscillations while flying FPV outdoors. If I clip a tree branch or get hit with a strong crosswind, there's a good chance the copter will destabilize in what looks like the same way, and spiral to the ground. So I'm hoping the throttle punch-out problem has the same cause, because it's a lot easier to reproduce and test.

Another possible test (but much more destructive to the copter without netting or padding) is to just throw it up in the air with lots of rotation, and then throttle up. With the IMU and processing power on the crazyflie, I don't see a reason why it shouldn't "catch itself": stop rotating and level out very quickly. However, this also seems to cause overcorrections and oscillations.

I had the same question about the physical limit, and in fact that's the main reason I spent the time porting Betaflight. I wanted to see what "the best" flight control software could do with the crazyflie hardware, and it's nearly perfect. The leveling is solid, the drift is minimal, and hitting 100% throttle at takeoff produces a very even and smooth upwards trajectory.

I think I'm going to take a deeper look at how Betaflight handles the IMU data for stabilization to see if anything stands out as interesting. I was really hoping to figure this out without "cheating" and looking at the Betaflight source, but I think I've exhausted all the simple ideas for potential fixes. My guess is it's going to come down to nuances in the PID algorithm or data filtering. If I recall correctly they're using the same AHRS algorithm as the estimator_complementary (Mahoney/madgwick) so it's probably not that.

Finally, I'm also going to play around with the Kalman filter some. I tried it a while ago and I think I remembered it was a lot better. That's definitely a good thing, but it's probably just masking the underlying issue (again, because the issue also happens in 'acro' mode with self-leveling disabled) so improving on how the data is handled will make the Kalman have to work less hard to compensate.

That was a way longer post than I was expecting! Hope I answered your question.
http://www.thejumperwire.com
Tips, tutorials, and science about DIY electronics, drones, and embedded software.
Post Reply