Fixed rot_deg to compare heading to its previous value in order to detect when the 180 degree mark is passed.