Reset FW throttle rate limit when switching to a non-limiting battery profile - #11980
sensei-hacker wants to merge 1 commit into
Conversation
… profile mixerInit() only set throttleRateLimit when the active battery profile's throttleRateLimiter was nonzero, and setBatteryProfile() never re-derived it. Switching in-flight to a profile with limiting disabled (or a different rate) left the previous profile's limit applied for the rest of the flight. Extract the derivation into mixerUpdateThrottleRateLimit(), add the missing reset-to-zero branch, and call it from setBatteryProfile() as well as mixerInit().
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoRefresh FW throttle rate limit on battery profile changes
AI Description
Diagram
High-Level Assessment
Files changed (6)
|
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewTip of the day💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history |
|
RAM / Flash usage vs. base commit
See RAM/flash optimization guide for techniques to reduce usage. |
|
Test firmware build ready — commit Download firmware for PR #11980 249 targets built. Find your board's
|
Summary
Fixes a stale
throttleRateLimit(fixed-wing throttle rate limiter) across an in-flight battery-profile switch.Problem
mixerInit()only assignedthrottleRateLimitwhen the active battery profile'smotor.throttleRateLimiterwas nonzero — there was noelsebranch to reset it.setBatteryProfile()swaps the active profile pointer but never re-derived the limit. Result: a pilot who arms on a limiting-enabled profile, then switches in-flight to a profile with limiting disabled (or a different rate), keeps the old limit applied for the rest of the flight.Changes
mixerInit()intomixerUpdateThrottleRateLimit()(declared inmixer.h), adding the missing reset-to-0.0fbranch when the profile's limiter is disabled.mixerInit()now calls this new function.setBatteryProfile()(sensors/battery.c) now also calls it after swapping the active battery profile, so the limit is re-derived immediately on switch.UNIT_TEST-only accessormixerGetThrottleRateLimit()for test verification.Testing
src/test/unit/mixer_battery_profile_throttle_rate_limit_unittest.cc: reproduces the bug (confirmed failing against the pre-fix code — old profile's limit persisted after switching to a limiter-disabled profile) and passes with the fix.mixer_transition_logic_unittest,mixer_transition_policy_unittest,mixer_transition_scenarios_unittest,battery_ina226_unittest) — all pass, no regressions.MATEKF405hardware target — links cleanly, no new warnings/errors.Code Review
Reviewed with the inav-code-review agent — no critical/important issues found. Verified call-ordering at boot (via
readEEPROM()) and on in-flight profile switch; both run in normal main-loop context with no reentrancy concern.Addresses Qodo finding #2 from PR #11870.