Multicopter can't fly straight after a launch. Position slides sideways

Hello,

What could cause following behavior. This behavior is repeatable on with different vehicles and locations.

LOG: https://drive.google.com/file/d/1ZKGzMJzU781zQhipO3jjwjnPJpqHCWR6/view

I waited for a dgps status before I manually liftoff the multicopter in Loiter mode. After that I raised height to about 5 to 10 meters. I checked that YAW heading is pointing outwards from me and then I tried to fly straight forward outwards from me. Multicopter’s position starts to wander/slide to right compared to the course it should have while going forward. Then I will release PITCH control which starts the braking maneuver. While the drone is braking its doing something that looks like a toilet bowl effect.


The green line on the image shows which direction I have pointed the heading and where it should have flied if it would flown straight.

After flying/maneuvering for two to three times to some directions (e.g. backwards, forwards) the drone starts to go straight and starts to stop in a straight path. I have checked that behavior with Compass EKF learning ON and OFF.

NKF1.YAW and ATT.YAW show that it was at least thinking it has a solid YAW direction. The autopilot has chosen declination that is checked to be correct. EKF seems to be quite happy with all estimations.

Is this non precise flying related to EKF converging for better estimation at the beginning of the flight?

This behavior prevents to have precise control from beginning of the flight. I believe that this could also cause a bit incorrect flight path in a automated mission, where drone will launch and tries to head to the closest waypoint.

I did not look at the log. But this is very typical behavior if something regarding the compass is not right.
There is a small deviation between what arducopter thinks is north and what is north, both relative to the vehicle.

First get the calibrations right, make sure the values from the compas-cal are low enough on all compasses or turn off the internal compass(es) (that’s what i almost always do in larger mutlirotors).
Do a Compas/motor-cal! The most important part is not the calibration itself (imo) but to know that the value is not to high, aim for the 30% @75% throttle and move the external one around until you get it that low. (And redo the first calibration.)

Not the locations of the waypoints. It will do a S line towards the waypoint and if the deviation gets any bigger a stop in the beginning of the flight could could start it toilet-bowling.

1 Like

I have checked log’s if the motors/current could affect the compass. I found out that magnetometer shows barely any difference when using maximum power for lifting high weight payload while going max speed upwards.

The drone is rather big, so I wont do a compass/mot-cal as it would need to have load on the motors (propellers). I cannot attach it to ground safely enough.

I have done the compass calibration in “very strict” multiple times, without any ferromagnetic items close by. I also have checked the heading to be correct by visually checking heading and then checking if the autopilot agrees. Typically it is within 2 degrees. The declination is “precisely” correct. Autopilot has 0,172 declination and the local declination is 0,171 (in radians)

In my opinion this is not directly related to compass or compass calibration. I believe that this is some how related to EKF as it is the only thing that can “learn” the offset/error out. It doesen’t matter if compass learning is off or on. It will behave the same way. I have used some hundred hours to “debug” the compass and I cannot find any issue with it anymore.

Is it possible that the EKF has incorrect gyroscope/accelerometer bias estimation that causes it to be very slightly off of level.

To do CompassMot you turn the props over and shift them around. The net effect is the props are pushing DOWN and not UP…

I looked at your log, and the only thing I noted is you started in Loiter and there was a “mission” message, so I’m curious as to how this “mission” was setup and flown…

And make sure the external magnetometer is mounted perfectly straight ahead, not some degrees to a side…
I did not check the logs, but as others pointed out, what you described is an perfect example of bad heading data based on magnetometer.

I’ve done this many times with a large drone (12kg max). And i would find a way to do it with any drone, Magnetometer placement is to important to me.

I do the props on in reverse, CW instead of CCW and upside down, this way the drone will push itself down. With a strong and stable landing gear nothing else is needed. (except some space)

I don’t think it’s related to calibration but to interference. I would do a calibration to clearly see it.

If your looking at a heading in degrees you’re not looking at the measurement from the compass. That’s the output of the EKF.
If you see 3 seperate milligaus values, that’s what comes out of the compass sensor. The ekf makes sense of these values and combines it with all other data and gives a ahrs (attitude &heading reference system) .
That’s why it can be good on the ground, then semi-bad right after takeoff and good again after a while. It does not just use compass to get a heading estimation.

What compass_learn does on “2” vs “1” is not 100% clear to me either.
Here (look for compass) is a hint for “1” but the documentation is not to clear.
Here (look for compass_learn) it states it has to do with saving it, not with turning the feature on/off…

Thank you for your time.

It’s mounted perfectly straight forward, not tilted or anything else. It’s mounting error is within a one degree.

I will have to give that a try.

I will do that motor calibration later to be sure it’s not interference. But by looking several logs, I’m not able to see any severe interference on the magnetometer. I don’t see that motor outputs (current) would affect magnetometer. I’m only seeing differences on lifting up out off ground and doing normal maneuvers. The wiring is designed, so that it has minimal magnetic field and is not routed next to important sensors. The high current wires are twisted.


On this image I have plotted the primary magnetometers X,Y,Z axes and RMS of total magnetic fields and throttle output.

There seems to be no severe changes on the magnetometer data. In my opinion this looks normal data. Magnetometer values changes slowly when lifting off the ground, which is normal. Throttle output doesn’t seems to affect the “total” RMS value.

You are correct that it does state its only affecting if its saved or not. That compass_learn “2” is more preferred learning method, if EKF has normally good quality estimations. The “1” setting “internal-learning” is not clear to me either.

I had a quick look at the logs.

In general the slight turn indicates that the actual heading is not what the compass is indicating. Because it seems the problem goes away after a few maneuvers, this indicates that the EKF is able to use the GPS movement to get the heading to the correct value.

So as for the cause of the problem… there doesn’t seem to be much interference from the motors on the compass. This is clear from looking at the length of the vector (sqrt(sq(MAG.x)+sq(MAG.y)+sq(Mag.Z)) vs the throttle (CTUN.ThO) and the length of the vector doesn’t change hardly at all during the flight. In general it doesn’t look like interference. This means that compassmot won’t help.

If we graph the compass heading there are quite a few times where it is very far from the EKF estimate although I suspect the mission planner is not correct adjusting the heading based on the vehicle’s attitude.

I can imagine a few possible causes:

  • the automatically looked-up declination (COMPASS_DEC = 0.172rad = about 10 deg) is not correct. Manually updating the declination could fix this although I don’t know of any cases in the past where this has helped.
  • the compass on the vehicle is not perfectly pointing forward
  • some kind of issue with the EKF. only @priseborough could perhaps give some advice

Thanks for the comprehensive reply @rmackay9.

Automatically looked-up declination is almost as correct as it can be as the local declination is 9°55’ = 0.173rad. Local declination is checked from http://www.magnetic-declination.com/.
I probably should fly somewhere else to see if the behavior changes. This could rule out the possibility of some local magnetic phenomena or difference from the declination.

I have already manually tried to adjust the compass module “heading” to see if this is the case. I went trough +/- 5° with about 0.5° steps and re-calibrated compass and it didn’t get any better from the default 0° position. The behavior either stayed the same (no significant improvement) or got worse. These results were only evaluated visually. I believe that I could not see any significant improvement from the logs either.

Hi,
Do you see a crabbing effect in Auto missions or Loiter ?
i.e.
when the drone path is straight to the target ,and in the MP the heading is right to the target, The actual heading ( what you see when you look at the drone ) , has offset to the side , such the drone heading will be offside to the direction of flight ?

Hi, @VDLJu @priseborough @rmackay9 Have you solved this problem, as I have faced the similar problem. I am very appreciate that you can give me some ideas to solved this problem.

This is my log here log file.

Now when I switch to the loiter mode, it can not go straight。

and i found that the magnetic length is

I have not resolved the issue, but I have a feeling that this could be caused by IMU yaw offset. I haven’t found any code regarding IMU yaw rotation calibration. Only Pitch and Roll is “trimmed”.

@priseborough @rmackay9, how does ardupilot solve the IMU yaw (rotational) offset?.

I have created other post which is related to this issue. IMU yaw orientation aligment?

@ VDLJu
If it is possible, could you please add my wechat huangwenfuture or my e-mail huangwenfuture@sina.com and share the log to me, maybe i can give some help. I have solved this issue Copter can not go straight in Loiter mode . (I can not get the google web as in China)

Hello @huangwen0907,

I haven’t had any issues with compass due motor/current interference. I have done multiple tests with maximum loads and still the external compass doesn’t show any interference. The cabling is made with minimizing compass issues in mind and the external compass is quite far away from interferers.

I strongly believe that this issue is due some other than compass. I haven’t found any reason why it couldn’t be that IMU YAW (rotational) offset from the drone body heading. Also, this issue goes away after flying a while. I believe that EKF compensates this error.

Could some one look in to this log, if they see something that could be the cause.
Google Drive link to log

I have had randomly the same issue (copter not going straight) and recover after few minutes. Maybe some devs can come in and take a look at why it does it.

It is very easy to find out if it is compass related.
Fly in alt-hold mode. If it flies straight in alt hold then it is definitely a compass problem.

Ok, will try that, thanks for the hint.

Corrado

@Eosbandi @anon67614380
For me this only happens when using GPS assisted mode (Loiter mode). So it is most likely a compass related issue?

I haven’t solved the issue yet.
Things tried so far that didn’t help:

  • Recalibrating compasses numerous times with no visible interferers close by.
  • Changed to a new GPS/Compass unit (Here2).

Things that have had effect on some degree:

  • Manually adjusting the compass yaw axis by rotating it relative to frame. This minimizes the original issue after the take-off for a short time, but after that the drone is very susceptible to toilet-bowling while doing quick 180+ degree rotations (+90deg/s).

Hi.
I have this same problem on all our Drones that we manufacture.

Drone moves off straight line and leans to left.

After a bit of flying around it corrects itself, but on restart it is back to same problem immediately after take off with first forward flight.
Can you help?

Although data above showed that magnetometer is giving pretty much correct values, the problem was solved with improving the compass calibration procedure to have more consistent measurements and better elliptical calibration. The error on compass calibration values doesn’t need to be much off to have this issue.