Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Holden9607/FRC-Academy/llms.txt

Use this file to discover all available pages before exploring further.

WPILib includes utility classes that go beyond basic motor control. This page covers MathUtil, PIDController, and NetworkTable — tools you’ll use as your robot code grows more sophisticated. While FRC Academy’s introductory lessons focus on direct motor output, these classes become essential the moment you start handling real joystick drift, automated movement, or driver-station telemetry.

edu.wpi.first.math.*

MathUtil

Full class: edu.wpi.first.math.MathUtil A static utility class that exposes helper methods to bounds-restrict and normalize numeric ranges gracefully. All methods are static — no instance is needed. Key Static Methods
MethodReturnsDescription
MathUtil.clamp(double value, double low, double high)doubleClamps value to the range [low, high] — values outside the range are pinned to the nearest bound
MathUtil.applyDeadband(double value, double deadband)doubleReturns 0.0 if `value< deadband`; otherwise scales the remaining range to start from zero. Useful for joystick drift
MathUtil.inputModulus(double input, double minimumInput, double maximumInput)doubleWraps input within a continuous range — handy for angle arithmetic
Example — Joystick Deadband Joysticks rarely return exactly 0.0 when centered. Use applyDeadband to ignore small noise values and prevent the motors from creeping:
import edu.wpi.first.math.MathUtil;

double rawY = driverController.getLeftY();
double speed = MathUtil.applyDeadband(rawY, 0.05); // ignore values under ±5%
m_leftMotor.set(speed);

PIDController

Full class: edu.wpi.first.math.controller.PIDController Calculates error-correction outputs using proportional, integral, and derivative gains. Feed it a sensor measurement and a target setpoint each loop cycle, and it returns the corrective output to apply to your motor. Constructor
new PIDController(double kP, double kI, double kD)
ParameterTypeDescription
kPdoubleProportional gain — primary driving term
kIdoubleIntegral gain — corrects steady-state error over time
kDdoubleDerivative gain — dampens oscillation
Key Methods
MethodReturnsDescription
calculate(double measurement, double setpoint)doubleReturns the corrective output for this loop cycle
setTolerance(double positionTolerance)voidDefines the acceptable error window around the setpoint
atSetpoint()booleanReturns true when the measurement is within the configured tolerance
reset()voidClears the integral accumulator — call this before restarting a move
Example
import edu.wpi.first.math.controller.PIDController;

PIDController pid = new PIDController(0.1, 0.0, 0.01);
double output = pid.calculate(encoder.getDistance(), targetDistance);
m_motor.set(output);

edu.wpi.first.networktables.*

NetworkTable

Full class: edu.wpi.first.networktables.NetworkTable The core data structure managing fast telemetry synchronization between the robot and driver station dashboards such as Shuffleboard and SmartDashboard. Data is organized into named tables, and each table holds key-value entries that stream live over the network. Key Usage Pattern
import edu.wpi.first.networktables.NetworkTableInstance;
import edu.wpi.first.networktables.NetworkTable;

NetworkTable table = NetworkTableInstance.getDefault().getTable("MyRobot");
table.getEntry("motorSpeed").setDouble(m_motor.get());
Call this inside teleopPeriodic() or periodic() to continuously push live values to the dashboard.
Use SmartDashboard.putNumber("motorSpeed", m_motor.get()) as a simpler one-liner alternative during development — it writes to the default NetworkTable under the hood, and the value appears instantly in Shuffleboard.

MathUtil and PIDController are not directly used in FRC Academy’s current introductory lessons, but they are essential tools in any real FRC codebase. Expect to reach for them as soon as you start building autonomous routines or more precise teleop behaviors.

WPILib Core

TimedRobot, XboxController, DriverStation, and the foundational WPILib framework classes.

WPILib Commands

CommandXboxController, RunCommand, InstantCommand, and the command-based architecture.

Build docs developers (and LLMs) love