jonasoreland / runnerup

A open source run tracker
GNU General Public License v3.0
719 stars 271 forks source link

Cadence is wrong #1040

Open Uatschitchun opened 2 years ago

Uatschitchun commented 2 years ago

Hi there,

have an issue with using step counter on my Honor 20 pro. A intervall training I did of 7k, results in 810spm! Sadly Runnerup doesn't show cadence somewhere, but runalyze and tredict both come to same numbers!? What to do? Screenshot_20210908_193245

gerhardol commented 2 years ago

Cadence is calculated from the stepcounter, averaged with a filter. I would expect that the sensor reports that the sensor is updated but do not actually update the count normally but only in steps. This seems quite weird. However, I will try to make a fix with this assumption.

Uatschitchun commented 2 years ago

Anything I can provide to help?

gerhardol commented 2 years ago

Anything I can provide to help?

No, the filtering etc is internal. I plan to create a beta release in some weeks with some more changes (as usual, Google required changes requires most of the time I have available, so not much new user changes), including this.

Uatschitchun commented 2 years ago

I'll check the 2.4.0.0 pre-release once I'm out for a run!

Uatschitchun commented 2 years ago

Was able to test and it seems better, but not fixed. If you like to, I could send the tcx by mail to check. It has total step count correct as it seems, but few exorbitant values still appear and it seems to have only recorded the first 2km!?

gerhardol commented 2 years ago

Was able to test and it seems better, but not fixed. If you like to, I could send the tcx by mail to check.

Filtering is done deeper in the application (the phone should send update at every new step), so the processed and filtered data will not help. Will take a look again.

It has total step count correct as it seems, but few exorbitant values still appear and it seems to have only recorded the first 2km!?

If no data is recorded, then no data is delivered. Huawei is doing something here...

Uatschitchun commented 2 years ago

Here's a screenshot Screenshot_20210925_084811

Uatschitchun commented 2 years ago

I found an implementation which seems to be working: https://github.com/j4velin/Pedometer/blob/master/src/main/java/de/j4velin/pedometer/SensorListener.java

Have the app installed and it seems to count steps correctly, from first glance.

I even found this video explaining different implementations: https://m.youtube.com/watch?v=8Wku0jvnXEA

Don't know if it is of any help...

gerhardol commented 2 years ago

I do not think the counted steps is (much) incorrect in general, but the reported time is occasionally incorrect from step to step. The reported value must be smoothed too, otherwise the value is expected to jump quite some.

It could be that the sensor is "sleeping" occasionally and not reporting in time, then the cadence will be strange and affect the filter. The sensor API has a function "accuracyChanged that maybe should be handled, assuming that the time is off after that. Also old values should be ignored as well as unreasonable high values (over 300 rpm or so).

I am sure that someone will look at this code and ask why so weird checks were applied... So another update.

Uatschitchun commented 2 years ago

As said, the implementation from j4velin seems to be working well, although it just count steps over a long period. Btw, my wife's recording shows the same behavior (Honor 6x).

If I read correctly, there are 2 possibilities to read counted steps: to read each counted step (on change) or to read a bunch of counted steps.

Uatschitchun commented 2 years ago

Sad to say, but even with latest changes, cadence isn't as expected ...

This is Runalyze: Cadence Runalyze

This is Tredict: Cadence Tredict 1 Cadence Tredict 2 Cadence Tredict 3

gerhardol commented 2 years ago

In that case the raw trace from the sensor is needed. I will look into something later, for you to test in a private build.

Uatschitchun commented 2 years ago

Ideally we would add some debug logging to a file, so it could be tested out in the fields.

I've tried a few sensor test tools and all report proper changes in step counts: Screenshot_20211013_093051_com wered sensorsmultitool

gerhardol commented 2 years ago

I do not think that counting steps is a problem, if RU counted steps it would be the same answer. The problem is how Android reports changes to RU, if there are "empty updates", delays or bundled reporting the calculated cadence will be incorrect. I tried to ignore incorrect values, but there is obviously something more special.

Uatschitchun commented 2 years ago

Thing is, I do not know any android app that records cadence when running. There are pedometer apps, yes, but maybe this is the reason why no app is providing cadence/strides!? Is step counting working for anyone correctly?

gerhardol commented 2 years ago

Cadence worked fine with my Moto X4 with Android 9 and Sony Xperia Z3 (Android 6), not with my just deceased Sony Xperia 5ii (trapped in a door) or the OnePlus 8T replacement (Android 11) (only 0 reading).