Posted by Heli Hacker |
Aug 01, 2010 @ 11:56 PM | 5,653 Views
Even with gains carefully adjusted, DCM has a drift of several degrees per minute. Without an accelerometer to correct the drift, I need to introduce decay into the update matrix that rotates the DCM matrix. Unfortunately adding pitch and roll decay causes the matrix to have even larger drift around the yaw axis.
The whole purpose in implementing DCM was so that yaw would automatically cause rotation of pitch and roll. But since yaw accuracy goes to pieces, I have decided to use a simpler approach - one similar to the swash servo mixing equations.
' Use Yaw rotation to rotate Pitch and Yaw values
' if roll is clockwise looking down on vehicle:
' newxval = xval(cos(yaw angle)) - yval(sin(yaw angle)
' newyval = xval(sin(yaw angle)) + yval(cos(yaw angle)
'if roll is counter clockwise looking down on vehicle:
' newxval = xval(cos(yaw angle)) + yval(sin(yaw angle)
' newyval = -xval(sin(yaw angle)) + yval(cos(yaw angle)
This allows roll and pitch to be rotated at each 100hz update cycle, without tracking all three axes together.
I almost have this working, just now chasing a bug that appears to be in my sine(angle) routine.
Update: This code was causing problems, so I decided to set it aside for now and work on getting an accelerometer integrated so I can use DCM.