1

Currently using the Apple Watch to calculate its yaw, pitch, and roll angles.

However when trying to use the Core Motion functions, the app crashes. Has anyone experienced this problem?

if motionManager.deviceMotionAvailable{
    self.referenceAttitude = self.deviceMotionManger.attitude
    let currentAttitude : CMAttitude = self.deviceMotionManger.attitude
    currentAttitude.multiplyByInverseOfAttitude(self.referenceAttitude)
    self.Yaw.setText( "Yaw " + String(format: "%.1f", currentAttitude.yaw))
    self.Pitch.setText( "Pitch " + String(format: "%.1f", currentAttitude.pitch))
    self.Roll.setText("Roll " + String(format: "%.1f", currentAttitude.roll) )
}

else {
    self.Yaw.setText("device motion is not" + String(motionManager.deviceMotionActive))
}
2
  • 1
    Crashes with what error?
    – zoul
    May 19, 2016 at 6:45
  • The comment below answered my question. None of the other sensors are functional on the apple watch. @zoul May 19, 2016 at 22:55

1 Answer 1

2

The only Core Motion data available from the Apple Watch is raw accelerometer data.

The watch won't provide raw gyroscope data, raw magnetometer data, or processed device-motion data; deviceMotionAvailable will always return false.

As for a crash, you would get a "fatal error: unexpectedly found nil while unwrapping an Optional value" when the outlet for your implicitly unwrapped Yaw label is not connected to the storyboard.

2
  • How can I use the accelerometer data to get the yaw, pitch, and roll of the device? @PetahChristian May 19, 2016 at 23:05
  • You could try some other answers, but it's really not practical or possible using raw accelerometer data alone. You may want to submit a feature request.
    – user4151918
    May 19, 2016 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.