I am debating whether I should get the new inertial sensor to assist in turning. Does the gyro part wrap around to 0 when it gets to 360 or is it continuous? We figured out how to fix the drift with the old gyro but struggled with the wrap-around.
I’m not sure, but if it doesn’t “wrap around” it’s trivially easy to implement that yourself -
gyro_value % 360 (where
gyro_value is the value returned by the inertial sensor) will keep the value in the 0-360 range, effectively “wrapping it around” every time the robot does a complete circle.
% is the “modulo operator”, more on that here.
I want it to go beyond 360 though. As far as I know, it is a massive pain to detect if the robot has turned more than one rotation if it does wrap.
You have the choice, Inertial.heading() will wrap at 360 Inertial.rotation() does not.
Or you could check if it’s less than 0 and add 360, or if it’s over 360 subtract 360