It's your problem?
After desired angle changes it sign(ie. 180->-180)
then suddenly control input(ie. P * error) becomes bigger.
For instance.
--------------------------------
| desired | real | error |
|-----------|--------|---------|
| 170 | 160 | 10 |
| -170 | 160 | -330 |
--------------------------------
If your problem is the same as I understood, how about this? Before you go, please note that it is assumed that all angle values are in the range from [-pi, pi].
error = desired - real;
if(error > 180)
error = error - 360;
else if(error < -180)
error = error + 360;
else
error = error;//do nothing
This method always selects the direction, so that the control input becomes smaller. (You know that there are two options for referral)
source
share