feat(fw_performance_model): scale vehicle weight by remaining fuel#27901
Open
mahima-yoga wants to merge 4 commits into
Open
feat(fw_performance_model): scale vehicle weight by remaining fuel#27901mahima-yoga wants to merge 4 commits into
mahima-yoga wants to merge 4 commits into
Conversation
Add a WEIGHT_FUEL parameter for the mass of a full fuel load. When set, the weight used for trim throttle, min/stall airspeed, and climb/sink rate scaling is reduced by the burned fuel mass derived from fuel_tank_status (filtered to reject sloshing). Disabled by default.
Contributor
🔎 FLASH Analysispx4_fmu-v5x [Total VM Diff: 920 byte (0.05 %)]px4_fmu-v6x [Total VM Diff: 984 byte (0.05 %)]Updated: 2026-07-15T12:18:04 |
mbjd
reviewed
Jul 15, 2026
mbjd
left a comment
Contributor
There was a problem hiding this comment.
Cool stuff! Looks nice and correct, some minor points below 👇
| // only a single fuel tank is supported: use the first reported tank id and ignore all others | ||
| if (_fuel_tank_id < 0) { | ||
| _fuel_tank_id = fuel_tank_status.fuel_tank_id; | ||
| } |
Contributor
There was a problem hiding this comment.
could we not support multiple instances very easily too?
- Change weight param to fuel density or total fuel mass when all tanks are full (assume the same fuel is in all tanks)
- Just below, loop over all tanks, accumulate the consumed fuel weight, and convert that back to the fraction of total tank volume
- or just always use weight
maybe multiple tanks are outlandish enough to not worry as well though
Contributor
Author
There was a problem hiding this comment.
I shall give this a think
Contributor
💡 Commit messages could be improvedNot blocking, but these commit messages could use some cleanup.
See the commit message convention for details. This comment will be automatically removed once the issues are resolved. |
hamishwillee
left a comment
Contributor
There was a problem hiding this comment.
@mahima-yoga When you're done, this may well require an update to https://docs.px4.io/main/en/config_fw/weight_and_altitude_tuning#vehicle-weight-compensation
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.
Thought I would push something to get the discussion going:
Solved Problem
The FW performance model scales trim throttle, min/stall airspeed, and climb/sink rates from the static
WEIGHT_GROSSparameter. For combustion vehicles a large share of the takeoff weight is fuel, so these limits become increasingly wrongas fuel burns off during flight - which leads to inefficient flight.
Solution
Add an optional
WEIGHT_FUELparameter (mass of a full fuel load). When set, the weight used by the performance model is reduced by the burned fuel mass derived fromfuel_tank_status(remaining fuel preferred, then percentage, then consumed fuel), low-pass filtered to reject sloshing.Also adds
weight_ratiotoTecsStatus(appended field, uLog-compatible) for log analysis.Test coverage
Needs to be tested.
Unit tests for the weight-ratio math and the fuel-fraction fallback chain
(
make tests TESTFILTER=PerformanceModel)Some points / limitations: