Drive straight forward function

Is it possible and as accurate to create a drive straight program that corrects using an inertial sensor heading value As the inertial sensor heading value is always positive (0-360),instead of two encoders on each side of the robot.

Does this work?

int Heading = Inertial.Heading() % 360;

-30%360

530%360

2 Likes

or use rotation() which does not roll over from 359.9 to 0. You could set rotation to 0, it will then return +/- values depending of you have rotated slightly right or left.

5 Likes