'm having some trouble adapting the new IMU v3 to Jean-Louis' code written for tricopters. His code used the APM_Compass library and for some reason, it wont compile with any reference to that library. The new IMU doesnt use that library, so I havent let that stop me from trying. It compiles and gives me output, but something is still wrong. The debug wont print GPS and the attitude values although stable seem way off. I'm hoping some experts can look at my code and tell me what's wrong or even what is right.
I've included the code I have now. Please help if you can.ardimupter-120708b.zip
I dont know what to try now. It seems like the PID is what needs tweaking. I give it throttle and it gets wobbly like the throttle changes are too slow or too big, not sure which or how to proceed.
I wont say it's right yet, but I found a big problem with the gyro gains used by the DCM. They were the gains for the IMU V2 hardware, so I set them for the V3 hardware. The difference in gains was huge. The jello dance on the yaw servo went away and holding it by hand isnt the fight that it was. I'm charging the battery and will test it again. I'm optimistic that it will get off the ground.
I couldnt get it off the ground. The first move it wanted to make was right roll. I'm going to calibrate each ESC and see if that helps. At high throttle it feels stable, but I dont have the guts to just throttle through.
Youre right Jeff, it's the physical orientation of the IMU relative to the airframe. I'm trying to get it close now. It was about 5 degrees off in roll and that's what I was seeing. The wires and solder nubs on the bottom threw it off. It wasnt lying, the IMU was tilted.
This is where Greg Fletcher's code is needed. I just cant mount it exactly 0,0 but his code has "level" which assumes where you set that is 0,0 . I tested it tonight and it corrects for a slightly sloppy mount. I also tested the tricopter and almost got it in the air with the sloppy mount job corrected with modeling clay. I had to give it full down and full left roll and full right rudder. It almost made it.
I just have to fit the "level" stuff in and it might work or figure out how to give it a correction factor for the mounting. It's very consistent in how the tricopter code sets up the IMU, just that it's consistently tilted and wants to correct it by flying in a bank.
Could it be that the code is assuming that one of the forward motors is spinning in the opposite direction (I.e. compensation in the code that corrects for the inevitable torque rotation of an uneven number of rotors)? In a quad the pairs work against each other to cancel out the torque...
That may explain the odd behavior of the tail servo as well.
I realized I had a few more mistakes in the code. The V3 IMU code does have a leveling part in the ground_start(). I neglected to get that right. It was stable, but now when I start it up it assumes the whatever little amount it's out of level and "offsets" it. I'll try it again tomorrow and see if it wants to fly level.
The gyro_gain_s were too high before and that's what was causing the yaw servo to wiggle all over. I dont have counter rotating props on the front which might be a factor but all the other wrongness had to be eliminated too.
The output of euler's shows the board is considered level to within a couple hundreths which is way better than a few degrees. I got my fingers crossed again.
Still no luck. It was better in that it didnt want to roll immediately, but it still isnt ready to fly. It wants to spin and that could be the props all spinning the same direction. I'm tempted to rip it apart and put the KK back to see if the props give that board the same problem. Youre probably right, Jeff.
Yeah, there is no way it would fly that way but I had to see that the hard way I have to get a good source of props in the right size and counter rotating. I'd say the good news is that it will hold level if I let it spin like a top. It was about 6 inches up and spinning and I could see it making small corrections in pitch and roll. I'll get it right eventually.