cagnulein / qdomyos-zwift

Zwift bridge for smart treadmills and bike/cyclette
https://www.qzfitness.com/
GNU General Public License v3.0
415 stars 115 forks source link

[BUG] Conversion gain setting and conversion offset setting do not work with Tacx Neo 2 and Peloton. + resistance crashes when adjusted manually #1707

Open AnneAstrid88 opened 1 year ago

AnneAstrid88 commented 1 year ago

See closed Issue #1418

Describe the bug The target resistance is always 1 below the peloton target resistance; no matter what I put in 'peloton gain' or 'peloton offset' I can't even adjust it manually. If I adjust the target resistance manually, the resistance crashes and goes to zero until Peloton pushes a new resistance to QZ.

I'm talking here about target resistance and target peloton resistance, because both resistance and peloton resistance are unusable for me. They change continuously and do not contain any comprehensible data, I think they change based on the cadence. (So that might be another bug)

To Reproduce Start Peloton app on Ipad and start video. Start QZ app on android phone. Connect to tacx neo 2. Start workout.

Target Resistance goes to zero when you click the + or - button.

Peleton gain and offset were changed but the number in 'target resistance' didn't change. Target resistance is always 1 below peloton target resistance. If for example, Peloton target Resistance was 20, then target resistance would be 19.

Expected behavior 1) The Target Resistance is automatically 5 higher when i set the offset with 5 and gain multiplies the resistance.

2) Resistance doesn't go to zero when I hit - or +

Screenshots WhatsApp Image 2023-10-15 at 15 52 12_447735a0

Smartphone (please complete the following information):

AnneAstrid88 commented 1 year ago

Yes, the resistance gives the correct value, thank you.

The only thing that is not correct yet is how much the 'gears tile' adds to/subtracts from the resistance. I have an example below, but you can find the complete debug log here:

debug-Tue_Oct_31_06_46_23_2023.zip

So in the following example, I have set my gear gain to '0.1', which should be correct for my bike as 0.1% incline is the same as 1 peloton resistance.

Here is a sequence of weird values: Here I expect that when I do gears = 1 and peloton resistance = 25 that my resistance goes to 35, but instead it goes to 36. I have a feeling there is somewhere a multiplier of 11, that I'm missing. On top of that, I sometimes get weird values for gear (not in increments of 0.1).

target_peloton_resistance = 25 gears = 0.1 resistance = 26

target_peloton_resistance = 25 gears = 0.2 resistance = 27

target_peloton_resistance = 25 gears = 0.3 resistance = 28

target_peloton_resistance = 25 gears = 0.30000000000000004 → I don't have a clue how this happened resistance = 28

target_peloton_resistance = 25 gears = 0.4 resistance = 28

target_peloton_resistance = 25 gears = 0.4 resistance = 29

target_peloton_resistance = 25 gears = 0.5 resistance = 30

target_peloton_resistance = 25 gears = 0.6 resistance = 31

target_peloton_resistance = 25 gears = 0.7 resistance = 32

target_peloton_resistance = 25 gears = 0.7999999999999999 → Again I don't know how i did this resistance = 32

target_peloton_resistance = 25 gears = 0.7999999999999999 resistance = 33

target_peloton_resistance = 25 gears = 0.8999999999999999 resistance = 34

target_peloton_resistance = 25 gears = 0.9999999999999999 resistance = 34

target_peloton_resistance = 25 gears = 0.9999999999999999 resistance = 36 → Here I expect 35

target_peloton_resistance = 25 gears = 0.7 resistance = 33

Another sequence with weird values: Here I expect that when I do gears = -0.1 and peloton resistance = 25 that my resistance goes to 24, but instead it goes to 23.

target_peloton_resistance = 25 gears = 0 resistance = 25

target_peloton_resistance = 25 gears = -0.1 resistance = 23 → Here I expect 24 target_peloton_resistance = 25 gears = -0.2 resistance = 21.999999999999996 → Here I expect 23

target_peloton_resistance = 25 gears = -0.1 resistance = 21.999999999999996 → Here I expect 24

target_peloton_resistance = 25 gears = -0.1 resistance = 23 → Here I expect 24

I you need any more information, let me know. Thank you in advance.

cagnulein commented 1 year ago

got it, thanks for the detailed debug. It's a classic double precision error. The double format of the gears (but that's true for all the floating numbers and double numbers in any software) can't represent ALL the numbers, but only a fraction of them (more details here https://en.wikipedia.org/wiki/Double-precision_floating-point_format ).

So that's why when you have a gear with a lot of .999999 is creating this issue. I know that it's not you, but at least we understood it :)

So I guess the fix for this will be truncating and fix the gears value accordingly to the precision that you set in the settings.

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

AnneAstrid88 commented 11 months ago

So I just saw that this issue was closed, but the issue of the gears not properly adjusting the resistance still exist.

You mentioned:

So I guess the fix for this will be truncating and fix the gears value accordingly to the precision that you set in the settings.

As I understood, it was something that had to be adjusted in the code. But maybe I misunderstood and I should adjust something in the settings? Can you elaborate a bit further? Thank you in advance!

cagnulein commented 11 months ago

it was autoclosed because you didn't comment anymore.

As I understood, it was something that had to be adjusted in the code. But maybe I misunderstood and I should adjust something in the settings? Can you elaborate a bit further?

It's something about the double precision of the gears, yes it's something in the code. Actually i'm overwhelmed by requests. So i'm pinning this, feel free to ping me in the next weeks about this

AnneAstrid88 commented 11 months ago

Don't worry, it's not a priority. It's just good that it's still on your radar. I didn't comment anymore because I didn't want to put any extra pressure on you, as I realize you have lots of work with QZ. In the future, I will just give a comment whenever it is about to go stale.

cagnulein commented 11 months ago

thanks for understanding this!