How to end Function

Hello. I am currently working on an odometry system that will have an angle to point function. The purpose of this function is to turn the robot to a (x,y) on the field. I got the robot to turn to the angle and is within the error (+ or - 0.5 degrees). All of the motors come to a stop but there is one issue. The program is not exiting the function when it needs to (once the robot is within the desired error). Does anyone know how to end the function so the robot can move onto the next function in auton. A pic of the code is below.

Assuming you want to exit the function once you call Chassis_Group.stop() in each of the if/else blocks, if you add a line return; after each .stop(); that will exit the function.


This along with a 10 msec wait inside of the while loop got it working. Thank you for the help.

you could also do

bool x = 1;

// when x is true (1), it is active, when x is false (0), it is inactive.
while (x) {
// code in here