mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[copybara] Resync with mostrobotpy (#8662)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
[build-system]
|
||||
build-backend = "hatchling.build"
|
||||
requires = [
|
||||
"semiwrap~=0.2.6",
|
||||
"semiwrap~=0.3.0",
|
||||
"hatch-meson~=0.1.0",
|
||||
"hatch-robotpy~=0.2.1",
|
||||
"hatchling",
|
||||
|
||||
@@ -111,4 +111,7 @@ def test_unpack() -> None:
|
||||
def test_repr() -> None:
|
||||
velocities = ChassisVelocities(2.0, 1.0, 0.0)
|
||||
|
||||
assert repr(velocities) == "ChassisVelocities(vx=2.000000, vy=1.000000, omega=0.000000)"
|
||||
assert (
|
||||
repr(velocities)
|
||||
== "ChassisVelocities(vx=2.000000, vy=1.000000, omega=0.000000)"
|
||||
)
|
||||
|
||||
@@ -40,7 +40,9 @@ def test_straight_line_forward_kinematics(kinematics_test):
|
||||
wheel_velocities = MecanumDriveWheelVelocities(
|
||||
frontLeft=5, frontRight=5, rearLeft=5, rearRight=5
|
||||
)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(wheel_velocities)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(
|
||||
wheel_velocities
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(5.0, abs=0.1)
|
||||
assert chassis_velocities.vy == pytest.approx(0.0, abs=0.1)
|
||||
@@ -72,7 +74,9 @@ def test_strafe_forward_kinematics(kinematics_test):
|
||||
wheel_velocities = MecanumDriveWheelVelocities(
|
||||
frontLeft=-5, frontRight=5, rearLeft=5, rearRight=-5
|
||||
)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(wheel_velocities)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(
|
||||
wheel_velocities
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(0.0, abs=0.1)
|
||||
assert chassis_velocities.vy == pytest.approx(5.0, abs=0.1)
|
||||
@@ -107,7 +111,9 @@ def test_rotation_forward_kinematics(kinematics_test):
|
||||
rearLeft=-150.79644737,
|
||||
rearRight=150.79644737,
|
||||
)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(wheel_velocities)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(
|
||||
wheel_velocities
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(0.0, abs=0.1)
|
||||
assert chassis_velocities.vy == pytest.approx(0.0, abs=0.1)
|
||||
@@ -146,7 +152,9 @@ def test_mixed_rotation_translation_forward_kinematics(kinematics_test):
|
||||
rearRight=16.26,
|
||||
)
|
||||
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(wheel_velocities)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(
|
||||
wheel_velocities
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(1.41335, abs=0.1)
|
||||
assert chassis_velocities.vy == pytest.approx(2.1221, abs=0.1)
|
||||
@@ -184,7 +192,9 @@ def test_off_center_rotation_forward_kinematics(kinematics_test):
|
||||
rearLeft=-16.971,
|
||||
rearRight=33.941,
|
||||
)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(wheel_velocities)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(
|
||||
wheel_velocities
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(8.48525, abs=0.1)
|
||||
assert chassis_velocities.vy == pytest.approx(-8.48525, abs=0.1)
|
||||
@@ -221,7 +231,9 @@ def test_off_center_translation_rotation_forward_kinematics(kinematics_test):
|
||||
rearLeft=-12.02,
|
||||
rearRight=36.06,
|
||||
)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(wheel_velocities)
|
||||
chassis_velocities = kinematics_test.kinematics.toChassisVelocities(
|
||||
wheel_velocities
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(12.02, abs=0.1)
|
||||
assert chassis_velocities.vy == pytest.approx(-7.07, abs=0.1)
|
||||
|
||||
@@ -164,7 +164,9 @@ def test_turn_in_place_forward_kinematics(kinematics_test):
|
||||
bl = SwerveModuleVelocity(velocity=106.629, angle=Rotation2d.fromDegrees(-135))
|
||||
br = SwerveModuleVelocity(velocity=106.629, angle=Rotation2d.fromDegrees(-45))
|
||||
|
||||
chassis_velocities = kinematics_test.m_kinematics.toChassisVelocities((fl, fr, bl, br))
|
||||
chassis_velocities = kinematics_test.m_kinematics.toChassisVelocities(
|
||||
(fl, fr, bl, br)
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(0.0, abs=kEpsilon)
|
||||
assert chassis_velocities.vy == pytest.approx(0.0, abs=kEpsilon)
|
||||
@@ -209,7 +211,9 @@ def test_off_center_cor_rotation_forward_kinematics(kinematics_test):
|
||||
bl = SwerveModuleVelocity(velocity=150.796, angle=Rotation2d.fromDegrees(-90))
|
||||
br = SwerveModuleVelocity(velocity=213.258, angle=Rotation2d.fromDegrees(-45))
|
||||
|
||||
chassis_velocities = kinematics_test.m_kinematics.toChassisVelocities((fl, fr, bl, br))
|
||||
chassis_velocities = kinematics_test.m_kinematics.toChassisVelocities(
|
||||
(fl, fr, bl, br)
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(75.398, abs=kEpsilon)
|
||||
assert chassis_velocities.vy == pytest.approx(-75.398, abs=kEpsilon)
|
||||
@@ -254,7 +258,9 @@ def test_off_center_cor_rotation_and_translation_forward_kinematics(kinematics_t
|
||||
bl = SwerveModuleVelocity(velocity=54.08, angle=Rotation2d.fromDegrees(-109.44))
|
||||
br = SwerveModuleVelocity(velocity=54.08, angle=Rotation2d.fromDegrees(-70.56))
|
||||
|
||||
chassis_velocities = kinematics_test.m_kinematics.toChassisVelocities((fl, fr, bl, br))
|
||||
chassis_velocities = kinematics_test.m_kinematics.toChassisVelocities(
|
||||
(fl, fr, bl, br)
|
||||
)
|
||||
|
||||
assert chassis_velocities.vx == pytest.approx(0.0, abs=kEpsilon)
|
||||
assert chassis_velocities.vy == pytest.approx(-33.0, abs=kEpsilon)
|
||||
|
||||
Reference in New Issue
Block a user