Lesson: Exercise: Using a Gyro

Explore using the Gyroscope Sensor device to gather information about the robot's environment.

Understand how to use the Gyroscope Sensor to gather information about the robot's environment.


Modern Robotics has an gyroscopic sensor designed for use with the Tetrix control system. This sensor can return heading and rate of rotation information. The FTC SDK has a sample program you can use to experiment with the Gyro sensor. In AS, open the path FtcRobotController/java/[first package]/external.samples/SensorMRGyro. You can enable this program and work with it but any changes you make will be overwritten at the next update of the SDK. You can copy the class to the teamcode area so any changes you make will be retained.

Here is a detailed discussion of the Gyro sensor on the Modern Robotics website. There are links on the page to programming information. This is recommended viewing.

Below is a simplified sample program that uses a gyro to drive in a straight line and avoid obstacles by backing up from contact with an obstacle and turing 90 degress and resuming driving in the new direction. You can paste it into AS and experiment with it.