Tuning crazyflie for smooth, stable and responsive flight

Firmware/software/electronics/mechanics
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by chad »

nanobot9000 wrote:after I create the config.mk with the appropriate statement how do I know for sure that the build was correct aside from the behavior once I load it? Is there some number in this example that tells me it used my config.mk as part of enabling the experimental PID?
The config.mk file is in crazyflie-firmware/.gitignore, so it's ignored by git and won't show you that it's a modified build even if config.mk is present. If you wanted to make sure a flag has an effect on the binary you could remove (or rename) your config.mk file, build the binary clean, checksum it, put back the config.mk file, build clean again, checksum the binary again and see if the two checksums are different. If they are, your change had an effect. If not, it didn't.

e.g. (on the VM):

Code: Select all

cd ~/projects/crazyflie-firmware

mv tools/make/config.mk tools/make/config.mk.bak
make clean
make
md5 cf2.bin > md5.clean.txt # md5 hash for non-experimental PIDs

mv tools/make/config.mk.bak tools/make/config.mk
make clean
make
md5 cf2.bin > md5.experimental.txt # md5 hash for experimental PIDs

diff --brief md5.clean.txt md5.experimental.txt # Differences found? Flag worked.

rm md5.*.txt
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
liwanggt
Beginner
Posts: 5
Joined: Thu Apr 14, 2016 3:43 pm

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by liwanggt »

I did a simple comparison between the new and old PID parameters. The experiment set up is:
30s manual control using joystick
Optitrack motion capture system tracking the crazyflie2
ROS recording joystick command and Optitrack data

Here is the result. (yaw input is yawrate, ignored here)
1. Roll/Pitch response using old PID parameters. Average error is 2.92 degree for pitch, and 2.27 degree for roll. cmd is the joystick input, track is the Optitrack data.
Error_Old_PID.png
2. Roll/Pitch response using new PID parameters. Average error is 1.59 degree for pitch, and 2.22 degree for roll. cmd is the joystick input, track is the Optitrack data.
Error_New_PID.png
That's almost a 25% accuracy improvement. We can also see the crazyflie is now tracking large roll/pitch angle inputs very accurately. Very suitable for advanced flight. Great contribution indeed!

Li
nanobot9000
Beginner
Posts: 26
Joined: Mon Apr 11, 2016 4:33 pm

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by nanobot9000 »

chad wrote:
nanobot9000 wrote:after I create the config.mk with the appropriate statement how do I know for sure that the build was correct aside from the behavior once I load it? Is there some number in this example that tells me it used my config.mk as part of enabling the experimental PID?
The config.mk file is in crazyflie-firmware/.gitignore, so it's ignored by git and won't show you that it's a modified build even if config.mk is present. If you wanted to make sure a flag has an effect on the binary you could remove (or rename) your config.mk file, build the binary clean, checksum it, put back the config.mk file, build clean again, checksum the binary again and see if the two checksums are different. If they are, your change had an effect. If not, it didn't.

e.g. (on the VM):

Code: Select all

cd ~/projects/crazyflie-firmware

mv tools/make/config.mk tools/make/config.mk.bak
make clean
make
md5 cf2.bin > md5.clean.txt # md5 hash for non-experimental PIDs

mv tools/make/config.mk.bak tools/make/config.mk
make clean
make
md5 cf2.bin > md5.experimental.txt # md5 hash for experimental PIDs

diff --brief md5.clean.txt md5.experimental.txt # Differences found? Flag worked.

rm md5.*.txt
Thank you! Sorry for the late reply as I have been traveling. I will do what you said.
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 »

Li, those graphs are super interesting to see. Thanks for sharing. Could you give a rough number for what the latency is? It's observable but too small to figure out what the value is from your graphs.

It's also really interesting to me that the roll error remained relatively constant between PID values as compared with pitch. I'd have expected them to be the same given the symmetrical design of the crazyflie.
http://www.thejumperwire.com
Tips, tutorials, and science about DIY electronics, drones, and embedded software.
liwanggt
Beginner
Posts: 5
Joined: Thu Apr 14, 2016 3:43 pm

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by liwanggt »

From what I observed during some autonomous flights, the latency is about 0.1s with logging frequency of 50Hz.

Yes, the Crazyflie is symmetric. But the tracking markers I attached to the Crazyflie is not symmetric. The markers I placed are slightly off the center in the roll direction. The motion capture system needs non-symmetric marker placement to identify correct heading direction and distinguish between multiple crazyflies.

Li
theseankelly wrote:Li, those graphs are super interesting to see. Thanks for sharing. Could you give a rough number for what the latency is? It's observable but too small to figure out what the value is from your graphs.

It's also really interesting to me that the roll error remained relatively constant between PID values as compared with pitch. I'd have expected them to be the same given the symmetrical design of the crazyflie.
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 »

Are the markers heavy enough to alter the flight characteristics?
http://www.thejumperwire.com
Tips, tutorials, and science about DIY electronics, drones, and embedded software.
liwanggt
Beginner
Posts: 5
Joined: Thu Apr 14, 2016 3:43 pm

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by liwanggt »

My tracking markers weigh 1g each. I also have 3D printed frames hanging there. I assume they do influence the flight performance for a 27g crazyflie. But since current flight performance is rock solid, I didn't bother changing to lighter markers and frames.

Li
theseankelly wrote:Are the markers heavy enough to alter the flight characteristics?
jonschoning
Beginner
Posts: 1
Joined: Tue Jun 21, 2016 5:38 am

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by jonschoning »

Using rate mode (modifying commander.c to stabilizationModeRoll=RATE, stabilizationModePitch=RATE) and using new "experimental pid settings" (CFLAGS+=-DEXPERIMENTAL_ATTITUDE_PID) makes flight MUCH better, thank you!

with stabilizationModeRoll/stabilizationModePitch = ANGLE the crazyflie would flip over very easily... now it's much harder to flip when the crazyflie is moving at a decent clip.
chad
Expert
Posts: 555
Joined: Sun Sep 28, 2014 12:54 am
Location: New York, USA
Contact:

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by chad »

jonschoning wrote:with stabilizationModeRoll/stabilizationModePitch = ANGLE the crazyflie would flip over very easily... now it's much harder to flip when the crazyflie is moving at a decent clip.
I have the same experience WRT angle vs. rate and flipping.
Crazyflier - my CF journal...
4x Crazyflie Nano (1.0) 10-DOF + NeoPixel Ring mod.
3x Crazyflie 2.0 + Qi Charger and LED Decks.
Raspberry Pi Ground Control.
Mac OS X Dev Environment.
Walkera Devo7e, ESky ET6I, PS3 and iOS Controllers.
Yaro
Member
Posts: 31
Joined: Wed May 20, 2015 11:28 am

Re: Tuning crazyflie for smooth, stable and responsive flight

Post by Yaro »

I've recently tried new Experimental PID and it' very very smooth in movements that my previous settings(little vibrations on movements). I've just lowered values in proportion to have less agressive response when flying indoor(of course I think it's the same to lowering controller sensibility).
The problem is that I've too this 'slippery' feeling like being on ice. Maybe outdoor this is not a problem, but indoor it's quite hard to hover since I must constantly counter this 'slippery' after each movement.

Some kind of react control was implemented to null or reduce this effect?
Post Reply