my inertial proportional turn works fine when turning right but it spins forever when turning left.
pls help
void inertialTurn(double targetHeading, bool turnDirection ){
IS.resetRotation();
double error = targetHeading;
double Kp = 0.5;
double motorSpeed;
while (fabs(error) > 3){
motorSpeed = Kp*error;
if (turnDirection == true){
LDrive.spin(forward, motorSpeed, pct);
RDrive.spin(reverse, motorSpeed, pct);
}
else if (turnDirection == false){
LDrive.spin(reverse, motorSpeed, pct);
RDrive.spin(forward, motorSpeed, pct);
}
error = targetHeading - IS.rotation(degrees);
}
Chassis.stop();
}
theres the code
any help would be greatly appreciated!!!