Commit Graph

63 Commits

Author SHA1 Message Date
Tyler Veness
8d79dc8738 [wpimath] Add ImplicitModelFollower (#4056) 2022-03-20 00:36:12 -07:00
Tyler Veness
3f77725cd3 Remove uses of iostream (#4004)
Most of these were unused, the IMU ones were just debug messages.

The only one that wasn't removed is in portable-file-dialogs.cpp since
the replacement looks less trivial.
2022-02-05 23:00:31 -08:00
Tyler Veness
eb4d183e48 [wpimath] Fix clang-tidy bugprone-integer-division warning (#3966)
The integer conversion is deliberate.
2022-01-26 18:38:45 -08:00
modelmat
42908126b9 [wpilib] Add DCMotorSim (#3910) 2022-01-21 20:42:06 -08:00
Tyler Veness
7f4265facc [wpimath] Add LinearFilter::FiniteDifference() (#3900)
This allows making more general finite difference filters, like central
finite difference. SysId uses this for acceleration filtering.
2022-01-15 20:18:11 -08:00
Tyler Veness
db0fbb6448 [wpimath] Fix LQR matrix constructor overload for Q, R, and N (#3884)
It was using the continuous B matrix to compute the feedback gain
instead of the discrete B matrix.

Tests were added for the matrix constructor overloads.
2022-01-08 23:23:53 -08:00
Matt
315be873c4 [wpimath] Add TimeInterpolatableBuffer (#2695)
These classes are useful for storing previous robot positions to use in conjunction with the upcoming pose estimators.

Co-authored-by: Prateek Machiraju <prateek.machiraju@gmail.com>
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: cttew <cttewari@gmail.com>
2021-12-30 19:08:05 -08:00
Oblarg
b8d019cdb4 [wpilib] Rename NormalizeWheelSpeeds to DesaturateWheelSpeeds (#3791) 2021-12-30 18:30:08 -08:00
Oblarg
aa9dfabde2 [wpimath] Move debouncer to filters (#3838) 2021-12-28 09:49:41 -08:00
Tyler Veness
92ba98621c [wpimath] Add helper variable templates for units type traits (#3790) 2021-12-18 11:32:32 -08:00
Tyler Veness
04957a6d30 [wpimath] Fix units of RamseteController's b and zeta (#3757)
Fixes #3755.
2021-12-03 18:21:30 -08:00
Oblarg
da90c1cd2c [wpilib] Add bang-bang controller (#3676)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2021-11-23 20:34:46 -08:00
Tyler Veness
a939cd9c89 [wpimath] Print uncontrollable/unobservable models in LQR and KF (#3694)
IsDetectable() was added to make the code easier to read.
2021-10-29 00:03:02 -07:00
Tyler Veness
d5270d113b [wpimath] Clean up C++ StateSpaceUtil tests (#3692) 2021-10-29 00:02:03 -07:00
Tyler Veness
181723e573 Replace .to<double>() and .template to<double>() with .value() (#3667)
It's a less verbose way to do the same thing.
2021-10-25 08:58:12 -07:00
Tyler Veness
95dd20a151 [build] Enable spotbugs (#3601)
Benign spotbugs warnings were suppressed, and all others were fixed. Bug
descriptions are documented here:
https://spotbugs.readthedocs.io/en/stable/bugDescriptions.html

Co-authored-by: Austin Shalit <austinshalit@gmail.com>
2021-09-24 16:04:02 -07:00
Tyler Veness
d6f185d8e5 Rename tests for consistency (#3592)
I started with the output of styleguide#217, then renamed a few classes
to fix compilation.

ntcore's StorageTest needed some manual renaming since it put the Test
word in the middle instead of at the end.

One limitation of wpiformat is test cases that were only named "Test"
were unmodified, and an error was generated. These test cases were
manually given more descriptive names:

* TimedRobotTest mode test cases had "Mode" appended to the name. Java
  tests were renamed to match.
* UvAsyncTest and UvAsyncFunctionTest cases were given alternate names
2021-09-21 06:12:50 -07:00
Tyler Veness
fe59e4b9fe Make C++ test names more consistent (#3586)
Inconsistent names were found using the following regular expressions.

* `rg "TEST(_F|_P)?\(\w+,\s+\w+Test\)"`
* `rg "TEST(_F|_P)?\(\w+,\s+Test\w+\)"`
* `rg "TEST(_F|_P)?\(\w+Tests,\s+\w+\)"`

Fixes #3495.
2021-09-17 22:51:51 -07:00
Tyler Veness
9359431bad [wpimath] Clean up Eigen usage
* Replace Matrix<> with Vector<> where vectors are explicitly intended.
  I found these via `rg "Eigen::Matrix<double, \w+, 1>"`.
* Pass all Eigen matrices by const reference. I found these via `rg
  "\(Eigen"` on main (the initializer list constructors make more false
  positives).
* Replace MakeMatrix() and operator<< usage with initializer list
  constructors. I found these via `rg MakeMatrix` and `rg "<<"`
  respectively.
* Deprecate MakeMatrix()
2021-09-17 12:12:19 -07:00
Tyler Veness
32d9949e4d [wpimath] Move controller tests to wpimath (#3541) 2021-09-06 17:00:13 -07:00
Tyler Veness
aa3848b2c8 [wpimath] Move RobotDriveBase::ApplyDeadband() to MathUtil (#3529)
It's a useful function outside of the drive classes.

For backwards compatibility, deprecate (rather than remove) RobotDriveBase.applyDeadband()
2021-08-28 20:52:05 -07:00
Tyler Veness
3b5d0d141a [wpimath] Add LinearFilter::BackwardFiniteDifference() (#3528)
This is an alternative to #2344 that handles arbitrary order derivatives
of arbitrary precision. The downside is that since it's part of
LinearFilter, it can't utilize the units type system in the same way to
make Calculate()'s input type different from its output type.
2021-08-28 20:50:18 -07:00
Tyler Veness
e0c6cd3dcc [wpimath] Add an operator for composing two Transform2ds (#3527) 2021-08-23 20:22:48 -07:00
Tyler Veness
3838cc4ec4 Use unicode characters in docs equations (#3487)
javac and javadoc needed the encoding set to UTF-8.
2021-07-29 22:42:43 -07:00
Tyler Veness
50af74c38f [wpimath] Clean up NumericalIntegration and add Discretization tests (#3489)
* Rename Butcher tableau sections in NumericalIntegration such that
  top-left is c, top-right is A, and bottom-right is b
* Move edu.wpi.first.math.Discretization to
  edu.wpi.first.math.system.Discretization
* Sort Java Discretization to match C++ function order
* Add tests for Java Discretization
  * Required adding Runge-Kutta time-varying impl to tests
* Move C++ Runge-Kutta time-varying impl to tests only
  * Users don't need it
2021-07-25 07:42:59 -07:00
Tyler Veness
ab8e8aa2a1 [wpimath] Update drake with upstream (#3484)
Our patches for the DARE and [[noreturn]] attributes were merged
upstream. We missed their monthly release window by a day, so we'll use
a commit hash for now.
2021-07-22 17:48:48 -07:00
Tyler Veness
52bddaa97b [wpimath] Disable iostream support for units and enable fmtlib (#3481)
Supersedes #2497.
2021-07-13 13:41:07 -05:00
Tyler Veness
1daadb812f [wpimath] Implement Dormand-Prince integration method (#3476)
Also refactored RKF45 implementation to match the new style, which is
easier to read.

The tests were switched from RKF45 to RKDP since it's more accurate.
2021-07-11 09:42:33 -05:00
Tyler Veness
9fb4f35bb6 [wpimath] Add tests for DARE overload with Q, R, and N matrices (#3472)
The autodiff headers weren't used by the tests, so they were removed.
2021-07-09 21:41:33 -05:00
Tyler Veness
f7db09a128 [wpimath] Move C++ filters into filter folder to match Java (#3417) 2021-06-08 21:21:01 -07:00
Tyler Veness
dea841103d [wpimath] Add fmtlib formatter overloads for Eigen::Matrix and units (#3409)
This allows using Eigen matrices or units natively with fmt::format() or
fmt::print().
2021-06-05 21:10:41 -07:00
Tyler Veness
82856cf816 [wpiutil] Improve wpi::circular_buffer iterators (#3410)
The implementation of wpi::circular_buffer has been effectively replaced
with a dynamically sized copy of wpi::static_circular_buffer with a
resize() member function.
2021-06-05 21:08:12 -07:00
Tyler Veness
01dc0249de [wpimath] Move SlewRateLimiter from wpilib to wpimath (#3399)
Timer was replaced with wpi::Now() to avoid a dependency on other wpilib
classes.
2021-05-31 10:35:54 -07:00
Tyler Veness
a238cec12b [wpiutil] Deprecate wpi::math constants in favor of wpi::numbers (#3383)
The constants were moved from std::math to std::numbers before
ratification in C++20.
2021-05-26 00:09:36 -07:00
Tyler Veness
04dae799a2 [wpimath] Add SimpleMotorFeedforward::Calculate(velocity, nextVelocity) overload (#3183)
This is often more convenient than using the overload with velocity and
acceleration.

Fixes #3160.
2021-05-21 23:44:10 -07:00
Peter Johnson
3cc2da3328 Merge branch '2022' 2021-05-09 14:15:40 -07:00
Tyler Veness
ba08baabb9 [wpimath] Update Drake DARE solver to v0.29.0 (#3336)
This version incorporated the patch we were manually applying, so we're
synced back up with upstream now except for some minor #include changes
to reduce header bloat.
2021-05-05 09:16:55 -07:00
Tyler Veness
365f5449ca [wpimath] Fix MecanumDriveKinematics (#3266) 2021-04-30 15:50:16 -07:00
Prateek Machiraju
d3e45c297c [wpimath] Make C++ geometry classes immutable (#3249) 2021-03-19 13:38:54 -07:00
Prateek Machiraju
9522f2e8c7 [wpimath] Add methods to concatenate trajectories (#3139)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2021-02-16 18:06:36 -08:00
Tyler Veness
2c2ccb3618 [wpimath] Fix Rotation2d equality operator (#3128) 2021-01-25 21:41:34 -08:00
Prateek Machiraju
e9c86df468 [wpimath] Add tests for swerve module optimization (#3100) 2021-01-20 20:44:37 -08:00
Tyler Veness
f393989a5b [wpimath, wpiutil] Add wpi::array for compile time size checking (#3087)
The wpimath APIs use std::array, which doesn't do size checking. Passing
an array with the wrong size can result in uninitialized elements
instead of a compilation error.

This is a breaking change but is worthwhile to avoid hard-to-debug errors.
2021-01-16 20:26:17 -08:00
Matt
85a0bd43c2 [wpimath] Add RKF45 integration (#3047)
This is more stable than Runge-Kutta for systems with large elements in their A or B matrices.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2021-01-06 21:40:25 -08:00
Tyler Veness
62f0f8190d [wpimath] Deduplicate angle modulus functions (#2998)
frc::NormalizeAngle(), units::math::NormalizeAngle(), and
frc::GetModulusError() were replaced with frc::InputModulus() and
frc::AngleModulus().

They were placed in wpimath/src/main/native/include/frc/MathUtil.h for
C++ and wpimath/src/main/java/edu/wpi/first/wpiutil/math/MathUtil.java
for Java.
2021-01-01 16:22:00 -08:00
Peter Johnson
6131f4e32b clang-tidy: modernize-concat-nested-namespaces (NFC) 2020-12-29 14:26:19 -08:00
Peter Johnson
67e03e625d clang-tidy: modernize-use-equals-default 2020-12-29 14:26:19 -08:00
Peter Johnson
d11a3a6380 clang-tidy: modernize-use-override (NFC)
Add NOLINT to CommandTestBase due to gmock not adding "override" keyword,
which causes warnings on clang.
2020-12-29 14:26:19 -08:00
Peter Johnson
4cc0706b06 clang-tidy: modernize-use-using (NFC)
Excludes C-compatible headers
2020-12-29 14:26:19 -08:00
Peter Johnson
5d7315280a [wpimath] Update UnitsTest.cpp copyright (#2985) 2020-12-28 10:40:20 -08:00