Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Rotation2d
✓ from wpimath.geometry import Rotation2d
✗ from wpimath import Rotation2d
Leading to AttributeError: module 'wpimath' has no attribute 'Rotation2d'
Pose2d
✓ from wpimath.geometry import Pose2d
✗ from wpimath import Pose2d
Same issue; geometry module is separate
SwerveDrive2Kinematics
✓ from wpimath.kinematics import SwerveDrive2Kinematics
✗ from wpimath import SwerveDrive2Kinematics
Kinematics module is required
DifferentialDriveKinematics
✓ from wpimath.kinematics import DifferentialDriveKinematics
✗ from wpimath import DifferentialDriveKinematics
Common import error
Trajectory
✓ from wpimath.trajectory import Trajectory
✗ from robotpy.wpimath import Trajectory
Old pattern from robotpy-wpilib; now under wpimath.trajectory
Basic usage: geometry objects (Rotation2d, Translation2d) and SwerveDrive2Kinematics example.
from wpimath.geometry import Rotation2d, Translation2d
from wpimath.kinematics import SwerveDrive2Kinematics, SwerveDrive2ModuleState
# Example: Create a rotation and translation
rot = Rotation2d.fromDegrees(90)
trans = Translation2d(3, 4)
print(f"Rotation: {rot.degrees()} deg")
print(f"Translation: {trans}")
# Example: Swerve kinematics (module positions in meters)
frontLeft = Translation2d(0.381, 0.381) # 15 inches
frontRight = Translation2d(0.381, -0.381)
backLeft = Translation2d(-0.381, 0.381)
backRight = Translation2d(-0.381, -0.381)
kinematics = SwerveDrive2Kinematics(frontLeft, frontRight, backLeft, backRight)
# Desired chassis speed (m/s), rotation (rad/s), and center of rotation
chassis_speed = Translation2d(1.0, 0.0)
chassis_omega = 0.0
states = kinematics.toSwerveModuleStates(chassis_speed, chassis_omega)
for i, s in enumerate(states):
print(f"Module {i}: speed={s.speed} m/s, angle={s.angle.degrees()} deg")
Debug
Known issues
breakingBreaking changes at each year version (e.g., 2025.x.x to 2026.x.x). Algebra classes like Pose2d and Twist2d may change method signatures or add new required arguments.fixCheck the WPILib migration guide for each year. Update code to match new signatures.
affects: 2024.x.x -> 2025.x.x -> 2026.x.x
deprecatedTrajectory parameterization and differential drive kinematics from old wpilib module are deprecated. Use wpimath.trajectory and wpimath.kinematics directly.fixUpdate imports: from wpimath.kinematics import DifferentialDriveKinematics instead of from wpilib import kinematics.
affects: 2023.x.x and earlier
gotchaRotation2d and Translation2d are immutable. Methods like rotateBy return a new object.fixAlways assign the result: rot2 = rot1.rotateBy(other). Do not rely on mutability.
affects: All
gotchaUnit handling: LinearVelocity and AngularVelocity classes are used in kinematics. Forgetting to provide the correct unit (e.g., meters per second vs feet per second) leads to runtime errors.fixUse wpimath.units (e.g., from wpimath.units import metersPerSecond) to construct velocity objects.
affects: All
breakingSwerveDrive2Kinematics (and 4) changed the order of module positions in some year versions. The order (frontLeft, frontRight, backLeft, backRight) must match the expected wheel ordering.fixVerify the order matches WPILib convention. Typically: frontLeft, frontRight, backLeft, backRight (counterclockwise when looking from above).
affects: 2025.x.x -> 2026.x.x
Errors
Common errors & fixes
AttributeError: module 'wpimath' has no attribute 'Rotation2d'
Importing from the top-level wpimath instead of its submodule.
fixUse 'from wpimath.geometry import Rotation2d'.
TypeError: __init__() takes 1 positional argument but 2 were given
Using old constructor pattern for Rotation2d (e.g., Rotation2d(x, y)). The current version takes radians or uses factory methods.
fixUse 'Rotation2d(radians)' or 'Rotation2d.fromDegrees(degrees)' or 'Rotation2d(cos, sin)' with named parameters: 'Rotation2d(cosAngle=cos, sinAngle=sin)'.
ModuleNotFoundError: No module named 'wpimath.geometry'
Installed an older version of robotpy-wpimath that does not include the geometry submodule. Or misconfigured robotpy installation.
fixUpgrade: 'pip install --upgrade robotpy-wpimath'. If using robotpy-wpilib, ensure both are same year version.
ValueError: The number of modules does not match the number of wheel locations
SwerveDrive2Kinematics expects exactly 4 Translation2d objects for a 4-module swerve drive.
fixProvide exactly 4 positions: (frontLeft, frontRight, backLeft, backRight).
Upgrade
Version history
2026.2.2latest on PyPI · released Mar 13, 2026
Audit
Dependencies
robotpy-wpiutilrequiredRequired for unit handling and low-level WPILib utilities
numpyoptionalUsed for matrix representations in kinematics and trajectory calculations
Resources
No resource links recorded.