Hello everyone,
I am a programmer from team 85, and 2023 was our first year using a swerve drive. Over the offseason we decided that we would learn how to use and implement pathplanner to our autos, and we have gotten pretty far. Our robot can drive paths we draw out perfectly, but our problem is that when we try to rotate and drive straight, the robot goes in an arc.
Here is our command to drive the path:
public Command followTrajectoryCommand(PathPlannerTrajectory traj, boolean isFirstPath) {
return new SequentialCommandGroup(
new InstantCommand(() → {
// Reset odometry for the first path you run during auto
if(isFirstPath){
// If we are running our first path of the auto it will set an origin point to where are robot starts at the beggining of the auto
m_drivetrainSubsystem.resetOdometry(traj.getInitialHolonomicPose());
}
}),
new PPSwerveControllerCommand(
traj,
// Note: the :: as opposed to . when calling a function means that it is refrencing the function, but not running it, as the
//PPSwerveControllerCommand will run it in its own code from pathplanner when the followTrajectoryCommand is run.
m_drivetrainSubsystem::getPose, // Supplies command with the function to get the robot’s position
m_drivetrainSubsystem.getKinematics(), // Wheelbase, tracklength, and other variables
new PIDController(0, 0, 0), // X controller. Tune these values for your robot. Leaving them 0 will only use feedforwards.
new PIDController(0, 0, 0), // Y controller (usually the same values as X controller)
new PIDController(0, 0, 0), // Rotation controller. Tune these values for your robot. Leaving them 0 will only use feedforwards.
m_drivetrainSubsystem::setModuleStates, // This function is most likley where broken code would be that causes the robot to not move at all
false, // Should the path be automatically mirrored depending on alliance color. Optional, defaults to true
m_drivetrainSubsystem // Requires this drive subsystem
)
);
}
From prior experience I assume we will have to tune those 3 PID controllers? Is there any other thing that I could be missing?
Thanks from team 85!