Developer

RESOLVED: ArduCopter 2.5.3 Yaw Issues

3689449977?profile=original

I just finished a long debugging session with Andrew Tridgell and he has discovered the cause of my yaw (and attitude) issues. In case you don't know Andrew Tridgell, he is the genius developer who made the the latest release fly so well with his DCM improvements.

I think the majority of people out there are experiencing this issue can fix the problem very easily.

"So, what is it?!?!"

It turns out that the automatic compass calibration code on the APM does not work so well. I suspect it is working even more poorly under 2.5 because of the improvements to the DCM, but that correlation has not been confirmed. Like most of the users out there, I have never given more than a moments thought to compass offsets because they have been set automatically for as long as I have been a user, but it turns out they have an enormous impact on the performance of one's copter.

First, what are compass offsets? The offsets are three values that account for the difference in the magnetic field of the earth and the magnetic field that your copter experiences due to interference created by the ESCs, motors, etc. So, the magnetic interference can't possible effect heading that much, right? Wrong. If you don't believe me take a look at this graph:

3689449977?profile=original

You can see that towards the beginning of the flight when I am not doing much, the red and green lines are not that far off. As the flight continues and I start using more throttle, they are way off. At about 5:20:20 my heading is off by about 250 degrees. That is massive!!!! So why does it change throughout the flight? The more throttle that is applied the more current is flowing through one's electronics which increases the magnetic interference. Normally this field offset is accounted for, but recently I suspect that some users have bad offsets like I did. My offsets were essentially 1,1,1 when they should have been -180,3,52. Check out the next graph which shows the effect throttle has on the magnetic field:

3689450007?profile=originalThis is a log from another user, Marco Robustini. The green line shows the throttle and the red line shows the magnetic field. You can see that as the throttle increases, the magnetic field more than doubles.

So how do you fix it? There is a new feature in the latest Mission Planner that allows you to use a telemetry log to determine the offsets OR you can calibrate your compass in real time by holding and spinning your copter 360 degrees. It is highly recommended that you use the telemetry log method. The reason is that when you are holding your copter and spinning it, you are not accounting for the amount of mag interference from the motors (because they are hopefully not running :-D ). Follow these steps:

With Telemetry Log (recommended)

1. Connect to your copter via telemetry.

2. Take off and fly around for a few minutes like you would normally fly. At this point we are collecting data about the magnetic fields during flight.

3. Land and disarm.

4. Download the tlog from that flight. (Instructions here: http://code.google.com/p/arducopter/wiki/AC2_Logs)

5. Connect to your board

3689450031?profile=original

6. Goto the Configuration tab

3689449991?profile=original

7. Click on the Setup tab

8. Click on the Hardware tab in the popup

3689449825?profile=original

9. Click the "Calibrate" button

10. Click "No" when asked if you want to use live data.

3689450040?profile=original

11. Browse to the fresh tlog

12. Your offsets are now saved

Without Telemetry Log

1. Follow the above steps 1 through 9

2. Click "Yes" when asked to use Live Data

3. Rotate the copter 360 degrees

The calibration utility is leagues ahead of the automatic calibration on the board that most of us are relying on. Many thanks to Andrew Tridgell, Michael Oborne, and all the devs who had a hand in the compass calibration utility in the planner. There is some serious brain power behind these features we take for granted.

Andrew Tridgell is working on improving the automatic calibration routines that reside on the board based on the updated (and original) algorithms by Bill Premerlani, but for now the Mission Planner calibration is everyone's best bet for improved flight performance.

If you have any questions just leave a comment.

Thanks,
Adam

E-mail me when people leave their comments –

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

Join diydrones

Comments

  • Hi Paul,

    I'm also having some similar problem on my Y6, yesterday I tried it with quite a bit of wind, and I had to keep pushing the Y6 forward, as the rear arm tended to fall.

    Yaw  eeps moving all the time -+ 10º/15º. I'll try to apply afernan's magnetic solution.

    As for the rear arm falling back, I've had a quick look at the code in motors_Y6, and it seems to me that both rear arm motors are given less power.   For left and right motors we get  + (g.rc_2.pwm_out * 2 / 3), but for the rear motors we get   - (g.rc_2.pwm_out * 4 / 3).  Can someone show some light on this??

  • Adam, Tridge

     check out: http://diydrones.com/forum/topics/compass-and-yaw-relationship-logs  for my logs

    Thanks!

  • Developer

    Jonathan,

    I'd be interested in seeing the tlog too, plus the tlog for the flight where you thought it made things worse. It may be that we need to improve the offline calibration algorithm. In particular it currently doesn't try to only use mag vectors from times when the copter is in the air, so if the log contains a lot of time when the copter was on the ground it could produce bad offsets. I've asked MichaelO if he could add an option to the offline calibration to ask it to only use mag vectors from when the throttle is over a specific level.

    Cheers, Tridge

  • Adam, I will post that along with a couple of logs showing the mag vs. yaw differences.  Generally, my yaw tracks the mag pretty well, but I check some mag oscillations at times.  The offset generated by the tlog created drastic difference between the yaw and mag.  It's most likely the tlog, but I will post later for you to digest :)

  • Developer

    @Jonathan M: Good to know. The majority of users I have been in contact with have reported good results from the tlog method. I would be interested to see your tlog.

  • I tried the tlog method yesterday, and it drastically worsened my yaw situation.  I could barely control yaw, and the heading drifted quite a bit.  I am not sure if my tlog file was "bad", but I tried to pick a representative flight.  When I do the live cal, it's much more responsive.  I still have some yaw drift issues (hence trying this method) though.

    I will post logs later when I am home.  Just thought I would post my experience.

  • Developer

    @Paul Emous: The compass offsets probably aren't your problem. You may want to look into tuning your yaw pid settings. Could you be more specific about this: "When I increase the throttle the back arm of the "Y" stays behind as the front arms want to go up." ?

    What would be even more helpful is if you posted a video of the issue and a screenshot of your current PID settings.

  •  I had strong mag interference that I´ve solved using power twisted lines. See here more details.

    Angel

  • You need telemetry log - did you have telemetry connected while flying? Is sensor reading enabled in planner?

  • Ok I am going somewhere. Finally I managed to get the copter from the ground as I did the manual calibration again. Its still very aggressive but it feels more stable.

    Now when I try to get the log for calibration it says that there is not enough data? I flew (tried to fly) for over 5 minutes?

This reply was deleted.