Commit Graph

145 Commits

Author SHA1 Message Date
Tyler Veness
a9ab08f48b [wpimath] Rename ChassisSpeeds.fromDiscreteSpeeds() to discretize() (#5616)
This better reflects what's actually going on mathematically.
2023-09-08 20:14:59 -07:00
Tyler Veness
1a6df6fec6 [wpimath] Fix DARE Q decomposition (#5611) 2023-09-05 10:48:43 -07:00
Gold856
8e2465f8a0 [wpimath] Add arithmetic functions to wheel speeds classes (#5465) 2023-08-31 11:57:24 -07:00
Tyler Veness
99f66b1e24 [wpimath] Replace frc/EigenCore.h typedefs with Eigen's where possible (#5597) 2023-08-31 11:03:37 -07:00
Omar Zrien
67043a8eeb [wpimath] Add angular jerk unit (#5582) 2023-08-29 12:53:14 -07:00
Tyler Veness
8e2a7fd306 Include thirdparty libraries with angle brackets (#5578) 2023-08-28 15:13:34 -07:00
Tyler Veness
8f3d6a1d4b [wpimath] Remove discretizeAQTaylor() (#5562)
It gives incorrect results. Any replacement should just be an
implementation detail of discretizeAQ().

Closes #5339.
2023-08-23 10:47:32 -07:00
Tyler Veness
7c20fa1b18 [wpimath] Refactor DARE tests to reduce RAM usage at compile time (#5557) 2023-08-23 10:46:50 -07:00
Tyler Veness
186b409e16 [wpimath] Remove internal Eigen header include (#5539) 2023-08-15 08:47:48 -07:00
Tyler Veness
03764dfe93 [wpimath] Add static matrix support to DARE solver (#5536)
Using static matrices where possible results in a 2x performance
improvement.
2023-08-14 09:15:58 -07:00
Tyler Veness
394cfeadbd [wpimath] Use SDA algorithm instead of SSCA for DARE solver (#5526)
Both seem to work, but the SDA algorithm is specifically recommended for
solving DAREs as opposed to P-DAREs.

The QR decomposition was replaced with a partial pivoting LU
decomposition at the recommendation of section 2.4 of the paper.

More tests and a separate JNI function for each DARE solver variant were
added.
2023-08-12 19:45:45 -07:00
amquake
8121566258 [wpimath] Fix CoordinateSystem.convert() Transform3d overload (#5532) 2023-08-12 15:20:22 -07:00
Tyler Veness
35a8b129d9 [wpimath] Add RotateBy() function to pose classes (#5491)
Fixes #5472.
2023-07-31 21:16:44 -07:00
Gold856
86e91e6724 [wpimath] Refactor TrapezoidProfile API (#5457) 2023-07-19 17:25:10 -07:00
camaj
c69e34c80c [wpimath] ChassisSpeeds: Add arithmetic functions (#5293)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-07-18 16:30:21 -07:00
Joseph Eng
593767c8c7 [wpimath] Improve Euler angle calculations in gimbal lock (#5437) 2023-07-17 17:19:42 -07:00
Tyler Veness
fd5699b240 Remove references to Drake (#5427)
Fixes #5426.
2023-07-09 21:25:14 -07:00
Vasista Vovveti
6b5817836d [wpimath] Add tolerance for some tests (#5416) 2023-06-27 14:22:46 -07:00
Tyler Veness
5d3a133f9f Remove spaces in NOLINT comments (#5407)
clang-tidy ignores the category filter if there's a space. wpiformat now
ignores categories it doesn't understand, so we can remove the spaces.
2023-06-20 20:29:23 -07:00
Tyler Veness
3a0e484691 [wpimath] Fix clang-tidy warnings (#5403) 2023-06-20 11:35:15 -07:00
Gold856
991f4b0f62 [wpimath] PIDController: Add IZone (#5315)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2023-06-19 23:01:01 -07:00
Gold856
f5b0d1484b [wpimath] Add isNear method to MathUtil (#5353)
This method is used to check if the given value matches an expected value within a certain tolerance.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2023-06-19 23:00:07 -07:00
Gold856
50b90ceb54 [wpimath] SwerveDriveKinematics: Add reset method (#5398)
Adds a reset method where teams can pass in module headings for the kinematics object to use if it gets an all-zero ChassisSpeeds while converting ChassisSpeeds to module states. Also removes internal states array, replacing it with an internal headings array.
2023-06-19 22:57:55 -07:00
Tyler Veness
5acc5e22aa [wpimath] Only compute eigenvalues with EigenSolvers (#5369)
We don't need the eigenvectors, so we're doing a lot of extra work we
don't need to.
2023-06-07 09:47:09 -07:00
Tyler Veness
a94a998002 [wpimath] Generalize Eigen formatter (#5360) 2023-05-30 23:35:15 -07:00
Tyler Veness
51066a5a8a [wpimath] Move unit formatters into units library (#5358) 2023-05-26 01:05:27 -07:00
Tyler Veness
52bd5b972d [wpimath] Rewrite DARE solver (#5328)
I timed the DARE unit tests, and the new solver is 0 to 100% faster in
all cases (that is, it's at least as fast as Drake's and up to 2x faster
in some cases).

The new solver is also much simpler, takes less time to compile, and
drops the libwpimath.so size from 325 MB to 301 MB.

I think most of the compilation time is coming from the eigenvalue
decompositions used to enforce argument preconditions.
2023-05-14 22:23:00 -07:00
Tyler Veness
7ce75574bf [wpimath] Upgrade to Drake v1.15.0 (#5310) 2023-05-07 22:54:58 -07:00
Gold856
24828afd11 [wpimath] Fix desaturateWheelSpeeds to account for negative speeds (#5269) 2023-04-28 20:53:20 -07:00
Tyler Veness
63512bbbb8 [wpimath] Fix potential divide-by-zero in RKDP (#5242)
If f(x, u) has no dynamics, the truncation error can be zero.
2023-03-26 17:00:09 -07:00
nt
08f298e4cd [wpimath] Fix Pose3d log returning Twist3d NaN for theta between 1E-8 and 1E-7 (#5168) 2023-03-13 21:27:32 -07:00
nt
099d048d9e [wpimath] Fix Pose3d log returning Twist3d NaN for theta between 1E-9 and 1E-8 (#5143)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-02-26 16:41:36 -08:00
sciencewhiz
4af84a1c12 Fix Typos (NFC) (#5137) 2023-02-26 15:06:37 -08:00
Jordan McMichael
59be120982 [wpimath] Fix Pose3d exp()/log() and add rotation vector constructor to Rotation3d (#5072)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-02-08 21:31:03 -08:00
Jordan McMichael
4079eabe9b [wpimath] Discard stale pose estimates (#5045)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-02-03 22:04:30 -08:00
Ryan Blue
7b828ce84f [wpimath] Add nearest to Pose2d and Translation2d (#4882)
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2023-02-03 15:27:16 -08:00
Jordan McMichael
42c997a3c4 [wpimath] Fix Pose3d exponential and clean up Pose3d logarithm (#4970)
Implementation based on this paper: https://ethaneade.org/lie.pdf
2023-01-18 20:38:03 -08:00
sciencewhiz
1e05b21ab5 [wpimath] Fix PID atSetpoint to not return true prematurely (#4906)
Wait until setpoint and measurement have been set.
2023-01-13 22:26:30 -08:00
Matt
f7f19207e0 [wpimath] Allow multiple vision measurements from same timestamp (#4917)
Co-authored-by: Jordan McMichael <jlmcmchl@gmail.com>
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-01-11 23:04:30 -08:00
ohowe
330ba45f9c [wpimath] Fix swerve kinematics util classes equals function (#4907)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-01-08 16:29:35 -08:00
Tyler Veness
2121bd5fb8 [wpimath] Remove RKF45 (#4870)
RKDP is strictly better in terms of accuracy per unit of work. We used
RKF45 for sim physics in the 2021 season, but we transitioned to RKDP
before the 2022 season.
2022-12-27 19:29:59 -06:00
sciencewhiz
989c9fb29a [wpimath] Revert Rotation2D change that limits angles (#4781)
Reverts "[wpimath] Constrain Rotation2d range to -pi to pi (#4611)"
This reverts commit d1d458db2b.

This broke multiple teams code in beta. It is also easier to limit the angle externally, then reconstruct a larger angle that got limited. This additionally adds comments to clarify the behavior and retains tests that were added in the reverted commit, and fixes a javadoc comment angle reference.
2022-12-08 18:10:44 -08:00
Tyler Veness
f18fd41ac3 [wpimath] Remove broken and obsoleted ComputerVisionUtil functions (#4775)
The ComputerVisionUtil class was added before AprilTag support was
announced. Now that it has, the functions for estimating a pose from
range and yaw are no longer needed; it's just better to get the pose
directly from the AprilTag.

The coordinate system on some function arguments was confusing or didn't
match the NWU convention the rest of the library uses. It's easier to
remove the functions now and add them back after they're fixed since the
fixes aren't trivial.

The range function was removed because it uses pitch and yaw in the
camera's spherical coordinate system, which is obsoleted by AprilTags.
AprilTags give you a 6DOF pose directly, so range can be obtained via
Pose2d.getTranslation().getDistance().

Fixes #4757.
2022-12-06 21:11:27 -08:00
Tyler Veness
74cc86c4c5 [wpimath] Make transform tests use pose/transform equality operators (#4675)
Also add more nonzeros to Transform3d tests to make them more
comprehensive.
2022-12-02 08:36:57 -08:00
Jordan McMichael
e22d8cc343 [wpimath] Use Odometry for internal state in Pose Estimation (#4668)
This effectively replaces the Unscented Kalman Filter used for Pose Estimation with the Odometry model, and uses a recalculable Kalman gain matrix to update pose estimations whenever a vision measurement is added.

Notably, this change removes the need for the confusing generics used in Java, and the C++ implementation got quite a bit less complex as well.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2022-12-02 08:36:10 -08:00
Jordan McMichael
902e8686d3 [wpimath] Rework odometry APIs to improve feature parity (#4645)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2022-11-18 20:42:00 -08:00
Drew Williams
2e88a496c2 [wpimath] Add support for swerve joystick normalization (#4516) 2022-11-17 10:53:49 -08:00
Jordan McMichael
ce4c45df13 [wpimath] Rework function signatures for Pose Estimation / Odometry (#4642)
Forcing the use of SwerveModulePostition[] and wpi::array<SwerveModulePosition, len> in place of variadic function signatures.
2022-11-17 10:36:33 -08:00
ohowe
d1d458db2b [wpimath] Constrain Rotation2d range to -pi to pi (#4611)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2022-11-14 14:25:15 -08:00
CarloWoolsey
dbcc1de37f [wpimath] Add DifferentialDriveFeedforward classes which wrap LinearPlantInversionFeedforward (#4598)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2022-11-10 16:54:51 -08:00