-
Notifications
You must be signed in to change notification settings - Fork 13.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Multirotor] add yaw rate low pass filter #24173
base: main
Are you sure you want to change the base?
Conversation
co-authored-by: danielmellinger <[email protected]> co-authored-by: Eric Katzfey <[email protected]>
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 352 byte (0.02 %)]
px4_fmu-v6x [Total VM Diff: 208 byte (0.01 %)]
Updated: 2025-01-09T16:32:29 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about the much quicker and opposite sign yaw torque from inertia change of the rotor before but wasn't sure how to compensate it since it depends on the model and could lead to an additional undesired tuning configuration space. It might be possible to find adequate defaults for such a compensation.
But since that's not guaranteed and extensive testing is currently not on the plan I like your solution to attenuate the effect limiting the yaw dynamics. Given the limited yaw authority of a typical planar multirotor I don't see any limitation arising with this. The racer you tested with has small rather high drag propellers and obviously already benefits so I'd expect it to be even better on large low drag propellers.
@@ -89,6 +89,16 @@ class AlphaFilter | |||
return true; | |||
} | |||
|
|||
void setCutoffFreq(float cutoff_freq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function could potentially be misleading in the case you call setCutoffFreq(float cutoff_freq)
which sets _time_constant
but then use update(const T &sample)
for the update which assumes setParameters(dt, _time_constant)
was already called. I don't have a great idea how to make it clear but see the potential for people to run into this 😬
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was wondering about this too. Should we instead have two distinct classes? One where dt needs to be set during the update
call and the other one that uses the setParameters
to update the alpha.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems overkill no? Would it be a performance hit to just always use the "One where dt needs to be set during the update" and in the cases it's static just pass a constant? Seems way easier compared to the multiple options for basically the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem like overkill, but having separate classes could make each individually a bit easier to use, harder to misuse. Having to know which update to call when used a certain way is a leaky abstraction.
This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there: |
* @decimal 3 | ||
* @group Multicopter Rate Control | ||
*/ | ||
PARAM_DEFINE_FLOAT(MC_YAWRATE_FC, 2.f); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I have a better suggestion, but does this naming make sense?
Something more along the lines of yaw torque filter cutoff or in someway distinguish that it's specifically the output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The suggested name from #21434 was MC_YAW_CUTOFF
. I like the _CUTOFF
prefix but MC_YAW
is too inaccurate. Also, it would be problematic if we want to add a yaw filter (not yawrate like now).
What about MC_YAW_TQ_CUTOFF
or MC_Y_TRQ_CUTOFF
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed it to MC_YAW_TQ_CUTOFF
in 28bc950
replaces #21434
Solved Problem
On multirotors, yaw torque is produced by two effects:
Due to 1., the yaw rate loop gain is often limited as this high-frequency torque amplifies vibrations through the feedback loop.
Solution
Reduce the inertia wheel effect by low-passing the yaw torque setpoint. This allows higher yaw rate gains and reduces vibrations.
A default value of 2Hz should be good for most drones and should reduce vibrations without affecting the yaw rate stability.
Changelog Entry
For release notes:
Test coverage
Tested on a QAV250 with Pixhawk4 mini
Without filtering (MC_YAWRATE_FC = 0):
https://logs.px4.io/plot_app?log=5b8bf4af-3107-4257-8b89-99579cfabd45
With default filtering (MC_YAWRATE_FC = 2Hz):
https://logs.px4.io/plot_app?log=e13d88d0-8d9a-405e-ab09-a284c88c9af0
The control signal is smoother and no control degradation is visible.