Closed haozes closed 2 years ago
As I test, if i set ExerciseType.JUMP_ROPE , the Accelerometer sample rate will be 100HZ,
ExerciseType.RUNNING will be 20HZ.
It seems that WHS has some side effects on Accelerometer.😢
If I use WHS, I may not be able to control the sampling rate
@haozes Unfortunately it's possible for WHS to affect the behavior of the Android SensorManager. (The sampling rate is "only a hint to the system".) Can you provide your WHS configuration? What's your overall goal/use case?
Also, if it's not possible for the system to generate samples at the rate you specify, what would be the next best behavior be? (From your second comment it seems that having different rates for different exercise types is especially unexpected—would you prefer them to be consistent, at least?)
@ithinkihaveacat thank you for reply.
I use watch accelerator data to compute jump rope repetition. It depends on my own algorithm. So I must specify a sample rate.
This is what i built on watchOS: https://apps.apple.com/app/yaoyao-jump-rope/id1179393901
When i have not use WHS, the Watch workout auto detection always interrupt my app after jump 10min.
As I test, after using WHS, Watch auto workout detection disappears. That what i want WHS to do, only this thing.
But now, that is all undefined. so disappointed, Maybe from the beginning, It didn't fully consider others to making a workout app on wearOS.
If it's not possible for the system to generate samples at the rate I specify,
let me know what's sample rate now in different types of exercise.
Otherwise it's impossible to build a workout app depending on anyone's own algorithm.
PS: My WHS config
private val workoutType:ExerciseType = ExerciseType.JUMP_ROPE
----
suspend fun startExercise() {
Log.d(TAG, "Starting exercise")
// Types for which we want to receive metrics. Only ask for ones that are supported.
val capabilities = getExerciseCapabilities() ?: return
val dataTypes = setOf(
DataType.HEART_RATE_BPM,
).intersect(capabilities.supportedDataTypes)
val aggDataTypes = setOf(
DataType.TOTAL_CALORIES
).intersect(capabilities.supportedDataTypes)
val config = ExerciseConfig.builder()
.setExerciseType(workoutType)
.setShouldEnableAutoPauseAndResume(false)
.setAggregateDataTypes(aggDataTypes)
.setDataTypes(dataTypes)
// Required for GPS for LOCATION data type, optional for some other types.
.setShouldEnableGps(false)
.build()
exerciseClient.startExercise(config).await()
exerciseClient.setUpdateListener(this).await()
}
Is this a good summary of your issue?
What you would like:
I think it's reasonable to want to disable the automatic activity recognition mechanism (I will look into this, although as I recall this was not as straightforward as it seems…). However I still think you should not depend on receiving accelerometer data at a constant rate since the sampling period is only a hint (see ref above).
Can you adapt your algorithm to deal with a variable rate?
Thank you for your advice. I will change my algorithm to adapt a variable rate.
I use WHS and Accelerator at the same time.
After using the HealthServices and exerciseClient to start startExercise,
the the accelerator always sampled by 100HZ, not the sample rate which i specified.
Is this a bug?
BTW: Test on galaxy watch 4