// sometime the Kinematics spits out too fast of speeds, so this will fix this
@SuppressWarnings("ParameterName")
    public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
        // ask the kinematics to determine our swerve command
        ChassisSpeeds speeds;
        if (fieldRelative == true) {
            speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
        } else {
            speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
        }
        SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
        // sometime the Kinematics spits out too fast of speeds, so this will fix this
        SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
        // command each swerve module
        for (int i = 0; i < modules.length; i++) {
            modules[i].setDesiredState(swerveModuleStates[i]);
        }
        // report our commands to the dashboard
        SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
        SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
        SmartDashboard.putNumber("SwerveDrive/rot", rot);
        SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
    }
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
@SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
@SuppressWarnings("ParameterName")
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative) {
// ask the kinematics to determine our swerve command
ChassisSpeeds speeds;
if (fieldRelative == true) {
speeds = ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, getHeading());
} else {
speeds = new ChassisSpeeds(xSpeed, ySpeed, rot);
}
SwerveModuleState[] swerveModuleStates = kinematics.toSwerveModuleStates(speeds);
// sometime the Kinematics spits out too fast of speeds, so this will fix this
SwerveDriveKinematics.desaturateWheelSpeeds(swerveModuleStates, kMaxSpeed);
// command each swerve module
for (int i = 0; i < modules.length; i++) {
modules[i].setDesiredState(swerveModuleStates[i]);
}
// report our commands to the dashboard
SmartDashboard.putNumber("SwerveDrive/xSpeed", xSpeed);
SmartDashboard.putNumber("SwerveDrive/ySpeed", ySpeed);
SmartDashboard.putNumber("SwerveDrive/rot", rot);
SmartDashboard.putBoolean("SwerveDrive/fieldRelative", fieldRelative);
}