wpimath functions

wpimath.angleModulus(angle: wpimath.units.radians) wpimath.units.radians
wpimath.applyDeadband(value: SupportsFloat | SupportsIndex, deadband: SupportsFloat | SupportsIndex, maxMagnitude: SupportsFloat | SupportsIndex = 1.0) float

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

Parameters:
  • value – Value to clip.

  • deadband – Range around zero.

  • maxMagnitude – The maximum magnitude of the input (defaults to 1). Can be infinite.

Returns:

The value after the deadband is applied.

wpimath.copyDirectionPow(value: SupportsFloat | SupportsIndex, exponent: SupportsFloat | SupportsIndex, maxMagnitude: SupportsFloat | SupportsIndex = 1.0) float

Raises the input to the power of the given exponent while preserving its sign.

The function normalizes the input value to the range [0, 1] based on the maximum magnitude so that the output stays in the range.

This is useful for applying smoother or more aggressive control response curves (e.g. joystick input shaping).

Parameters:
  • value – The input value to transform.

  • exponent – The exponent to apply (e.g. 1.0 = linear, 2.0 = squared curve). Must be positive.

  • maxMagnitude – The maximum expected absolute value of input (defaults to 1). Must be positive.

Returns:

The transformed value with the same sign and scaled to the input range.

wpimath.inputModulus(input: SupportsFloat | SupportsIndex, minimumInput: SupportsFloat | SupportsIndex, maximumInput: SupportsFloat | SupportsIndex) float

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.

wpimath.objectToRobotPose(objectInField: wpimath.geometry._geometry.Pose3d, cameraToObject: wpimath.geometry._geometry.Transform3d, robotToCamera: wpimath.geometry._geometry.Transform3d) wpimath.geometry._geometry.Pose3d
wpimath.slewRateLimit(*args, **kwargs)

Overloaded function.

  1. slewRateLimit(current: wpimath.geometry._geometry.Translation2d, next: wpimath.geometry._geometry.Translation2d, dt: wpimath.units.seconds, maxVelocity: wpimath.units.meters_per_second) -> wpimath.geometry._geometry.Translation2d

Limits translation velocity.

Parameters:
  • current – Translation at current timestep.

  • next – Translation at next timestep.

  • dt – Timestep duration.

  • maxVelocity – Maximum translation velocity.

Returns:

Returns the next Translation2d limited to maxVelocity

  1. slewRateLimit(current: wpimath.geometry._geometry.Translation3d, next: wpimath.geometry._geometry.Translation3d, dt: wpimath.units.seconds, maxVelocity: wpimath.units.meters_per_second) -> wpimath.geometry._geometry.Translation3d

Limits translation velocity.

Parameters:
  • current – Translation at current timestep.

  • next – Translation at next timestep.

  • dt – Timestep duration.

  • maxVelocity – Maximum translation velocity.

Returns:

Returns the next Translation3d limited to maxVelocity