Servers by jDrones

Notch filter is not a notch filter?

(Guglie) #17

:slightly_smiling_face: thank you @andyp1per, I was having same issue!

@Leonardthall Were can I move NotchFilter::apply() to test it?

(Leonard Hall) #18

Sorry @guglie, it isn’t that simple. I will chat to Tridge and Randy tomorrow and see what we can do.

1 Like
(Guglie) #19

@Leonardthall Ok, thanks!
Let me know if I can help by the way

1 Like
(Andyp1per) #20

I have put up a potential fix https://github.com/andyp1per/ardupilot/commit/44451f545594ec7044921a3f387242b468acd636

2 Likes
(Andyp1per) #21

I have created a pull request for master https://github.com/ArduPilot/ardupilot/pull/11371

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:

2 Likes
(Andyp1per) #22

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:

2 Likes
(S) #23

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 :).

(Giorgio Rinolfi) #24

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

(Andyp1per) #25

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)

Notch filter not working?
(S) #26

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.

(Andyp1per) #27

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

(Andyp1per) #28

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

1 Like
(Guglie) #29

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…

(Rick) #30
  • 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.

(Andyp1per) #31

Autotune was before applying the filter

QAV180

No idea on the clipping :slight_smile:

(Guglie) #32

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

(Andyp1per) #33

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…

(Guglie) #34

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

(Andyp1per) #35

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

(Guglie) #36

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.

2 Likes