diff --git a/rdev.toml b/rdev.toml index 08b0de5e6..24d1b9568 100644 --- a/rdev.toml +++ b/rdev.toml @@ -13,7 +13,7 @@ exclude_artifacts = [ "opencv-cpp" ] -robotpy_build_req = "<2025.0.0b1,~=2025.0.0a6" +robotpy_build_req = "<2025.0.0b1,~=2025.0.0a8" # # Subproject configuration diff --git a/subprojects/pyntcore/pyproject.toml b/subprojects/pyntcore/pyproject.toml index 2358dfb6a..105757dd0 100644 --- a/subprojects/pyntcore/pyproject.toml +++ b/subprojects/pyntcore/pyproject.toml @@ -12,7 +12,7 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", "robotpy-wpinet~=2025.0.0b3", ] diff --git a/subprojects/robotpy-apriltag/pyproject.toml b/subprojects/robotpy-apriltag/pyproject.toml index 8b15cb897..4c046be8c 100644 --- a/subprojects/robotpy-apriltag/pyproject.toml +++ b/subprojects/robotpy-apriltag/pyproject.toml @@ -12,7 +12,7 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", "robotpy-wpimath~=2025.0.0b3", ] diff --git a/subprojects/robotpy-cscore/pyproject.toml b/subprojects/robotpy-cscore/pyproject.toml index 0085bc250..c19747018 100644 --- a/subprojects/robotpy-cscore/pyproject.toml +++ b/subprojects/robotpy-cscore/pyproject.toml @@ -13,7 +13,7 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", "robotpy-wpinet~=2025.0.0b3", "pyntcore~=2025.0.0b3", diff --git a/subprojects/robotpy-hal/pyproject.toml b/subprojects/robotpy-hal/pyproject.toml index d45f991db..e40067dbf 100644 --- a/subprojects/robotpy-hal/pyproject.toml +++ b/subprojects/robotpy-hal/pyproject.toml @@ -11,7 +11,7 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", ] diff --git a/subprojects/robotpy-halsim-ds-socket/pyproject.toml b/subprojects/robotpy-halsim-ds-socket/pyproject.toml index 6851bbbcf..b7a2329fe 100644 --- a/subprojects/robotpy-halsim-ds-socket/pyproject.toml +++ b/subprojects/robotpy-halsim-ds-socket/pyproject.toml @@ -15,7 +15,7 @@ robotpysimext = ["ds-socket = halsim_ds_socket"] [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-hal~=2025.0.0b3", "robotpy-wpinet~=2025.0.0b3", ] diff --git a/subprojects/robotpy-halsim-gui/pyproject.toml b/subprojects/robotpy-halsim-gui/pyproject.toml index 14742958c..c49297f2f 100644 --- a/subprojects/robotpy-halsim-gui/pyproject.toml +++ b/subprojects/robotpy-halsim-gui/pyproject.toml @@ -14,7 +14,7 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", "robotpy-wpimath~=2025.0.0b3", "robotpy-hal~=2025.0.0b3", diff --git a/subprojects/robotpy-halsim-ws/pyproject.toml b/subprojects/robotpy-halsim-ws/pyproject.toml index a99bd6bcb..15120ea3f 100644 --- a/subprojects/robotpy-halsim-ws/pyproject.toml +++ b/subprojects/robotpy-halsim-ws/pyproject.toml @@ -19,7 +19,7 @@ robotpysimext = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-hal~=2025.0.0b3", "robotpy-wpinet~=2025.0.0b3", ] diff --git a/subprojects/robotpy-romi/pyproject.toml b/subprojects/robotpy-romi/pyproject.toml index 39315227d..63ed05097 100644 --- a/subprojects/robotpy-romi/pyproject.toml +++ b/subprojects/robotpy-romi/pyproject.toml @@ -11,7 +11,7 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "wpilib~=2025.0.0b3" ] diff --git a/subprojects/robotpy-wpilib/pyproject.toml b/subprojects/robotpy-wpilib/pyproject.toml index 48e5c98b4..24573f723 100644 --- a/subprojects/robotpy-wpilib/pyproject.toml +++ b/subprojects/robotpy-wpilib/pyproject.toml @@ -18,7 +18,7 @@ robotpy = ["run = wpilib._impl.start:Main"] [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", "robotpy-wpimath~=2025.0.0b3", "robotpy-hal~=2025.0.0b3", diff --git a/subprojects/robotpy-wpimath/gen/geometry/Pose2d.yml b/subprojects/robotpy-wpimath/gen/geometry/Pose2d.yml index af7374703..30d5f32d2 100644 --- a/subprojects/robotpy-wpimath/gen/geometry/Pose2d.yml +++ b/subprojects/robotpy-wpimath/gen/geometry/Pose2d.yml @@ -21,6 +21,9 @@ classes: '': Translation2d, Rotation2d: units::meter_t, units::meter_t, Rotation2d: + const Eigen::Matrix3d&: + rename: fromMatrix + keepalive: [] Translation: Rotation: RotateBy: @@ -28,6 +31,7 @@ classes: RelativeTo: Exp: Log: + ToMatrix: Nearest: overloads: std::span [const]: diff --git a/subprojects/robotpy-wpimath/gen/geometry/Pose3d.yml b/subprojects/robotpy-wpimath/gen/geometry/Pose3d.yml index e79a566ca..5b2c0120f 100644 --- a/subprojects/robotpy-wpimath/gen/geometry/Pose3d.yml +++ b/subprojects/robotpy-wpimath/gen/geometry/Pose3d.yml @@ -23,6 +23,10 @@ classes: Translation3d, Rotation3d: units::meter_t, units::meter_t, units::meter_t, Rotation3d: const Pose2d&: + keepalive: [] + const Eigen::Matrix4d&: + rename: fromMatrix + keepalive: [] operator+: operator-: operator==: @@ -39,6 +43,7 @@ classes: RelativeTo: Exp: Log: + ToMatrix: ToPose2d: inline_code: | diff --git a/subprojects/robotpy-wpimath/gen/geometry/Rotation2d.yml b/subprojects/robotpy-wpimath/gen/geometry/Rotation2d.yml index d87a9bd8c..12362c7f7 100644 --- a/subprojects/robotpy-wpimath/gen/geometry/Rotation2d.yml +++ b/subprojects/robotpy-wpimath/gen/geometry/Rotation2d.yml @@ -25,7 +25,11 @@ classes: template_impls: - ['units::radian_t'] double, double: + const Eigen::Matrix2d&: + rename: fromMatrix + keepalive: [] RotateBy: + ToMatrix: Radians: Degrees: Cos: diff --git a/subprojects/robotpy-wpimath/gen/geometry/Rotation3d.yml b/subprojects/robotpy-wpimath/gen/geometry/Rotation3d.yml index 9d486652b..99342e225 100644 --- a/subprojects/robotpy-wpimath/gen/geometry/Rotation3d.yml +++ b/subprojects/robotpy-wpimath/gen/geometry/Rotation3d.yml @@ -16,12 +16,18 @@ classes: overloads: '': const Quaternion&: + keepalive: [] units::radian_t, units::radian_t, units::radian_t: const Eigen::Vector3d&, units::radian_t: + keepalive: [] const Eigen::Vector3d&: + keepalive: [] const Eigen::Matrix3d&: + keepalive: [] const Eigen::Vector3d&, const Eigen::Vector3d&: + keepalive: [] const Rotation2d&: + keepalive: [] operator+: operator-: overloads: @@ -38,6 +44,7 @@ classes: Z: Axis: Angle: + ToMatrix: ToRotation2d: inline_code: | diff --git a/subprojects/robotpy-wpimath/gen/geometry/Transform2d.yml b/subprojects/robotpy-wpimath/gen/geometry/Transform2d.yml index 957d1f38d..0f7961dcd 100644 --- a/subprojects/robotpy-wpimath/gen/geometry/Transform2d.yml +++ b/subprojects/robotpy-wpimath/gen/geometry/Transform2d.yml @@ -16,13 +16,18 @@ classes: Transform2d: overloads: const Pose2d&, const Pose2d&: + keepalive: [] Translation2d, Rotation2d: units::meter_t, units::meter_t, Rotation2d: + const Eigen::Matrix3d&: + rename: fromMatrix + keepalive: [] '': Translation: - Rotation: X: Y: + ToMatrix: + Rotation: Inverse: operator*: operator/: diff --git a/subprojects/robotpy-wpimath/gen/geometry/Transform3d.yml b/subprojects/robotpy-wpimath/gen/geometry/Transform3d.yml index 0957a2371..974ba98bd 100644 --- a/subprojects/robotpy-wpimath/gen/geometry/Transform3d.yml +++ b/subprojects/robotpy-wpimath/gen/geometry/Transform3d.yml @@ -15,14 +15,20 @@ classes: Transform3d: overloads: const Pose3d&, const Pose3d&: + keepalive: [] Translation3d, Rotation3d: units::meter_t, units::meter_t, units::meter_t, Rotation3d: + const Eigen::Matrix4d&: + rename: fromMatrix + keepalive: [] '': const frc::Transform2d&: + keepalive: [] Translation: X: Y: Z: + ToMatrix: Rotation: Inverse: operator*: diff --git a/subprojects/robotpy-wpimath/pyproject.toml b/subprojects/robotpy-wpimath/pyproject.toml index db911e464..b1266f58e 100644 --- a/subprojects/robotpy-wpimath/pyproject.toml +++ b/subprojects/robotpy-wpimath/pyproject.toml @@ -11,7 +11,7 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", # "numpy", # broken in raspbian CI ] diff --git a/subprojects/robotpy-wpimath/tests/geometry/test_rotation2d.py b/subprojects/robotpy-wpimath/tests/geometry/test_rotation2d.py new file mode 100644 index 000000000..8457d3877 --- /dev/null +++ b/subprojects/robotpy-wpimath/tests/geometry/test_rotation2d.py @@ -0,0 +1,82 @@ +import importlib.util +import math + +import pytest + +from wpimath.geometry import Rotation2d + + +@pytest.mark.parametrize( + "radians,degrees", + [ + (math.pi / 3, 60.0), + (math.pi / 4, 45.0), + ], +) +def test_radians_to_degrees(radians: float, degrees: float): + rot = Rotation2d(radians) + assert math.isclose(degrees, rot.degrees()) + + +@pytest.mark.parametrize( + "degrees,radians", + [ + (45.0, math.pi / 4), + (30.0, math.pi / 6), + ], +) +def test_degrees_to_radians(degrees: float, radians: float): + rot = Rotation2d.fromDegrees(degrees) + assert math.isclose(radians, rot.radians()) + + +def test_rotate_by_from_zero() -> None: + zero = Rotation2d() + rotated = zero + Rotation2d.fromDegrees(90) + + assert math.isclose(math.pi / 2, rotated.radians()) + assert math.isclose(90.0, rotated.degrees()) + + +def test_rotate_by_non_zero() -> None: + rot = Rotation2d.fromDegrees(90.0) + rot += Rotation2d.fromDegrees(30.0) + + assert math.isclose(120.0, rot.degrees()) + + +def test_minus() -> None: + rot1 = Rotation2d.fromDegrees(70) + rot2 = Rotation2d.fromDegrees(30) + + assert math.isclose(40.0, (rot1 - rot2).degrees()) + + +def test_unary_minus() -> None: + rot = Rotation2d.fromDegrees(20) + assert math.isclose(-20.0, (-rot).degrees()) + + +def test_equality() -> None: + rot1 = Rotation2d.fromDegrees(43.0) + rot2 = Rotation2d.fromDegrees(43.0) + assert rot1 == rot2 + + rot1 = Rotation2d.fromDegrees(-180.0) + rot2 = Rotation2d.fromDegrees(180.0) + assert rot1 == rot2 + + +def test_inequality() -> None: + rot1 = Rotation2d.fromDegrees(43.0) + rot2 = Rotation2d.fromDegrees(43.5) + assert rot1 != rot2 + + +@pytest.mark.skipif( + importlib.util.find_spec("numpy") is None, reason="numpy is not available" +) +def test_to_matrix() -> None: + before = Rotation2d.fromDegrees(20.0) + after = Rotation2d.fromMatrix(before.toMatrix()) + assert before == after diff --git a/subprojects/robotpy-wpinet/pyproject.toml b/subprojects/robotpy-wpinet/pyproject.toml index d5d91e539..1951e73b0 100644 --- a/subprojects/robotpy-wpinet/pyproject.toml +++ b/subprojects/robotpy-wpinet/pyproject.toml @@ -41,6 +41,6 @@ install_requires = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "robotpy-wpiutil~=2025.0.0b3", ] diff --git a/subprojects/robotpy-wpiutil/pyproject.toml b/subprojects/robotpy-wpiutil/pyproject.toml index ef7c22c62..7bc431eaa 100644 --- a/subprojects/robotpy-wpiutil/pyproject.toml +++ b/subprojects/robotpy-wpiutil/pyproject.toml @@ -9,7 +9,7 @@ install_requires = [] [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", ] [tool.robotpy-build] diff --git a/subprojects/robotpy-xrp/pyproject.toml b/subprojects/robotpy-xrp/pyproject.toml index 2d3b16e46..c15c1fdbc 100644 --- a/subprojects/robotpy-xrp/pyproject.toml +++ b/subprojects/robotpy-xrp/pyproject.toml @@ -16,7 +16,7 @@ robotpysimext = [ [build-system] requires = [ - "robotpy-build<2025.0.0b1,~=2025.0.0a6", + "robotpy-build<2025.0.0b1,~=2025.0.0a8", "wpilib~=2025.0.0b3" ]