ExamplesField-Oriented Drive (FRC)Full LabVIEW Source code on GithubRotate to Angle (FRC)Automatically rotating a robot to an angle using navX-MXP can be used to rotate a robot quicklyand accurately to a known angle, as long as the robot drive system provides independent Z-axisrotation (the capability to “spin on a dime”). This same technique can be used to help a robotdrive in a straight line.This example code below will automatically rotate the robot to one of four angles (0, 90, 180and 270 degrees) whenever the corresponding “rotate to preset angle” button is pressed. Thisrotation can occur not only when the robot is still, but also when the robot is driving. When usingfield-oriented control, this will cause the robot to drive in a straight line, in whatever direction isselected.This example also includes a feature allowing the driver to “reset” the “yaw” angle. When thereset occurs, the new gyro angle will be 0 degrees. This can be useful in cases when the gyrodrifts, which doesn’t typically happen during a FRC match, but can occur during long practicesessions.41