calculateAngle - 18684092/Steering-Wheel-Project GitHub Wiki

calculateAngle

Access: Public

Prototype: Sint16 calculateAngle(Sint16 position)

Parameters: position is an Integer between -32768 to 32767.

Return Value: Sint16 value between -32768 to 32767.

Description: The full lock position, found during calibration, of both left and right, is added together to get the encoder count travel the wheel can make. That is divided by the number of (constant) DEGREES the wheel can turn by. In turn the current position is then divided by this calculation. If the left and right full lock count is not known, because calibration has not been done, then the constant SDL_MAX_UINT16 is used.

Angle = current position / ((left lock + right lock) / DEGREES)

Note: On G27 the full left lock is -32768 and the full right lock is 32767. On other wheels, specifically Sim Steering, the left and right lock are much smaller values since the wheel controller must make the end stops using software. The difference here is that G27 has a physical end stop at the end of itโ€™s rotational travel but Sim Steering has no physical end stop.

Related Functions: gotoAngle(), gotoAngleSlow(), gotoAngleFast(), gotoAngleFull(), findJitter(), findLeftLock(), findRightLock(), calibrate(), getAngle(), getPosition(), getCentre(), calculateAngle, getLeftLock(), getRightLock()