Wrap robot angle between -180 and 180

This commit is contained in:
Ulysse Cura 2025-05-27 23:04:10 +02:00
parent d964cdf9cf
commit 4505d68705
1 changed files with 3 additions and 0 deletions

View File

@ -59,4 +59,7 @@ void get_inputs(void)
if(controller.inputs_buffer.buttons_states[BUTTON_R])
controller.inputs_buffer.robot_angle -= controller.delta_time_ms / 1000.0f * ANGLE_PER_SECOND;
if(controller.inputs_buffer.robot_angle > 180) controller.inputs_buffer.robot_angle -= 360;
if(controller.inputs_buffer.robot_angle < -180) controller.inputs_buffer.robot_angle += 360;
}