Robot Lagging Behind

Hi everyone!

Our team is having an issue where the robot only moves after a weird .5 second delay in our driver control task (i.e. if we tap and release a button for the rollers, they’ll intake and stop after a short delay). We only sleep for 5 milliseconds each cycle, and most of the controls involve simply running the motors when a button is pressed or braking.

while (true){
if(button.pressed){
motor.spin(----);
}
else{
motor.brake(----);
}
sleep(5);
}

Does anyone have a suggestion for how to fix this?

Thanks for your help!

Temporarily remove the wait and see if the problem is no more. In addition, I find vex::task::sleep(amount); to work reliably for me as it measures in miliseconds, but I find anything less than 20 miliseconds go beyond unnecessary.

1 Like