Generic Sensor, readMySensorCallback(), does it need to return between 0 and 2*PI?

Saw these instructions in the documentation and was confused because the standard encoder sensor appears to return the angle in radians but might return a number much greater than 2*PI.

Does the generic sensor actually need to return a number between 0 and 2*PI or will the angle (for any number of revolutions) in radians work? I haven’t found any evidence yet that the number needs to be within 0-2*PI (and I’m pretty sure if the was the case, the standard encoder would be broken).

I’m relatively new to the library and trying to wrap my ahead around the innerworkings… trying to figure out if I’m missing something.

Hi @Jonathan_Bowen,

The angle needs to be between 0 and 2PI, the library itself will make sure to count the number of full rotations and calculate the electric angles and all the other stuff needed for the library. :smiley:

We have chosen to handle the rotation counting internally because in this way we have the full control of how this is handled and we are able to remove some float rounding errors within the library.

So in your case, if you provide the angle between 0 and 2pi to the generic sensor, it will count itself the revolutions and you will still be able to get the absolute angle with sensor.getAngle().

Thanks for the information!