How I solved my Yaw issue.

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.



You need to be a member of diydrones to add comments!

Join diydrones

Email me when people reply –


  • 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.)

    YAW PID:

    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,


    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.



  • 3D Robotics
    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.
  • Nice detective work.
  • 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!
This reply was deleted.


sam liked Jimmy Oliver's profile
Aug 25
Mike Whitney liked Mike Whitney's profile
Jul 19
Abdulatif Tlaib liked Ryan's profile
Jun 24