This code near the end of the PID task is the “exit” condition:
// stop PID from controlling motors when at target
if ((fabs(error) < deadBand) || pidAbort) {
enableDrivePID = false;
}
If the abort is working then the error is not smaller than deadBand. What is your value of kP? It may be too small to move the motors when the error is small that is why there is a dead band.
I’ve been thinking about how the current code uses lateralMotorPower +/- turnMotorPower. I think it needs to use the arcade drive scaling methods.
I have some equations that can be found here, (the 127 is for joystick value, so that would change to 12 for voltage). https://timeconfusing.github.io/arcade.html
Also, when using turnPID the importance of output clamp can be seen when either value exceeds the max input value for motor.spin(). Take the case where output is not clamped and the forward value reaches 18 and the turn value is 6.
leftside = 18 + 6 = 24
rightside = 18 - 6 = 12
motor.spin() internally clamps to 12 and 12 so turning does not happen
now if the output s are clamped