Hi everyone, I tried to follow this tutorial
FRC Java Tutorial - WPILib 2022 Command Based Programming Ep 3:Autonomous Trajectory & Path Planning - YouTube (checkout time : 1h12 min)
trying to learn about trajectories and cannot have the Roborio loading the generated JSON files. I used the PathPlanner to generate my paths and placed them in the deploy folder.
I am pretty sure that the problem resides in how I copy the path
I tried to copy the relative path
//When simply copying the path - the windows format is wrong and gives an error
m_choixTrajectoireAuto.addOption("Aller au element de jeu", lierTrajetsACommandeRamsete(" C:\Users\src\main\deploy\deploy\pathplanner\generatedJSON\SnakePath.wpilib.json", true));
// Tried to swap the "\" for "/" still does not work
// Tried to copy the relative path instead still does not work - Ex: src/main/deploy/deploy/pathplanner/generatedJSON/SnakePath.wpilib.json
// tried to shorten path still doesn't work ex: pathplanner/generatedJSON/SnakePath.wpilib.json
// Here is the code for the commad tying the file to the Ramsete command
public Command lierTrajetsACommandeRamsete(String fileName, boolean resetOdometry) {
Trajectory trajectory;
try{
Path trajectoryPath = Filesystem.getDeployDirectory().toPath().resolve(fileName);
trajectory = TrajectoryUtil.fromPathweaverJson(trajectoryPath);
}catch(IOException exception){
DriverStation.reportError("Incappable d'ouvrir la trajectoire" + fileName, exception.getStackTrace());
System.out.println("Impossible de lire le fichier" + fileName);
return new InstantCommand();
}
I basically tried with no success - here is the stacktrace message
- Error at frc.robot.RobotContainer.lierTrajetsACommandeRamsete(RobotContainer.java:112): Incappable d’ouvrir la trajectoire/SnakePath.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.RobotContainer.lierTrajetsACommandeRamsete(RobotContainer.java:112)
- at frc.robot.RobotContainer.(RobotContainer.java:88)
- at frc.robot.Robot.robotInit(Robot.java:30)
- 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)
- Impossible de lire le fichier/SnakePath.wpilib.json
Any help would be so appreciated!