ControlAllocator: Always respect output slew rate#26530
Open
Conversation
Will also be handled by main motor slew rate in later commit
introducing more variables than strictly necessary to clearly specify what is input and what is output. no functional change
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 64 byte (0 %)]px4_fmu-v6x [Total VM Diff: 56 byte (0 %)]Updated: 2026-02-20T09:13:23 |
- get stopped motors mask in main Run() - introduce ApplyNanToActuators in ControlAllocation to apply it - refactor ice shedding with extra function that modifies the actuator_sp (passed by ref)
f3fe0ec to
88f7191
Compare
sfuhrer
reviewed
Feb 19, 2026
Contributor
sfuhrer
left a comment
There was a problem hiding this comment.
Not extremely elegant but I can't think of a more straight forward way. The issue is real, you expect the slew rate also to work when stopping a motor suddenly as it often is added to protect the hardware (e.g. from large back currents).
src/lib/control_allocation/control_allocation/ControlAllocation.cpp
Outdated
Show resolved
Hide resolved
src/lib/control_allocation/control_allocation/ControlAllocation.hpp
Outdated
Show resolved
Hide resolved
f169b75 to
d18a652
Compare
d18a652 to
c9f7522
Compare
Contributor
Contributor
Author
|
no, will do next week :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Solved Problem
It is possible to override the slew rates
CA_Rx_SLEWby sending a very low thrust setpoint, which then causes the motor to be labelled stopped, which immediately gives it a motor output ofNaNand thus its disarmed PWM. In some cases the ESC is not able to spin back up, even after only a very short spike of disarmed PWM.More details
Such zero-thrust spikes currently happen via this path:
While this issue should be addressed at its root in a general navigator cleanup ™️, setting an output slew rate limit provides an easy hotfix after this PR for this and similar issues.
But also generally, it is very unintuitive (and possibly dangerous if the propulsion system actually requires a limited slew rate...) for the output slew rate to have this type of exception.
Solution
publish_actuator_controlsto mainrun, crucially before applying the slew rate.publish_actuator_controlsnow only does what it saysContext
This is one part of the changes I pushed on to #24684.
The changes are actually quite orthogonal, they just happen to touch some of the same lines in CA, so I propose to do it in two steps.
Changelog Entry
For release notes:
Open questions
src/lib/slew_rate/SlewRate.hpp, which we could use instead. Then we would also have to fix the current parameterisation inconsistency:FW_THR_SLEW_MAX,FW_PN_R_SLEW_MAX,VT_PSHER_SLEW, everything handled by theSlewRatelib) are in units of[unit]/sor1/s, specifying the max absolute rate of change either in absolute units, or in "normalised" units as a fraction of the relevant max-min range.CA_Rx_SLEWrates are parameterised ins(the min allowed time to traverse the range). This is the inverse of the default.Test coverage
Sim sanity check:
gz_standard_vtolin altitude mode (MC), with fast pitch inputs to enable/disable pusher assist,CA_R4_SLEW=1and high rate logging.before:

actuator_motors/control.05switches immediately between NaN and large positive values. End result is that the motor switches immediately from disarmed PWM to high PWM without respecting slew rateafter:

actuator_motors/control.05switches between NaN and 0 (not directly to nonzero values), and otherwise always respects slew rate. End result: physical motor respects slew rate.