class frc_apriltags.Utilities.MathUtil

Bases: object

Use this class to perform useful math functions.

static angleModulus(angleRadians)

Wraps an angle to the range -pi to pi radians.

Parameters:

angleRadians – Angle to wrap, in radians.

Returns:

The wrapped angle.

static applyDeadband(value, deadband)

Returns 0.0 if the given value is within the specified range around zero. The remaining range between the deadband and 1.0 is scaled from 0.0 to 1.0.

Parameters:
  • value – Value to clip.

  • deadband – Range around zero.

Returns:

The value after the deadband is applied.

static clamp(value, low, high)

Returns value clamped between low and high boundaries.

Parameters:
  • value – Value to clamp.

  • low – The lower boundary to which to clamp value.

  • high – The higher boundary to which to clamp value.

Returns:

The clamped value.

static inputModulus(input, minimumInput, maximumInput)

Returns modulus of input.

Parameters:
  • input – Input value to wrap.

  • minimumInput – The minimum value expected from the input.

  • maximumInput – The maximum value expected from the input.

Returns:

The wrapped value.

static interpolate(startValue, endValue, t)

Perform linear interpolation between two values.

Parameters:
  • startValue – The value to start at.

  • endValue – The value to end at.

  • t – How far between the two values to interpolate. This is clamped to [0, 1].

Returns:

The interpolated value.