mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[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:
@@ -3,7 +3,7 @@ import math
|
||||
|
||||
import pytest
|
||||
|
||||
from wpimath.geometry import Rotation2d
|
||||
from wpimath import Rotation2d
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
||||
@@ -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)"
|
||||
)
|
||||
@@ -1,7 +1,6 @@
|
||||
import math
|
||||
|
||||
from wpimath.geometry import Rotation2d
|
||||
from wpimath.kinematics import ChassisSpeeds
|
||||
from wpimath import ChassisSpeeds
|
||||
|
||||
|
||||
def test_plus() -> None:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import pytest
|
||||
from wpimath.kinematics import DifferentialDriveWheelAccelerations
|
||||
from wpimath import DifferentialDriveWheelAccelerations
|
||||
from wpimath.units import feetToMeters
|
||||
|
||||
K_EPSILON = 1e-9
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import wpimath.controller
|
||||
|
||||
|
||||
def test_todo():
|
||||
pass
|
||||
@@ -1,5 +0,0 @@
|
||||
import wpimath.estimator
|
||||
|
||||
|
||||
def test_todo():
|
||||
pass
|
||||
@@ -1,7 +1,8 @@
|
||||
import math
|
||||
|
||||
from wpimath.geometry import Pose2d, Rotation2d
|
||||
from wpimath.interpolation import (
|
||||
from wpimath import (
|
||||
Pose2d,
|
||||
Rotation2d,
|
||||
TimeInterpolatableFloatBuffer,
|
||||
TimeInterpolatablePose2dBuffer,
|
||||
TimeInterpolatableRotation2dBuffer,
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import math
|
||||
import random
|
||||
|
||||
from wpimath.optimization import SimulatedAnnealing
|
||||
from wpimath import SimulatedAnnealing
|
||||
|
||||
|
||||
def clamp(v, minval, maxval):
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
import wpimath.spline
|
||||
|
||||
|
||||
def test_todo():
|
||||
pass
|
||||
@@ -1,6 +0,0 @@
|
||||
import wpimath.system
|
||||
import wpimath.system.plant
|
||||
|
||||
|
||||
def test_todo():
|
||||
pass
|
||||
@@ -1,25 +1,22 @@
|
||||
import math
|
||||
|
||||
from wpimath.geometry import (
|
||||
from wpimath import (
|
||||
CubicHermiteSpline,
|
||||
Ellipse2d,
|
||||
EllipticalRegionConstraint,
|
||||
MaxVelocityConstraint,
|
||||
Pose2d,
|
||||
Rectangle2d,
|
||||
RectangularRegionConstraint,
|
||||
Rotation2d,
|
||||
Transform2d,
|
||||
Translation2d,
|
||||
)
|
||||
from wpimath.spline import CubicHermiteSpline, SplineHelper
|
||||
from wpimath.trajectory import (
|
||||
SplineHelper,
|
||||
TrajectoryConstraint,
|
||||
Trajectory,
|
||||
TrajectoryConfig,
|
||||
TrajectoryGenerator,
|
||||
TrajectoryParameterizer,
|
||||
)
|
||||
from wpimath.trajectory.constraint import (
|
||||
EllipticalRegionConstraint,
|
||||
MaxVelocityConstraint,
|
||||
RectangularRegionConstraint,
|
||||
TrajectoryConstraint,
|
||||
Transform2d,
|
||||
Translation2d,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
|
||||
import pytest
|
||||
|
||||
from wpimath.controller import SimpleMotorFeedforwardMeters
|
||||
from wpimath.trajectory import ExponentialProfileMeterVolts
|
||||
from wpimath import ExponentialProfileMeterVolts, SimpleMotorFeedforwardMeters
|
||||
|
||||
kDt = 0.01
|
||||
feedforward = SimpleMotorFeedforwardMeters(0, 2.5629, 0.43277, kDt)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import pytest
|
||||
|
||||
from wpimath import trajectory
|
||||
import wpimath
|
||||
|
||||
trapezoid_profile_types = [
|
||||
trajectory.TrapezoidProfile,
|
||||
trajectory.TrapezoidProfileRadians,
|
||||
wpimath.TrapezoidProfile,
|
||||
wpimath.TrapezoidProfileRadians,
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import math
|
||||
|
||||
from wpimath.trajectory import TrapezoidProfile
|
||||
from wpimath import TrapezoidProfile
|
||||
|
||||
kDt = 0.01 # 10 ms
|
||||
|
||||
|
||||
Reference in New Issue
Block a user