Skip to content

Commit

Permalink
got onto phoenix six! updated all the things to match to phoenix6 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTinker64 committed Jan 10, 2024
1 parent 122c9dd commit ce756b3
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 145 deletions.
14 changes: 7 additions & 7 deletions src/main/java/frc/robot/subsystems/SwerveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import java.util.List;

import com.ctre.phoenix.sensors.BasePigeonSimCollection;
import com.ctre.phoenix.sensors.WPI_Pigeon2;
import com.ctre.phoenix6.sim.Pigeon2SimState;
import com.ctre.phoenix6.hardware.Pigeon2;

import edu.wpi.first.math.estimator.SwerveDrivePoseEstimator;
import edu.wpi.first.math.geometry.Pose2d;
Expand Down Expand Up @@ -64,8 +64,8 @@ public class SwerveSubsystem extends SubsystemBase implements AutoCloseable {

private final List<SwerveModule> modules = List.of(m_frontLeft, m_frontRight, m_backLeft, m_backRight);

private WPI_Pigeon2 m_gyro = new WPI_Pigeon2(0);
private final BasePigeonSimCollection gyroSim = m_gyro.getSimCollection();
private Pigeon2 m_gyro = new Pigeon2(0);
private final Pigeon2SimState gyroSim = new Pigeon2SimState(m_gyro);

SwerveDrivePoseEstimator poseEstimator = new SwerveDrivePoseEstimator(
DriveConstants.kDriveKinematics,
Expand Down Expand Up @@ -116,7 +116,7 @@ public SwerveSubsystem() {
}

// ! For testing purposes only
public SwerveSubsystem(WPI_Pigeon2 gyro) {
public SwerveSubsystem(Pigeon2 gyro) {
m_gyro = gyro;

new Thread(() -> {
Expand Down Expand Up @@ -246,7 +246,7 @@ public void simulate(){
SmartDashboard.putData("Module 2", m_frontRight);
SmartDashboard.putData("Module 3", m_backLeft);
SmartDashboard.putData("Module 4", m_backRight);
gyroSim.addHeading(Units.radiansToDegrees(DriveConstants.kDriveKinematics.toChassisSpeeds(getModuleStates()).omegaRadiansPerSecond)
gyroSim.addYaw(Units.radiansToDegrees(DriveConstants.kDriveKinematics.toChassisSpeeds(getModuleStates()).omegaRadiansPerSecond)
* (DriveConstants.kGyroReversed ? -1.0 : 1.0) * 0.02);
SmartDashboard.putNumber("Heading", getHeading());
}
Expand Down Expand Up @@ -277,6 +277,6 @@ public void close() throws Exception {
m_frontRight.close();
m_backLeft.close();
m_backRight.close();
m_gyro.DestroyObject();
m_gyro.close();
}
}
49 changes: 0 additions & 49 deletions src/test/java/SwerveSubsystemTest.java

This file was deleted.

Loading

0 comments on commit ce756b3

Please sign in to comment.