FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(mc_pos_control): handle rejected velocity filter cutoffs by Saibernard · Pull Request #28451 · PX4/PX4-Autopilot · GitHub

fix(mc_pos_control): handle rejected velocity filter cutoffs - #28451

Merged
dakejahl merged 1 commit into
PX4:mainfrom
Saibernard:pr-mc-pos-vel-lp-guard
Aug 29, 2026
Merged

dakejahl merged 1 commit into
PX4:mainfrom
Saibernard:pr-mc-pos-vel-lp-guard

Conversation

Copy link
Copy Markdown
Contributor

Summary

Follow-up from the #28415 review sweep. The velocity low pass configuration in the position controller now checks whether the filter accepted the requested cutoff.

Problem

All four setCutoffFreq calls ignored the return value, and the call is a silent no-op when the cutoff is at or above half the sample rate. The filters start at an alpha of zero, so a rejected configuration freezes the velocity feedback at zero. MPC_VEL_LP permits up to 50 Hz while the position loop runs at 100 Hz or less, so the maximum permitted value triggers this. In SIH a hover with MPC_VEL_LP=50 oscillates half a metre in altitude with vertical speed peaks near 1 m/s.

Solution

Check the return and bypass the low pass stage when the cutoff is not achievable, the pattern VehicleAngularVelocity already uses. The same hover then holds 2.5 m within a centimetre, and the default and valid cutoff configurations behave as before. One deliberate behaviour change, a runtime switch from a valid to an unachievable cutoff now bypasses the stage instead of keeping the stale configuration. The notch filter call at the same site also ignores its return but disables itself internally on invalid input, and a warning on rejection could be added here if wanted.

github-actions Bot added kind:bug Something is broken or behaving incorrectly. vehicle:copter Copter-specific behavior. scope:control Rate, attitude, position, allocation, or actuator control. labels Aug 29, 2026

github-actions Bot commented Aug 29, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 56 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +56  +0.0%     +56    .text
    +1.5%     +52  +1.5%     +52    MulticopterPositionControl::parameters_update()
    +3.0%      +8  +3.0%      +8    AlphaFilter<>::setCutoffFreq()
    +0.6%      +2  +0.6%      +2    matrix::SliceT<>::operator=()
    -2.1%      -2  -2.1%      -2    events::send<>()
    -8.3%      -4  -8.3%      -4    Navigator::stop_capturing_images()
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%     +20  [ = ]       0    .debug_info
  +0.0%     +21  [ = ]       0    .debug_line
   -80.0%      -4  [ = ]       0    [Unmapped]
    +0.0%     +25  [ = ]       0    [section .debug_line]
  +0.0%     +84  [ = ]       0    .debug_loclists
  -0.8%      -2  [ = ]       0    .shstrtab
  -0.0%     -14  [ = ]       0    .strtab
   -12.8%     -14  [ = ]       0    AlphaFilter<>::setCutoffFreq()
     +36%     +16  [ = ]       0    ___ZL19param_get_cplusplustPf.isra.0_veneer
   -34.0%     -16  [ = ]       0    __nxsched_merge_pending_veneer
  -0.5%     -56  [ = ]       0    [Unmapped]
  +0.0%    +164  +0.0%     +56    TOTAL

px4_fmu-v6x [Total VM Diff: 56 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +56  +0.0%     +56    .text
    +1.5%     +52  +1.5%     +52    MulticopterPositionControl::parameters_update()
    +3.0%      +8  +3.0%      +8    AlphaFilter<>::setCutoffFreq()
    +0.6%      +2  +0.6%      +2    matrix::SliceT<>::operator=()
    -2.1%      -2  -2.1%      -2    events::send<>()
    -8.3%      -4  -8.3%      -4    Navigator::stop_capturing_images()
   +50%      +4  [ = ]       0    .ARM.exidx
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%     +20  [ = ]       0    .debug_info
  +0.0%     +29  [ = ]       0    .debug_line
    +200%      +4  [ = ]       0    [Unmapped]
    +0.0%     +25  [ = ]       0    [section .debug_line]
  +0.0%     +84  [ = ]       0    .debug_loclists
  -0.8%      -2  [ = ]       0    .shstrtab
  -0.0%     -14  [ = ]       0    .strtab
   -12.8%     -14  [ = ]       0    AlphaFilter<>::setCutoffFreq()
  -1.5%     -60  [ = ]       0    [Unmapped]
  +0.0%    +172  +0.0%     +56    TOTAL

Updated: 2026-08-29T15:54:43

…rejected

setCutoffFreq refuses a cutoff at or above half the sample rate and
leaves the filter untouched, but all four velocity filter calls ignored
the return. With the filters at their initial alpha of zero this froze
the velocity feedback at zero, and the condition is reachable from a
permitted parameter value, MPC_VEL_LP allows up to 50 Hz while the
position loop commonly runs at 100 Hz or less. In SIH a hover with
MPC_VEL_LP=50 oscillates half a metre in altitude with vertical speed
peaks near 1 m/s, and holds 2.5 m within centimetres with this change.

Follow the pattern VehicleAngularVelocity already uses, check the
return and bypass the low pass stage when the requested cutoff is not
achievable. One deliberate behaviour change comes with that, a runtime
parameter change from a valid to an unachievable cutoff now bypasses
the stage instead of keeping the stale previous configuration.

Assisted-by: Claude:claude-fable-5
Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
Saibernard force-pushed the pr-mc-pos-vel-lp-guard branch from f3d8d04 to 1ab0236 Compare August 29, 2026 15:49
Saibernard marked this pull request as ready for review August 29, 2026 16:53
dakejahl merged commit 71f8b37 into PX4:main Aug 29, 2026
69 checks passed
stahlbauer pushed a commit to stahlbauer/PX4-Autopilot that referenced this pull request Aug 31, 2026
…rejected (PX4#28451)

setCutoffFreq refuses a cutoff at or above half the sample rate and
leaves the filter untouched, but all four velocity filter calls ignored
the return. With the filters at their initial alpha of zero this froze
the velocity feedback at zero, and the condition is reachable from a
permitted parameter value, MPC_VEL_LP allows up to 50 Hz while the
position loop commonly runs at 100 Hz or less. In SIH a hover with
MPC_VEL_LP=50 oscillates half a metre in altitude with vertical speed
peaks near 1 m/s, and holds 2.5 m within centimetres with this change.

Follow the pattern VehicleAngularVelocity already uses, check the
return and bypass the low pass stage when the requested cutoff is not
achievable. One deliberate behaviour change comes with that, a runtime
parameter change from a valid to an unachievable cutoff now bypasses
the stage instead of keeping the stale previous configuration.

Assisted-by: Claude:claude-fable-5

Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
dakejahl pushed a commit that referenced this pull request Sep 4, 2026
…rejected (#28451) (#28534)

setCutoffFreq refuses a cutoff at or above half the sample rate and
leaves the filter untouched, but all four velocity filter calls ignored
the return. With the filters at their initial alpha of zero this froze
the velocity feedback at zero, and the condition is reachable from a
permitted parameter value, MPC_VEL_LP allows up to 50 Hz while the
position loop commonly runs at 100 Hz or less. In SIH a hover with
MPC_VEL_LP=50 oscillates half a metre in altitude with vertical speed
peaks near 1 m/s, and holds 2.5 m within centimetres with this change.

Follow the pattern VehicleAngularVelocity already uses, check the
return and bypass the low pass stage when the requested cutoff is not
achievable. One deliberate behaviour change comes with that, a runtime
parameter change from a valid to an unachievable cutoff now bypasses
the stage instead of keeping the stale previous configuration.

Assisted-by: Claude:claude-fable-5


(cherry picked from commit 71f8b37)

Signed-off-by: Saibernard Yogendran <bernie97@seas.upenn.edu>
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

Labels

kind:bug Something is broken or behaving incorrectly. scope:control Rate, attitude, position, allocation, or actuator control. vehicle:copter Copter-specific behavior.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL