[py] Add wpimath/kinematics tests (#8461)

Used Gemini to convert the C++ tests in wpimath/.../kinematics to
pytest. For ease of use required a better constructor for
`MecanumDriveWheelPositions`

I did this conversion months ago (before robotpy landed and before the
reorg), so new tests might be missing. At least its better than nothing
🤷

Broke the huge pr that does almost everything into parts so its easier
to review.

---------

Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
This commit is contained in:
PJ Reiniger
2026-01-12 22:14:14 -05:00
committed by GitHub
parent c2b339cfc9
commit eccc2301ac
15 changed files with 2061 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
import pytest
import math
from wpimath import DifferentialDriveOdometry, Rotation2d
def test_encoder_distances():
odometry = DifferentialDriveOdometry(
gyroAngle=Rotation2d.fromDegrees(45), leftDistance=0, rightDistance=0
)
pose = odometry.update(
gyroAngle=Rotation2d.fromDegrees(135), rightDistance=0, leftDistance=5 * math.pi
)
assert pose.x == pytest.approx(5.0, abs=1e-9)
assert pose.y == pytest.approx(5.0, abs=1e-9)
assert pose.rotation().degrees() == pytest.approx(90.0, abs=1e-9)