Package edu.wpi.first.units
Class Units
java.lang.Object
edu.wpi.first.units.Units
public final class Units extends Object
Contains a set of predefined units.
-
Field Summary
Fields Modifier and Type Field Description static Current
Amp
The base unit of electrical current.static Current
Amps
The base unit of electrical current.static Unit
AnonymousBaseUnit
Used as an internal placeholder value when a specific unit type cannot be determined.static Temperature
Celsius
The base 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.static Distance
Centimeter
1/100 of aMeter
.static Distance
Centimeters
1/100 of aMeter
.static Angle
Degree
1/360 of a turn around a circle, or 1/57.3Radians
.static Angle
Degrees
1/360 of a turn around a circle, or 1/57.3Radians
.static Velocity<Angle>
DegreesPerSecond
static Temperature
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.static Distance
Feet
static Velocity<Distance>
FeetPerSecond
static Distance
Foot
static Mass
Gram
1/1000 of aKilogram
.static Mass
Grams
1/1000 of aKilogram
.static Velocity<Velocity<Distance>>
Gs
A unit of acceleration equivalent to the pull of gravity on an object at sea level on Earth.static Power
Horsepower
A unit equal to 745.7Watts
.static Distance
Inch
static Distance
Inches
static Velocity<Distance>
InchesPerSecond
static Energy
Joule
The base unit of energy.static Energy
Joules
The base unit of energy.static Temperature
Kelvin
The base unit of temperature, where a value of 0 corresponds with absolutely zero energy in the measured system.static Mass
Kilogram
The base SI unit of mass.static Mass
Kilograms
The base SI unit of mass.static Energy
Kilojoule
A unit equal to 1,000Joules
.static Energy
Kilojoules
A unit equal to 1,000Joules
.static Distance
Meter
The base unit of distance.static Distance
Meters
The base unit of distance.static Velocity<Distance>
MetersPerSecond
static Velocity<Velocity<Distance>>
MetersPerSecondPerSecond
static Time
Microsecond
Alias forMicroseconds
to make combined unit definitions read more smoothly.static Time
Microseconds
1/1,000,000 of aSecond
.static Current
Milliamp
A unit equal to 1/1000 of anAmp
.static Current
Milliamps
A unit equal to 1/1000 of anAmp
.static Energy
Millijoule
A unit equal to 1/1000 of aJoule
.static Energy
Millijoules
A unit equal to 1/1000 of aJoule
.static Distance
Millimeter
1/1000 of aMeter
.static Distance
Millimeters
1/1000 of aMeter
.static Time
Millisecond
Alias forMilliseconds
to make combined unit definitions read more smoothly.static Time
Milliseconds
1/1000 of aSecond
.static Voltage
Millivolt
1/1000 of aVolt
.static Voltage
Millivolts
1/1000 of aVolt
.static Power
Milliwatt
A unit equal to 1/1000 of aWatt
.static Power
Milliwatts
A unit equal to 1/1000 of aWatt
.static Time
Minute
Alias forMinutes
to make combined unit definitions read more smoothly.static Time
Minutes
60Seconds
.static Mass
Ounce
1/16 of aPound
.static Mass
Ounces
1/16 of aPound
.static Dimensionless
Percent
A dimensionless unit equal to to 1/100th of aValue
.static Mass
Pound
A unit of mass equivalent to approximately 453Grams
.static Mass
Pounds
A unit of mass equivalent to approximately 453Grams
.static Angle
Radian
The base SI unit of angle, represented by the distance that the radius of a unit circle can wrap around its circumference.static Angle
Radians
The base SI unit of angle, represented by the distance that the radius of a unit circle can wrap around its circumference.static Velocity<Angle>
RadiansPerSecond
static Angle
Revolution
A single turn of an object around an external axis.static Angle
Revolutions
A single turn of an object around an external axis.static Velocity<Angle>
RevolutionsPerSecond
A unit of angular velocity equivalent to spinning at a rate of oneRevolution
perSecond
.static Angle
Rotation
A single turn of an object around an internal axis.static Angle
Rotations
A single turn of an object around an internal axis.static Velocity<Angle>
RotationsPerSecond
static Velocity<Angle>
RPM
static Time
Second
Alias forSeconds
to make combined unit definitions read more smoothly.static Time
Seconds
The base unit of time.static Dimensionless
Value
A dimensionless unit that performs no scaling whatsoever.static Voltage
Volt
The base unit of electric potential.static Voltage
Volts
The base unit of electric potential.static Per<Voltage,Velocity<Distance>>
VoltsPerMeterPerSecond
A standard unit for measuring linear mechanisms' feedforward voltages based on a model of the system and a desired commanded linear velocity.static Per<Voltage,Velocity<Velocity<Distance>>>
VoltsPerMeterPerSecondSquared
A standard unit for measuring linear mechanisms' feedforward voltages based on a model of the system and a desired commanded linear acceleration.static Per<Voltage,Velocity<Angle>>
VoltsPerRadianPerSecond
A standard unit for measuring angular mechanisms' feedforward voltages based on a model of the system and a desired commanded angular velocity.static Per<Voltage,Velocity<Velocity<Angle>>>
VoltsPerRadianPerSecondSquared
A standard unit for measuring angular mechanisms' feedforward voltages based on a model of the system and a desired commanded angular acceleration.static Power
Watt
The base unit of power.static Power
Watts
The base unit of power. -
Method Summary
Modifier and Type Method Description static <U extends Unit<U>>
Uanonymous()
Returns an anonymous unit for use when a specific unit type is not known.static <U extends Unit<U>>
UnitBuilder<U>derive(Unit<U> unit)
Creates a new unit builder object based on a given input unit.static <U extends Unit<U>>
UKilo(Unit<U> baseUnit)
Creates a unit equal to a thousand of the base unit, eg Kilograms = Kilo(Units.Grams).static <U extends Unit<U>>
UKilo(Unit<U> baseUnit, String name, String symbol)
Creates a unit equal to a thousand of the base unit, eg Kilograms = Kilo(Units.Grams).static <U extends Unit<U>>
UMicro(Unit<U> baseUnit)
Creates a unit equal to a millionth of the base unit, eg Microseconds = Micro(Units.Seconds).static <U extends Unit<U>>
UMicro(Unit<U> baseUnit, String name, String symbol)
Creates a unit equal to a millionth of the base unit, egMicroseconds = Micro(Units.Seconds, "Microseconds", 'us")
.static <U extends Unit<U>>
UMilli(Unit<U> baseUnit)
Creates a unit equal to a thousandth of the base unit, eg Milliseconds = Milli(Units.Seconds).static <U extends Unit<U>>
UMilli(Unit<U> baseUnit, String name, String symbol)
Creates a unit equal to a thousandth of the base unit, eg Milliseconds = Milli(Units.Seconds).
-
Field Details
-
AnonymousBaseUnit
Used as an internal placeholder value when a specific unit type cannot be determined. Do not use this directly. -
Meters
The base unit of distance. -
Meter
The base unit of distance. -
Millimeters
1/1000 of aMeter
. -
Millimeter
1/1000 of aMeter
. -
Centimeters
1/100 of aMeter
. -
Centimeter
1/100 of aMeter
. -
Inches
-
Inch
-
Feet
-
Foot
-
Seconds
The base unit of time. -
Second
Alias forSeconds
to make combined unit definitions read more smoothly. -
Milliseconds
1/1000 of aSecond
. -
Millisecond
Alias forMilliseconds
to make combined unit definitions read more smoothly. -
Microseconds
1/1,000,000 of aSecond
. -
Microsecond
Alias forMicroseconds
to make combined unit definitions read more smoothly. -
Minutes
60Seconds
. -
Minute
Alias forMinutes
to make combined unit definitions read more smoothly. -
Radians
The base SI unit of angle, represented by the distance that the radius of a unit circle can wrap around its circumference. -
Radian
The base SI unit of angle, represented by the distance that the radius of a unit circle can wrap around its circumference. -
Revolutions
A single turn of an object around an external axis. Numerically equivalent toRotations
, but may be semantically more expressive in certain scenarios. -
Revolution
A single turn of an object around an external axis. Numerically equivalent to aRotation
, but may be semantically more expressive in certain scenarios. -
Rotations
A single turn of an object around an internal axis. Numerically equivalent toRevolutions
, but may be semantically more expressive in certain scenarios. -
Rotation
A single turn of an object around an internal axis. Numerically equivalent to aRevolution
, but may be semantically more expressive in certain scenarios. -
Degrees
1/360 of a turn around a circle, or 1/57.3Radians
. -
Degree
1/360 of a turn around a circle, or 1/57.3Radians
. -
MetersPerSecond
-
FeetPerSecond
-
InchesPerSecond
-
RevolutionsPerSecond
A unit of angular velocity equivalent to spinning at a rate of oneRevolution
perSecond
. -
RotationsPerSecond
-
RPM
-
RadiansPerSecond
-
DegreesPerSecond
-
MetersPerSecondPerSecond
-
Gs
A unit of acceleration equivalent to the pull of gravity on an object at sea level on Earth. -
Kilograms
The base SI unit of mass. -
Kilogram
The base SI unit of mass. -
Grams
1/1000 of aKilogram
. -
Gram
1/1000 of aKilogram
. -
Pounds
-
Pound
-
Ounces
1/16 of aPound
. -
Ounce
1/16 of aPound
. -
Value
A dimensionless unit that performs no scaling whatsoever. -
Percent
A dimensionless unit equal to to 1/100th of aValue
. A measurement ofPercent.of(42)
would be equivalent toValue.of(0.42)
. -
Volts
The base unit of electric potential. -
Volt
The base unit of electric potential. -
Millivolts
1/1000 of aVolt
. Useful when dealing with low-voltage applications like LED drivers or low-power circuits. -
Millivolt
1/1000 of aVolt
. Useful when dealing with low-voltage applications like LED drivers or low-power circuits. -
Amps
The base unit of electrical current. -
Amp
The base unit of electrical current. -
Milliamps
A unit equal to 1/1000 of anAmp
. Useful when dealing with low-current applications like LED drivers or low-power circuits. -
Milliamp
A unit equal to 1/1000 of anAmp
. Useful when dealing with low-current applications like LED drivers or low-power circuits. -
Joules
The base unit of energy. -
Joule
The base unit of energy. -
Millijoules
A unit equal to 1/1000 of aJoule
. Useful when dealing with lower-power applications. -
Millijoule
A unit equal to 1/1000 of aJoule
. Useful when dealing with lower-power applications. -
Kilojoules
A unit equal to 1,000Joules
. Useful when dealing with higher-level robot energy usage. -
Kilojoule
A unit equal to 1,000Joules
. Useful when dealing with higher-level robot energy usage. -
Watts
-
Watt
-
Milliwatts
A unit equal to 1/1000 of aWatt
. Useful when dealing with lower-power applications. -
Milliwatt
A unit equal to 1/1000 of aWatt
. Useful when dealing with lower-power applications. -
Horsepower
A unit equal to 745.7Watts
. May be useful when dealing with high-power gearboxes and motors. -
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
The base 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
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
A standard unit for measuring linear mechanisms' feedforward voltages based on a model of the system and a desired commanded linear velocity. -
VoltsPerMeterPerSecondSquared
A standard unit for measuring linear mechanisms' feedforward voltages based on a model of the system and a desired commanded linear acceleration. -
VoltsPerRadianPerSecond
A standard unit for measuring angular mechanisms' feedforward voltages based on a model of the system and a desired commanded angular velocity. -
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
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 measurename
- the name of the new derived unitsymbol
- the symbol of the new derived unit- Returns:
- the milli-unit
-
Milli
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
Creates a unit equal to a millionth of the base unit, egMicroseconds = 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 measurename
- the name of the new derived unitsymbol
- the symbol of the new derived unit- Returns:
- the micro-unit
-
Micro
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
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 measurename
- the name of the new derived unitsymbol
- the symbol of the new derived unit- Returns:
- the kilo-unit
-
Kilo
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
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
-
anonymous
Returns an anonymous unit for use when a specific unit type is not known. Do not use this directly.- Type Parameters:
U
- the dimension of the desired anonymous unit- Returns:
- the anonymous unit
-