From the course: Advanced iOS App Development: Core Motion

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Rotation rate with the gyro

Rotation rate with the gyro - iOS Tutorial

From the course: Advanced iOS App Development: Core Motion

Start my 1-month free trial

Rotation rate with the gyro

- [Narrator] In fencing, all motion should be that linear Y motion in a thrust attack. You are not allowed to slash. However, in saber, slashing is allowed. Let's look at adding slash movements by reading the rotation rate of another sensor, the gyroscope. The slash motion we'll make is a high rotation rate, either positive or negative, along the Z-axis. At the same time, we have a thrust acceleration in Y. I'll measure rotation rates through the gyroscope. Unlike the accelerometer, the gyroscope needs time to start up, as much as three seconds. Before using that sensor, check to make sure it's available. So let's go into the code again. Close the console and put under our thrust and parry, if self.motionManager.isGyroAvailable. Make a block. And afterwards, make it else. If it's not, we'll print a message, "Gyro not available yet." In the code for the gyro, I'm going to make another constant, let gyro = deviceMotion.rotationRate. We'll have an X, Y, and Z in gyro that we can then use…

Contents