Quote:
Originally Posted by Chexposito
we also had to create a function that converted the counts from 0 to 360 no matter what the count. then a pass that into another function that decided the closest way to get to the heading determined by the joystick. then had to do vector addition from the joystick to create ... a degree for the heading.
|
Since you are a programmer you may be interested in this. The following 2 lines of C code will do everything mentioned above. Try it with any gyro angle (positive, negative, greater than 360, etc) and any Joystick coordinates:
Code:
error = atan2(Xj,-Yj)*180/pi - gyroAngle;
error = error-360*floor(0.5+error/360);
"Xj,Yj" are the "uncorrected" joystick coordinates (Yj = -1 is full forward)
"gyroAngle" is in degrees clockwise
"error" is the clockwise angle error in degrees. It is the shortest path to the target.