Loop time of 0.02s Overrun - FRC 2020 Programming Question

We have an issue in our code starting with the new season ever since we updated our CTRE Phoenix framework. We have written code for our robot after updating everything (radio, RoboRio, wpilib vscode, etc.) and after deploying we get this error:
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:276): Loop time of 0.02s overrun

For reference, we are coding in Java.

We have tried adding
leftVictor.setExpiration(5.0);
rightVictor.setExpiration(5.0);

to robotInit() in our code, but we receive the same exact error, 0.2 seconds included (doesn’t change loop time)

What should we do next to fix this error?

Do you just get that message once on startup? Because of how Java works, that message has about a 90% chance of occuring the first iteration of robot code, and safely can be ignored. You only need to be concerned if it happens continuously and often.

It does only occur once on startup, but our code won’t run and we think this is the cause. It additionally occurs every time code is deployed without failure (so far)

There is something else causing your code to not run. That message in itself will not cause code to not run, and because of how Java works it will happen every time code deploys or restarts. That message can safely be ignored on startup, and will not cause code to not work. Is there any other messages occurring?

Also, does your code seem to be continously rebooting? If not, you might have an infinite loop somewhere in your robot code. We’d need to see your code or another error message to help debug that.

Not continuously rebooting. Here’s the code we are trying to use:

public class Robot extends TimedRobot {
      WPI_VictorSPX leftVictor = new WPI_VictorSPX(6);
      WPI_VictorSPX rightVictor = new WPI_VictorSPX(5);
      XboxController control = new XboxController(0);
    ...
    public void teleopPeriodic() {
       boolean noButtons = !(control.getAButtonPressed()) && !(control.getBButtonPressed()) && !(control.getXButtonPressed()) && !(control.getYButtonPressed());
        if (control.getAButtonPressed()) leftVictor.set(ControlMode.PercentOutput, 1.0);
        if (control.getBButtonPressed()) rightVictor.set(ControlMode.PercentOutput, 1.0);
        if (control.getXButtonPressed()) leftVictor.set(ControlMode.PercentOutput, 0.5);
        if (control.getYButtonPressed()) rightVictor.set(ControlMode.PercentOutput, 0.5);
        if (noButtons)
        {
          leftVictor.set(ControlMode.PercentOutput, 0.0);
          rightVictor.set(ControlMode.PercentOutput, 0.0);
        }
    }

Additionally, here is our RioLog:
********** Robot program starting **********
Default disabledInit() method… Override me!
Default disabledPeriodic() method… Override me!
Watchdog not fed within 0.020000s
Loop time of 0.02s overrun
SmartDashboard.updateValues()Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:276): Loop time of 0.02s overrun
:
0.014156s
disabledInit(): 0.005914s
disablePeriodic(): 0.001668s
robotPeriodic(): 0.000114s
LiveWindow.updateValues(): 0.076894s
Shuffleboard.update(): 0.000112s
[phoenix] Library initialization is complete.
Default teleopInit() method… Override me!
Default disabledInit() method… Override me!

we are actually currently experiencing the same problem, as our auton code is not initializing.

What makes you think your code isn’t running? I don’t see any print statements or other diagnostics in there; it seems entirely likely that it’s running just fine and simply isn’t doing what you expect it to.

1 Like

You’ll probably want to look into the difference between the getAButtonPressed and getAButton methods.

https://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/XboxController.html#getAButtonPressed()

2 Likes

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.