I have some code in which I am waiting on the current x,y,z position of a motor to be equal to the position I sent to the motors. There is no command to ask the motors directly so I set up a boolean to be set to true when the current.x , current.y, and current.z are equal to my move(x,y,z) numbers.
I have tried several different ideas, first, setting up a timer and on each tick of the timer, check if the values are equal. But with this attempt I can’t get the code to wait if they are not equal.
I also tried a recursion method where if the boolean was false, wait some milliseconds and check again. The code said I had infinite recursion and returned a stackoverflow.
How can I wait for the motors to stop moving before sending my next command?
(The only data I can access from the motor is the current position of it)
You can create an event and register the waiting code with the event. Back in the motors code, as soon as the values matches, you can fire the event.