Detecting bad compass offsets before takeoff

Hi:

Normally mission planner will let me know when my compass offsets are high and will deny arming/takeoff. Today, I was able to to takeoff and get a good flight in, but during decent, my craft tilted to one side and crashed somewhat gracefully. After reviewing the logs, I noticed that the X and Y values of my compass were almost touching! Well over 50 flights on this craft, with no problems before this. No GPS glitches or errors in the logs. The auto-analysis, however says the compasses failed.

Is there a way for me to catch bad compass offsets in preflight? The log is too large for me to upload so here is a picture of the compasses.

Any insight would be appreciated!

Can you zoom closer to where it took off?

@Alvin, Sorry for the delay.

There were two takeoff points during the flight. I have commented on the attachments.

image
image
image
image
image
image

This drone had 50ish flights without a compass calibration, but the exact same thing happened the next flight after compass calibration with almost identical logs.

I think something interfered your compass during the flight.
Did you fly near some building? or maybe you activated some equipment on your drone.

You may also check RCOUT to see if any motor had output pattern similar to the compass offset

@Alvin

Still having some issues with this. We have a quad that had a decent amount of very successful flights, and have had some MAG issues here in the last few days. First time the drone acted erratically during flight, it jerked and recovered twice. The second time it lost about 10 ft in altitude, luckily recovered itself. This last time, the drone was flying great, and upon landing, acted erratically and almost flipped.

I do, however have a Gremsy S1V3 with an A6000 on it. Silly question, but how often should I calibrate? At every site? Before every flight? There are no correlations between the thrust and MAGs, so I am confused how to counteract this bad GPS data… Any advice on calibration or how to account for these environmental differences would be so helpful… I have added the last log below, where the drone experienced it on landing.

I feel like I should mention I am running 15.5inch props and 460KV motors. I pull around 51A at a hover. I have never done the motor/compass calibration test due to the shielding method we created a few years ago, but since I see no correlation between the motors and the MAGs would this even help?

2021-06-30 12-42-08.bin (2.0 MB)

I see a few things here to fix :frowning:
The attitude excursion and near-crash is not related to compass offsets

Attitude control
Pitch and roll attitude control could be a fraction better but it’s reasonably good. Yaw is overshooting a bit but that will be a combination of the yaw bias explained below, and the fact that there’s no special tuning done and just about everything is at defaults. The good thing is the quad flies quite OK on defaults.

There’s a physical yaw bias, twisted motor mount or arm, maybe motor 2. Motors 3 and 4 have to work harder to counteract 1 and 2.

This will cause 2 motors/ESCs to run hotter and it will reduce the ability to control pitch/roll attitude.

Almost Crashed
Then just before landing there’s a pitch/roll/yaw event that looks to be caused by Motor 4 desync or temporary loss of power (it’s commanded to maximum) and motor 3 is commanded to minimum to compensate. Soon after things return to relative normality.
The graph gets rather busy so I haven’t shown it here, but if you look closely the pitch/roll/yaw only start to deviate when motor 4 starts losing thrust.

At the same time voltage dips quite a bit and current goes through the roof, so look for an electrical short, failing ESC or similar.

Compasses
Disable the onboard compass, the external one seems to be doing fine with minimal interference.
You only ever need to calibrate the compass once and auto-declination looks after the rest.
Disable the onboard compass, go outside away from everything, wait for a good 3D GPS fix, then run the compass calibration.

Tuning
Connect up to MissionPlanner and press Alt A , select you props and battery sizes, accept everything it offers. This spreadsheet gives a slightly more comprehensive view of the parameters

Ideally you’d next set up the Harmonic Notch Filter, this is easier if you can wire up and set your BLHELI telemetry. There’s several advantages to having the BLHELI telem data.
Then you would run Autotune. You will need a conventional RC transmitter for this.
Let us know if you need help with that.

I would also enable the Fence and any other failsafes available.
FENCE_ACTION,1
FENCE_ALT_MAX,120 <- set for local laws and safety
FENCE_ENABLE,1
FENCE_RADIUS,600 <- set for local laws and safety
FENCE_TYPE,3
This will have the side effect of making you wait for a good 3D fix and Home can be set, if you were using a conventional RC you wouldnt be able to arm and takeoff until then.

EDIT:
Autotune with minimum takeoff weight, remove the gimbal and camera or any other payload. Then adjust these later:
ATC_ACCEL_P_MAX x (min_TOW / max_TOW)
ATC_ACCEL_R_MAX x (min_TOW / max_TOW)
ATC_ACCEL_Y_MAX x (min_TOW / max_TOW)

And here’s the link to the Tuning guide:
https://ardupilot.org/copter/docs/tuning-process-instructions.html

1 Like

And I just realised, It looks like you want to use DHSOT but it’s not set up correctly.
You will need to move the servo connectors from the Main outputs to the Aux outputs and change these params:
SERVO1_FUNCTION,0
SERVO2_FUNCTION,0
SERVO3_FUNCTION,0
SERVO4_FUNCTION,0
SERVO9_FUNCTION,33
SERVO10_FUNCTION,34
SERVO11_FUNCTION,35
SERVO12_FUNCTION,36
Reboot the FC then check that those are still in place correctly

@xfacta

Great response I really do appreciate the detailed writeup.

When running autotune, should the payload be on there. if so, should you autotune with every variation of payload?

Do an autotune with the quad in the lightest configuration. If for example the ATC_ACCEL_P turned out to be 90000 and take off weight was 2kg, you add a 0.75kg payload:
new ATC_ACCEL_P = 90000 x (2 / 2.75)
new ATC_ACCEL_P = 65448
You can even round this value up or down to a convenient figure like 65000 or 66000
Alter it to suit different payloads if they are very different.

Don’t redo the Autotune unless you change something significant about the power system or size of the quad. For example, motors and props are changed.

@xfacta

I took your advice, and tried the autotune out, and it is flying noticeably better, especially along the yaw. The roll and pitch are a little better, but even after some manual adjustments, I cant seem to get them any better. Do you mind taking a look and telling me what you think? Thanks for the help!

https://drive.google.com/file/d/1cInwp266sLBTngdRUZlft9h6SM9wGX4s/view?usp=sharing

that is a tlog, have you got the .bin file?

@xfacta

my appologies

https://drive.google.com/file/d/18oFNLLJoo9jFioGFcyfSfL4bUtDI0-dU/view?usp=sharing