hi Arducopter fans there,
i will try to give some suggestions regarding arducopter v2.6 before its release. Since there has been some time without any improvement about AHRs algorithms over recent arducopter versions. I think, the best place to begin is DCM algoritm itself.
My suggestion is to combine DCM and quaternion methods with their most superior parts. I know there has been a marg quaternion algorithm, but it is unnecessarily complicated. We know that DCM is easy to understand and has a better implemention for drift correcting algorithms and magnetic offset calculations. But DCM algorithm needs to orthogonalize and normalize rows or colums of the direction cosine matrix, also it is slightly inefficient due to 9 elements of the matrix is to be updated. As for quaternion method, only one vector of element size 4 needs to be updated and normalized. Actually, it is possible to integrate quaternions while preserving their unity. There is an algorithm for it. A DCM matrix, which can be calculated from updated quaternion will have aldready orthonomalized rows and columns. So i think it will be much more efficient and logical to do attitude update using quaternions with unity preserving integration and then calculate DCM representation from the updated quaternions and use it when necessary .
I have already implemented my DCM-quaternion hybrid suggestion. It can be easly integrated to the arducopter v2.5.5 code just using new versions of AP_AHRS_DCM library which i put in the attachments. I hope we will have more stable loiter and waypoint navigation in the future.
Really appreciate this work Ozan, I'm a novice regarding code changes and coding, however I am prepared to try out all sorts of wild and crazy codes on my quad, as long as its a simple matter of just uploading (I'm ok with arduino) and flying. I have 2 unbreakable quads for testing APM1 and 2, always start testing indoors for safety of course.
Would there be any chance of zipping up your mods, I'd be happy to give my opinions, for what they are worth. Or am i correct in thinking I can just copy the attachments above into my 2.6gamma build and try that?
it very easy, you just need to copy .h and .cpp files (in my attachment) in your library/AP_AHRS then you are ready to go! You may want to save default files before that. Then compile and upload .
Thanks Ozin, i thought that may be the case. Is it ok to do this with 2.6 gamma too?
Yes,it is ok.
Ozan, I had a go at your code and it works pretty well. Unfortunately where I am now is very windy all the day, so it is difficoult to have a real comparison.
But I had more or less 6 batteries and had no issues at all.
What do you thing about gains in the DCM? Do you think they need to be updated, or should we just stick with defaults?
I'm talking about the KP_roll_pitch and KP_yaw.
i had a real comparison today. I tried simple, altitude hold and loiter modes. As far as i could observed, DCM-Quaternion hybrid code performed better. Especially control of the quad was more stable and fast. I recommend to fly aggresively and stop suddenly in simple mode. I started to tune my quad parameters today, so need some time to make them perfect. Maybe i can also upload a video later. I will push my branch today to google git.
As for the gains in imu, we do not need to stick with defaults but for now they are well enough. Soon i will add other improvements about imu including gains. Keep update.
I pushed my branch about DCM-Quaternion hybrid implementation to arducopter git repository