Notch filter is not a notch filter?

I have created a pull request for master

It seems to work pretty well. I can see the clearly defined notch in the logs and am able to set the notch frequency above 200Hz. Not had enough time or good weather to really bash on it, but was able to hover my miniquad inside, so the control can’t be too messed up :slightly_smiling_face:


I’ve now had a chance to bash on this and the results are pretty encouraging - everything works well and I’m getting crisper control from the copter as I can push P higher. A few things to note:

  • With the gyro filters set high (so I have ATC_RAT_PIT_FILT=100 and INS_GYRO_FILTER=90) it’s pretty easy to let a lot of noise into D and if D is set too high the motors can get really hot. I wasn’t really monitoring this before, but once wise to it I reduced D and everything was fine. I am running the main loop at 800Hz.
  • With D lower and the notch enabled I was able to push P pretty high ATC_RAT_PIT_P=0.200 where the autotune value was 0.083
  • The notch performance is pretty obvious with my fix (because you can see the post-filter values). Interestingly I was able to make the notch pretty wide (80Hz) and deep (30dB) with no negative impact on performance and noticeable reduction in gyro noise. I have the notch centered on 215Hz which is the resonant frequency of the props. (see the log here)
  • With a pretty decent tune I then tried an experimental patch which replaces the gyro low-pass bi-quad filter with a single pass filter (the equivalent of PT1 in betaflight). The noise then if anything got better and the copter was more stable. I’m pretty encouraged by this and may experiment a bit more with different filters. For instance the D term filter (ATC_RAT_PIT_P) looks like a single pass filter as well, whereas the betaflight crew seem to think this can benefit from more aggressive two-pass filtering. See the log here
  • In retrospect it is obvious why people think they can see the effect of the notch filter in the raw gyro values - it is because they can! The notch prevents noise getting into the motors which is the source of gyro noise in the first place, so enable the notch and the raw values get better - including accel. Obvious when you think about it, but a head scratcher initially.

If anyone is interested here are the two builds I used. FMUv4 only - so Pixracer or equivalent, use at your own risk! Based on 3.6.9rc2:


Great work! I’m not set up for compiling, but if you want to make a copy for the omnibus nano, I’d run it to test it. (I’m not expecting you to or anything, though).

When you say you decreased D, what is yours set to now?

I can’t wait until this is in Master so I can try it :).

Thanks!!! I was really waiting for this to happen and I cannot resist to test on the sub 190g . Please keep on with this USEFULL works, I believe ,as you, we could be inspired by betaflight improving the small copter segment here

I’ve built the two versions for the OmnibusNanov6. This is against 3.6.9rc2. No testing at all so if you do try please be really careful!

On D I was up to 0.002, but dropped that to 0.001 when I discovered the heat problem - probably orthogonal to the notch, but interesting that there was no visible sign of issues, the copter flew really well, it’s just the motor’s were roasting. At 0.001 the motors were cool again. I had to drop it more when I started trying GF4053x3’s (0.0004)

Thanks a lot! But, I’m running master and have a few things configured that are not in 3.6…
I can still test it, but it will be a few days, since it won’t just be a quick install… Maybe Wednesday I’ll have time to get things working in 3.6.

My master branch is messed up. If I get some time to fix it I’ll do a build for you.

I posted builds from master from my mac. Never flown with anything built with this machine, so caveat emptor

1 Like

Tested today on multiple flights, it works like a charm!

The post filter logging is wonderful! (I’ve set INS_LOG_BAT_OPT to 2 to enable it)

Looking forward to put more than one notch on my single IMU…

  • With D lower and the notch enabled I was able to push P pretty high ATC_RAT_PIT_P=0.200 where the autotune value was 0.083

Was the autotune run before or after the filter was applied. I’d be interested to know if autotune might get a more aggressive tune (or autotune_aggr set higher) with a filter applied.

Also, what’s the size of your copter?

Also again, do you know what the effect of the filter might be on accelerometer clipping? If the accelerometer is saturating its readings are essentially junk, but if they’re being attenuated by a filter, would that improve handling of clipped readings? Maybe that’s a better question for Leonard.

Autotune was before applying the filter


No idea on the clipping :slight_smile:

Can the notch be applied also on accelerometer?
Is it a good idea?

By the way with the notch I’ve been able to raise the low pass filter to 100hz, it flies very well now

I don’t think you are really using the accelerometer for control much (at all in ACRO or much in STAB) and the EKF doesn’t filter the gyros or accelerometer at all because it uses delta angles and delta velocity. So I don’t think it will have any affect on anything you care about.

Notch on the D-term is a different matter :slightly_smiling_face: I am working on that…

I think it has impact on ALT_HOLD and LOITER, but please let me know if I’m wrong!

Sure, but this is about improving latency and response which are hardly concerns in ALT_HOLD and LOITER

Actually I’m using GUIDED and I’m trying to have fast response and control :slight_smile:

Today I was able to test the increase in the notch filtering a lot, also opening up bandwidth, and I have almost cancelled the first resonance frequency and the cluster around, is almost flat now, all thanks to your post filtering option.

In the last test I’ve disabled the low pass filter setting it to 0. Not only I was able to fly very well, but also I didn’t notice almost any change in the log, even if here is clearly logged with the LPF…

So I think I’ve found a possible bug in the notch filtering skipping low pass filter, commented on you pull.


After the above test with @guglie, I’ve made an AUTOTUNE roll finally with a working notch filter: a perfectly done center frequency andyp1per’s notch filter at 120 dB and 240 bandwith! and gyro FILT at 110, in 2 different way: mainloop at 800 and after mainloop at 1600.

The autotune procedure at mainloop 1600 was incredibly SHARPER, more PRECISE, even though the performed velocity was higher, and I guess at 2400 will be even better!

Thanks again @andyp1per, today a lot of evidence emerge from the flying in front of our eyes :slight_smile:

What FC do you have? I thought i read that anything over about 1000Hz in the main loop leads to instability.

Its a Pixracer, ESC Dshot 600,1404 motors and 5" for 190g total weight.

I thought i read that anything over about 1000Hz in the main loop leads to instability.

Fortunatly not true! Its only that the telemetry and probably logs don’t works above 1000Hz, master @tridge is working on this and there is a branch where telemetry works already.
Also in the Ardupilot 2019-2020 Roadmap here

We could see " 4kHz+ loop rate PIDs"

P.S.: I’ve fly 2 complete battery few hours ago with mainloop set at 1600, and was top of the top performance to date, no joke. I 'm really temped to try tomorrow at 2400 :slight_smile:

1 Like

We’re going to have some very well performing copters soon! I already think mine is flying better than my betaflight copter now… (Probably just because I’m more used to it now, flying it every day).
I need GPS coordinates and the flight path in my ground station, otherwise I’d try higher loop rates.

This notch build is working for me, too, but I haven’t done a lot of testing yet…