Class Formula
java.lang.Object
dev.doglog.Formula
A formula that DogLog Studio calculates a computed entry with, from the values of other entries.
Log one with
DogLog.computed(String, Formula).
Build formulas from entries and numbers with the static methods and the arithmetic methods,
ex. abs(entry("Arm/Position").minus(entry("Arm/Target"))).minus(Inches.of(2)). Studio
converts between units, so values with different units of the same measure can be combined.
Comparisons, like lessThan(Formula), make a Condition.
Fields of logged structs are entries too, ex. entry("Drive/Pose/translation/x"), and
Studio knows the units of WPILib's.
toString() returns the formula's text in the @team581/log-formula language.
-
Method Summary
Modifier and TypeMethodDescriptionstatic FormulaThe absolute value.static FormulaThe angle of the point (x,y) from the X axis, in radians.static FormulaavgOverTime(Condition value) The fraction of the time since the first value that the condition was true, from 0 to 1.static FormulaavgOverTime(Condition value, org.wpilib.units.measure.Time window) The fraction of the lastwindowthat the condition was true, from 0 to 1.static FormulaavgOverTime(Formula value) The average since the first value, weighted by how long each value was held.static FormulaavgOverTime(Formula value, org.wpilib.units.measure.Time window) The average over the lastwindow, weighted by how long each value was held, ex.static FormulaThe value rounded up, for numbers without a unit.static FormulaThe value limited tolowthroughhigh.static FormulaThe cosine of an angle.static FormulaHow many times the condition became true, ex.static Formula0 when the value is withinwidthof 0, otherwise the value.static Formuladerivative(Formula value) The rate of change per second, ex.div(double other) This divided by a number.This divided byother.div(org.wpilib.units.Measure<?> other) This divided by a measure.static FormulaAn entry's value.static FormulaAn entry's value in a unit, for entries logged without unit metadata.booleanstatic FormulaThe value rounded down, for numbers without a unit.greaterThan(double other) Whether this is more than a number.greaterThan(Formula other) Whether this is more thanother.greaterThan(org.wpilib.units.Measure<?> other) Whether this is more than a measure.greaterThanOrEqualTo(double other) Whether this is at least a number.greaterThanOrEqualTo(Formula other) Whether this is at leastother.greaterThanOrEqualTo(org.wpilib.units.Measure<?> other) Whether this is at least a measure.inthashCode()static FormulaThe square root of the sum of the values' squares, ex.static FormulaThe sum of the value over time in seconds, ex.isEqualTo(double other) Whether this is exactly a number, seeisNear(Formula, Formula)for measured values.Whether this is exactlyother, seeisNear(Formula, Formula).isEqualTo(org.wpilib.units.Measure<?> other) Whether this is exactly a measure, seeisNear(Formula, Formula).isNear(double other, double tolerance) Whether this is withintoleranceof a number, likeMathUtil.isNear().Whether this is less thantoleranceaway fromother, likeMathUtil.isNear().Whether this is withintoleranceofother, ex.isNear(org.wpilib.units.Measure<?> other, org.wpilib.units.Measure<?> tolerance) Whether this is withintoleranceof a measure.isNotEqualTo(double other) Whether this isn't exactly a number.isNotEqualTo(Formula other) Whether this isn't exactlyother.isNotEqualTo(org.wpilib.units.Measure<?> other) Whether this isn't exactly a measure.lessThan(double other) Whether this is less than a number.Whether this is less thanother.lessThan(org.wpilib.units.Measure<?> other) Whether this is less than a measure.lessThanOrEqualTo(double other) Whether this is at most a number.lessThanOrEqualTo(Formula other) Whether this is at mostother.lessThanOrEqualTo(org.wpilib.units.Measure<?> other) Whether this is at most a measure.static FormulaThe largest value, in the first value's unit.static FormulamaxOverTime(Formula value) The largest value since the first one, including the current value.static FormulamaxOverTime(Formula value, org.wpilib.units.measure.Time window) The largest value over the lastwindow, including the current value.static FormulaThe smallest value, in the first value's unit.static FormulaminOverTime(Formula value) The smallest value since the first one, including the current value.static FormulaminOverTime(Formula value, org.wpilib.units.measure.Time window) The smallest value over the lastwindow, including the current value.minus(double other) This minus a number.This minusother.minus(org.wpilib.units.Measure<?> other) This minus a measure.negate()The negative of this.static Formulaof(double value) A number without a unit.static Formulaof(double value, org.wpilib.units.Unit unit) A number in a unit, ex.static Formulaof(org.wpilib.units.Measure<?> value) A measure, ex.plus(double other) This plus a number.This plusother.plus(org.wpilib.units.Measure<?> other) This plus a measure.pow(double exponent) This to the power of a number, an integer when this has a unit.This to the power ofexponent, which has no unit.static FormulaThe value rounded to the nearest integer, halves away from zero, for numbers without a unit.static Formula-1, 0, or 1 for negative, zero, or positive values, without a unit.static FormulaThe sine of an angle.static FormulaThe square root, its unit's powers are halved.static FormulaThe seconds the condition was true the latest time, counting up while it is and keeping that time's length after it ends, ex.times(double other) This times a number.This timesother.times(org.wpilib.units.Measure<?> other) This times a measure.toString()The formula's text, ex.static FormulaThe seconds the condition was true since the first value, ex.static FormulaAn angle that keeps counting past a full turn instead of wrapping, ex.static FormulaAn angle wrapped to a half turn either way, ex.
-
Method Details
-
abs
-
atan2
-
avgOverTime
-
avgOverTime
-
avgOverTime
-
avgOverTime
-
ceil
-
clamp
-
cos
-
count
-
deadband
-
derivative
-
entry
-
entry
-
floor
-
hypot
-
integral
-
max
-
maxOverTime
-
maxOverTime
-
min
-
minOverTime
-
minOverTime
-
of
A number without a unit. -
of
A number in a unit, ex.of(2, Inches). -
of
A measure, ex.of(Inches.of(2)). -
round
-
sign
-
sin
-
sqrt
-
time
-
totalTime
-
unwrap
-
wrap
-
div
This divided by a number. -
div
-
div
This divided by a measure. -
equals
-
greaterThan
Whether this is more than a number. -
greaterThan
-
greaterThan
Whether this is more than a measure. -
greaterThanOrEqualTo
Whether this is at least a number. -
greaterThanOrEqualTo
-
greaterThanOrEqualTo
Whether this is at least a measure. -
hashCode
-
isEqualTo
Whether this is exactly a number, seeisNear(Formula, Formula)for measured values. -
isEqualTo
Whether this is exactlyother, seeisNear(Formula, Formula). -
isEqualTo
Whether this is exactly a measure, seeisNear(Formula, Formula). -
isNear
Whether this is withintoleranceof a number, likeMathUtil.isNear(). -
isNear
-
isNear
-
isNear
Whether this is withintoleranceof a measure. -
isNotEqualTo
Whether this isn't exactly a number. -
isNotEqualTo
-
isNotEqualTo
Whether this isn't exactly a measure. -
lessThan
Whether this is less than a number. -
lessThan
-
lessThan
Whether this is less than a measure. -
lessThanOrEqualTo
Whether this is at most a number. -
lessThanOrEqualTo
-
lessThanOrEqualTo
Whether this is at most a measure. -
minus
This minus a number. -
minus
-
minus
This minus a measure. -
negate
The negative of this. -
plus
This plus a number. -
plus
-
plus
This plus a measure. -
pow
This to the power of a number, an integer when this has a unit. -
pow
-
times
This times a number. -
times
-
times
This times a measure. -
toString
-