qdomyos-zwift
qdomyos-zwift copied to clipboard
Added tests for bike power functions
To finish this PR, some thought will be needed about what it should test.
I have defined the erginterface abstract class, which acts as an interface for the powerFromResistance and resistanceFromPower functionality offered by the bike class. Currently the bikeergfunctions class implements this for bikes, by setting the bike's current cadence, using the corresponding function to get the resistance or power, then restoring the bike's original cadence.
The interface supports optionally defined (min, max) x (cadence, resistance) representing the domain the bike knows about so the tests adapt to the boundaries provided, where provided.
What is tested?
- if there is a (minimum,maximum) (cadence,resistance) defined, if the (cadence, resistance) goes (below,above) the (minimum,maximum) for a constant (resistance, cadence), does the power stop changing?
- if the bike::powerFromResistanceRequest function returns a power p for a specific cadence c and range of resistances rmin..rmax, does the bike::resistanceFromPowerRequest function return the rmin when called on p and c?
What is not tested?
- effects of watt gain and offset, resistance gain and offset
- wattsFromResistance function
@cagnulein is this something you want to continue with?
- I think it would be helpful to refactor the power/resistance functions in the bike class so that are not dependent on bike state then put these functions into an implementation of erginterface (or whatever you'd like to rename it to), then make bike have a field referring to an erginterface object.
- The power tables you have been implementing could be passed as an array into an implementation of erginterface that generically takes care of storage and searching.
- I believe I can make many tests pass simply by returning 0 resistance or 0W for a negative cadence.
- In all the cases I've looked at, the resistance from power doesn't invert the power from resistance. I wonder if you don't intend it to.
@drmason789 Actually I was looking to finalize the dynamic erg table for the bike where I don't have a static power table first. Do you agree?
Of course the dynamic power table will be applied only to the bike with automatic resistance and without the static power table.
@drmason789 i mean this one https://github.com/cagnulein/qdomyos-zwift/pull/2175 if you want to review my code go on! (I didn't test myself yet)
Actually I was looking to finalize the dynamic erg table for the bike where I don't have a static power table first. Do you agree?
Yes.
@drmason789 i mean this one https://github.com/cagnulein/qdomyos-zwift/pull/2175 if you want to review my code go on! (I didn't test myself yet)
Definately. I took a quick look and will have some comments about this later.
@cagnulein What is the intended difference between the functions wattsFromResistance and powerFromResistanceRequest?
@cagnulein Remember the resistance_t change? Would you be agreeable to me adding cadence_t, heartRate_t, power_t, pelotonResistance_t, inclination_t alongside it and propagating throughout the codebase, in a different PR?
@cagnulein What is the intended difference between the functions wattsFromResistance and powerFromResistanceRequest?
@drmason789 it was intented to use for renpho bikes but at the end powerFromResistanceRequest is a dead code
@cagnulein Remember the resistance_t change? Would you be agreeable to me adding cadence_t, heartRate_t, power_t, pelotonResistance_t, inclination_t alongside it and propagating throughout the codebase, in a different PR?
@drmason789 yes sure!
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.
@drmason789 i added erg tables for all the bikes with the new ergtable module. Maybe it could impact also this
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.