FortiusANT icon indicating copy to clipboard operation
FortiusANT copied to clipboard

Control Gearbox settings by keyboard?

Open ChrisLambert1 opened this issue 2 years ago • 3 comments

Hi, I wonder if it's possible to control the gearbox by keyboard? Formerly I used a Tacx fortius headunit, that worked like a charm, but upgraded to a Genius with a T2022 headunit. This headunit is not recognized nor pressing buttons on the unit changes the gearbox settings. So I wonder if it's possible to change the gearbox settings by the PC keyboard?

Regards, Chris

ChrisLambert1 avatar Feb 27 '22 14:02 ChrisLambert1

Welcome to the FortiusANT community


I'm always curious to know who I communicate with, where FortiusANT is used and what configuration is used. Please tell me what bundle did you buy, and what brake and what head unit do you use? I would therefore appreciate that you introduce yourself; perhaps leave a comment under issue #14. You could also consider to visit the sponsor page


The Genius is controlled directly (FortiusAnt <--> Brake) and the headunit is not used. The computer is not used to control, because it is assumed the keayboard is not close to the bike.

In the current implementation, you have two alternatives:

  • use a remote control, see manual 4.1.7 to change gears (e.g. from O-Synce)
  • use a raspberry with buttons, which can control the gearbox

WouterJD avatar Feb 27 '22 21:02 WouterJD

Keyboard switching could be implemented... feature to be implemented

WouterJD avatar Mar 23 '22 21:03 WouterJD

Perfect!

ChrisLambert1 avatar Mar 24 '22 07:03 ChrisLambert1

Welcome to the FortiusANT community

I'm always curious to know who I communicate with, where FortiusANT is used and what configuration is used. Please tell me what bundle did you buy, and what brake and what head unit do you use? I would therefore appreciate that you introduce yourself; perhaps leave a comment under issue #14. You could also consider to visit the sponsor page

The Genius is controlled directly (FortiusAnt <--> Brake) and the headunit is not used. The computer is not used to control, because it is assumed the keayboard is not close to the bike.

In the current implementation, you have two alternatives:

  • use a remote control, see manual 4.1.7 to change gears (e.g. from O-Synce)
  • use a raspberry with buttons, which can control the gearbox

Hello, I have a Genius and would like to use virtual shifting. The manual states, that it is not implemented (yet). Are there plans to implement it? With a ANT+ remote i managed to change virtual gears. The shown speed in FortiusAnt is changed, but the power/resistance from the Genius is unchanged.

Greetings from Germany, Thomas

krusty82 avatar Jan 03 '24 16:01 krusty82

The manual states, that it is not implemented (yet).

What do you mean with "manual states"?

ANT+ remote i managed to change virtual gears.

Nice

The shown speed in FortiusAnt is changed, but the power/resistance from the Genius is unchanged.

As described in the manual, the buttons on the Remote work exactly like the buttons of a tacx head unit; it changes the virtual gears (I understand you see that happening) which in the end means that the required resistance changes and the speed.

I checked the implementation: https://github.com/WouterJD/FortiusANT/blob/master/pythoncode/usbTrainer.py#L550 differs from https://github.com/WouterJD/FortiusANT/blob/master/pythoncode/usbTrainer.py#L569

Which suggests that the virtual gears would only work in PowerMode and not in GradeMode. PowerMode is when the CTP requires to produce a certain power (Watts) where GradeMode is when the CTP tells FortiusAnt to simulate a hill (slope with certain degree)

PowerMode is usually used during structured training and GradeMode is used for virtual rides.

As a first step, please explain a bit more what training you do, including what CTP is used. A screen short while testing the Shifting helps.

WouterJD avatar Jan 03 '24 20:01 WouterJD

Reopened to investigate whether Virtual Shifting would not work in GradeMode... Although the issue does not cover the title, but what the heck. I leave it, @BikeBeppe64 I believe you tested this with Rouvy...

WouterJD avatar Jan 03 '24 20:01 WouterJD

And @krusty82 Welcome to the FortiusANT community Dit you visit the sponsor page already?


WouterJD avatar Jan 03 '24 20:01 WouterJD

Hi @pquentin I see you follow this issue, Do you use FortiusAnt - all the way in La Reunion?

WouterJD avatar Jan 03 '24 20:01 WouterJD

Okay, maybe I should mention, that I also have a Fortius Unit and with this Virtual shifting works perfectly. Now I also got the Genius Unit and with this the Virtual Shifting does not work in Grade Mode. I used Rouvy and Zwift to test it. It seems like the Genius only uses the Grade to determine the needed resitance and ignoring the VirtualGear

With normal (Virtual)Gear everything is fine: LowGear

But with a high Gear the expected and the reported Power don't match: HighGear

krusty82 avatar Jan 03 '24 20:01 krusty82

Fortius Unit and with this Virtual shifting works perfectly

Also in GradeMode?

WouterJD avatar Jan 03 '24 20:01 WouterJD

With normal (Virtual)Gear everything is fine:

According to the screen prints, FortiusAnt is not paired with the Genius. === There is no communication between FortiusAnt and trainer.

WouterJD avatar Jan 03 '24 20:01 WouterJD

Fortius Unit and with this Virtual shifting works perfectly

Also in GradeMode?

Yes. So the problem must be with the implementation of the Genius. I think I read somewhere, that the Genius is not controlled by resistance, but only by grade

krusty82 avatar Jan 03 '24 20:01 krusty82

With normal (Virtual)Gear everything is fine:

According to the screen prints, FortiusAnt is not paired with the Genius. === There is no communication between FortiusAnt and trainer.

No, it is connected. After starting FortiusAnt the message to Nudge the wheel to start Calibrating appears. Genius gets calibrated. Then the Pairing message appears again. But the trainer is connected and works with CTP.

krusty82 avatar Jan 03 '24 20:01 krusty82

Then the Pairing message appears again.

That's a bug in itself (please raise an issue); which is hard for me to investigate because I have no Genius.

(It could be that the self._DeviceNumber is zero, where a postivie value is expected aftfer pairing - this is dongle-dependant)

WouterJD avatar Jan 03 '24 21:01 WouterJD

Yes. So the problem must be with the implementation of the Genius. I think I read somewhere, that the Genius is not controlled by resistance, but only by grade

Fortius implementation:

The brake requires a TargetResistance. If a TargetPower is given, it's calculated to a TargetResistance If a TargetGrade is given, it's calculated to a TargetPower then to a TargetResistance

Genius implementation:

The brake requires a TargetPower or a TargetGrade and further conversions required.

Common code

The VirtualGearbox modifies the TargetPower 550 but not the TargetGrade 569

Both Fortius AND Genius use the same TargetPower (modified) and TargetGrade. So how can the Fortius then work well with the virtual gear IN GRADE MODE and Genius does not? That's an interestinmg question...

WouterJD avatar Jan 03 '24 21:01 WouterJD

So @krusty82 your assessment is important here: Please confirm that VirtualGearBox works in GradeMode for Tacx Fortius, please provide some visuals to illustrate.

WouterJD avatar Jan 03 '24 21:01 WouterJD

I am not good at programming, but if I understand that correctly: https://github.com/WouterJD/FortiusANT/blob/5a89179f456e84e48d88c0b5200b650a7ca28b89/pythoncode/usbTrainer.py#L1609

for mode_Grade the Genius is used in mode_slope and only the grade is send, without conversion. So the VirtualGearRatio has no effect.

krusty82 avatar Jan 03 '24 22:01 krusty82

Hi @pquentin I see you follow this issue, Do you use FortiusAnt - all the way in La Reunion?

Hello! What makes you think I am following this issue? I have never heard about FortiusAnt, sorry, and I don't understand what it does from the README.

pquentin avatar Jan 04 '24 07:01 pquentin

Hello! What makes you think I am following this issue?

When typing @, github provides your name @pquentin as suggestion ... which put me on your track. The previous post is also marked by github as contributor And at https://github.com/pquentin?tab=repositories&q=FortiusAnt I saw that you forked the repository. So that's why...

See also: https://github.com/WouterJD/FortiusANT/graphs/contributors

Funny that github shows this and you have no clue. But hey, no harm done :-)

WouterJD avatar Jan 04 '24 18:01 WouterJD

if I understand that correctly

You're on the right way!

In base class, there are two functions SetGrade() and SetPower() importing the required grade or power to the trainer-class. The lines as mentioned before: https://github.com/WouterJD/FortiusANT/blob/master/pythoncode/usbTrainer.py#L550 and https://github.com/WouterJD/FortiusANT/blob/master/pythoncode/usbTrainer.py#L569

As you see in line 550, TargetPower is adjusted by the virtual gearbox, but TargetGrade is NOT in line 569. It would be easy and a logical action to adjust TargetGrade at line 569.

BUT ... you tell me that the virtual gearbox works for the Fortius in Grade mode. Therefore (refer to https://github.com/WouterJD/FortiusANT/issues/381#issuecomment-1876002893) So @krusty82 your assessment is important here: Please confirm that VirtualGearBox works in GradeMode for Tacx Fortius, please provide some visuals to illustrate.

PS. The reason NOT to adjust at line 1609 as you suggest (https://github.com/WouterJD/FortiusANT/issues/381#issuecomment-1876044380) is that: a- I prefer a symmetric approach in code, so aroun lines 550 and 569 b- The solution must work for all trainers (legacyUSB, newUSB, Genius, ...) and not for Genius only.

WouterJD avatar Jan 04 '24 18:01 WouterJD

So, I finally got Python running on my maschine and could play a bit with the code. Also I tried to understand the code some more. I think the difference with the Genius and the other trainers is, that for the other trainers the grade is converted to a resistance which then is send to the trainer. In this conversion the virtual shifting comes in to play. But for the Genius the grade is send directly to the trainer without conversion. So I don't think it's a bug, but a feature of the Genius that it has the slope mode.

Now that I can mess with the code, I can adjust the grade that is send to the Genius, because my problem with it is, that on flat parts I have to use a very high gear and the genius becomes quite loud.

Maybe with some more coding it is possible to implement a virtual shifting for the Genius that works and feels right. I just played around a bit with power mode, but didn't work well.

krusty82 avatar Jan 04 '24 19:01 krusty82

Actually I remember now! I forked to contribute https://github.com/WouterJD/FortiusANT/pull/433 because I was trying to get urllib3 2.0 adopted as an urllib3 maintainer.

pquentin avatar Jan 04 '24 20:01 pquentin

I have created a new branch #381-Virtual-Gear-in-GradeMode and a new usbTRainer/py

https://github.com/WouterJD/FortiusANT/blob/%23381-Virtual-Gear-in-GradeMode/pythoncode/usbTrainer.py

Please test and let me know

WouterJD avatar Jan 06 '24 19:01 WouterJD

Thanks, will test tomorrow. In the meantime I changed the code myself. In usbTrainer.py I changed lines 1608ff to:

Weight = max(0x0a, int(self.GearboxReduction * self.UserAndBikeWeight))
                        if self.TargetResistance < 0:
                           abspower = 0
                        else: 
                           abspower = self.TargetResistance 
                        info = ant.msgPage220_01_TacxGeniusSetTarget(self.Channel, ant.GNS_Mode_Power,
                                                                     abspower, Weight)    

Weight to change the flywheel accordingly. The abspower is needed, because if power is negative in descent, then the brake blocks. With this change, the genius is handled the same as the other trainers, especially the Vortex. The only thing missing is the speeding up of the wheel on steep descents, but I don't miss this. The cycling feels good.

krusty82 avatar Jan 06 '24 19:01 krusty82

OK @krusty82 it may work. But: it works for Genius only And: instead of modifying the targetResistance, you modify the userAndBikeWeight.

Anyway, it's great that you have made it work.

Thanks, will test tomorrow.

This would be nice. If that provides the desired result it may imply that it works for all trainers.

WouterJD avatar Jan 06 '24 20:01 WouterJD

Please note the concerns (in the code) regarding the effect when Grade=0

WouterJD avatar Jan 06 '24 20:01 WouterJD

Please note the concerns (in the code) regarding the effect when Grade=0

Yeah, thats one concern, because I use the virtual gears mostly on flat parts. Also I am curious what happens in the descents? I guess the gears get inverted.

krusty82 avatar Jan 06 '24 20:01 krusty82

OK @krusty82 it may work. But: it works for Genius only And: instead of modifying the targetResistance, you modify the userAndBikeWeight.

No, I used the same method, that is already used for the other trainers. targetResistance gets modified by GearboxReduction in the grade2power formula. But in the original code the Genius didn't use this formula but got send the grade directly. Also for the Fortius the flywhel weight gets adjusted, so I did this also for the Genius. I think the other trainers can't adjust the flywheel anyways.

Anyway, it's great that you have made it work.

Thanks, will test tomorrow.

This would be nice. If that provides the desired result it may imply that it works for all trainers.

krusty82 avatar Jan 06 '24 20:01 krusty82

On the Tacx Fortius, when Grade get's negative, the brake becomes an engine and produces a negative resistance. I think that the Genius cannot do that, but as said I don't have a Genius so cannot test that.

Gears will not invert, but in a low gear with no resistance, your cadence wil go high. (cycling with no resistance).

The abspower is needed, because if power is negative in descent, then the brake blocks.

Apparently the provided Terget must be a positive value Hence; Genius does not support decents.

WouterJD avatar Jan 06 '24 20:01 WouterJD

Apparently the provided Terget must be a positive value Hence; Genius does not support decents.

Genius does support it, but i guess only in slope_mode, in which it is not possible (or ot that easy) to use virtual gears

krusty82 avatar Jan 06 '24 20:01 krusty82