We are using the wpilib trajectoryutil.fromPathweaverJson method and having issues with paths generated with the current pathweaver (2022 WPILIB VSCode->Tools->Pathweaver). The files at a high level look similar enough to files we generated in 2020/2021, but we get this json exception:
Path filenames are: [‘C:\Users\15073\Desktop\FRC\code\git\rc2022/paths\1.json’]
Traceback (most recent call last):
File “C:\Users\15073\Desktop\FRC\code\git\rc2022\robot.py”, line 23, in
trajectories = list(map(TrajectoryUtil.fromPathweaverJson, filenames))
RuntimeError: [json.exception.type_error.302] type must be number, but is null
We’ve upgraded to all the latest NI, WPIlib, and RobotPy code. All of our previous paths generated with Pathweaver 2020/2021 work fine. It’s just new paths that throw the exception. We’re using the same code as previously, essentially just getting a list of files and turning them into trajectories:
trajectories = list(map(TrajectoryUtil.fromPathweaverJson, filenames))
This particular path is a basic move 1 meter straight line for testing.
Let me know if that works/fails. It will fail to deploy or load the sim with the “bad” path and at least load the sim and then complain with the “good” path.
The first curvature is “null” in the bad file. Were these generated from the same waypoints? For example, is this an issue where pathweaver is generating different output year to year for the same input, or is this an issue with a particular set of inputs that causes pathweaver to generate a bad output.
For this particular path, I basically just generated a single path and manually edited the coordinates to be (1,1) and (2,1) and then I believe I set the tangents manually to be straight along that path as well. I can certainly try a different path and see if that helps.
And, no, the “good file” is just one of many working paths we used. (I think it’s the first path of a generic 3 ball shooting sequence). I have a path that is essentially just move straight similar to the “bad” path (but generated in pathweaver 2020/2021) and that one works fine.
I took the bad file and replaced the null curvature on the first and last point and it loaded in Java. I am looking into why it would have a null curvature now.
So I just generated a new path by just clicking “+” to get a new path (so it makes the curve from the upper left hangar out and down). That path does work fine.
So something about my straight line path was not happy. I just checked and that path is just a line from (1,1) tangent (0,0) to (2,1) tangent (0,0). And… that’s the problem. If I make the tangents (1,0) it works fine. So, this was my fault.
Sorry for the false alarm. I think we’re ok now. I need to play with some more test paths, etc, but I think the 0 tangents was the problem.
No, not generally. We just did that path to verify our characterization values were reasonable. We do tweak paths manually but it’s normally just moving points and changing (nonzero) tangent values. So, certainly not a show stopper for us at least. I suspect most pathweaver users do similar things too (draw path, tweak it in the GUI, tweak tangents, etc)?
I agree I would only expect this to effect someone that did exactly what you did for testing (makes sense since it hasn’t been reported yet!). I added an issue here.