Following Path Planner Trajectories causing violent swerve Chatter

Hi all, My team used Pathplanner with great results last year, but when we updated our code to use the latest Pathplanner updates, our swerves violently chatter when running the path command. We are thinking that somehow the swerves are being fed a desired state of 0 or are somehow being set to zero. Our other hypothesis is that two commands are being fed into the swerves at the same time. We are following a simple path that simply drives forward and following the examples in the wiki. Has anyone else had this problem or know a possible solution?

NOTE: Our swerves work perfectly in teleop, but when using Pathplanner, we run into this issue. Also, all PID values for the command are set to 0

Our code is attached below

Thanks so much!

public class DirectBalance extends SequentialCommandGroup {

  SwerveSubsystem swerve = SwerveSubsystem.getInstance();
  Gyro gyro = Gyro.getInstance();
  PIDController xController = new PIDController(0, 0, 0);
  PIDController yController = new PIDController(0, 0, 0);
  PIDController thetaController = new PIDController(0, 0, 0);
  PathPlannerTrajectory autoPath = PathPlanner.loadPath("Direct Balance", 2, 1);

  PPSwerveControllerCommand command = new PPSwerveControllerCommand(

  public DirectBalance() { 
      new InstantCommand(() -> thetaController.enableContinuousInput(0, 360)),
      new InstantCommand(() -> swerve.resetOdometer(autoPath.getInitialPose())),
      new InstantCommand(() -> swerve.stopModules())

Check that your requirements are set correctly on all commands. If you’re missing a requirement on the subsystem, the default command will try to override what the path is doing.

1 Like

The requirement added is an instance of our swerve subsystem class. Could it be that using that singleton is our issue? I attached our code to my original post.

Thank you so much

We actually had the same problem when using WPILib’s SwerveControllerCommand. Therefore we ended up making our own swerve follower command, which worked perfectly! It also allowed us to understand the insides more and change the insides of the command if needed.

Here is the link to our own swerve controller/follower command (it was made last year for a drivebase system made with SDS SwerveLib, but could most likely be easily adapted to BaseFalconSwerve and more):

I would start by making sure that you are only calling setModuleStates() once per loop during autonomous. Check your drivetrain periodic and make sure you don’t try to set module states there. The SDS SwerveLib for example has a “desired state” that is used to update the swerve modules every cycle in periodic. That means you’ll be interleaving every path follow setModuleStates with another setModuleStates to stop. (Another reason to avoid the SweveLib, you need to restructure it to be compatible with autonomous.)

If that’s not it, make sure the teleop drive command is not running at the same time. This should take care of itself if you have set the command required subsystems correctly.

1 Like

This worked perfectly, we were setting our default command in Robot Container to a swerve command and I guess the Path Planner command wasn’t always giving it a command so it defaulted to 0. Thanks so much!

1 Like


We are using Team 364’s BaseFalconSwerve drivebase and we are having the same issue, and it seems like a conflicting commands is being sent to the motors. during Auto My team tried to comment out the setDefaultCommand() in our, yet the solution did not work.

We tried commenting out this part of the code in the initialization of our RobotContainer, but could not solve it.

Here is a snippet of the code where the initialization is happening

public RobotContainer() {
            new TeleopSwerve(
                () -> -driver.getRawAxis(translationAxis), 
                () -> -driver.getRawAxis(strafeAxis), 
                () -> -driver.getRawAxis(rotationAxis), 
                () -> robotCentric.getAsBoolean()

        // Configure the button bindings

Any help would be greatly appreciated!

Does your autonomous command require your drivetrain subsystem? If it doesn’t, then the default command will run.

To view better what’s happening, you can log the current command within the drivetrain subsystem to your dashboard of choice. It will show the command that the drivetrain subsystem knows about. If it shows TeleopSwerve while you’re running your autonomous, that’d be your problem.


Sorry for the late reply. We were able to log what commands were being run during our autonomous period, and it seems like there were no issues or conflicts with the commands being run. However, after further testing, we discovered the problem with PID tuning and the present values. I was wondering if there were any resources or tutorials that other teams used to tune PID with the Base Falcon Swerve repo, as the code uses WPIlib’s odometry, which is different from our team’s odometry.

Thank You!