Answer the question
In order to leave comments, you need to log in
How to detect jump with Core Motion?
I'm trying to make an application for counting jump rope, I just can't figure out how to implement the definition of a jump. Couldn't find any tutorials or any hint how to do it.
Please help!
final class WorkoutViewController: UIViewController {
private var motionManager = CMMotionManager()
private var jumpCounter = 0
func jump() {
let xAxis = motionManager.deviceMotion!.userAcceleration.x
let yAxis = motionManager.deviceMotion!.userAcceleration.y
let zAxis = motionManager.deviceMotion!.userAcceleration.z
let xGravity = motionManager.deviceMotion!.gravity.x
let yGravity = motionManager.deviceMotion!.gravity.y
let zGravity = motionManager.deviceMotion!.gravity.z
// I don't know how to detect a jump here
}
override func viewDidLoad() {
super.viewDidLoad()
motionManager.deviceMotionUpdateInterval = self.updateDataInterval
motionManager.startDeviceMotionUpdates(to: .main) { (_, _) in
self.jump()
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question