src/main/java/frc/robot/subsystems/swerveDrivetrain.java
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative, boolean calibrateGyro) {
    
    if(calibrateGyro){
      //gyro.reset(); //recalibrates gyro offset
     resetYaw();
    }

    SwerveModuleState[] states =
      kinematics.toSwerveModuleStates(
        fieldRelative // if field relative is true, do the ? line, otherwise do the : line //called a conditional operator condition ? result_if_true : result_if_false
          ? ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, Rotation2d.fromDegrees(-getAngle()))
          : new ChassisSpeeds(xSpeed, ySpeed, rot));


    // using states generated above normalize using the max wheel speed.
    SwerveDriveKinematics.desaturateWheelSpeeds(states, kMaxSpeed);



    //-----smart Dashboard outputs ----// re-write without the fancy states thing to make it clearer
    for (int j = 0; j < states.length; j++) {
      
      swerveModules module = modules[j];
      SwerveModuleState state = states[j];
     SmartDashboard.putNumber(String.valueOf(j), module.getRawAngle());//USE THIS TO DISPLAY WHEEL ANGLE
     //SmartDashboard.putNumber(String.valueOf(j), module.getWheelPosition());
      //below is a line to comment out from step 5
     //
      module.setDesiredState(state); ///-----COMMENT THIS OUT/IN FOR SWERVE MODULE ANGLE CONFIGURATION--------//
      SmartDashboard.putNumber("gyro Angle", getAngle());
     
    }



     //-----smart Dashboard outputs ----// re-write without the fancy states thing to make it clearer
     for (int i = 0; i < states.length; i++) {
      swerveModules module = modules[i];
      SwerveModuleState state = states[i];
      //SmartDashboard.putNumber(String.valueOf(i), module.getWheelPosition()/1350);
    }
     // SmartDashboard.putNumber("Average Drive EncoderValue", getAverageEncoderValue());
      
  }
/**
   * Method to drive the robot using joystick info.
   *
   * @param xSpeed Speed of the robot in the x direction (forward).
   * @param ySpeed Speed of the robot in the y direction (sideways).
   * @param rot Angular rate of the robot.
   * @param fieldRelative Whether the provided x and y speeds are relative to the field.
   * @param calibrateGyro button to recalibrate the gyro offset
   */
Method to drive the robot using joystick info.
@param xSpeed Speed of the robot in the x direction (forward).
@param ySpeed Speed of the robot in the y direction (sideways).
@param rot Angular rate of the robot.
@param fieldRelative Whether the provided x and y speeds are relative to the field.
@param calibrateGyro button to recalibrate the gyro offset
Method to drive the robot using joystick info . @param xSpeed Speed of the robot in the x direction ( forward ) . @param ySpeed Speed of the robot in the y direction ( sideways ) . @param rot Angular rate of the robot . @param fieldRelative Whether the provided x and y speeds are relative to the field . @param calibrateGyro button to recalibrate the gyro offset
public void drive(double xSpeed, double ySpeed, double rot, boolean fieldRelative, boolean calibrateGyro) {
    if(calibrateGyro){
     resetYaw();
    }
    SwerveModuleState[] states =
      kinematics.toSwerveModuleStates(
        fieldRelative 
          ? ChassisSpeeds.fromFieldRelativeSpeeds(xSpeed, ySpeed, rot, Rotation2d.fromDegrees(-getAngle()))
          : new ChassisSpeeds(xSpeed, ySpeed, rot));
    SwerveDriveKinematics.desaturateWheelSpeeds(states, kMaxSpeed);
    for (int j = 0; j < states.length; j++) {
      swerveModules module = modules[j];
      SwerveModuleState state = states[j];
     SmartDashboard.putNumber(String.valueOf(j), module.getRawAngle());
      module.setDesiredState(state); /-----COMMENT THIS OUT/IN FOR SWERVE MODULE ANGLE CONFIGURATION--------
      SmartDashboard.putNumber("gyro Angle", getAngle());
    }
     for (int i = 0; i < states.length; i++) {
      swerveModules module = modules[i];
      SwerveModuleState state = states[i];
      SmartDashboard.putNumber(String.valueOf(i), module.getWheelPosition()/1350);
    }
      SmartDashboard.putNumber("Average Drive EncoderValue", getAverageEncoderValue());
  }
public void drive ( double xSpeed , double ySpeed , double rot , boolean fieldRelative , boolean calibrateGyro ) { if ( calibrateGyro ) { resetYaw ( ) ; } SwerveModuleState [ ] states = kinematics . toSwerveModuleStates ( fieldRelative ? ChassisSpeeds . fromFieldRelativeSpeeds ( xSpeed , ySpeed , rot , Rotation2d . fromDegrees ( - getAngle ( ) ) ) : new ChassisSpeeds ( xSpeed , ySpeed , rot ) ) ; SwerveDriveKinematics . desaturateWheelSpeeds ( states , kMaxSpeed ) ; for ( int j = 0 ; j < states . length ; j ++ ) { swerveModules module = modules [ j ] ; SwerveModuleState state = states [ j ] ; SmartDashboard . putNumber ( String . valueOf ( j ) , module . getRawAngle ( ) ) ; module . setDesiredState ( state ) ; SmartDashboard . putNumber ( "gyro Angle" , getAngle ( ) ) ; } for ( int i = 0 ; i < states . length ; i ++ ) { swerveModules module = modules [ i ] ; SwerveModuleState state = states [ i ] ; } }
Method to drive the robot using joystick info.
Method to drive the robot using joystick info .
//gyro.reset(); //recalibrates gyro offset // if field relative is true, do the ? line, otherwise do the : line //called a conditional operator condition ? result_if_true : result_if_false // using states generated above normalize using the max wheel speed. //-----smart Dashboard outputs ----// re-write without the fancy states thing to make it clearer //USE THIS TO DISPLAY WHEEL ANGLE //SmartDashboard.putNumber(String.valueOf(j), module.getWheelPosition()); //below is a line to comment out from step 5 // ///-----COMMENT THIS OUT/IN FOR SWERVE MODULE ANGLE CONFIGURATION--------// //-----smart Dashboard outputs ----// re-write without the fancy states thing to make it clearer //SmartDashboard.putNumber(String.valueOf(i), module.getWheelPosition()/1350); // SmartDashboard.putNumber("Average Drive EncoderValue", getAverageEncoderValue());