navX2-Micro can be used to rotate a robot quickly and accurately to a specified angle. This can occur not only with holonomic drive systems that provide independent Z-axis rotation (the capability to “spin on a dime” while also moving in a linear direction), but also on robots with only two drive motors This same technique can be used to help a robot drive in a straight line.
This example code below will automatically rotate the robot to a specified angle. This rotation can occur not only when the robot is still as in this example, but also when the robot is driving. When using field-oriented control on a holonomic drive system, this will cause the robot to drive in a straight line, in whatever direction is selected.
The PID Controller coefficients defined in the example code will need to be tuned for your drive system.
For more details on this approach, please visit Chief Delphi, including this helpful post.