Loop time of 0.02s overrun warning message + question about robot's default period and how fast should the roboRIO loop for MP



I remember I ran into a similar problem like this last year where motor outputs and the drivetrain outputs were not updated enough, as well as motor safety check. That was simply solved by setting the expiration, and setting safety enabled to false.

motor.expiration = Robot.period // default period of robot = 0.02s
motor.isSafetyEnabled = false

And same with the drivetrain:

differentialDrive = DifferentialDrive(leftMaster, rightMaster)
differentialDrive.expiration = Robot.period
differentialDrive.isSafetyEnabled = false

But for some reason there is still this one additional warning that pops up which I don’t know how to get rid of:

Warning at
(IterativeRobotBase.java:273): Loop time of 0.02s overrun

On the same topic of robot expiration times, I was reading up on the motion profiling manual from CTRE, and saw that trajectory points have a set time, usually 10ms as a default, and a notifier must be used to make sure it has sufficient time to process the points which must run at twice the speed as the points are being processed so 5ms, so does this mean I have to set the robot’s default period to 5ms by simply setting the period of TimedRobot to 0.005 or is it more complicated than that?


You should be using TimedRobot instead of IterativeRobot. Regarding the warning, it’s simply informational. It won’t disable any motors, it’s just letting you know that the loop is taking longer to run than you’ve asked it to run. The warning cannot be disabled.

For feeding something like trajectory points which is not done all the time, it’s typical to have a separate Notifier set up (on a separate thread), rather than speeding up the entirety of TimedRobot. Notifier takes a Runnable so you can execute an arbitrary function at the periodic rate of the Notifier, e.g. (Java code)

Notifier follower = new Notifier(() -> { /* do something */ });

will do something every 5 ms in a separate thread of execution.


There’s something in your code that is causing each loop to take longer than 20 ms. If you post it, we can help find it. Nothing should run longer than 20 ms, especially using JVM or C++.

Disabling MotorSafety is never never never never never never the answer. Don’t do it.


should is the operative word here. Yes, posting code would help.


My code is on Github


Try removing the log() function that outputs stuff to SmartDashboard and see if that addresses the issue?


I think I realize what the problem might be, I was also running into another problem:

ERROR -44019 FRC: The mDNS service is slow to respond. Check firewall settings. Driver Station

I usually don’t bat an eye to this problem since by regionals it doesn’t show up during matches. Is there a way to fix this problem?


I’m having the same issue. I’m using 254’s looper structure and that thread is running on time every 5ms, presumably at the expense of the TimedRobot periodic methods. Is there any recommendation other than ‘make your code faster’?