Pathplanner Code overruns

I am trying to implement pathplanner to our swerve drive code. Predefined trajectory code works fine with the Simulation however when I try to use imported pathplanner trajectory Sim Gui crashes due to an overrun. Any suggestions?

PathPlannerTrajectory examplePath = PathPlanner.loadPath("ay", new PathConstraints(4, 3));

var thetaController = new ProfiledPIDController(
    AutoConstants.kPThetaController, 0, 0, AutoConstants.kThetaControllerConstraints);
thetaController.enableContinuousInput(-Math.PI, Math.PI);

SwerveControllerCommand swerveControllerCommand = new SwerveControllerCommand(
    examplePath,
    m_robotDrive::getPose, // Functional interface to feed supplier
    DriveConstants.kDriveKinematics,

    // Position controllers
    new PIDController(AutoConstants.kPXController, 0, 0),
    new PIDController(AutoConstants.kPYController, 0, 0),
    thetaController,
    m_robotDrive::setModuleStates,
    m_robotDrive);

Can you post your full error message?

Are you using the latest version of pathplanner? The latest version no longer takes a ProfiledPIDController.

Warning at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:373): The robot program quit unexpectedly. This is usually due to a code error.
The above stacktrace can help determine where the error occurred.
See Reading Stacktraces — FIRST Robotics Competition documentation for more information.
Error at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:380): The startCompetition() method (or methods called by it) should have handled the exception above.
Warning at edu.wpi.first.wpilibj.IterativeRobotBase.printLoopOverrunMessage(IterativeRobotBase.java:387): Loop time of 0.02s overrun

Yes it is the latest version

Above that output block there should be a full stack trace which looks something like this:

Error at frc.robot.Robot.robotInit(Robot.java:23): Unhandled exception: java.lang.NullPointerException
        at frc.robot.Robot.robotInit(Robot.java:23)
        at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:107)
        at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:373)
        at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:463)
        at frc.robot.Main.main(Main.java:23)

Could you paste that here?

1 Like

Error at java.base/java.util.Objects.requireNonNull(Objects.java:233): Unhandled exception: java.lang.NullPointerException: Parameter trajectory in method SwerveControllerCommand was null when it should not have been! Check the stacktrace to find the responsible line of code - usually, it is the first line of user-written code indicated in the stacktrace. Make sure all objects passed to the method in question were properly initialized - note that this may not be obvious if it is being called under dynamically-changing conditions! Please do not seek additional technical assistance without doing this first!
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at edu.wpi.first.util.ErrorMessages.requireNonNullParam(ErrorMessages.java:27)
at edu.wpi.first.wpilibj2.command.SwerveControllerCommand.(SwerveControllerCommand.java:197)
at edu.wpi.first.wpilibj2.command.SwerveControllerCommand.(SwerveControllerCommand.java:74)
at edu.wpi.first.wpilibj2.command.SwerveControllerCommand.(SwerveControllerCommand.java:119)
at frc.robot.RobotContainer.getAutonomousCommand(RobotContainer.java:118)
at frc.robot.Robot.autonomousInit(Robot.java:88)
at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:320)
at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:130)
at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:358)
at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:431)
at java.base/java.lang.Thread.run(Thread.java:833)

Your trajectory is null

Start tracing back from here frc.robot.RobotContainer.getAutonomousCommand(RobotContainer.java:118)

3 Likes

This likely means you typed in the name of the path wrong when loading it in code.

I’m trying Path Weaver, too. But it say that unable to open trajectory. Could you help me?
error codes:

  • Unable to open trajectory: paths/blueRight.wpilib.json

  • Error at frc.robot.Robot.robotInit(Robot.java:54): Unable to open trajectory: paths/blueRight.wpilib.json

  • at edu.wpi.first.math.WPIMathJNI.fromPathweaverJson(Native Method)

  • at edu.wpi.first.math.trajectory.TrajectoryUtil.fromPathweaverJson(TrajectoryUtil.java:78)

  • at frc.robot.Robot.robotInit(Robot.java:54)

  • at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:106)

  • at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:343)

  • at edu.wpi.first.wpilibj.RobotBase.startRobot(RobotBase.java:433)

  • at frc.robot.Main.main(Main.java:23)

Do you know how to find your deploy directory in your robot project? If so, send a screenshot of the contents.


This?

In this case, the file in the deploy directory is blueRight1.wpilib.json not blueRight.wpilib.json. For PathPlanner, you have a deploy nested inside the main deploy. You need to move the pathplanner directory up one level to get the paths to be recognized. It should look like this:
image
(Ignore the apriltag directory)

1 Like

Oh WOW, I sucess. Thank you so much.

1 Like

You can mark my post as a solution in order to show the question as solved on the front page. Glad I could help.

I wanna do so. But I ain’t author, so I can’t do that, right(I am not sure)?

Never mind, you’re not.

1 Like

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