-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Team334/sub-request
wheel radius characterization
- Loading branch information
Showing
9 changed files
with
150 additions
and
21 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
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
46 changes: 46 additions & 0 deletions
46
src/test/java/frc/robot/WheelRadiusCharacterizationTest.java
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,46 @@ | ||
package frc.robot; | ||
|
||
import static edu.wpi.first.units.Units.Meters; | ||
import static edu.wpi.first.units.Units.Seconds; | ||
import static frc.lib.UnitTestingUtil.*; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
import frc.robot.commands.WheelRadiusCharacterization; | ||
import frc.robot.generated.TunerConstants; | ||
import frc.robot.subsystems.Swerve; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class WheelRadiusCharacterizationTest { | ||
// chassis omega during characterization (TODO: this would be tuneable later) | ||
private final double velOmega = 1; | ||
|
||
private Swerve _swerve; | ||
private WheelRadiusCharacterization _characterization; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
setupTests(); | ||
|
||
_swerve = TunerConstants.createDrivetrain(); | ||
_characterization = new WheelRadiusCharacterization(_swerve); | ||
} | ||
|
||
@AfterEach | ||
public void close() throws Exception { | ||
reset(_swerve); | ||
} | ||
|
||
@Test | ||
public void wheelRadiusCharacterization() { | ||
// run enough ticks to complete 4pi radians at the given characterization omega | ||
run(_characterization, (int) ((Math.PI * 4 / velOmega) / TICK_RATE.in(Seconds))); | ||
|
||
// accept with a tolerance of 0.002 meters (i think that's good?) | ||
assertEquals( | ||
TunerConstants.kWheelRadius.in(Meters), | ||
_characterization.getWheelRadius().in(Meters), | ||
2e-3); | ||
} | ||
} |