Problem of Stacktraces

There are some problems whem I am run my auto code. By the way, I can run it 2 hours ago, and I don’t change anything. This is the message.

I have seen Reading Stacktraces by FIRST. But I still don’t know how to do, because I’m actually a design team member. Fortunately, we have a competition tomorrow. So, if there is anyone see this, please help me. Below is my codes.

Constants.java (7.6 KB)
CTREConfigs.java (2.7 KB)
Main.java (775 Bytes)
Robot.java (4.1 KB)
RobotContainer.java (2.7 KB)
SwerveModule.java (4.9 KB)
exampleAuto.java (2.6 KB)
TeleopSwerve.java (1.6 KB)
Swerve.java (5.1 KB)

You tried to generate a trajectory with a set of waypoints that cannot be effectively interpolated with a spline, and the interpolation code is erroring when it encounters a singularity.

Try plotting your waypoints and look for sharp corners.

3 Likes

Looking at a stacktrace is the easy part! If you see the “Error at:” line in the screenshot, it will tell you where an error was detected, in this case in exampleAuto.java, at line 30. That’s where an error is occurs, but it may not be the true source of an error. Fortunately the rest of the stack trace gives you some context and where to look. You can work your way back up, if needed and follow how you ended up in exampleAuto.java:30. Main.java line 23 was the initial call, RobotBase line 433, etc.

As for your actual error, it is a TrajectoryGenerationException, from the screenshot. I’m not as familiar with generating trajectories but that seems to happen when you try to generate a trajectory that’s impossible to follow.

If you changed line 30 to go in a straight line, does it work?

Trajectory exampleTrajectory =
            TrajectoryGenerator.generateTrajectory(
                // Start at the origin facing the +X direction
                new Pose2d(0, 0, new Rotation2d(0)),
                List.of(),
                // End 3 meters straight ahead of where we started, facing forward
                new Pose2d(4, -0.5, new Rotation2d(0)),
                config);
1 Like

I try, but it still fail

Have you tried Oblarg’s suggestion?

Sorry, I didn’t see that. I will try it 10min after

Sorry, I’m not sure what you mean.
I think my codes are similar to what you suggest

Chart the waypoints on a plot, with arrows/vectors to show the headings, so that you can see what kind of curve the algorithm is trying to make.

This is my plot. Is I put the right number into codes?
But I still can’t run the code because there are some error.

In your code you have the (4, -0.5) point twice, once in the interior waypoints list and once as the end point, which could be the cause of an issue.

Also your start heading is not facing towards your first point so the path would look something like this which the generator might have trouble with

4 Likes

Thank you. So, should I program my codes like below one?

new Pose2d(0, 0, new Rotation2d(0)),
List.of(new Translation2d(0.3, 0), new Translation2d(0.3, 0.5)),
new Pose2d(4, 0.5, Rotation2d.fromDegrees(180)),
config);

You’re 180 degrees should be 0 as it is approaching that last point heading into the positive x direction. Also, the change to the internal points looks better than before.

1 Like

Thank all you guy. I can run auto codes perfectly. And I 7/7 engage on charge station with that code.