Commit Graph

26 Commits

Author SHA1 Message Date
Peter Johnson
a751fa22d2 [build] Apply spotless for java formatting (#1768)
Update checkstyle config to be compatible with spotless.

Co-authored-by: Austin Shalit <austinshalit@gmail.com>
2020-12-29 22:45:16 -08:00
Austin Shalit
6e1919414e [build] Bring naming checkstyle rules up to date with Google Style guide (#1781)
Also update Checkstyle to 8.38.

Google changed their style guide from the last time we imported it. This PR brings in those naming changes. The change they made is allowing single letter member, parameter, and local variable names. They also added a lambda naming scheme and I thought it would be good to bring that in too.
2020-12-29 09:27:48 -08:00
Matt
254931b9a8 [wpimath] Remove LinearSystem from LinearSystemLoop (#2968)
The system wasn't being used internally, and as LinearSystem is stateless, it doesn't need to be held by LinearSystemLoop.
2020-12-28 10:35:51 -08:00
Peter Johnson
8f1f64ffb6 Remove year from file copyright message (NFC) (#2972)
Also update copyright to include "and other WPILib contributors" and clarify
license referral language to not be restricted to FIRST teams.
2020-12-26 14:12:05 -08:00
Matt
6b567e0066 [wpimath] Add support for varying vision standard deviations in pose estimators (#2956)
Exposes the R passed to vision correct to users.
2020-12-24 16:05:07 -08:00
Tyler Veness
df299d6edd [wpimath] Add UnscentedKalmanFilter::Correct() overload (#2966)
This adds an overload of UnscentedKalmanFilter::Correct() that takes a
custom measurement covariance but uses default mean and residual
calculation functions.

Closes #2965.
2020-12-24 16:00:36 -08:00
Declan Freeman-Gleason
bc8f338771 [wpilib] Add pose estimators (#2867)
Pose and state estimators can filter latency-compensated global measurements and fuse them with state-space drivetrain model information to estimate robot position. They are drop-in replacements for the existing odometry classes.

Co-authored-by: Declan Freeman-Gleason <declanfreemangleason@gmail.com>
Co-authored-by: Prateek Machiraju <prateek.machiraju@gmail.com>
Co-authored-by: Claudius Tewari <cttewari@gmail.com>
Co-authored-by: Matt <matthew.morley.ca@gmail.com>
2020-11-28 14:35:35 -08:00
Tyler Veness
c8ea1b6c38 [wpilib] Add function to adjust LQR controller gain for pure time delay (#2878)
There were three options for where to put this function:

1. A free function in LinearQuadraticRegulator.h. Returning a K matrix
   means the user can't use the LinearQuadraticRegulator in a loop
   anymore.
2. A default argument added to ctors in LinearQuadraticRegulator for a
   time delay (default of 0). This has the smallest API footprint from
   the user perspective, but it bloats the already substantial
   constructor overload set of LinearQuadraticRegulator.
3. A member function in LinearQuadraticRegulator that modifies the
   internal K. This would still have to take in a LinearSystem or (A, B)
   pair because the ctor doesn't store it. Storing it internally feels
   like paying for what we don't use most of the time.

I went with option 3.

I verified the tests's expected values in Python with
scipy.linalg.fractional_matrix_power().

Closes #2877.
2020-11-20 15:28:00 -08:00
Prateek Machiraju
ac3c336b98 [wpimath] Use units for LinearSystemId Kv and Ka (#2852) 2020-11-11 22:33:04 -08:00
Claudius Tewari
0ce9133b55 [wpimath] Address issues with LinearSystemLoop reset() and matrix initialization (#2819)
This address some problems with the LinearSystemLoop class that were discovered through testing.

The initial state estimate of the observer was set to the provided initial state rather than zero as previously, a non zero initial state passed into reset() would lead to a discrepancy between the current state estimate and the actual system state.
2020-10-29 18:10:48 -07:00
Austin Shalit
6e7c7374fd [build] Globally Exclude PMD.TooManyMethods (#2793)
This was not a useful check, as every time we hit it, we simply excluded it.
2020-10-22 20:53:48 -07:00
Prateek Machiraju
17698af5e3 [wpimath] Add distance/angle constructor to Translation2d (#2791) 2020-10-20 21:22:41 -07:00
Prateek Machiraju
07ac5370d8 [wpimath] Fix m_nextR instantiation in LinearSystemLoop ctor (#2783) 2020-10-17 16:44:55 -07:00
Tyler Veness
32f429a819 [wpimath] Move DiscretizeR() in EKF and UKF from Predict() to Correct() (#2753)
By storing the previous dt, it can be moved into Correct() where it is
actually used. This lets us take the continuous R as an argument in the
user-provided R overload.
2020-10-07 21:54:38 -07:00
Prateek Machiraju
bf26656547 [wpimath] Fix quintic spline generation from control vectors (#2762)
This does not introduce any breaking changes for teams that used the TrajectoryGenerator API for
quintic splines with poses.

The GetQuinticControlVectorsFromWaypoints() method was removed because it is not possible for us (or
would require breaking changes to the shape of the splines) to generate only one quintic control vector
per Pose2d.  Users who actually have control vectors directly (i.e. not from Pose2d objects, but a
dashboard such as PathWeaver) should have the number of control vectors correspond to the number of
"waypoints" and can call GetQuinticSplinesFromControlVectors() directly.
2020-10-04 12:51:48 -07:00
Matt
b61f08d3fa [wpilib] Add physics simulation support with state-space (#2615)
This includes physics simulation support for arms/elevator models, as well as differential drivetrains.

Swerve might be added at a later date.

Co-authored-by: Claudius Tewari <cttewari@gmail.com>
Co-authored-by: Prateek Machiraju <prateek.machiraju@gmail.com>
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2020-09-20 09:39:52 -07:00
Tyler Veness
b0a296477e [wpimath] Use newer link to controls book in comments (NFC) (#2700) 2020-09-10 14:20:06 -07:00
Tyler Veness
35790a8990 [wpimath] Remove rho overload from LinearQuadraticRegulator constructors (#2687)
It was added as part of Bryson's rule described in
https://file.tavsys.net/control/controls-engineering-in-frc.pdf. It
doesn't really simplify usage though, and the same thing can be
replicated by multiplying the elements of Q by rho manually. It's easier
to do it that way, it's how 3512 has been doing controller debugging for
a while, and it's probably what other teams will do as well instead of
using the "more structured" way.

Removing these unhelpful overloads also simplifies the LQR interface.
2020-09-03 20:53:17 -07:00
Matt
8edc17dac9 [wpimath] Add Vector overload for times and div (#2686) 2020-09-03 20:48:43 -07:00
Matt
502f5c8b5f [wpimath] Make LinearPlantInversionFeedforward's A and B matrices final (#2688) 2020-09-03 19:07:36 -07:00
sciencewhiz
3e41d92c18 [wpilib] Use misspell to fix spelling errors (NFC) (#2674) 2020-08-31 00:33:11 -07:00
Tyler Veness
947ff655c5 [wpimath] Refactor KalmanFilter to be steady-state only (#2657)
I didn't notice a performance difference between the original
implementation and this one for a flywheel simulation, so this
simplifies a lot of internals.

This class can no longer implement KalmanTypeFilter because that class
allows setting the error covariance for use in the
KalmanFilterLatencyCompensator class. This won't impact the holonomic pose
estimators that use KalmanFilterLatencyCompensator because they all use an EKF.
2020-08-30 11:46:57 -07:00
Matt
ef5e0c2e75 [wpimath] Remove duplicate WPIMathJNI class (#2639) 2020-08-16 17:16:53 -07:00
Matt
3b283ab9aa [wpimath] Add core State-space classes (#2614)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: Claudius Tewari <cttewari@gmail.com>
Co-authored-by: Declan Freeman-Gleason <declanfreemangleason@gmail.com>
2020-08-14 23:40:33 -07:00
Peter Johnson
8dc3d23831 [wpimath] Move DrakeJNI to edu.wpi.first.math.WPIMathJNI 2020-08-07 12:02:02 -07:00
Peter Johnson
42993b15c6 [wpimath] Move math functionality into new wpimath library (#2629)
The wpimath library is a new library designed to separate the reusable math functionality
from the common utility library (wpiutil) and the hardware-dependent library (wpilibc/j).

Package names / include file names were NOT changed to minimize breakage.  In a future year
it would be good to revamp these for a more uniform user experience and to reduce the risk
of accidental naming conflicts.

While theoretically all of this functionality could be placed into wpiutil, several pieces
of this library (e.g. DARE) are very time-consuming to compile, so it's nice to avoid this
expense for users who only want cscore or ntcore.  It also allows for easy future separation
of build tasks vs number of workers on memory-constrained machines.

This moves the following functionality from wpiutil into wpimath:
- Eigen
- ejml
- Drake
- DARE
- wpiutil.math package (Matrix etc)
- units

And the following functionality from wpilibc/j into wpimath:
- Geometry
- Kinematics
- Spline
- Trajectory
- LinearFilter
- MedianFilter
- Feed-forward controllers
2020-08-06 23:57:39 -07:00