But it seems no one mentions how can I use the trajectories I created in PathWeaver in the WPILib Ramsete Command and Tajectory Following framework.
The problem for me is the use of Rotation2d objects in WPILib (I just don’t know how to find the x, y and angle values of the path I wish to create, looking on answers on that, too!). I was thinking to simply insert the x, y and tangent x, tangent y values of the PathWeaver trajectories, but the angle is made of two values, which I really don’t know how to integrate into the Rotation2d objects.
If anyone knows how to use those two and explain to me, as it seems i’m not so proficient in this topic, please write me.
Thanks!
You want to move the .wpilib.json into SRX/main/deploy, not the .path file. And note the docs for that article just got updated (by me). It’s fromPathweaverJson not fromPathweaverJSON.
Your trajectory variable is declared inside of the try catch statement, meaning it’s scope is contained within the statement. Try declaring the trajectory variable outside of the try catch. Trajectory trajectory; try { … trajectory = TrajectoryUtil.fromPathWeaverJson…
You need to set trajectory to something in the catch so either way it exists. Honestly though I would just hardcore the trajectories. Pathweaver is a pain to work with imo.
Yep, missed that part. The trajectory needs to be created outside the try catch but initialized in both parts. In the try it is from a file, in the catch you set it to go from it’s current pose to its current pose.
I meant hardcode not hardcore. Basically initialize them all in a class and use as needed.