Class Units

java.lang.Object
org.wpilib.units.Units

public final class Units extends Object
Contains a set of predefined units.
  • Field Details

    • Value

      public static final DimensionlessUnit Value
      A dimensionless unit that performs no scaling whatsoever.
    • Percent

      public static final DimensionlessUnit Percent
      A dimensionless unit equal to to 1/100th of a Value. A measurement of Percent.of(42) would be equivalent to Value.of(0.42).
    • Meters

      public static final DistanceUnit Meters
      The base unit of distance.
    • Meter

      public static final DistanceUnit Meter
      The base unit of distance.
    • Millimeters

      public static final DistanceUnit Millimeters
      1/1000 of a Meter.
    • Millimeter

      public static final DistanceUnit Millimeter
      1/1000 of a Meter.
    • Centimeters

      public static final DistanceUnit Centimeters
      1/100 of a Meter.
    • Centimeter

      public static final DistanceUnit Centimeter
      1/100 of a Meter.
    • Inches

      public static final DistanceUnit Inches
      25.4/1000 of a Meter and 1/12 of a Foot.
    • Inch

      public static final DistanceUnit Inch
      25.4/1000 of a Meter and 1/12 of a Foot.
    • Feet

      public static final DistanceUnit Feet
      304.8/1000 of a Meter, or 12 Inches.
    • Seconds

      public static final TimeUnit Seconds
      The base unit of time.
    • Second

      public static final TimeUnit Second
      Alias for Seconds to make combined unit definitions read more smoothly.
    • Milliseconds

      public static final TimeUnit Milliseconds
      1/1000 of a Second.
    • Millisecond

      public static final TimeUnit Millisecond
      Alias for Milliseconds to make combined unit definitions read more smoothly.
    • Microseconds

      public static final TimeUnit Microseconds
      1/1,000,000 of a Second.
    • Microsecond

      public static final TimeUnit Microsecond
      Alias for Microseconds to make combined unit definitions read more smoothly.
    • Nanoseconds

      public static final TimeUnit Nanoseconds
      1/1,000,000,000 of a Second.
    • Nanosecond

      public static final TimeUnit Nanosecond
      Alias for Nanoseconds to make combined unit definitions read more smoothly.
    • Minutes

      public static final TimeUnit Minutes
    • Minute

      public static final TimeUnit Minute
      Alias for Minutes to make combined unit definitions read more smoothly.
    • Radians

      public static final AngleUnit Radians
      The standard SI unit of angle, represented by the distance that the radius of a unit circle can wrap around its circumference.
    • Radian

      public static final AngleUnit Radian
      The standard SI unit of angle, represented by the distance that the radius of a unit circle can wrap around its circumference.
    • Revolutions

      public static final AngleUnit Revolutions
      A single turn of an object around an external axis. Numerically equivalent to Rotations, but may be semantically more expressive in certain scenarios.
    • Revolution

      public static final AngleUnit Revolution
      A single turn of an object around an external axis. Numerically equivalent to a Rotation, but may be semantically more expressive in certain scenarios.
    • Rotations

      public static final AngleUnit Rotations
      A single turn of an object around an internal axis. Numerically equivalent to Revolutions, but may be semantically more expressive in certain scenarios.
    • Rotation

      public static final AngleUnit Rotation
      A single turn of an object around an internal axis. Numerically equivalent to a Revolution, but may be semantically more expressive in certain scenarios.
    • Degrees

      public static final AngleUnit Degrees
      1/360 of a turn around a circle, or 1/57.3 Radians.
    • Degree

      public static final AngleUnit Degree
      1/360 of a turn around a circle, or 1/57.3 Radians.
    • MetersPerSecond

      public static final LinearVelocityUnit MetersPerSecond
      The standard SI unit of linear velocity, equivalent to travelling at a rate of one Meter per Second.
    • FeetPerSecond

      public static final LinearVelocityUnit FeetPerSecond
      A unit of linear velocity equivalent to travelling at a rate one Foot per Second.
    • InchesPerSecond

      public static final LinearVelocityUnit InchesPerSecond
      A unit of linear velocity equivalent to travelling at a rate of one Inch per Second.
    • RevolutionsPerSecond

      public static final AngularVelocityUnit RevolutionsPerSecond
      A unit of angular velocity equivalent to spinning at a rate of one Revolution per Second.
    • RotationsPerSecond

      public static final AngularVelocityUnit RotationsPerSecond
      A unit of angular velocity equivalent to spinning at a rate of one Rotation per Second.
    • RotationsPerMinute

      public static final AngularVelocityUnit RotationsPerMinute
      A unit of angular velocity equivalent to spinning at a rate of one Rotation per Minute. Motor spec sheets often list maximum velocities in terms of RPM.
    • RPM

      public static final AngularVelocityUnit RPM
      A unit of angular velocity equivalent to spinning at a rate of one Rotation per Minute. Motor spec sheets often list maximum speeds in terms of RPM.
    • RadiansPerSecond

      public static final AngularVelocityUnit RadiansPerSecond
      The standard SI unit of angular velocity, equivalent to spinning at a rate of one Radian per Second.
    • DegreesPerSecond

      public static final AngularVelocityUnit DegreesPerSecond
      A unit of angular velocity equivalent to spinning at a rate of one Degree per Second.
    • Hertz

      public static final FrequencyUnit Hertz
      The standard SI unit of frequency, equivalent to a periodic signal repeating once every Second.
    • Millihertz

      public static final FrequencyUnit Millihertz
      1/1000th of a Hertz.
    • MetersPerSecondPerSecond

      public static final LinearAccelerationUnit MetersPerSecondPerSecond
      The standard SI unit of linear acceleration, equivalent to accelerating at a rate of one Meter per Second every second.
    • FeetPerSecondPerSecond

      public static final LinearAccelerationUnit FeetPerSecondPerSecond
      A unit of linear acceleration equivalent to accelerating at a rate of one Foot per Second every second.
    • InchesPerSecondPerSecond

      public static final LinearAccelerationUnit InchesPerSecondPerSecond
      A unit of linear acceleration equivalent to accelerating at a rate of one Inch per Second every second.
    • RotationsPerSecondPerSecond

      public static final AngularAccelerationUnit RotationsPerSecondPerSecond
      A unit of angular acceleration equivalent to accelerating at a rate of one Rotation per Second every second.
    • RadiansPerSecondPerSecond

      public static final AngularAccelerationUnit RadiansPerSecondPerSecond
      The standard SI unit of angular acceleration, equivalent to accelerating at a rate of one Radian per Second every second.
    • DegreesPerSecondPerSecond

      public static final AngularAccelerationUnit DegreesPerSecondPerSecond
      A unit of angular acceleration equivalent to accelerating at a rate of one Degree per Second every second.
    • Gs

      public static final LinearAccelerationUnit Gs
      A unit of acceleration equivalent to the pull of gravity on an object at sea level on Earth.
    • Kilograms

      public static final MassUnit Kilograms
      The standard SI unit of mass.
    • Kilogram

      public static final MassUnit Kilogram
      The standard SI unit of mass.
    • Grams

      public static final MassUnit Grams
      1/1000 of a Kilogram.
    • Gram

      public static final MassUnit Gram
      1/1000 of a Kilogram.
    • Pounds

      public static final MassUnit Pounds
      A unit of mass equivalent to approximately 453 Grams. This is not equivalent to pounds-force, which is the amount of force required to accelerate an object with one pound of mass at a rate of one G.
      See Also:
    • Pound

      public static final MassUnit Pound
      A unit of mass equivalent to approximately 453 Grams. This is not equivalent to pounds-force, which is the amount of force required to accelerate an object with one pound of mass at a rate of one G.
      See Also:
    • Ounces

      public static final MassUnit Ounces
      1/16 of a Pound.
    • Ounce

      public static final MassUnit Ounce
      1/16 of a Pound.
    • Newtons

      public static final ForceUnit Newtons
      The standard unit of force, equivalent to accelerating a mass of one Kilogram at a rate of one meter per second per second.
    • Newton

      public static final ForceUnit Newton
      The standard unit of force, equivalent to the standard force of gravity applied to a one Kilogram mass.
    • PoundsForce

      public static final ForceUnit PoundsForce
      The standard Imperial unit of force, equivalent to the standard force of gravity applied to a one Pound mass.
    • PoundForce

      public static final ForceUnit PoundForce
      The standard Imperial unit of force, equivalent to the standard force of gravity applied to a one Pound mass.
    • OuncesForce

      public static final ForceUnit OuncesForce
      1/16th of PoundsForce, equivalent to the standard force of gravity applied to a one Ounce mass.
    • OunceForce

      public static final ForceUnit OunceForce
      1/16th of PoundsForce, equivalent to the standard force of gravity applied to a one Ounce mass.
    • NewtonMeters

      public static final TorqueUnit NewtonMeters
      The standard SI unit for torque.
    • NewtonMeter

      public static final TorqueUnit NewtonMeter
      The standard SI unit for torque.
    • PoundFeet

      public static final TorqueUnit PoundFeet
      The equivalent of one pound of force applied to an object one Foot away from its center of rotation.
    • PoundFoot

      public static final TorqueUnit PoundFoot
      The equivalent of one pound of force applied to an object one Foot away from its center of rotation.
    • PoundInches

      public static final TorqueUnit PoundInches
      The equivalent of one pound of force applied to an object one Inch away from its center of rotation.
    • PoundInch

      public static final TorqueUnit PoundInch
      The equivalent of one pound of force applied to an object one Inch away from its center of rotation.
    • OunceInches

      public static final TorqueUnit OunceInches
      The equivalent of one ounce of force applied to an object one Inch away from its center of rotation.
    • OunceInch

      public static final TorqueUnit OunceInch
      The equivalent of one ounce of force applied to an object one Inch away from its center of rotation.
    • KilogramMetersPerSecond

      public static final LinearMomentumUnit KilogramMetersPerSecond
      The standard SI unit for linear momentum, equivalent to a one Kilogram mass moving at one MetersPerSecond.
    • PoundInchesPerSecond

      public static final LinearMomentumUnit PoundInchesPerSecond
      The equivalent of a one Pound mass moving at one InchesPerSecond.
    • KilogramMetersSquaredPerSecond

      public static final AngularMomentumUnit KilogramMetersSquaredPerSecond
      The standard SI unit for angular momentum, equivalent to a rotating object with a linear momentum of one KilogramMetersPerSecond one Meter away from its center of mass.
    • PoundInchesSquaredPerSecond

      public static final AngularMomentumUnit PoundInchesSquaredPerSecond
      The angular momentum of an object with a linear momentum of one PoundInchesPerSecond one Inch away from its center of mass.
    • KilogramSquareMeters

      public static final MomentOfInertiaUnit KilogramSquareMeters
      The standard SI unit for moment of inertia.
    • PoundSquareInches

      public static final MomentOfInertiaUnit PoundSquareInches
      A common imperial unit for moment of inertia.
    • Volts

      public static final VoltageUnit Volts
      The base unit of electric potential.
    • Volt

      public static final VoltageUnit Volt
      The base unit of electric potential.
    • Millivolts

      public static final VoltageUnit Millivolts
      1/1000 of a Volt. Useful when dealing with low-voltage applications like LED drivers or low-power circuits.
    • Millivolt

      public static final VoltageUnit Millivolt
      1/1000 of a Volt. Useful when dealing with low-voltage applications like LED drivers or low-power circuits.
    • Amps

      public static final CurrentUnit Amps
      The base unit of electrical current.
    • Amp

      public static final CurrentUnit Amp
      The base unit of electrical current.
    • Milliamps

      public static final CurrentUnit Milliamps
      A unit equal to 1/1000 of an Amp. Useful when dealing with low-current applications like LED drivers or low-power circuits.
    • Milliamp

      public static final CurrentUnit Milliamp
      A unit equal to 1/1000 of an Amp. Useful when dealing with low-current applications like LED drivers or low-power circuits.
    • Ohms

      public static final ResistanceUnit Ohms
      The base unit of resistance. Equivalent to one Volt per Amp.
    • Ohm

      public static final ResistanceUnit Ohm
      The base unit of resistance. Equivalent to one Volt per Amp.
    • KiloOhms

      public static final ResistanceUnit KiloOhms
      A unit equal to 1,000 Ohms.
    • KiloOhm

      public static final ResistanceUnit KiloOhm
      A unit equal to 1,000 Ohms.
    • MilliOhms

      public static final ResistanceUnit MilliOhms
      A unit equal to 1/1000 of a Ohm.
    • MilliOhm

      public static final ResistanceUnit MilliOhm
      A unit equal to 1/1000 of a Ohm.
    • Joules

      public static final EnergyUnit Joules
      The base unit of energy.
    • Joule

      public static final EnergyUnit Joule
      The base unit of energy.
    • Millijoules

      public static final EnergyUnit Millijoules
      A unit equal to 1/1000 of a Joule. Useful when dealing with lower-power applications.
    • Millijoule

      public static final EnergyUnit Millijoule
      A unit equal to 1/1000 of a Joule. Useful when dealing with lower-power applications.
    • Kilojoules

      public static final EnergyUnit Kilojoules
      A unit equal to 1,000 Joules. Useful when dealing with higher-level robot energy usage.
    • Kilojoule

      public static final EnergyUnit Kilojoule
      A unit equal to 1,000 Joules. Useful when dealing with higher-level robot energy usage.
    • Watts

      public static final PowerUnit Watts
      The base unit of power. Equivalent to one Joule per Second.
    • Watt

      public static final PowerUnit Watt
      The base unit of power. Equivalent to one Joule per Second.
    • Milliwatts

      public static final PowerUnit Milliwatts
      A unit equal to 1/1000 of a Watt. Useful when dealing with lower-power applications.
    • Milliwatt

      public static final PowerUnit Milliwatt
      A unit equal to 1/1000 of a Watt. Useful when dealing with lower-power applications.
    • Horsepower

      public static final PowerUnit Horsepower
      A unit equal to 745.7 Watts. May be useful when dealing with high-power gearboxes and motors.
    • Kelvin

      public static final TemperatureUnit Kelvin
      The base unit of temperature, where a value of 0 corresponds with absolutely zero energy in the measured system. Not particularly useful for robots unless you're cooling motors with liquid helium.
    • Celsius

      public static final TemperatureUnit Celsius
      The standard SI unit of temperature, where a value of 0 roughly corresponds to the freezing point of water and a value of 100 corresponds to the boiling point. Electronics tend to exhibit degraded performance or damage above 90 degrees Celsius.
    • Fahrenheit

      public static final TemperatureUnit Fahrenheit
      The base imperial (American) unit of temperature, where a value of 32 roughly corresponds to the freezing point of water and a value of 212 corresponds to the boiling point.
    • VoltsPerMeterPerSecond

      public static final PerUnit<VoltageUnit, LinearVelocityUnit> VoltsPerMeterPerSecond
      A standard unit for measuring linear mechanisms' feedforward voltages based on a model of the system and a desired commanded linear velocity.
    • VoltsPerMeterPerSecondSquared

      public static final PerUnit<VoltageUnit, LinearAccelerationUnit> VoltsPerMeterPerSecondSquared
      A standard unit for measuring linear mechanisms' feedforward voltages based on a model of the system and a desired commanded linear acceleration.
    • VoltsPerRadianPerSecond

      public static final PerUnit<VoltageUnit, AngularVelocityUnit> VoltsPerRadianPerSecond
      A standard unit for measuring angular mechanisms' feedforward voltages based on a model of the system and a desired commanded angular velocity.
    • VoltsPerRadianPerSecondSquared

      public static final PerUnit<VoltageUnit, AngularAccelerationUnit> VoltsPerRadianPerSecondSquared
      A standard unit for measuring angular mechanisms' feedforward voltages based on a model of the system and a desired commanded angular acceleration.
  • Method Details

    • Milli

      public static <U extends Unit> U Milli(U baseUnit, String name, String symbol)
      Creates a unit equal to a thousandth of the base unit, eg Milliseconds = Milli(Units.Seconds).
      Type Parameters:
      U - the type of the unit
      Parameters:
      baseUnit - the unit being derived from. This does not have to be the base unit of measure
      name - the name of the new derived unit
      symbol - the symbol of the new derived unit
      Returns:
      the milli-unit
    • Milli

      public static <U extends Unit> U Milli(U baseUnit)
      Creates a unit equal to a thousandth of the base unit, eg Milliseconds = Milli(Units.Seconds).
      Type Parameters:
      U - the type of the unit
      Parameters:
      baseUnit - the unit being derived from. This does not have to be the base unit of measure
      Returns:
      the milli-unit
    • Micro

      public static <U extends Unit> U Micro(U baseUnit, String name, String symbol)
      Creates a unit equal to a millionth of the base unit, eg Microseconds = Micro(Units.Seconds, "Microseconds", 'us").
      Type Parameters:
      U - the type of the unit
      Parameters:
      baseUnit - the unit being derived from. This does not have to be the base unit of measure
      name - the name of the new derived unit
      symbol - the symbol of the new derived unit
      Returns:
      the micro-unit
    • Micro

      public static <U extends Unit> U Micro(U baseUnit)
      Creates a unit equal to a millionth of the base unit, eg Microseconds = Micro(Units.Seconds).
      Type Parameters:
      U - the type of the unit
      Parameters:
      baseUnit - the unit being derived from. This does not have to be the base unit of measure
      Returns:
      the micro-unit
    • Kilo

      public static <U extends Unit> U Kilo(U baseUnit, String name, String symbol)
      Creates a unit equal to a thousand of the base unit, eg Kilograms = Kilo(Units.Grams).
      Type Parameters:
      U - the type of the unit
      Parameters:
      baseUnit - the unit being derived from. This does not have to be the base unit of measure
      name - the name of the new derived unit
      symbol - the symbol of the new derived unit
      Returns:
      the kilo-unit
    • Kilo

      public static <U extends Unit> U Kilo(U baseUnit)
      Creates a unit equal to a thousand of the base unit, eg Kilograms = Kilo(Units.Grams).
      Type Parameters:
      U - the type of the unit
      Parameters:
      baseUnit - the unit being derived from. This does not have to be the base unit of measure
      Returns:
      the kilo-unit
    • derive

      public static <U extends Unit> UnitBuilder<U> derive(U unit)
      Creates a new unit builder object based on a given input unit. The builder can be used to fluently describe a new unit in terms of its relation to the base unit.
      Type Parameters:
      U - the dimension of the unit to derive
      Parameters:
      unit - the base unit from which to derive a new unit
      Returns:
      a builder object