Skip to content

Add Rate PID target/error filter FFT plots and LOG_BITMASK note#328

Open
amilcarlucas wants to merge 8 commits into
ArduPilot:mainfrom
amilcarlucas:PID_notch
Open

Add Rate PID target/error filter FFT plots and LOG_BITMASK note#328
amilcarlucas wants to merge 8 commits into
ArduPilot:mainfrom
amilcarlucas:PID_notch

Conversation

@amilcarlucas

Copy link
Copy Markdown
Contributor

Add two new frequency-domain graphs that visualise the effect of the ArduPilot rate PID input filters:

  • "Rate PID target filters": overlays the FFT of the unfiltered rate target (RATE.RDes/PDes/YDes) against the filtered target seen by the PID controller (PIDR/PIDP/PIDY.Tar), making the effect of the target filter (ATC_RAT_xxx_FLTT) visible.

  • "Rate PID error filters": overlays the FFT of the raw error (Tar - Act, before the error filter) against the filtered error used by the PID (PIDR/PIDP/PIDY.Err), making the effect of the error filter (ATC_RAT_xxx_FLTE) visible.

Both plots share the existing frequency-axis zoom/pan link and respect the amplitude/frequency scale controls. They are only shown when a Roll, Pitch, or Yaw axis is selected; hidden for PIQR/PIQP/PIQY, PIDS, and PIDA. RATE data is processed at its own sample rate (no interpolation onto PID timestamps).

Also adds a prominent notice at the top of the page reminding users that the PID bit of LOG_BITMASK must be enabled for any PID log messages to be present in the log.

@amilcarlucas

amilcarlucas commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

This is a complement to the only written documentation about the Ardupilot 4.5 PID notch filters

@andyp1per this should make it a lot easier for you and our users to tune the PID notch filters.

@IamPete1

Copy link
Copy Markdown
Member

I like the update to add the D FF properly. I'm not really a huge fan of mixing data between messages. They can be at a different rate, or at different points in time. If we did want to support notches correctly I would want to see all parameters tracked so changes split the log correctly. My preference would be to add new boxes to the exiting interface rather than add two new plots.

image

In the PID -> Inputs box there could be a check box for "Filtered target" and "Filtered error"

I'm not sure adding the center frequencies to the plots really helps.

From the ArduPilot side I would like to see the PID logs improved so they log the target both sides of the filter.

@amilcarlucas

Copy link
Copy Markdown
Contributor Author

It already shows filtered target and filtered error.

It is missing unfiltered target and unfiltered error. Both can be derived from information already present in the log.

The extra graphs contain extra usefull data at the bottom

@amilcarlucas

amilcarlucas commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

And regarding the Target, Actual and Error checkboxes, it is more complicated than that.
PID "Target" currently has different meanings depending on the message:

  • For RATE messages is the unfiltered target.
  • For PID messages it is the filtered target.

For PID Actual it might be similar.

And we want this tool to work for both ArduPilot 4.5, 4.6, 4.7 ... Even if we improve logging upstream, it will not fix the many legacy systems deployed out there.

I think this is a big step forward that should go in as it is. What do you think?

@IamPete1

Copy link
Copy Markdown
Member

Can you give a example where the new plots are useful?

@amilcarlucas

Copy link
Copy Markdown
Contributor Author

I added a third commit containing documentation explaining how these graphs are used to remove frame resonances.

Also adds a prominent notice at the top of the page reminding users
that the PID bit of LOG_BITMASK must be enabled for any PID log
messages to be present in the log.

Adds documentation and a signalflow graph
IamPete1 and others added 6 commits July 12, 2026 20:42
… note

Add two new frequency-domain graphs that visualise the effect of the
ArduPilot rate PID input filters:

- "Rate PID target filters": overlays the FFT of the unfiltered rate
  target (RATE.RDes/PDes/YDes) against the filtered target seen by the
  PID controller (PIDR/PIDP/PIDY.Tar), making the effect of the target
  filter (ATC_RAT_xxx_FLTT) visible.

- "Rate PID error filters": overlays the FFT of the raw error
  (Tar - Act, before the error filter) against the filtered error used
  by the PID (PIDR/PIDP/PIDY.Err), making the effect of the error
  filter (ATC_RAT_xxx_FLTE) visible.

Both plots share the existing frequency-axis zoom/pan link and respect
the amplitude/frequency scale controls. They are only shown when a
Roll, Pitch, or Yaw axis is selected; hidden for PIQR/PIQP/PIQY,
PIDS, and PIDA. RATE data is processed at its own sample rate
(no interpolation onto PID timestamps).

Also adds a prominent notice at the top of the page reminding users
that the PID bit of LOG_BITMASK must be enabled for any PID log
messages to be present in the log.
@amilcarlucas

amilcarlucas commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Here is a usage example:
image

We can clearly see frame resonance at 44, 88, 132 and 176 Hz.

The dynamic notch filters are removing a lot more than they should but still the motor noise finds it's way to the target signal at 62 and 124 Hz.

The error signal also contains noise, but I guess it's mostly coming from the target input:

image

Here is the .bin log for this:

@IamPete1

Copy link
Copy Markdown
Member

The dynamic notch filters are removing a lot more than they should but still the motor noise finds it's way to the target signal at 62 and 124 Hz.

The plot looks a bit odd, I would have expected the filtered and unfiltered to be the same close to 0Hz, there seems to be a 30dB difference. Maybe it would be worth getting a log with the filter turned off to make sure it is the same then.

@amilcarlucas

amilcarlucas commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

The problem is that one signal is from the RATE message the other id from ´the PID message and I guess they scale differently. I guess the RATE message has a 1000 multiplier, hence the ca. 30 dB difference?
yes, I would also like to fix that at some point.
But the main point now is why does the angle controller uses the unfiltered gyro signal? is it the EKF position signal that has noise?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants