package frc.robot.subsystems;
import java.io.IOException;
import java.nio.file.Path;
import edu.wpi.first.math.trajectory.Trajectory;
import edu.wpi.first.math.trajectory.TrajectoryUtil;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.Filesystem;
public class pegatrajeto {
String trajectoryJSON = "paths/Unnamed_.wpilib.json";
Trajectory trajectory = new Trajectory();
try {
Path trajectoryPath = Filesystem.getDeployDirectory().toPath().resolve(trajectoryJSON);
trajectory = TrajectoryUtil.fromPathweaverJson(trajectoryPath);
}catch (IOException ex) {
DriverStation.reportError("não foi possivel abrir a trajetoria:" + trajectoryJSON, ex.getStackTrace());
}
}
i am triing to initialize a pathweaver trajectory in a separate archive, to reference it in the autonomous mode in robot container. i copied the example code from FIRST site ant it has something that is not right
[{
"resource": "/e:/coisas/programations/swerve-2/src/main/java/frc/robot/subsystems/pegatrajeto.java",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "1610612967",
"severity": 8,
"message": "Syntax error on token \";\", { expected after this token",
"source": "Java",
"startLineNumber": 14,
"startColumn": 45,
"endLineNumber": 14,
"endColumn": 46
}]
and
[{
"resource": "/e:/coisas/programations/swerve-2/src/main/java/frc/robot/subsystems/pegatrajeto.java",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "1610612976",
"severity": 8,
"message": "Syntax error, insert \"}\" to complete ClassBody",
"source": "Java",
"startLineNumber": 22,
"startColumn": 1,
"endLineNumber": 22,
"endColumn": 2
}]
it is probably a very dumb solution, but i’m not too familiar with java and how to reference it properly