Loop Timing on Robot Drive

We have been doing some experimenting with an issue we have put off for a while. We read our joysticks in teleop and then set global variables. We actuate the motors, including drive in periodic.

This works well and our robots drives just fine. However when we set our loop time to 100ms, setting our Drive vi, we get the following error/message at the diagnostic tab of the driver’s console.

Robot drive is running too fast or being starved due to too much code.

When we set that loop for 10ms, no diagnostics error/message.

The performance of the robot does not change. The setting of the drive is the only action in the loop. This error does not seem to hurt us, but I have wondered for a while why we get it and was hoping for some help from the community.

The error you’re experiencing (“the loop that contains RobotDrive is not running fast enough…”) occurs when the default safety timers within the drive code trip. Whenever the drive motors go >100ms without an update, the motors will be disabled. This prevents things like runaway robots.

When you set the wait on your loops to be 100ms, you’re cutting this threshold very close. The Wait VI is not extremely precise (it’s good enough for our purposes but there are ways to do it with more accuracy), and it’s possible that your loop times could differ by a little bit, thus tripping the safety.

If you reduce the wait on your loop (~20ms is usually pretty good - that’s the speed at which new packets are received by the robot), you should eliminate this problem. Times greater than 20ms often occur some control lag, since new data is being sent faster than the robot can process it, and you want your loops throttled somewhat to be nice to the CPU. 20ms is a pretty good number for this.

Alright, thank you very much! We changed it to wait to 20 milliseconds and that fixed the problem. Its alwasy nice to know why solution works, so thanks for explaining.