mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-04 03:11:43 +00:00
[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:
@@ -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)
|
||||
Reference in New Issue
Block a user