PID or auto correcting turn system help

Here is how you do forward/backward and turn PID:

for your turning, replace the variable from rightencoder-leftencoder to the inertial sensor heading