The story.

I always had yaw not being stable, not even in hover. It was bouncing left and right even with no input.

Also different YAW_OPTIONS in APM_config.h yeld to bad results. It was either too strong, or too slow. It always had really big overshooting like if PID was tto high. I decreased P till I almost had no control, but the left-right problem was still there.

Something I've noticed is that in the Planner, MAg was not steady as it was in previous NG code. It looked like it was giving +/- 1 degree in an interval similar to what I was experiencing in flight. It is not much, that's why I've never gave too much importance, bu apparently this was enough to yaw my copter.


The solution. 

So finally looking into the code I have noticed the _kp_yaw(0.8) in the DCM constructor. 

Since this is used to correct drift of Gyro Z:

_omega_P += _error_yaw * _kp_yaw; // Adding yaw correction to proportional correction vector.

, I thought it could be a problem of a too high drift correction, resulting in a bouncing of the value due to the normal mag noise.

So I lowered to _kp_yaw to 0.35 ( I tried also 0.1 but in the planner I saw really slow compass movement when stabilizing after quick movement) lowered my P yaw to 0.3 and set my YAW_OPTION to 0 in APM_config.


Flying like that was like Night and Day difference! I still see a little (very little) yaw corrections, but now yaw is very nice! It is responsive, precise and stops when I let the sticks. Just like old days! :)


Beware, this was good for my setup, but could be a good start point for everybody having this kind of issue.


Now the question.

Since I understand this issue could affect non "standard" frames/motors (even though I think also standard frames could be affected) could it be possible to make this a runtime variable adjustable via mission planner?


My setup:

Arducopter frame (using only center frame parts), ALU arms with a motor to motor length of 50cm.

Motors: KDA 20-22L. Props EPP 10x4.5 (soft) 


Hope this could help somebody else.



Views: 193

Reply to This

Replies to This Discussion

Hi Emile,

I just tried yesterday the 2.0.25, and same as you, after trying different yaw options, I ended up using option 2, using option 0 kept my Octo turning CW, with option 1 it was too strong. I'll give it a go!
Nice detective work.
Check out AC 2.0.25, which has a much improved yaw function. It may be that the official code is now closer to what you came up with.
That was the code I have tested. I'm trying to be as up to date as possible checking every single line of code change... :) My wife is getting worried as I'm getting a little obsessed about quad flying... :D
Anyway what I have changed is rooted in the DCM algorithm. It's about drift correction being too strong for my setup. This is probably not affecting people with standard ACM frame/motors but it was leading to a series of problems probably not related to the yaw code itself. Infact now everything is just perfect.

Hi Emile,


I'm having similar problems and I have also seen the noise in my compass +-1 º. I have a frame similar to yours, 50cm with KDA20-22L. Can you share your PIDs or at least the relevant changes from default values?


I'll give your solution a try and report here.



I'm using the MK50 frame with the KDA 20-22L.

Pids are 0.2/0.025/0.09


what are yours

At the moment this is what has worked for me but I had not much time to test so it is just a starting point :


_kp_yaw to 0.35 (defined in libraries/ap_dcm/ap_dcm.h (beware you have to change it in you arduino/libraries also.)


P 0.25

I: 0.01

D 0.09


Roll pitch PIDs are the ones I had better result with without loosing too much authority:

P 0.38

I 0.025

D 0.17


I could rise D to 0.18 but it gets a little too slow to react to commands.

If you want to get the best result and have a knob on Channel 6 you can set the #define CHANNEL_6_TUNING to CH6_DCM_Y to test the _kp_yaw. be sure to test the values in CLI->test>tune

I have used to test low, mid and high values since I only have a three pos switch on my 6th channel and i helped me to understand that I didn't want to go higher than the default 0.8


Last thing I only tested YAW_OPTION 0 in APM_config so I don't really know what are the results with other options.




Hi Emile,
Using your PIDS and modifing _kp_yaw in ap_dcm.h the yaw is stable when no sticks input. Thanks!
Next problem is different behaviour when I move the yaw stick to the left or to the right.
When I move the yaw stick to the left the quad rotates ok and when I release the stick the movement stops normally. BUT when I move the yaw stick to the right the quad is more lazy and it takes some time to complete the movement and when I release the stick the quad yaws back to left during 1 second....¿?¿?
I have been able to mitigate this behaviour increasing YAW_P but I found it really strange.
Which Yaw option are you using? In apm_config.h I used Yaw_option = 0
I also have noticed that right is slower than left, but before changing the values and the option.
I'm trying with Yaw_option = 0.
I also tried Yaw_option = 1 but it was unflyable.

At the moment, Yaw_option = 0, _kp_yaw = 0.35 and YAW_P in range between 0.25 and 0.45 and the strange behaviour continues.... yaw to the right is very lazy...

Please post your PIDS if you improve the behaviour in the future!
I will continue playing with the knob!


Reply to Discussion



Season Two of the Trust Time Trial (T3) Contest 
A list of all T3 contests is here. The current round, the Vertical Horizontal one, is here

© 2020   Created by Chris Anderson.   Powered by

Badges  |  Report an Issue  |  Terms of Service