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
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
edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage
(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 */ });
follower.startPeriodic(0.005);
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 nevernevernever the answer. Don’t do it.
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’?