My yaw angle varies from -180 degree to 180 degree.
-170 170
-135 135
-90 90
45 45
10 -10
If my current heading is about 170 degree, then the wind makes it rotate to the left at about -170 degree, then how can PID control it to make it rotate back to the right at 170 degree.
Since, for PID ERROR = SETPOINT - INPUT
In my case, SETPOINT = 170
, and INPUT = -170
, the the ERROR = 170 - (-170) = 340
.
So instead of moving to the right and apply PWM = 20
, it rotate to the left and apply PWM = 340
and come back to the desired position, which is 170 degree?