im using an inertial sensor but there is a problem.
the robot starts turning, but it never stops.
my code is below:
vexcodeInit();
IS.calibrate();
LDrive.spin(forward);
RDrive.spin(reverse);
waitUntil((IS.rotation(degrees) >= 90));
Chassis.stop();
I’d guess that it’s turning in the wrong direction, so the rotation never gets there. Try using IS.heading() instead of rotation.
I started tweaking the code and got this:
while (1){
if (IS.heading >= 90){
Chassis.stop();
break;
}
else if (IS.heading < 90) {
LDrive.spin(forward);
RDrive.spin(reverse);
}
}
This works fine in a testing file, but when copied onto my competition template file, the robot does not move at all. The code is the exact same. I do not think there is anything wrong with the code inside of the competition template file either. I don’t have the competition template file on me right now, but I will post it here later. Any help would be GREATLY appreciated!!!
Thanks!
Send your full code by exporting it as a zip.
If this is auton code, then it won’t run unless you either use Timed Run, Programming Skills, or a field controller. Also, make sure it is inside your auton function.