Hi all, this is my first post here but I've been lurking, reading and studying for a while.
I'm involved in a project entailing the development of a UAV (pretty much from the ground up), I've got the Adafruit 10-DOF of freedom IMU with the axes directions as indicated in the pic here:
Now, I've had test flights which have been successful - I'm developing all this stuff on an STM32F415RG which is a great platform. All the stuff is mounted in an AXN-Floater:
Everything has been (somewhat) smooth sailing, except the AHRS has been really tough. The approach I'm using is with a Complementary Filter (I have to do most everything from first principles and the complementary is do-able, I would've considered Kalman but that ups my complexity too much and would mean not reaching my deadline). So the complementary filter works okay, the plane can fly itself straight and level with autopilot (quite well actually) and handles the wind well too.
For centripetal compensation, I am calculating the acceleration: a = velocity x angular rates (cross-product).
The problem I'm having is with the AHRS in turns, I know this is a common problem - and I have since read up on the problem and formulated somewhat of a solution to compensate for both the IMU offset (it's located away from the CG, that was easy enough) and the centripetal force compensation works kind of... Previously the attitude indication would go absolutely nuts when in a relatively high-g turn (like displaying crazy pitch and roll values) which has since been fixed somewhat by the centripetal compensation that I have implemented now using GPS speed. My problem is that despite it improving the results quite a lot in level flight, it still struggles in turns which I have a feeling may be due to:
- GPS speed not being totally accurate (I am in the process of implementing the pitot tube as we speak)
- I have some kind of sign error in my compensation, perhaps due to the fact that my IMU is not following convention.
When I spin around in a rotating chair with the aircraft and watch the AHRS on my rudimentary GCS software, roll angle is perfectly calculated despite the centripetal forces - but when I pitch the aircraft nose up or nose down the attitude indication is not accurate ( it rolls over and the pitch indicated is completely wrong). In any case, here is my code (pastebin for formatting sake):
The IMUStruct contains the IMU information from gyro and accelerometer. Longitudinal speed is the reported GPS speed in m/s.
If anyone has any experience or has done this before, please I would really appreciate your input. Thanks in advance!