mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Add basic wpiunits support (#5821)
To reduce the need for users to manually perform unit conversions, this allows Measure objects from wpiunits to be passed into most places in wpimath that currently expect doubles in terms of SI units like meters. For example, users would need to know that unit conversion is required - and what the correct units are. Using units would be more difficult to write code for than just hardcoding a value or using Units.inchesToMeters. Now, using units has no more developer overhead than using raw numbers.
This commit is contained in:
@@ -203,13 +203,14 @@ class UnitsTest {
|
||||
|
||||
@Test
|
||||
void testRevolutions() {
|
||||
testBaseUnit(Revolutions);
|
||||
assertEquals(1, Revolutions.convertFrom(2 * Math.PI, Radians), thresh);
|
||||
assertEquals("Revolution", Revolutions.name());
|
||||
assertEquals("R", Revolutions.symbol());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRadians() {
|
||||
testBaseUnit(Radians);
|
||||
assertEquals(2 * Math.PI, Radians.convertFrom(1, Revolutions), thresh);
|
||||
assertEquals(2 * Math.PI, Radians.convertFrom(360, Degrees), thresh);
|
||||
assertEquals("Radian", Radians.name());
|
||||
|
||||
Reference in New Issue
Block a user