Skip to content

Commit

Permalink
add even more simulation support to driveSubsytem
Browse files Browse the repository at this point in the history
  • Loading branch information
kytpbs committed May 29, 2024
1 parent fafe026 commit 6501cef
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/main/java/frc/robot/subsystems/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ public DriveSubsystem() {
this // Reference to this subsystem to set requirements
);
SmartDashboard.putNumber("Move By", 0);
if (RobotBase.isSimulation()) {
SmartDashboard.putNumber("X position", 0);
SmartDashboard.putNumber("Y position", 0);
}
}

@Override
Expand Down Expand Up @@ -163,6 +167,13 @@ public void simulationPeriodic() {
SmartDashboard.putNumber("Rear Left Swerve Rotation", states[2].angle.getDegrees());
SmartDashboard.putNumber("Rear Right Swerve Speed", states[3].speedMetersPerSecond);
SmartDashboard.putNumber("Rear Right Swerve Rotation", states[3].angle.getDegrees());

var xPos = SmartDashboard.getNumber("X position", 0);
var yPos = SmartDashboard.getNumber("Y position", 0);

if (xPos != 0 && yPos != 0) {
resetOdometry(new Pose2d(xPos, yPos, getRotation2d()));
}
}

@Override
Expand Down

0 comments on commit 6501cef

Please sign in to comment.