mirror of
https://github.com/Team4388/2023WayOfTheRobot.git
synced 2026-06-09 08:38:02 -06:00
FINAL OFFSETS ARE IN CODE
This commit is contained in:
@@ -29,8 +29,6 @@ public class SwerveDrive extends SubsystemBase {
|
||||
|
||||
private SwerveModule[] modules;
|
||||
|
||||
|
||||
|
||||
// private RobotGyro gyro3
|
||||
|
||||
private Translation2d leftFrontLocation = new Translation2d(Units.inchesToMeters(SwerveDriveConstants.HALF_HEIGHT), Units.inchesToMeters(SwerveDriveConstants.HALF_WIDTH));
|
||||
@@ -207,6 +205,10 @@ public class SwerveDrive extends SubsystemBase {
|
||||
}
|
||||
}
|
||||
|
||||
public SwerveDriveKinematics getKinematics() {
|
||||
return this.kinematics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void periodic() {
|
||||
// This method will be called once per scheduler run
|
||||
|
||||
@@ -16,6 +16,7 @@ import edu.wpi.first.math.geometry.Rotation2d;
|
||||
import edu.wpi.first.math.kinematics.SwerveModulePosition;
|
||||
import edu.wpi.first.math.kinematics.SwerveModuleState;
|
||||
import edu.wpi.first.math.util.Units;
|
||||
import edu.wpi.first.wpilibj.motorcontrol.Talon;
|
||||
import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc4388.robot.Constants.SwerveDriveConstants;
|
||||
import frc4388.utility.Gains;
|
||||
@@ -30,7 +31,7 @@ public class SwerveModule extends SubsystemBase {
|
||||
public static Gains swerveGains = SwerveDriveConstants.PIDConstants.SWERVE_GAINS;
|
||||
|
||||
/** Creates a new SwerveModule. */
|
||||
public SwerveModule(WPI_TalonFX driveMotor, WPI_TalonFX angleMotor, /*CANCoder canCoder*/CANCoder encoder, double offset) {
|
||||
public SwerveModule(WPI_TalonFX driveMotor, WPI_TalonFX angleMotor, CANCoder encoder) {//, double offset) {
|
||||
this.driveMotor = driveMotor;
|
||||
this.angleMotor = angleMotor;
|
||||
this.encoder = encoder;
|
||||
@@ -47,9 +48,11 @@ public class SwerveModule extends SubsystemBase {
|
||||
angleMotor.configAllSettings(angleConfig);
|
||||
|
||||
CANCoderConfiguration canCoderConfig = new CANCoderConfiguration();
|
||||
canCoderConfig.magnetOffsetDegrees = offset;
|
||||
// canCoderConfig.magnetOffsetDegrees = offset;
|
||||
encoder.configAllSettings(canCoderConfig);
|
||||
|
||||
// driveMotor.config_kP(0, 0.4);
|
||||
|
||||
// canCoderConfig.magnetOffsetDegrees = 270;
|
||||
}
|
||||
|
||||
@@ -134,7 +137,10 @@ public class SwerveModule extends SubsystemBase {
|
||||
angleMotor.set(TalonFXControlMode.Position, currentTicks + deltaTicks);
|
||||
|
||||
double feetPerSecond = Units.metersToFeet(state.speedMetersPerSecond);
|
||||
double inchesPerSecond = Units.metersToInches(state.speedMetersPerSecond);
|
||||
|
||||
driveMotor.set(/*angleMotor.get() + */feetPerSecond / SwerveDriveConstants.MAX_SPEED_FEET_PER_SECOND);
|
||||
// driveMotor.set(TalonFXControlMode.Velocity, inchesPerSecond * SwerveDriveConstants.Conversions.TICKS_PER_INCH * SwerveDriveConstants.Conversions.SECONDS_TO_TICK_TIME);
|
||||
}
|
||||
|
||||
public void reset(double position) {
|
||||
|
||||
Reference in New Issue
Block a user