EdgeTX / edgetx

EdgeTX is the cutting edge open source firmware for your R/C radio
https://edgetx.org
GNU General Public License v2.0
1.56k stars 332 forks source link

Throttle warning still acts on throttle stick after throttle source assigned to CH5 #4339

Open mha1 opened 10 months ago

mha1 commented 10 months ago

Is there an existing issue for this problem?

What part of EdgeTX is the focus of this bug?

Transmitter firmware

Current Behavior

Consider the following minimal helicopter setup with 5 mixers defined:

Throttle set to CH5 (the governer output). All preflight checks disabled but throttle state.

Issue: the throttle warning when selecting the model still acts on the throttle stick. Please see attached minimal model.yml

image image

Expected Behavior

Throttle warning acts on CH5 state

Steps To Reproduce

see problem description and model33.yml.txt

Version

2.9.2

Transmitter

RadioMaster TX16S / TX16SMK2

Operating System (OS)

No response

OS Version

No response

Anything else?

2.9.2 (can't select 2.9.2 in issues)

Note: what does "0" mean? image

raphaelcoeffic commented 10 months ago

This is basically a known issue: the throttle warning code is pretty stupid and will only check the stick itself and ignore the throttle channel.

See here:

// throttle channel is either the stick according stick mode (already handled in evalInputs)
// or P1 to P3;
// in case an output channel is choosen as throttle source (thrTraceSrc>NUM_POTS+NUM_SLIDERS) we assume the throttle stick is the input
// no other information available at the moment, and good enough to my option (otherwise too much exceptions...)
uint8_t thrchn = ((g_model.thrTraceSrc==0) || (g_model.thrTraceSrc>NUM_POTS+NUM_SLIDERS)) ? THR_STICK : g_model.thrTraceSrc+NUM_STICKS-1;

if (!mixerTaskRunning()) getADC();
evalInputs(e_perout_mode_notrainer); // let do evalInputs do the job

int16_t v = calibratedAnalogs[thrchn];
if (g_model.thrTraceSrc && g_model.throttleReversed) { // TODO : proper review of THR source definition and handling
  v = -v;
}

if (g_model.enableCustomThrottleWarning) {
  int16_t idleValue = (int32_t)RESX * (int32_t)g_model.customThrottleWarningPosition / (int32_t)100;
  return abs(v - idleValue) > THRCHK_DEADBAND;
}
else {
  return v > THRCHK_DEADBAND - RESX;
}
mha1 commented 10 months ago

Ok, because the mixer task is not yet running?

raphaelcoeffic commented 10 months ago

Ok, because the mixer task is not yet running?

This. That would require triggering the full cycle instead of just evaluating the inputs. This code is very old and has never been changed. OpenTX behaves the same way.

mha1 commented 10 months ago

would be worth mentioning the rather unexpected behavior for selecting channels as throttle source: https://edgetx.gitbook.io/edgetx-user-manual/edgetx-user-manual/user-manual-for-color-screen-radios/model-settings/model-setup/throttle

Something like this:

Source: The source that will be used for the throttle. In case an output channel is chosen as throttle source it is assumed the throttle stick is the input, i.e. the throttle stick will be evaluated.

johnjoeallen commented 7 months ago

I get the Throttle not idle 1%, the warning goes when the throttle stick is a 0 (centered). Surely the check should be for -100

johnjoeallen commented 7 months ago

I get the Throttle not idle 1%, the warning goes when the throttle stick is a 0 (centered). Surely the check should be for -100

Turn off custom position, that was the problem :)

mha1 commented 4 months ago

@pfeerick @philmoz Can we at least try to make this a little better, by checking the real throttle input? I believe by extending the source selection options to physical inputs, ie sticks, switches, 6Pos, pots and also removing the channel options we'd cover 99% of all reasonable use case.

arnaudmz commented 4 months ago

Hi there. I just tested and confirm that using another input as throttle (S1, S2…) is correctly handled on OpenTX (tested on 2.3.15) and generates a warning adequately at startup.

I'd love to see at least this behaviour.