Page 1 of 1

Yaw orientation lock on crazyflie 2.0

Posted: Mon Mar 26, 2018 12:23 am
by jparker310
Hello everyone,

I am pretty new to crazyflie, so please excuse my possibly naïveté, but I was wondering if there is an easy way to disable the yaw lock on the crazyflie 2.0. In other words, by default, the crazyflie tries to maintain its yaw orientation based on its initial direction upon taking off. I would like to disable this feature, and believe the simple solution lies in altering one of the existing parameters in the parameter window on the python client. If someone could direct me to an existing solution, or knows of a existing parameter input to accomplish this, it would be greatly appreciated!

Also, just for my edification, if anyone knows what sensor or combination of sensors are responsible for this yaw lock, I would appreciate it as well (I suspect it is a magnetometer, but am not entirely sure).

Thanks in advance!

-Jake Parker

Re: Yaw orientation lock on crazyflie 2.0

Posted: Mon Mar 26, 2018 9:29 am
by arnaud

What behavior would you like instead?

The Crazyflie is running a control loop that work continuously at controlling the attitude, roll/pitch/yaw. Without this control, it would not fly. The yaw measurement comes from the gyroscope.

Re: Yaw orientation lock on crazyflie 2.0

Posted: Mon Mar 26, 2018 3:14 pm
by jparker310
Thanks for the timely response,

Currently, when the crazyflie lifts off in a certain orientation, it tries to maintain that initial yaw position. For example, if it were say: manually rotated by a person's hand or external force, it would aggressively resist and rotate back to its original yaw position. Instead, I would like it to disregard this urge to correct its yaw position, and rather than trying to turn back to its original orientation, it would simply remain in its new yaw orientation.

Hopefully that clarifies things a bit.

Thanks again,


Re: Yaw orientation lock on crazyflie 2.0

Posted: Tue Mar 27, 2018 8:20 am
by arnaud
Hi Jake,

Thanks for the clarification, now I understand better what you want to do.

I think you should play with the Ki part of the YAW PID. This will tell the controller to not care so much about static error (which is what you want to introduce). You can use the parameters from the client to change the PID parameters, setting pid_attitude.yaw_ki and pid_rate.yaw_ki to 0.0 could be a good start. My intuition is that if you want to keep the yaw from drifting continuously you will need some Ki but to modify the firmware to 'cap' the amount of accumulated integral part, this way the PID will keep the yaw stable when no force is applied but will not correct when the crazyflie is turned.

I tested quickly and I encountered a problem though: one of the thing (ie. hack) I implemented to have a clean take-off is to fake the yaw rate control: when sending a yaw rate, the Crazyflie generates a and moves an absolute yaw setpoint. You should be able to remove this behavior by removing this piece of code: ... .c#L41-L51. Then the Ki discussion from above should apply :).

If disabling the YAW absolute setpoint generation and tweaking the YAW integral capping helps for your work and you want to use stock firmware, feel free to add a parameter for it and do a pull request, that way you can continue to use the master firmware in the future and use parameters to setup your Crazyflie upon connection ;-).

Re: Yaw orientation lock on crazyflie 2.0

Posted: Sun May 27, 2018 2:50 am
by jparker310
Hello again,

I apologize for not following up sooner, but have greatly appreciated your assistance.

When removing the piece of code you pointed out and setting the pid_attitude.yaw_ki and pid_rate.yaw_ki parameters to 0.0 from the client, the Crazyflie did not exhibit the expected result and still tried to maintain its original yaw orientation lock. I did not previously mention that I also have the z-ranger attached, but tired removing it and still had no luck (would having the z-ranger attached even make a difference anyways?). Is there something that I may be missing or any other hacks/parameters I could try to adjust to remove the yaw orientation lock?


Jacob Parker