Robot not properly following generated paths

Hello, I’ve recently been making some progress using pathweaver to have our robot follow some more complicated trajectories during auton. The expected behaviour for the robot would be for it to go forward out of the tarmac (path 1), turn 60~ degrees towards the alliance wall and go there (path 2), then return to the tarmac (path 3).

The robot follows the first path perfectly, but on the 2nd path its like its doing the complete opposite. I tried to offset this by reversing the spline on this path through pathweaver then re running auton but same result. I’m inclined to think that the problem is realted to its heading/relative position to the field or something along those lines. If anyone has any ideas they would be appreciated, this is the command Im running:

    package frc.robot.commands.auton;
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
import edu.wpi.first.wpilibj2.command.WaitCommand;
import frc.robot.Constants.AutoConstants;
import frc.robot.RobotContainer;
import frc.robot.commands.index.IndexBall;
import frc.robot.commands.intake.IntakeBallForever;
import frc.robot.commands.intake.intakeExtend;
public class FourRareFish extends SequentialCommandGroup {
    private static final String FOUR_FISH_SWIM = "paths/2fishcuh.wpilib.json";
    private static final String FOUR_FISH_GLUP = "paths/2fishglup.wpilib.json";
    private static final String FOUR_FISH_DROWN = "paths/4fishcuh.wpilib.json";
    public FourRareFish(RobotContainer container) {
        // Initialize Subsytems
        addCommands(new intakeExtend(container.intake), new WaitCommand(AutoConstants.INTAKE_EXTEND), new IntakeBallForever(container.intake), new WaitCommand(AutoConstants.SHOOTER_INITIALIZE));
        // Get first ball the line up to shoot
        addCommands(new DriveTrainRamsete(container.driveTrain, FOUR_FISH_SWIM).robotRelative());
        // This should shoot bofa balls out bc shooter is already running
        addCommands(new IndexBall(container.index).withTimeout(AutoConstants.INDEX_BALL));
        addCommands(new DriveTrainRamsete(container.driveTrain, FOUR_FISH_GLUP).fieldRelative(), new IndexBall(container.index).withTimeout(AutoConstants.HUMAN_WAIT + AutoConstants.INDEX_BALL));
        // Return to tarmac and shoot remaining balls
        addCommands(new DriveTrainRamsete(container.driveTrain, FOUR_FISH_DROWN).fieldRelative(), new IndexBall(container.index).withTimeout(AutoConstants.INDEX_BALL));

Could it be just a matter of calling setReversed(true) on the trajectory? You could add reversed as an extra boolean parameter to DriveTrainRamsete.

I could definitely try, but wouldn’t that be the same thing as reversing the spline on pathweaver? Or is it different when you call it in code?

Reversing the spline on Pathweaver doesn’t actually change anything except the produced visuals. You have to set that boolean to actually make the robot drive in reverse for your given path.

This is why I moved to using PathPlanner instead.

Thats interesting, When i reversed the spline i saw that the path file itself had its velocity changed to negative among other things so I was assuming that it changed. Where exactly in my Drivetrainramsete command would I implement the setReversed Boolean?

I’d suggest something like:

public DriveTrainRamsete(DriveTrain driveTrain, String path, boolean reversed) {
    this(driveTrain, Trajectoryinjectory.getTrajectory(path).setReversed(reversed));

public DriveTrainRamsete(DriveTrain driveTrain, String path) {
    this(driveTrain, path, false);

Thank you, I will implement this and let you know how it goes.

1 Like

With this method specifically i get the error “The method setReversed(boolean) is undefined for the type Trajectory”. Do I maybe have to change something in the TrajectoryInjectory Util file?

My apologies. setReversed is a method on TrajectoryConfig, not Trajectory. My advice is not applicable here. I’m afraid I prefer to embed paths directly in Java, not load them from JSON.

It looks like this might be better advice for you. Is this what you already tried?

Unfortunately I already tried that. What confuses me is why does the first one work fine but the second one gets reversed? Maybe its because the robot is no longer starting from its inital start point. I think I’ll try and make some arbitrary paths to see how well those are followed. Worst case scenaroi i’ll learn how to use pathplanner :cry:

When the robot goes in the wrong direction, what does the field display on the shuffleboard show?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.