Pathplanner always goes 90 degrees off

Hello! Our robot currently drives +90 degrees in the wrong direction while we use pathplanner, even when we use a straight line. Here is a photo of our path:

image

We know that events and moving has worked before. (at our last offseason competition we rotated each holonomic degrees by 90 degrees as a band-aid fix) However rotation doesn’t work due to the holonomic degrees being 90 degrees off what the bot is actually facing.

We are unsure what is causing this issue, and what to fix it so we can do a more than 1 gamepiece auto.

This is how we building the auto command:

/**
   * Builds the auto command from the path group.
   * 
   * @param pathGroup The path group to build the auto command from.
   * @return The auto command.
   */
  public edu.wpi.first.wpilibj2.command.Command buildAuto(List<PathPlannerTrajectory> pathGroup) {
    buildCommands();

    // for (int i = 0; i < pathGroup.`; i++) {

    // }

    SwerveAutoBuilder autoBuilder = new SwerveAutoBuilder(
        poseStuff::get, // Pose2d supplier
        poseStuff::reset, // Pose2d consumer, used to reset odometry at the beginning of auto
        new PIDConstants(6, 0.0, 0.0), // PID constants to correct for translation error (used to create the X
                                       // and Y PID controllers)
        new PIDConstants(2.5, 0.0, 0.0), // PID constants to correct for rotation error (used to create the
                                         // rotation controller)
        swerveDrive::accept, // Module states consumer used to output to the drive subsystem
        eventMap,
        false, // Should the path be automatically mirrored depending on alliance color.
              // Optional, defaults to true
        swerveDrive // The drive subsystem. Used to properly set the requirements of path following
                    // commands
    );

    edu.wpi.first.wpilibj2.command.Command fullAuto = autoBuilder.fullAuto(pathGroup);
    traj = pathGroup.get(0);
    // holDrive = new HolonomicDriveCommand(swerveDrive, traj, poseStuff);
    return fullAuto;
  }

Simple but janky fix it to the offset your Gyro yaw by 90

3 Likes

Not janky, how it’s supposed to be done :slight_smile:

9 Likes

Yes… as it turns out it is actually the world that is 90 degrees off… not the robot… :slight_smile:

2 Likes

Thank you for your replies, turns out the can coders we used on our swerve modules were not calibrated correctly which led to a 90 degree offset to what everything should have been.

1 Like

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