-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Scale FW cruise throttle based on baro pressure #8304
Conversation
This seems fine, although shouldn't it be done in the position controller? The position controller depends on position (obviously), deals with altitude, and actively controls throttle. The attitude controller really shouldn't have any dependency on these things. |
I was trying to keep all throttle scaling together. It had global pos anyway for groundspeed |
@priseborough any feedback? |
Manual mode and stabilized should maintain manual throttle passthrough. For example think about something going wrong with the global position (altitude) estimate. I actually don't think any throttle scaling should happen at this level, but that's another discussion. |
I agree with the safety argument. And I think the throttle scaling should definitely come out of TECS, as this is an alternate mode of controlling altitude. |
Ok, i'll move it to pos ctl. I dont think tecs has absolute altitude. |
A complication is that the TECS total energy controller for throttle contains an integrator which needs to know if throttle is saturated. Additionally TECS relies on throttle_max passed through being the throttle required to climb at FW_T_CLMB_MAX and throttle_min being the throttle required to descend at FW_T_SINK_MIN when flying at the current speed demand. This means corrections for the change in performance with altitude should be achieved by modifying the throttle_min and throttle_max value passed through to TECS, rather than scaling the TECS throttle output. |
Moved to pos ctl |
@priseborough For now its only extending an already existing scaler on throttle (voltage). |
af61fef
to
b1474b0
Compare
Can you at least limit the scale adjustment so that physical throttle won't clip before TECS throttle has reached its own upper limit. |
573c319
to
52f8fbc
Compare
if (orb_copy(ORB_ID(sensor_baro), _sensor_baro_sub, &baro) == PX4_OK) { | ||
// scale throttle as a function of sqrt(p0/p) (~ EAS -> TAS at low speeds and altitudes ignoring temperature) | ||
const float scale = constrain(sqrtf(MSL_PRESSURE_MILLIBAR / baro.pressure), 0.9f, 1.1f); | ||
throttle_cruise = throttle_cruise * scale; |
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.
throttle_max should also be scaled up to a max value of 1.0 to prevent possible loss of speed an stalling during climbs at altitude.
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.
Can you elaborate on 1.0? shouldnt the same scaling apply? or do you mean as a lower limit?
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.
Or do you mean an absolute value of 1.0f ?
* @boolean | ||
* @group FW L1 Control | ||
*/ | ||
PARAM_DEFINE_INT32(FW_THR_ALT_SC_EN, 0); |
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.
Thus should be a float that multiplies by the pressure ratio to set the scale correction. A fixed ratio of 1 is not going to work for all propulsion types.
At the moment It's only adjusting throttle_cruise up and down. It should also adjust throttle_max up to a maximum of 1.0, otherwise there may be insufficient throttle to maintain safe airspeed during climbs without an airspeed sensor. Also, why make the gain from pressure ratio to throttle either 1.0 or nothing? A unity scaling from pressure ratio to throttle scaler seems arbitrary and will not work for all propulsion types. |
@priseborough i'll address your comments, they make sense. |
@sanderux Good idea, we should also add this for the multicopter part (but in the mixer since the input of the multicopter mixer are forces and moments). It would be nice to scale with the air temperature too (sqrt(T/T_ref)) if a reliable measurement is available. |
I don't think we have a basis for specifying how to scale throttle_min. It would depend on whether you were using the propeller as a brake or a thruster during that flight condition. Also have you thought about using the eas2tas instead of pressure ratio? With voltage or RPM control of the motor and a fixed pitch prop this does have a physical basis and will compensate for loss of air density and the higher TAS required at higher air temperatures. |
@priseborough this method was mostly meant for flying without airspeed sensor. I will address your scaling issue and apply to throttle_max too |
Sorry, I forgot that eas2tas wasn't available without an airspeed sensor. |
@dagar @priseborough changes made, please do another pass |
b49e377
to
f72f4d7
Compare
* When flying without airspeed sensor this will help to keep a constant performance over large altitude ranges. | ||
* | ||
* A value of 0 will disable scaling. | ||
* A value of 1 will add 1% throttle for every 1% of pressure descrease relative to standard pressure (1013.25) |
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.
Param description out of date.
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.
Whats out of date about it? i just rewrote it
ac632c3
to
2b18cda
Compare
I fixed the trivial CI failure (formatting), moved the scaling to within the constrain, and added finite checks for the baro and input parameter. I also increased the scaling maximum incase you want to go flying on everest or something. I still think the param description could be improved, but I'm fine with merging this. @priseborough @bresch any suggestions for describing the scaling parameter?
It seems to me we should be saying something about propulsion types. |
const float scale = constrain(eas2tas * _parameters.throttle_alt_scale, 0.9f, 1.8f); | ||
|
||
throttle_cruise = throttle_cruise * scale; | ||
throttle_max = throttle_max * scale; |
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.
limit throttle_max upper value to 1.0 and limit upper value of throttle_cruise to be lower than throttle_max.
I'm OK with describing what it does and leaving it to the user to tune. It is an advanced user parameter and set to 0 by default. We can update the description with suggested values when we have some flight test data of performance modelling for different propulsion system setups. |
2b18cda
to
ef6a134
Compare
Looks good to me now |
DO NOT PUSH this PR |
My previous comment has not been addressed. It still allows throttle_cruise = throttle_max which will cause a div0 condition here: https://github.com/PX4/ecl/blob/master/tecs/tecs.cpp#L351 |
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.
Please address the concerns from @priseborough.
@sanderux Please handle this with priority - we are now ready to release otherwise and it would be bad if your users would have a suboptimal experience without this patch. |
I'm on it |
ef6a134
to
7f5c0e3
Compare
@LorenzMeier @dagar @priseborough |
SITL tested, all still works as expected |
7f5c0e3
to
c2a2033
Compare
Looks good, but we never check it otherwise (param updates, or DO_CHANGE_SPEED). I'm going to do the constrain in general in another PR> |
This provides a method to scale cruise throttle based on altitude AMSL.
Mostly useful for flying without airspeed sensor on varying altitudes.
SITL tested and disabled by default.
Would be great if this could still make 1.7