Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phoenix6 update #13

Merged
merged 65 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
c06b117
Bring back setInstance of the SwerveDrive after merge
Emma03L Jan 8, 2024
7d92cd2
Rename function stopMotor to stop
Emma03L Jan 8, 2024
893cf4f
Fix unit conversion
Emma03L Jan 8, 2024
3722209
Calibrate motion magic
Emma03L Jan 8, 2024
ef1980e
Switch to better variable types in SwerveDriveInputs
Emma03L Jan 9, 2024
b5d6a97
Fix checkSwerve
Emma03L Jan 9, 2024
b42b8d9
Add AutoLogOutputs in SwerveDrive
Emma03L Jan 9, 2024
ee40f33
Calibrate PID and change to PositionVoltage
Emma03L Jan 9, 2024
1037e5f
Remove exclusion of robot classes from build
Emma03L Jan 9, 2024
6767076
Set command name in checkSwerve function
Emma03L Jan 10, 2024
db79b38
Add PhoenixOdometryThread
Emma03L Jan 10, 2024
2c042b4
Give gyro values initial value
Emma03L Jan 10, 2024
daf596f
I'm really sorry for this commit I just can't I'm so confused
Emma03L Jan 10, 2024
f43ee0c
add some odometry stuff that doesn't work yet
Emma03L Jan 12, 2024
76421fd
Update wheel diameter constant
Emma03L Jan 12, 2024
0b844e6
Update max linear velocity constant
Emma03L Jan 12, 2024
10c0993
Rename dthetaTwist to dThetaTwist
Emma03L Jan 12, 2024
a354048
some odometry stuff
Emma03L Jan 12, 2024
46a0dce
Rewrite phoenix odometry thread class
vichik123 Jan 13, 2024
d64a572
Remove unnecessary resetHighFreqOdometry function
Emma03L Jan 13, 2024
45b17c4
Use SwerveDrivePoseEstimator and clean up SwerveDrive class
Emma03L Jan 13, 2024
7d05dfb
Turn gyro variables into Rotation2d
Emma03L Jan 14, 2024
ea164c5
Use .withName and Commands.run
Emma03L Jan 14, 2024
d505b73
Remove unnecessary import
Emma03L Jan 14, 2024
28d69c3
Move calculation to module class
Emma03L Jan 14, 2024
5c0db02
Remove robot classes
Emma03L Jan 14, 2024
eee8acd
Use getRotorPosition instead of Integral to log module distance
Emma03L Jan 14, 2024
a458a55
Turn module offset to Rotation2d
Emma03L Jan 14, 2024
ceeb183
Remove unnecessary import and semicolon
Emma03L Jan 14, 2024
4c797c2
Rename ModuleIOReal to ModuleIOTalonFX
Emma03L Jan 15, 2024
f7a1679
Remove default option for checkModule method
Emma03L Jan 15, 2024
6c9cd2f
Add logged tunable numbers
Emma03L Jan 15, 2024
48cf107
Improve drive function
Emma03L Jan 15, 2024
86f0f26
Add 6328's copyright lines to PhoenixOdometryThread
Emma03L Jan 15, 2024
1cb4bb0
Remove unnecessary imports
Emma03L Jan 15, 2024
9e51e53
Rename control requests in sim IO
Emma03L Jan 15, 2024
239adf7
Add setAngleVelocity function to IOs
Emma03L Jan 15, 2024
e446342
Move checkModule function to module subsystem class
Emma03L Jan 15, 2024
b523ce8
Move logged tunable numbers under the Swerve Drive key
Emma03L Jan 16, 2024
31f67f3
Update real motors' slot 0 configs in updateInputs function
Emma03L Jan 16, 2024
d4c709b
Add simulated PID constants to SwerveConstants as logged tunable numbers
Emma03L Jan 16, 2024
e1e7d9d
Update sim motors' pid configs in updateInputs function
Emma03L Jan 16, 2024
7ceac0e
Turn slot 0 configs constants to individual logged tunable numbers
Emma03L Jan 16, 2024
b275710
Add function to check if PID tunable numbers have changed and one to …
Emma03L Jan 16, 2024
0111f2a
Implement new PID methods in real IO
Emma03L Jan 16, 2024
2588c40
Implement new PID methods in sim IO
Emma03L Jan 16, 2024
587d742
Add default option to hasPIDChanged method
Emma03L Jan 16, 2024
356bd20
Remove hasPIDChanged method from real IO
Emma03L Jan 16, 2024
145b2b0
Remove hasPIDChanged method from sim IO
Emma03L Jan 16, 2024
b652880
Add initConstants function
Emma03L Jan 16, 2024
d067b68
Fix ModuleIOSim's use of PID constants
Emma03L Jan 16, 2024
e86bb34
Remove unnecessary initialization
Emma03L Jan 16, 2024
bf6c8db
Remove unused constants
vichik123 Jan 16, 2024
b36278e
Rename constants file
vichik123 Jan 16, 2024
9157763
Fix steering multiplier in XboxDrive
Emma03L Jan 16, 2024
5936748
Update check module function
vichik123 Jan 16, 2024
1445deb
Apply spotless
vichik123 Jan 16, 2024
23c0366
Rename pid update function
vichik123 Jan 16, 2024
b2e0c4c
Merge remote-tracking branch 'origin/2024-common' into phoenix6-update
Emma03L Jan 17, 2024
5d323a7
Merge the two constants files into one
Emma03L Jan 17, 2024
3d764bb
Import SwerveModuleState in SwerveModuleInputs
Emma03L Jan 17, 2024
db6b8c1
Remove setAngleVelocity function
Emma03L Jan 17, 2024
7962380
Add checkModule function to sim IO
Emma03L Jan 17, 2024
42f1069
Rearrange function order to be more consistent
Emma03L Jan 17, 2024
5b42de0
Apply spotless
vichik123 Jan 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,6 @@ jar {
exclude('**/*.java')
// Exclude tests folder from the JAR
exclude('**/tests/**')
// exclude('frc/robot/Robot.class')
// exclude('frc/robot/RobotContainer.class')
// exclude('frc/robot/Main.class')
// exclude('frc/robot/Constants.class')
// exclude('frc/robot/Ports.class')
}

// Configure jar and deploy tasks
Expand Down
25 changes: 0 additions & 25 deletions src/main/java/frc/robot/Main.java

This file was deleted.

131 changes: 0 additions & 131 deletions src/main/java/frc/robot/Robot.java

This file was deleted.

118 changes: 0 additions & 118 deletions src/main/java/frc/robot/RobotContainer.java

This file was deleted.

14 changes: 8 additions & 6 deletions src/main/java/frc/robot/swerve/GyroIO.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package frc.robot.swerve;

import edu.wpi.first.math.geometry.Rotation2d;

public interface GyroIO {
void updateInputs(SwerveDriveInputs inputs);

double getYaw();
Rotation2d getYaw();

default double getRawYaw() {
return 0;
default Rotation2d getRawYaw() {
return new Rotation2d();
}

default double getPitch() {
return 0;
default Rotation2d getPitch() {
return new Rotation2d();
}

void resetGyro(double angle);
void resetGyro(Rotation2d angle);
}
19 changes: 10 additions & 9 deletions src/main/java/frc/robot/swerve/GyroIOReal.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@

import com.kauailabs.navx.frc.AHRS;
import edu.wpi.first.math.MathUtil;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj.SPI;

public class GyroIOReal implements GyroIO {
private final AHRS gyro;
private double gyroOffset = 0;
private Rotation2d gyroOffset = new Rotation2d();

public GyroIOReal() {
this.gyro = new AHRS(SPI.Port.kMXP);
}

@Override
public double getYaw() {
return getRawYaw() - gyroOffset;
public Rotation2d getYaw() {
return getRawYaw().minus(gyroOffset);
}

@Override
public double getRawYaw() {
return -MathUtil.angleModulus(Math.toRadians(gyro.getAngle()));
public Rotation2d getRawYaw() {
return new Rotation2d(-MathUtil.angleModulus(Math.toRadians(gyro.getAngle())));
}

@Override
public double getPitch() {
return gyro.getPitch() - 2.95;
public Rotation2d getPitch() {
return new Rotation2d(gyro.getPitch());
}

@Override
public void resetGyro(double angle) {
gyroOffset = -angle + getRawYaw();
public void resetGyro(Rotation2d angle) {
gyroOffset = getRawYaw().minus(angle);
}

@Override
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/frc/robot/swerve/GyroIOSim.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package frc.robot.swerve;

import edu.wpi.first.math.geometry.Rotation2d;
import lib.math.differential.Integral;

public class GyroIOSim implements GyroIO {
private final Integral yaw = new Integral();

@Override
public double getYaw() {
return yaw.get();
public Rotation2d getYaw() {
return new Rotation2d(yaw.get());
}

@Override
public void resetGyro(double angle) {
yaw.override(angle);
public void resetGyro(Rotation2d angle) {
yaw.override(angle.getRadians());
}

@Override
public void updateInputs(SwerveDriveInputs inputs) {
yaw.update(inputs.currentSpeeds[2]);
yaw.update(inputs.currentSpeeds.omegaRadiansPerSecond);
}
}
Loading