NullPointerException when using PathWeaver

Before I begin I would like to ask if it is recommended to use the autogenerated trajectory code that Pathweaver makes or is it better to manually set it in the ramsete command. Which one is quicker, which one is easier, which one ultimately grants better control. Now onto the problems. Whenever I deploy my code it throws a nullpointerexception such as:
Unhandled exception: java.lang.NullPointerException: Parameter trajectory in method RamseteCommand 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!

Which probably means that it didn’t find the JSON file. It does trigger the “catch” in the code so I think we know that. Because this was the code from the documentation I assume this may be a fairly common issue. This is my code here:

In this code I have comments detailing the file path on my laptop and the one that I believe is on the roborio. From my understanding, the Pathweaver file should be on the roborio’s physical storage. I moved the JSON file I made in Pathweaver onto the roborio using FileZilla but is this the right approach? Is this the way I should get the files onto the roborio? As well I want to ask whether the project directories in Pathweaver are correct?:

Here I have the file paths on my roborio, the json is actually in two locations I tried, one in the “Pathweaver” folder and the other in the “paths” folderimage

And just for the icing on the cake if you want to see how I used the Pathweaver class:

Any help at all is greatly appreciated thank you!

Have you looked at whether trajectoryPath contains the value you expect?

I think trajectoryPath is null because in DriverStation is the reported error the code runs so I think the issue is to do with not fetching the file properly. Just as a side note the method parameter “path” is not really being used properly since it was originally meant to choose different paths according to different placements on the field. I only have one pathweaver project so its a bit redundant as of now

Your issue is in the file path you’re expecting: you’re passing an absolute path where a relative one is expected. You should pass the path relative to the deploy directory.

As for the directories in pathweaver, the Project Dir should be set to the folder containing the project’s build.gradle, and then iirc the output dir should automatically point to the /deploy/ folder inside that project (not directly though, there are a few directory levels in between). Anyway, that’s the file path you should be resolving against getDeployDirectory.

Do you understand the differences between absolute and relative paths?

Your code is calling through the Java Path class to resolve a relative path.

You can infer from the code that the getDeployDirectory() method will return you the base directory of the deploy path, and then the code tries to resolve the file path of the object referenced by your String url variable.

In your case, you’re passing an absolute path to the resolver, which is building a string of paths that don’t make sense.

If you look a little bit higher in the stack trace you were given, there’s actually a String printout of the path it is trying to look for to make sure that you have the things you need.

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