The first time we run a PathPlanner auto after a new code deploy or restarting the robot there is always a lag of around 0.5 seconds. This causes a huge decrease in path accuracy; however, as soon as we run it again it works perfectly fine. This leads to inconsistent path following and it not traveling to the desired distance (way undershooting).
We haven’t configured it to run in simulation yet, so we can’t test it there.
4 m/s^2 acceleration and 3 m/s velocity.
We tried mapping the PathPlanner command to a button in teleop and it resulted in the same error (this happened regardless of when we hit the button in teleop, so it still occurred after moving the drivetrain).
It looks like it might be a loop overrun issue with the first time autos are run (1 Meter Auto.execute takes 0.038 seconds to run, causing the loop overrun).
We tried all of these options, but everything produced similar lag.
We were able to take data from our initial code and it produced similar lag every time. Here is a screenshot of our spreadsheet below (PathPlannerAutoName.execute always took the most amount of time by a significant magnitude).
Here is a slow-mo video of our robot running the auto the first time after a code deploy:
Here is a slow-mo video of our robot running the auto a second time after a code deploy:
It looks like the robot starts to move in auto as soon as the Loop Overrun message appears (around 14.8 seconds or so). In the second video it appears to happen immediately.
EDIT: Also, adding a 0.2 second wait command in the PathPlanner auto didn’t fix anything.
Java loads classes “on demand” (the first time a function is called in a class, the class is loaded). This means the first call may take significantly longer than later calls, particularly for cases when there’s a lot of static construction or the function pulls in many other classes, such as loading json does. There’s really not a good workaround for this other than trying to find ways to exercise the code path in disabled; I was doing some work in the offseason on a (conservative) class preloader but the Rio really doesn’t have enough memory for that.
We were able to run a PathPlanner Auto in disabled and this fixed most of our issues. We also added a 0.01 second delay to our all of our Autos and it seemed to fix a small swerve delay that was also causing issues after implementing this fix.
Thank you to everyone for their help.
Here is our Robot.java code that has the fixes talked about above:
Specifically we changed disabledInit to run a PathPlanner Auto with these lines: Command autonInitCommand = new PathPlannerAuto("1 Meter Auto").ignoringDisable(true); autonInitCommand.schedule();
We added a simple WaitCommand in our autonomousInit like this: Command autonCommand = new WaitCommand(0.01).andThen(Auton.getAutonomousCommand());