Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/swerve' into fix/swerve
Browse files Browse the repository at this point in the history
  • Loading branch information
NoraZitnick committed Nov 10, 2024
2 parents 893deb1 + c104a35 commit 7b7b215
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ gradle-app.setting
.settings/
bin/

.factorypath

# IntelliJ
*.iml
*.ipr
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* constants are needed, to reduce verbosity.
*/
public final class Constants {
public static double PERIODIC_LOOP_SEC = 0.02;

public static RobotType ROBOT_TYPE = RobotType.COMP;

public static Mode getRobotMode() {
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/frc/robot/subsystems/swerve/Drive.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.Util;
import frc.robot.Constants;
import org.littletonrobotics.junction.AutoLogOutput;
import org.littletonrobotics.junction.Logger;

Expand All @@ -35,7 +36,7 @@ public enum DriveModes {
private Rotation2d arbitraryYaw = new Rotation2d();

@AutoLogOutput(key = "Swerve/YawOffset")
private Rotation2d gyroYawOffset = new Rotation2d(0);
private Rotation2d gyroYawOffset = new Rotation2d();

private ChassisSpeeds teleopTargetSpeeds = new ChassisSpeeds();
private ChassisSpeeds targetSpeeds = new ChassisSpeeds();
Expand Down Expand Up @@ -79,6 +80,10 @@ public void periodic() {
}

// run modules

/* use kinematics to get desired module states */
ChassisSpeeds discretizedSpeeds =
ChassisSpeeds.discretize(targetSpeeds, Constants.PERIODIC_LOOP_SEC);
SwerveModuleState[] moduleTargetStates = KINEMATICS.toSwerveModuleStates(targetSpeeds);
SwerveDriveKinematics.desaturateWheelSpeeds(
moduleTargetStates, DRIVE_CONFIG.maxLinearVelocity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public class DriveConstants {
};

public static final ModuleConstants MODULE_CONSTANTS =
// FIXME tune
switch (getRobotType()) {
case COMP, SIM -> new ModuleConstants(
0.17, // steerkS
Expand Down

0 comments on commit 7b7b215

Please sign in to comment.