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. (7.6 KB) (2.7 KB) (775 Bytes) (4.1 KB) (2.7 KB) (4.9 KB) (2.6 KB) (1.6 KB) (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.


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, 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 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 =
                // Start at the origin facing the +X direction
                new Pose2d(0, 0, new Rotation2d(0)),
                // End 3 meters straight ahead of where we started, facing forward
                new Pose2d(4, -0.5, new Rotation2d(0)),
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


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)),

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.