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:
@@ -38,10 +38,9 @@ public final class Units {
|
||||
public static final Time Minute = Minutes; // singularized alias
|
||||
|
||||
// Angle
|
||||
public static final Angle Revolutions = BaseUnits.Angle;
|
||||
public static final Angle Rotations = new Angle(1, "Rotation", "R"); // alias
|
||||
public static final Angle Radians =
|
||||
derive(Revolutions).splitInto(2 * Math.PI).named("Radian").symbol("rad").make();
|
||||
public static final Angle Radians = BaseUnits.Angle;
|
||||
public static final Angle Revolutions = new Angle(2 * Math.PI, "Revolution", "R");
|
||||
public static final Angle Rotations = new Angle(2 * Math.PI, "Rotation", "R"); // alias revolution
|
||||
public static final Angle Degrees =
|
||||
derive(Revolutions).splitInto(360).named("Degree").symbol("°").make();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user