mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-03 03:01:44 +00:00
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>
19 lines
538 B
Python
19 lines
538 B
Python
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)
|