This is issue is resolved. Thankyou, everyone here and elsewhere, for the help! For those that come after…
There were three symptoms that needed explained:
-
the drone launched into the air as soon as throttle was raised above the arming region.
-
the drone suffered from poor control and poor stability once in the air.
-
even in stabilize flight mode, the throttle was extremely touchy. Only the bottom region of it was viable. This wasn’t entirely surprising because the power to weight ratio of this drone is over 4, although it still wasn’t working quite right.
This is what I did to fix it:
Change the notch filter settings:
INS_HNTCH_MODE=3 (was 3, verified it does NOT nullify the other settings)
INS_HNTCH_FREQ=133 (blade passing frequency for 4000 RPM with 2 blades, was 45)
INS_HNTCH_BW=66 (recommended in mission planner to be 50% the base frequency, was 25)
INS_HNTCH_OPTS=19 (double, multisource, and triple notch; was 18, multisource and triple notch)
Note:
INS_HNTCH_HMNCS enabled harmonics 1-3 (not changed)
PID gains:
—implemented—
ATC_ANG_PIT_P=7 (was 14.2514)
ATC_ANG_RLL_P=8 (was 16.2386)
ATC_ANG_YAW_P is unchanged
ATC_RAT_YAW_I,0.05
ATC_RAT_YAW_P,0.5
PSC_ACCZ_I=0.6 (was 0.7)
PSC_ACCZ_P=0.3 (was 0.35)
PSC_VELXY_D=0.25 (was 0.5)
—recommended but not implemented due to being close to existing values—
ATC_RAT_PIT_D=0.006
ATC_RAT_PIT_I=0.12
ATC_RAT_PIT_P=0.12
ATC_RAT_RLL_D,0.006
ATC_RAT_RLL_I,0.12
ATC_RAT_RLL_P,0.12
Logging:
INS_LOG_BAT_OPT=4 (was 3, enables logging of INS data before AND after the filter)
LOG_BITMASK=2238462 (enabled fast harmonic notch logging, disabled optical flow)
Motor thrust:
MOT_THST_HOVER=0.12
MOT_SPIN_MIN=0.1
MOT_SPIN_ARM=0.075
In the ESC configuration software:
Max volts=16.4 (was 25.6)
Report telemetry as speed = enabled (this means that all RPM values are positive regardless of direction)
Note: arming throttle max is 0.075
Why did that work? It’s complicated, since multiple problems were interacting with each other.
Problem #1, fundamentally, was an interaction between MOT_THST_HOVER being too high (thanks VexAzomi on discord) and the motor ESCs being configured to expect a 6 cell battery. MOT_THST_HOVER was set to 0.3, but in reality is 0.2. After arming, the throttle is raised and an ascent is commanded. Two things happen. First, the autopilot commands more thrust than expected in the first few iterations of the feedback loops due to MOT_THST_HOVER being 50% higher than it should be. This would be compensated for, but with other problems present it got out of hand. Secondly, the autopilot communicates to the ESCs (using droneCAN) to give x% of throttle. The ESCs, in voltage control mode, attempt to reach y% of voltage across the coils using y=f(x) internally. Part of y=f(x) is a converting the normalized throttle input to an actual voltage input. Because it was configured to use 25.6V, it was trying to get y% of 25.6V. This meant it there was something like a 1.56 factor more thrust obtained than what was expected by the autopilot, and it would saturate at something like 64% throttle. This, coupled with the MOT_THST_HOVER issue, caused it to absolutely launch into the sky the instant throttle went from ~10% to over 50% as it transitioned from the arming state to trying to hover.
Problem #2 likely rooted in accelerometer noise. Look back at log 6 - the accel data is noisy, even though VIBE is well within the recommended range. I compared that log with logs of another design that flies well and confirmed that the correlation between VIBE and peak to peak IMU.accz noise wasn’t straightforward. This was made a lot worse because the motors that reported a negative RPM in the esc telemetry caused the notch frequencies to be clamped low (visible in the NTF log entries). These frequencies were far below the blade pass frequency of the props at hover, causing the filter to be ineffective. This is very bad - degradation of any of the IMU’s data directly degrades the drone’s stability. Even worse, accel data is required in every flight mode I used. This probably made problem #1 even worse. This was addressed by configuring the ESCs to only output positive numbers (speed vs velocity) and setting INS_HNTCH_MODE parameters. Some work could be done on this, but the settings shown here worked pretty well.
Problem #3 is essentially the same core issues as #1, but manifesting differently. The main issue here was the scaling of the thrust output due to the ESCs being configured to a higher voltage.
Lastly, the PID parameters I changed might not have been necessary. I don’t think they caused any of the problem. However, slowing down the drone’s response (especially PSC) gives the human pilot more time to intervene and will somewhat dampen high frequency feedback from noisy sensors. I think it is a good idea to make these very slow on a new design unless you’re an ace pilot.