-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jack is not cool
- Loading branch information
Showing
11 changed files
with
271 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{ | ||
"keyboardJoysticks": [ | ||
{ | ||
"axisConfig": [ | ||
{ | ||
"decKey": 65, | ||
"incKey": 68 | ||
}, | ||
{ | ||
"decKey": 87, | ||
"incKey": 83 | ||
}, | ||
{ | ||
"decKey": 69, | ||
"decayRate": 0.0, | ||
"incKey": 82, | ||
"keyRate": 0.009999999776482582 | ||
} | ||
], | ||
"axisCount": 3, | ||
"buttonCount": 4, | ||
"buttonKeys": [ | ||
90, | ||
88, | ||
67, | ||
86 | ||
], | ||
"povConfig": [ | ||
{ | ||
"key0": 328, | ||
"key135": 323, | ||
"key180": 322, | ||
"key225": 321, | ||
"key270": 324, | ||
"key315": 327, | ||
"key45": 329, | ||
"key90": 326 | ||
} | ||
], | ||
"povCount": 1 | ||
}, | ||
{ | ||
"axisConfig": [ | ||
{ | ||
"decKey": 74, | ||
"incKey": 76 | ||
}, | ||
{ | ||
"decKey": 73, | ||
"incKey": 75 | ||
} | ||
], | ||
"axisCount": 2, | ||
"buttonCount": 4, | ||
"buttonKeys": [ | ||
77, | ||
44, | ||
46, | ||
47 | ||
], | ||
"povCount": 0 | ||
}, | ||
{ | ||
"axisConfig": [ | ||
{ | ||
"decKey": 263, | ||
"incKey": 262 | ||
}, | ||
{ | ||
"decKey": 265, | ||
"incKey": 264 | ||
} | ||
], | ||
"axisCount": 2, | ||
"buttonCount": 6, | ||
"buttonKeys": [ | ||
260, | ||
268, | ||
266, | ||
261, | ||
269, | ||
267 | ||
], | ||
"povCount": 0 | ||
}, | ||
{ | ||
"axisCount": 0, | ||
"buttonCount": 0, | ||
"povCount": 0 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"NTProvider": { | ||
"types": { | ||
"/FMSInfo": "FMSInfo" | ||
} | ||
}, | ||
"NetworkTables Info": { | ||
"visible": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import static org.junit.jupiter.api.Assertions.*; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.eq; | ||
import static org.mockito.Mockito.*; | ||
|
||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
import edu.wpi.first.math.kinematics.SwerveDriveKinematics; | ||
import edu.wpi.first.math.kinematics.SwerveModuleState; | ||
import frc.robot.subsystems.swerve.*; | ||
import frc.robot.subsystems.swerve.gyroIO.GyroInterface; | ||
import frc.robot.subsystems.swerve.moduleIO.ModuleInterface; | ||
import frc.robot.subsystems.swerve.odometryThread.OdometryThread; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
class SwerveDriveTest { | ||
|
||
@Mock private GyroInterface gyroIO; | ||
|
||
@Mock | ||
private ModuleInterface frontLeftModuleIO, | ||
frontRightModuleIO, | ||
backLeftModuleIO, | ||
backRightModuleIO; | ||
@Mock private SwerveModule frontLeftModule, frontRightModule, backLeftModule, backRightModule; | ||
|
||
@Mock private OdometryThread mockOdometryThread; | ||
|
||
@Mock private SwerveDriveKinematics swerveDriveKinematics; | ||
|
||
private SwerveDrive swerveDrive; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
// Initialize the mocks | ||
MockitoAnnotations.openMocks(this); | ||
|
||
swerveDrive = | ||
spy( | ||
new SwerveDrive( | ||
gyroIO, | ||
frontLeftModuleIO, | ||
frontRightModuleIO, | ||
backLeftModuleIO, | ||
backRightModuleIO)); | ||
|
||
swerveDrive.setKinematics(swerveDriveKinematics); | ||
} | ||
|
||
@Test | ||
void testDrive() { | ||
// Prepare mock module states | ||
SwerveModuleState[] mockStates = new SwerveModuleState[4]; | ||
for (int i = 0; i < 4; i++) { | ||
mockStates[i] = mock(SwerveModuleState.class); // Mock each SwerveModuleState | ||
} | ||
|
||
// Mock the toSwerveModuleStates method to return mock states | ||
when(swerveDriveKinematics.toSwerveModuleStates(any(ChassisSpeeds.class))) | ||
.thenReturn(mockStates); | ||
|
||
// Now when the drive method calls toSwerveModuleStates, it will return mockStates | ||
swerveDrive.drive(1.0, 1.0, 0.5, true); | ||
|
||
// Verify that setModuleStates was called with mockStates | ||
verify(swerveDrive).setModuleStates(mockStates); | ||
verify(swerveDrive.getKinematics()).toSwerveModuleStates(any(ChassisSpeeds.class)); | ||
} | ||
|
||
@Test | ||
void testSetPose() { | ||
// Mock pose setter | ||
Pose2d newPose = new Pose2d(3.0, 4.0, Rotation2d.fromDegrees(90)); | ||
swerveDrive.setPose(newPose); | ||
|
||
// Verify that the setPose method was called with the new pose | ||
verify(swerveDrive).setPose(eq(newPose)); | ||
} | ||
} |
Oops, something went wrong.