wpilibsuite / allwpilib

Official Repository of WPILibJ and WPILibC
https://wpilib.org/
Other
1.08k stars 611 forks source link

`TrajectoryUtil.fromPathweaverJson()` fails to read Pathweaver JSON #5012

Closed Daltz333 closed 1 year ago

Daltz333 commented 1 year ago

Reading a valid trajectory with code

try {
    var trajJson = Filesystem.getDeployDirectory().toPath().resolve("paths/GoStraight.wpilib.json");

    m_currentTraj = TrajectoryUtil.fromPathweaverJson(trajJson);
} catch (Exception ex) {
    DriverStation.reportError("Failed to init trajectory with exception: " + ex.getMessage(), ex.getStackTrace());
}

Results in a crash related to it failed to read the JSON

Error at frc.robot.StateMachine.updateAutonomous(StateMachine.java:46): Failed to init trajectory with exception: [json.exception.type_error.302] type must be number, but is null
        at edu.wpi.first.math.WPIMathJNI.fromPathweaverJson(Native Method)
        at edu.wpi.first.math.trajectory.TrajectoryUtil.fromPathweaverJson(TrajectoryUtil.java:78)
        at frc.robot.StateMachine.updateAutonomous(StateMachine.java:46)
        at frc.robot.Robot.autonomousPeriodic(Robot.java:74)
        at edu.wpi.first.wpilibj.IterativeRobotBase.loopFunc(IterativeRobotBase.java:344)
        at edu.wpi.first.wpilibj.TimedRobot.startCompetition(TimedRobot.java:130)
        at edu.wpi.first.wpilibj.RobotBase.runRobot(RobotBase.java:343)
        at edu.wpi.first.wpilibj.RobotBase.lambda$startRobot$0(RobotBase.java:413)
        at java.base/java.lang.Thread.run(Thread.java:833)

I have attached the JSON below.

GoStraight.zip

sciencewhiz commented 1 year ago

It's a bad path because of this issue: https://github.com/wpilibsuite/PathWeaver/issues/274