[copybara] mostrobotpy to allwpilib (#8503)

Resync with `mostrobotpy`

This mostly involves the big "ignore almost everything in the HAL
project" and some fixups for the Addressable LED classes.

Required two small hand fixes to get it building over here with bazel,
and with more compiler warnings on.

I also manually zeroed out the `repo_url` field in the toml files to
avoid unnecessary churn whenever it goes from a release build to a
development build. I already did this with `version` field in there, and
will do a follow up PR that updates the copybara script to do it
automatically.

---------

Co-authored-by: Default email <default@default.com>
This commit is contained in:
PJ Reiniger
2025-12-31 12:06:01 -05:00
committed by GitHub
parent bdc9391738
commit 40fb9ff562
233 changed files with 1796 additions and 4455 deletions

View File

@@ -1,119 +0,0 @@
import math
import pytest
from wpimath.kinematics import ChassisAccelerations
from wpimath.geometry import Rotation2d
from wpimath.units import feetToMeters
K_EPSILON = 1e-9
def test_default_constructor():
accelerations = ChassisAccelerations()
assert accelerations.ax == pytest.approx(0.0, abs=K_EPSILON)
assert accelerations.ay == pytest.approx(0.0, abs=K_EPSILON)
assert accelerations.alpha == pytest.approx(0.0, abs=K_EPSILON)
def test_parameterized_constructor():
# 1.0 m/s^2, 2.0 m/s^2, 3.0 rad/s^2
accelerations = ChassisAccelerations(1.0, 2.0, 3.0)
assert accelerations.ax == pytest.approx(1.0, abs=K_EPSILON)
assert accelerations.ay == pytest.approx(2.0, abs=K_EPSILON)
assert accelerations.alpha == pytest.approx(3.0, abs=K_EPSILON)
def test_to_robot_relative():
start_accel = ChassisAccelerations(1.0, 0.0, 0.5)
chassis_accelerations = start_accel.toRobotRelative(Rotation2d.fromDegrees(-90))
assert chassis_accelerations.ax == pytest.approx(0.0, abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(1.0, abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(0.5, abs=K_EPSILON)
def test_to_field_relative():
start_accel = ChassisAccelerations(1.0, 0.0, 0.5)
chassis_accelerations = start_accel.toFieldRelative(Rotation2d.fromDegrees(45))
expected_val = 1.0 / math.sqrt(2.0)
assert chassis_accelerations.ax == pytest.approx(expected_val, abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(expected_val, abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(0.5, abs=K_EPSILON)
def test_plus():
left = ChassisAccelerations(1.0, 0.5, 0.75)
right = ChassisAccelerations(2.0, 1.5, 0.25)
chassis_accelerations = left + right
assert chassis_accelerations.ax == pytest.approx(3.0, abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(2.0, abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(1.0, abs=K_EPSILON)
def test_minus():
left = ChassisAccelerations(1.0, 0.5, 0.75)
right = ChassisAccelerations(2.0, 0.5, 0.25)
chassis_accelerations = left - right
assert chassis_accelerations.ax == pytest.approx(-1.0, abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(0.0, abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(0.5, abs=K_EPSILON)
def test_unary_minus():
accel = ChassisAccelerations(1.0, 0.5, 0.75)
chassis_accelerations = -accel
assert chassis_accelerations.ax == pytest.approx(-1.0, abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(-0.5, abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(-0.75, abs=K_EPSILON)
def test_multiplication():
accel = ChassisAccelerations(1.0, 0.5, 0.75)
chassis_accelerations = accel * 2.0
assert chassis_accelerations.ax == pytest.approx(2.0, abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(1.0, abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(1.5, abs=K_EPSILON)
def test_division():
accel = ChassisAccelerations(2.0, 1.0, 1.5)
chassis_accelerations = accel / 2.0
assert chassis_accelerations.ax == pytest.approx(1.0, abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(0.5, abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(0.75, abs=K_EPSILON)
def test_feet_constructor():
chassis_accelerations = ChassisAccelerations.fromFps(10, 11, math.radians(45))
assert chassis_accelerations.ax == pytest.approx(feetToMeters(10), abs=K_EPSILON)
assert chassis_accelerations.ay == pytest.approx(feetToMeters(11), abs=K_EPSILON)
assert chassis_accelerations.alpha == pytest.approx(math.radians(45), abs=K_EPSILON)
assert chassis_accelerations.ax_fpss == pytest.approx(10, abs=K_EPSILON)
assert chassis_accelerations.ay_fpss == pytest.approx(11, abs=K_EPSILON)
assert chassis_accelerations.alpha_dpss == pytest.approx(45, abs=K_EPSILON)
def test_repr():
chassis_accelerations = ChassisAccelerations(1, 2, 3)
assert (
str(chassis_accelerations)
== "ChassisAccelerations(ax=1.000000, ay=2.000000, alpha=3.000000)"
)

View File

@@ -1,7 +1,6 @@
import math
from wpimath.geometry import Rotation2d
from wpimath.kinematics import ChassisSpeeds
from wpimath import ChassisSpeeds
def test_plus() -> None:

View File

@@ -1,5 +1,5 @@
import pytest
from wpimath.kinematics import DifferentialDriveWheelAccelerations
from wpimath import DifferentialDriveWheelAccelerations
from wpimath.units import feetToMeters
K_EPSILON = 1e-9

View File

@@ -1,5 +1,5 @@
import pytest
from wpimath.kinematics import MecanumDriveWheelAccelerations
from wpimath import MecanumDriveWheelAccelerations
from wpimath.units import feetToMeters
# Epsilon matching the C++ test

View File

@@ -1,7 +1,9 @@
import pytest
from wpimath.geometry import Pose2d, Rotation2d, Translation2d
from wpimath.kinematics import (
from wpimath import (
Pose2d,
Rotation2d,
Translation2d,
ChassisSpeeds,
SwerveDrive4Kinematics,
SwerveDrive4Odometry,

View File

@@ -1,7 +1,6 @@
import pytest
import math
from wpimath.kinematics import SwerveModuleAcceleration
from wpimath.geometry import Rotation2d
from wpimath import Rotation2d, SwerveModuleAcceleration
from wpimath.units import feetToMeters
K_EPSILON = 1e-9