-
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.
- Loading branch information
Showing
2 changed files
with
105 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
package frc.robot; | ||
|
||
/** Automatically generated file containing build version information. */ | ||
/** | ||
* Automatically generated file containing build version information. | ||
*/ | ||
public final class BuildConstants { | ||
public static final String MAVEN_GROUP = ""; | ||
public static final String MAVEN_NAME = "4829-BaseRobotCode-1"; | ||
public static final String MAVEN_NAME = "4829-BaseRobotCode"; | ||
public static final String VERSION = "unspecified"; | ||
public static final int GIT_REVISION = 32; | ||
public static final String GIT_SHA = "71a47d311fd066ba3b76be8d09eff3e03b893cd8"; | ||
public static final String GIT_DATE = "2024-10-28 22:21:12 EDT"; | ||
public static final String GIT_BRANCH = "docs"; | ||
public static final String BUILD_DATE = "2024-10-29 16:56:45 EDT"; | ||
public static final long BUILD_UNIX_TIME = 1730235405242L; | ||
public static final int GIT_REVISION = 8; | ||
public static final String GIT_SHA = "52fbf88798bd786d25dffff6b4769182ad9ea51c"; | ||
public static final String GIT_DATE = "2024-10-29 17:58:37 EDT"; | ||
public static final String GIT_BRANCH = "main"; | ||
public static final String BUILD_DATE = "2024-11-05 07:52:13 EST"; | ||
public static final long BUILD_UNIX_TIME = 1730811133569L; | ||
public static final int DIRTY = 0; | ||
|
||
private BuildConstants() {} | ||
private BuildConstants(){} | ||
} |
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,94 @@ | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
// import com.igknighters.commands.autos.Autos; | ||
// import com.igknighters.constants.ConstValues; | ||
// import com.igknighters.constants.RobotSetup; | ||
// import com.igknighters.constants.RobotSetup.RobotID; | ||
// import com.igknighters.util.RobotExtension.Robo; | ||
import com.pathplanner.lib.commands.PathPlannerAuto; | ||
|
||
import edu.wpi.first.hal.AllianceStationID; | ||
import edu.wpi.first.hal.HAL; | ||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.wpilibj.simulation.DriverStationSim; | ||
import edu.wpi.first.wpilibj2.command.CommandScheduler; | ||
import edu.wpi.first.wpilibj2.command.ProxyCommand; | ||
|
||
public class RobotTest { | ||
|
||
@BeforeEach | ||
protected void startSim() { | ||
GlobalState.setUnitTest(true); | ||
assert HAL.initialize(500, 0); | ||
} | ||
|
||
@AfterEach | ||
protected void teardownSim() { | ||
HAL.exitMain(); | ||
HAL.shutdown(); | ||
GlobalState.restoreDefaultState(); | ||
var cmdScheduler = CommandScheduler.getInstance(); | ||
cmdScheduler.cancelAll(); | ||
cmdScheduler.getActiveButtonLoop().clear(); | ||
cmdScheduler.getDefaultButtonLoop().clear(); | ||
cmdScheduler.clearComposedCommands(); | ||
cmdScheduler.unregisterAllSubsystems(); | ||
} | ||
|
||
@Test | ||
public void testRobotSetup() { | ||
for (RobotID id : RobotID.values()) { | ||
if (id == RobotID.Unlabeled) { | ||
continue; | ||
} | ||
|
||
RobotSetup.testOverrideRobotID(id); | ||
|
||
com.igknighters.ConstantHelper.applyRoboConst(ConstValues.class); | ||
|
||
new RobotContainer(); | ||
|
||
CommandScheduler.getInstance().getActiveButtonLoop().clear(); | ||
CommandScheduler.getInstance().getDefaultButtonLoop().clear(); | ||
|
||
System.gc(); | ||
Check failure on line 58 in src/test/java/RobotTest.java GitHub Actions / LintDo not explicitly trigger a garbage collection.
|
||
} | ||
} | ||
|
||
@Test | ||
public void testAuto(@Robo Robot robot) { | ||
RobotSetup.testOverrideRobotID(RobotID.SIM_CRASH); | ||
Pose2d desiredEndPose = new Pose2d( | ||
new Translation2d(3.0, 7.0), | ||
new Rotation2d()); | ||
|
||
DriverStationSim.setAllianceStationId(AllianceStationID.Blue1); | ||
|
||
// meters | ||
final double translationTolerance = 0.2; | ||
|
||
Autos.setAutoOverrideTest(new ProxyCommand(() -> new PathPlannerAuto("1 Meter Auto"))); | ||
DriverStationSim.setAutonomous(true); | ||
DriverStationSim.setEnabled(true); | ||
|
||
robot.withAutonomousPeriodicTest(robo -> { | ||
boolean isFinished = GlobalState.getLocalizedPose() | ||
.getTranslation() | ||
.getDistance(desiredEndPose.getTranslation()) < translationTolerance; | ||
|
||
if (isFinished) { | ||
robo.finishUnitTestRobot(); | ||
} else if (robo.getElapsedTime() > 2.5) { | ||
throw new RuntimeException( | ||
"Auto took to long, ended at " | ||
+ GlobalState.getLocalizedPose().toString()); | ||
} | ||
}); | ||
|
||
robot.runTest(3); | ||
} | ||
} |