Compare commits

...

1634 Commits

Author SHA1 Message Date
Jack Cammarata
1efaaefd78 [wpimath] Fix UnscentedKalmanFilter and improve math docs (#7850)
Throughout the code the state sqrt covariance S and innovation covariance Sy are maintained as upper triangular cholesky factors of those covariance matrices. The original paper defines P=S*S', so S should be lower triangular. The functions in the paper reflect this. In the code implementation, the sqrt covariance matrices are upper triangular, but the algorithm expects them to be lower triangular.

This bug was likely missed because the incorrect version of the filter is able to converge for some systems where all the states are observed, and the test case is set up such that all states are observed.

To fix the bug, a couple things needed to be changed:
all instances of rankUpdate() needed to be changed to use the lower triangular cholesky factor,
In the unscented transform, when S is found via QR decomposition, we need to take the transpose because R is upper triangular,
P() and SetP() functions need to be modified to be P=S*S' instead of P=S'*S, and P.llt().matrixL() instead of P.llt().matrixU() respectively.

Each part of the algorithm has also had the comments changed to clarify exactly which equation from the paper it implements.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2025-03-14 10:05:15 -07:00
Tyler Veness
71b6e8ec58 [wpiutil] Avoid including execinfo.h for Emscripten target (#7854) 2025-03-06 23:15:22 -08:00
Tyler Veness
1a835fec01 [wpimath] Fix singularities in Ellipse2d::Nearest() (#7851)
The problem was ill-conditioned if either semiaxis had zero length.
2025-03-04 18:52:17 -08:00
crueter
0ad595c33c [wpimath] Add Debouncer type and time setters (#7839)
Signed-off-by: swurl <swurl@swurl.xyz>
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2025-03-03 17:21:38 -07:00
Thad House
93bf6c70ba [build] Remove sources from ceres-cpp (#7844) 2025-03-02 10:46:50 -08:00
arbessette
a7ae22d764 [docs] Update code of conduct (#7833) 2025-02-27 11:02:13 -08:00
Tyler Veness
822457d45b [wpimath] Fix feedforward returning NaN when kᵥ = 0 (#7790) 2025-02-25 19:07:51 -08:00
Adrien Bourdeaux
75321f1d84 [wpimath] Add Translation2d/Translation3d slew rate limiter (#7806)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
2025-02-25 19:06:00 -08:00
Tyler Veness
cd6fee7fea [sysid] Refactor feedback analysis (#7827) 2025-02-25 19:05:05 -08:00
Tyler Veness
517344fe80 [wpimath] Fix another infinite loop in ArmFeedforward (#7823) 2025-02-25 19:04:31 -08:00
Rain Heuer
b0e588fd49 [glass] Update Field2D default field to 2025 (#7820) 2025-02-25 19:04:16 -08:00
Tyler Veness
0f0e93722e [ci] Upgrade to Clang 17 sanitizers (#7819) 2025-02-25 19:01:41 -08:00
sciencewhiz
f9307de04c [docs] Document that /format is disabled (#7810)
Add instructions for manual workarounds
2025-02-20 20:13:09 -08:00
sciencewhiz
15dcdebe21 [docs] Update contributing so breaking changes go to 2027 (#7809) 2025-02-20 20:12:48 -08:00
Tyler Veness
0c3c2c1fda [sysid] Remove extra period from exception messages (#7805) 2025-02-19 21:08:39 -08:00
HarryXChen
c898853b4d [wpilib] LinearSystemSim.setState: calculate new output state (#7799)
Establishes the invariant that the state and measurement always match up, even immediately after construction.
2025-02-18 22:49:28 -08:00
Sam Carlberg
bd2211119f [epilogue] Make nonloggable type warnings configurable (#7792)
Now a flag at the class level controls whether warning messages are printed.

Defaults to false (no warning messages).
2025-02-18 21:48:51 -08:00
Tyler Veness
13626063dc [wpimath] Fix units typo (#7789) 2025-02-13 23:22:44 -08:00
Peter Johnson
7e6077c546 [wpimath] Fix up order and docs for Feedforward gain setters (#7788) 2025-02-13 23:20:08 -08:00
Jade
4d126b158c [wpimath] Add setters to Feedforward gains (#7784)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-02-13 21:09:28 -08:00
Peter Johnson
e22f76ce73 [build] Bump native-utils to 2025.9.1 (#7783) 2025-02-13 20:23:07 -08:00
Jonah Bonner
e648b9c86d [wpinet] Serve index HTML file from WebServer if available (#7780) 2025-02-13 18:10:02 -08:00
Kevin-OConnor
23658a8c62 [apriltag] Split 2025 AprilTag Maps (#7781)
Splits maps for welded vs AndyMark field perimeters. More info about why and what fields are at what events will be in TU12.
2025-02-13 17:53:11 -08:00
Tyler Veness
155b3d45e7 [wpiutil] Remove broken StackWalker library (#7777)
A Discord user reported that StackWalker gives blank stacktraces.

MSVC's C++23 support is unstable, so we can't use std::stacktrace yet.
In the meantime, we can just return an empty string and remove the
unmaintained StackWalker library and its hacky upstream_utils script.
2025-02-12 22:54:41 -08:00
Austin Schuh
d62ab12855 [bazel] Add missing -ldl when building libuv in bazel (#7775)
I was getting:
external/arm_frc_linux_gnueabi_repo/bin/../arm-nilrt-linux-gnueabi/sysroot/usr/lib/gcc/arm-nilrt-linux-gnueabi/12/../../../../../../../arm-nilrt-linux-gnueabi/bin/ld: bazel-out/k8-opt--roborio/bin/external/com_github_wpilibsuite_allwpilib/wpinet/libwpinet.static.a(fs.o): undefined reference to symbol 'dlsym@@GLIBC_2.4'
external/arm_frc_linux_gnueabi_repo/bin/../arm-nilrt-linux-gnueabi/sysroot/usr/lib/gcc/arm-nilrt-linux-gnueabi/12/../../../../../../../arm-nilrt-linux-gnueabi/bin/ld: external/arm_frc_linux_gnueabi_repo/bin/../arm-nilrt-linux-gnueabi/sysroot/lib/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status

This fixes that error for me.

Signed-off-by: Austin Schuh <austin.linux@gmail.com>
2025-02-12 16:17:11 -07:00
Dustin Spicuzza
1921d7b79a [wpilibc] Remove Alert magic static with map lookup (#7712)
The magic static adds yet another thing that needs to be reset if you
want to run a unit test with a completely reset wpilib state. Use the
existing Sendable static map to store the data instead.

This leaks memory if ResetSmartDashboardInstance is called.
2025-02-11 22:05:22 -08:00
Gold856
9dbb0c8c3d [ci] Turn on sync labels for the labeler (#7770)
This means PRs that had labels for certain changes will have those labels removed if those changes are removed.
2025-02-09 23:04:36 -08:00
Michael Fisher
b2584c6bdf [cmake] Use binary output dir for generated field images code (#7772) 2025-02-09 23:03:15 -08:00
Peter Johnson
53df127535 [cmake] Suppress enum warning on all clang, not just Apple (#7771) 2025-02-09 23:01:51 -08:00
Peter Johnson
d2611d4ad5 [hal] SPI: Remove byte limit on size in Java API (#7774)
The underlying Linux spidev supports up to page size length.
2025-02-09 23:01:01 -08:00
Ryan Blue
b60b2b64bd [hal, wpilib] AddressableLED: add support for other color orders (#7102)
Many LED strips use different color order (GRB in particular is common).

This makes the change at the HAL level. This solves 2 problems; first, no code needs to change in the high level drivers, which was challenging for C++, and second, simulation will behave properly as no conversion is needed. The HAL will accept an array of data objects in the same order no matter what the selected output order is, and will convert before sending it to the FPGA for output.

To accomplish this, NEON bulk load/interleave instructions are utilized. The low level implementation (load, store, and alignment functions) come from the Simd Library. The high level implementations are inspired by the image conversion functions in the simd library, but have diverged significantly.

Much of the implementation uses templates and inlined functions rather than runtime parameters; This is a trade off between the size of the generated code and the amount of function calls done at runtime. Currently, the entire conversion operation is inlined.
2025-02-07 13:36:41 -07:00
Ryan Blue
a0976a1fd9 [build] Update developerRobot JRE (#7764) 2025-02-07 11:24:30 -07:00
DeltaDizzy
b3b515e1dd [sysid] Error on missing tests in loaded DataLog (#7747)
* add exception

* detect missing tests

* throw in analyzer

* define tests setter

* change to std::map

* alignas fail

* make missingTests parameter const&

* const& impl

* use set and naive comparison

* use default comparison

* add <utility>

* Revert "alignas fail"

This reverts commit 5e97940f34.

* indent validtests

* format
2025-02-04 18:12:00 -05:00
Joseph Eng
296986397b [wpimath] Document drift from desaturating discretized chassis speeds (NFC) (#7741) 2025-02-03 11:46:18 -07:00
Sam Carlberg
18321e5551 [epilogue] Fix epilogue with package-info files (#7749) 2025-01-30 13:34:51 -07:00
Tyler Veness
b31fd17d05 [wpimath] Fix infinite loop in ArmFeedforward::Calculate(xₖ, vₖ, vₖ₊₁) (#7745)
Small values of kₐ make the iterative solver ill-conditioned. This
change reverts to the constant-acceleration feedforward in that case. It
gives _very_ bad results (hence why we added the iterative solver in the
first place), but it's better than hanging.

```
TEST(ArmFeedforwardTest, CalculateIllConditioned) {
  constexpr auto Ks = 0.5_V;
  constexpr auto Kv = 20_V / 1_rad_per_s;
  constexpr auto Ka = 1e-2_V / 1_rad_per_s_sq;
  constexpr auto Kg = 0_V;
  frc::ArmFeedforward armFF{Ks, Kg, Kv, Ka};

  // Calculate(currentAngle, currentVelocity, nextAngle, dt)
  CalculateAndSimulate(armFF, 0_rad, 0_rad_per_s, 2_rad_per_s, 20_ms);
}
```
This produces 1 V and doesn't accelerate the system at all. Using
nextVelocity instead of currentVelocity in the feedforward outputs 41 V
and still only accelerates to 0.4 rad/s of the requested 2 rad/s.

I picked the kₐ cutoff by increasing kₐ until the iterative solver
started converging.

Fixes #7743.
2025-01-30 13:33:39 -07:00
Gold856
b44a80c07a [build] cmake: Install wpimath nanopb headers (#7731) 2025-01-24 23:26:09 -08:00
Gold856
25d11524e8 [ci] Re-enable Artifactory cleaner cron job (#7721)
The query now targets the local repo for extra safety.
2025-01-23 21:46:13 -08:00
Peter Johnson
d86a2ec83b [ci] Fix labeler indentation (#7716) 2025-01-21 12:51:48 -07:00
sciencewhiz
0690d3d832 [ci] Update labeler for wpical and usage reporting (#7710) 2025-01-20 09:14:27 -07:00
Ryan Blue
304b98c0c9 [wpilibc] Alert: Fix first alert in group not publishing data (#7711) 2025-01-20 09:10:03 -07:00
Joseph Eng
72541c10e6 [wpilib, commands] Improve HID direction documentation (NFC) (#7672) 2025-01-19 20:34:07 -08:00
sciencewhiz
00445f4f27 [hal] Add Kitbot framework usage reporting (#7709)
Used in FIRST's kitbot code
2025-01-18 15:02:41 -08:00
Matthew Wozniak
8fc3767b30 [wpimath] Fix macro name typo (#7707) 2025-01-17 22:19:21 -08:00
Peter Johnson
5ab0409c15 [wpilib] ADIS164xx: report product ID on mismatch (#7706) 2025-01-17 18:14:20 -08:00
Peter Johnson
4caa16e254 [wpilibj] ADIS16470: Allow product ID of 16470 (#7704)
C++ allows either 16982 or 16470, do the same for Java.
2025-01-17 13:53:20 -08:00
Sam Carlberg
e52f400687 [wpiunits] Add Measure.per overloads for all known unit types (#7699)
Instead of only providing per(TimeUnit)

Useful for making conversion factors easier, eg `Inches.of(10).per(Rotation)` vs `Inches.of(10).per(Rotation.one())`

Update VelocityUnit.one() and VelocityUnit.zero() to return Velocity objects instead of generic Measure<? extends VelocityUnit<D>>; VelocityUnit is final, so the wildcard generic is unnecessary, and this makes the generated `per` functions possible for this type
2025-01-16 23:24:11 -08:00
PJ Reiniger
a9f3fc6b2c [bazel] Update toolchain to support systemcore (#7689) 2025-01-16 10:52:43 -07:00
David Racovan
a14545102f [wpimath] DifferentialDriveWheelPositions: tag as Proto/StructSerializable (#7622) 2025-01-13 14:52:40 -07:00
Tyler Veness
25e6549398 [wpimath] Fix various constexpr support bugs (#7676) 2025-01-13 14:44:55 -07:00
ハイドラント
cd92b07321 [wpimath] Add Pose2d and Pose3d rotateAround() (#7659) 2025-01-13 12:55:26 -07:00
Jason Daming
fc9e413ce1 [hal, wpilib] Add note about support for WS2815 (#7664) 2025-01-13 12:26:54 -07:00
Tyler Veness
007526089e [wpimath] Fix LinearSystemId return type and docs (#7675)
Fixes #7674.
2025-01-13 12:22:53 -07:00
Sam Carlberg
c5f7a2b4ac [epilogue] Fix lazy logging of mutable arrays (#7665) 2025-01-11 10:25:47 -08:00
Jade
638d265b33 [commands] Add a warning to schedule docs (NFC) (#7073)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-09 23:31:40 -08:00
Elliot Scher
6125227836 [wpical] Add JSON Combiner (#7640)
This new feature allows users to combine multiple Apriltag layouts. This can be useful for fields where the apriltags are split into two or more sections: (red/blue side, grouped together by task, etc.)
2025-01-09 23:30:17 -08:00
HarryXChen
e37c35746a [wpimath] Implement Translation3d.RotateAround (#7661) 2025-01-09 20:31:34 -08:00
oh-yes-0-fps
995bc98ccf [epilogue] Revert "Add a measure's symbol to its name when logged by Epilogue (#7535)" (#7652)
This reverts commit 469bb3290d.

The approach used has issues due to the fact unit symbols often have a literal / in them,
which causes issues with NT topic visualization.

A better approach would be to use topic metadata.
2025-01-07 12:35:10 -07:00
Matt
2de03c9601 [cscore] Use frame time in Linux UsbCameraImpl (#7609) 2025-01-07 09:33:20 -07:00
Ryan Heuer
8e459a4f2a [glass] Field2d: Fix custom image padding to maintain aspect ratio (#7648) 2025-01-06 21:16:14 -08:00
Peter Johnson
58d7c07343 [fieldImages] Use rendered image (#7650)
Source: https://www.chiefdelphi.com/t/4k-field-image-2025-reefscape/478797
2025-01-06 21:15:39 -08:00
Peter Johnson
9b08f0244c [wpiutil] SignalObject: Fix move operator= (#7649) 2025-01-06 20:11:34 -08:00
sciencewhiz
7032de3d5d [glass] Field2D: Change field picker to show JSONs first (#7643)
Too many people don't realize that glass/simgui field2d can load
pathweaver JSON field files since it's hidden.
2025-01-05 22:36:14 -08:00
Kevin-OConnor
159e18ce05 [fieldImages] Flip 2025 Field Image (#7638)
Original image was flipped when it should have been rotated.
2025-01-04 11:37:44 -08:00
Peter Johnson
257d0e0824 [fieldImages] Add 2025 Reefscape to Fields, make default (#7635) 2025-01-04 11:14:27 -08:00
Kevin-OConnor
b65f159c3f Add 2025 field and apriltags (#7634)
Column in Field Drawings is labeled X-Rotation, but I believe it should be Y-Rotation so have reflected that here. We'll fix in a TU if this is correct.
2025-01-04 10:14:34 -08:00
Tyler Veness
11a0c36737 [wpimath] Make Rotation2d member initialization order match declaration order (#7632) 2025-01-03 22:44:17 -08:00
Wispy
17a03514ba [glass, simgui] Fix minimum widths of windows (#7604) 2025-01-01 15:20:35 -08:00
Jade
9ebc4b32ae [commands] Undeprecate deferredProxy (#7417)
This changes the way deferred proxy is implemented to not use the
deprecated ProxyCommand constructor.

This function serves a good purpose that should be kept IMO. The
constructor was confusing but this is just good syntactic sugar over
`defer(() -> supplier.get().asProxy())`.

Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-01 15:11:39 -08:00
Elliot Scher
ce60bd5035 [wpical] Add support for new Apriltags (ID 16-22) (#7619) 2025-01-01 14:53:58 -08:00
Jade
468a3c6d95 [apriltag] Add kDefaultField to C++ (#7618)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2025-01-01 14:34:51 -08:00
Peter Johnson
4350ea769c [build] Bump ni-libraries to 2025.2.0 (#7617) 2024-12-31 20:50:50 -08:00
sciencewhiz
83397392f4 [hal] Update Usage Reporting to match 2025v2 image numbers (#7616) 2024-12-31 20:24:26 -08:00
Tyler Veness
786d22049b [wpilibc] Rename DCMotorSim getters (#7614) 2024-12-31 16:48:45 -08:00
Dustin Spicuzza
86137c49f5 [wpilibc] DCMotorSim: Add setAngle/setAngularVelocity (parity with Java) (#7613) 2024-12-31 14:30:16 -08:00
Tyler Veness
4edf52d3b6 [wpilibc] Clean up Joystick::GetDirection() (#7612) 2024-12-31 13:31:05 -08:00
Gold856
a41fb460a9 Update ThirdPartyNotices.txt (#7608) 2024-12-30 20:16:10 -06:00
sciencewhiz
d4985b8ba0 [ci] Build RobotPy in tools workflow (#6800) 2024-12-29 23:47:45 -06:00
sciencewhiz
1538370034 Update license year to 2025 (#7607) 2024-12-29 23:46:38 -06:00
Carl Hauser
eef1bf33de [wpilib] Fix SmartDashboard.setDefault* docs (NFC) (#6490)
Fix incorrect comments related to NT SetDefault* methods across multiple components
2024-12-29 18:41:29 -06:00
ハイドラント
78b6d61e88 [commands] Use factories and decorators in Command tests (#7006) 2024-12-29 10:45:17 -06:00
David Vo
e7dd5dca82 [wpilibj] TimedRobot: Squash ErrorProne warnings (#7605) 2024-12-28 21:01:43 -08:00
Matt
a27df8ec24 [cscore] Sink: add ability to get most recent frame instead of waiting (#7572)
This allows more control over frame dropping.
2024-12-28 20:44:48 -08:00
Elliot Scher
85507a6c65 [wpical] Add WPIcal: Field Calibration Tool (#6915)
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
Co-authored-by: Jade <spacey-sooty@proton.me>
Co-authored-by: Matthew Morley <matthew.morley.ca@gmail.com>
2024-12-28 20:24:32 -08:00
Peter Johnson
b74f84f876 [upstream_utils] Add imgui_demo.cpp (#7602)
This has useful debugging functions; it was left out of the change
from the separate thirdparty repo.
2024-12-28 19:33:55 -08:00
Joseph Eng
54e9c76e03 [wpilibc] Fully qualify names in error macros (#7601) 2024-12-28 16:59:19 -06:00
sciencewhiz
203487a6aa [wpimath] improve LTVUnicycleController docs (NFC) (#7599)
Document the states and inputs so it isn't necessary to look at the code
Fix max velocity throws doc
2024-12-28 16:03:47 -06:00
Tyler Veness
57344ef3b2 [wpimath] Use ct_matrix instead of Eigen/LU for determinant in headers (#7600)
This caught a bug in ct_matrix's 3x3 determinant.
2024-12-28 16:03:29 -06:00
sciencewhiz
46d401553e [wpilib] Add Koors40 motor controller (#7469) 2024-12-27 15:04:43 -06:00
Tyler Veness
9e63dcfb16 [ci] Install wpiformat into venv (#7596) 2024-12-26 21:59:48 -06:00
Gold856
934bf7bf05 [build] CMake: Make NO_WERROR also work on MSVC (#7594) 2024-12-26 21:33:20 -06:00
Nicholas Armstrong
fe49cbe429 [wpimath] Remove Units class from Elevator and Arm Feedforwards (#7570) 2024-12-26 20:21:19 -06:00
Tyler Veness
0470e51569 [upstream_utils] Upgrade to fmt 11.1.0 (#7593)
Usage of FMT_STRING() was removed since it caused compilation failures,
and https://fmt.dev/11.1/api/#compile-time-checks says it's no longer
necessary for compile-time format strings.

Fixes #7592.
2024-12-26 19:14:02 -06:00
Tyler Veness
72fdca3507 [examples] Fix C-style cast warning from cpplint (#7591) 2024-12-25 23:33:41 -06:00
sciencewhiz
dee50bf500 [ci] Validate gradle wrapper inline (#7582)
Updates to v4 of the gradle wrapper validation action
2024-12-24 17:42:07 -08:00
Tyler Veness
939a9ceee1 [upstream_utils] Upgrade to LLVM 19.1.6 (#7101) 2024-12-24 17:40:31 -08:00
Gold856
b670a59b5b [build] Fix imgui libraries not being published (#7575) 2024-12-23 19:05:06 -08:00
Brendan Raykoff
9b12ddb595 [upstream_utils] Patch protobuf to remove deprecated ATOMIC_VAR_INIT (#7585) 2024-12-23 16:14:15 -06:00
Peter Johnson
76625fa0f9 [build] cmake: Build wpiutil dev executable (#7578) 2024-12-22 15:03:33 -08:00
Peter Johnson
bb130b67b8 [wpiutil] DataLogWriter: Don't crash on file open error (#7579) 2024-12-22 15:03:12 -08:00
Wispy
469bb3290d [epilogue] Add a measure's symbol to its name when logged by Epilogue (#7535) 2024-12-22 13:35:31 -08:00
Tyler Veness
02a0adc653 [wpimath] Add Rotation3d rotation vector getter (#7564)
The code churn in Java is just making the function order consistent
between languages.
2024-12-22 13:34:51 -08:00
Ryan Blue
0c99073b94 Use std::bit_cast (#7567)
Backport #7492

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-12-22 13:34:16 -08:00
Tyler Veness
d631fa8e4b [wpimath] Fix algorithm link (NFC) (#7569)
Fixes #7568.
2024-12-22 13:33:07 -08:00
Tyler Veness
19d385d149 [ci] Upgrade to wpiformat 2024.51 (#7573) 2024-12-22 13:44:40 -06:00
Ryan Blue
d0cc7e4eca [ci] Disable cleaner cron job (#7574) 2024-12-21 19:08:48 -08:00
Kaya
807dffed35 [commands] Fix C++ iterator invalidation bug (#7554)
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
Co-authored-by: Ryan Blue <13878527+rzblue@users.noreply.github.com>
2024-12-20 00:32:24 -06:00
Ryan Blue
f46c81cfe3 [ci] Delete comment command (#7566) 2024-12-19 20:53:17 -06:00
PJ Reiniger
9ccd73108b [bazel] MVP for building wpilibc + commands framework (#7231) 2024-12-18 22:00:40 -08:00
Gold856
38d8929f48 [ci] Move pregen steps into a composite action (#7474)
This ensures that complete uniformity in how the generation scripts are run. All dependencies and scripts are set up in the exact same way, each time. The old pregen_all script has been removed and moved into the composite action to ensure failed scripts will always fail the job.
2024-12-18 21:59:47 -08:00
Jan-Felix Abellera
cc73236a06 [hal] Add CAN device type for servo controllers (#7556) 2024-12-18 21:57:34 -08:00
Jade
f8720a628c [commands] Fix proxy command deprecation docs (#7396)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
2024-12-18 21:57:11 -08:00
Jade
156bd71fef [developerRobot] Workaround Eclipse annotation processor issues (#7537)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-12-18 09:46:31 -07:00
Ryan Blue
6e44187ff6 [build] cmake: Add wpilibNewCommands and apriltag to developerRobot (#7557) 2024-12-18 09:35:23 -07:00
Jan-Felix Abellera
e2cbdf9718 [hal] Add usage reporting for REV Servo Hub (#7555) 2024-12-18 09:34:45 -07:00
Jade
66cce1835c [ci] Add Buildifier to /format comment command (#7480)
Signed-off-by: Jade Turner <spacey-sooty@proton.me>
2024-12-18 09:31:02 -07:00
sciencewhiz
6fe5da7289 [examples] Fix example json for SimpleDifferentialDriveSimulation (NFC) (#7561)
Uses LTVUnicycleController now instead of RAMSETE.
2024-12-18 09:20:31 -07:00
Peter Johnson
80c391e182 [wpinet] WebServer: Unescape URI (#7552)
Also provide Content-Disposition filename header in response.

This fixes e.g. filenames with spaces in them.
2024-12-15 12:28:08 -08:00
Joseph Eng
70f36cce7e [commands] Extract common trigger binding logic (#7550)
This makes the logic clearer in the actual binding methods and will hopefully make it less annoying to make changes such as allowing control over initial edges.

Also changes Java to use previous and current to match C++.
2024-12-14 23:13:41 -08:00
Peter Johnson
564c1f2de2 [wpinet] WebServer: Fix Windows (#7551)
The order of evaluation of parameters is not defined; on Windows,
the std::move was executed before the GetBuffer().
2024-12-14 23:07:48 -08:00
Peter Johnson
a1b642a402 [wpinet] Add simple web server (#7527)
Also add EscapeHTML to HttpUtil.
2024-12-14 11:51:21 -08:00
Falon
f9b3efb712 [wpiunits] Refactor MomentOfInertiaUnit constructor to use MomentOfInertiaUnit instead of a Per<> (#7546) 2024-12-14 11:26:26 -08:00
Thad House
782459dff4 [wpiutil] Make runtime loader exception message slightly better (#7536) 2024-12-14 11:25:27 -08:00
Peter Johnson
4bca79b9af [wpimath] Revert "ChassisSpeeds fromRelative and discretize methods made instance methods (#7115)" (#7549)
This reverts commit a3b12b3bd9.
2024-12-14 10:42:49 -08:00
Daniel Chen
68285dae77 [commands] Add withDeadline modifier (#7299)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2024-12-13 18:30:02 -07:00
Daniel Chen
5e3dba672a [wpiutil] Record/Enum struct generation fix (#7538)
ProceduralStructGenerator's genRecord and genEnum were package-private, and only extractClassStruct was made public.
However, this package private visibility rendered them unable to be used by the rest of wpilib(and advanced users).

Here, ProceduralStructGenerator is split into 2 classes: StructGenerator(which generates structs) and StructFetcher(the new namespace for extractClassStruct). In addition, genRecord and genEnum have been made public methods.
2024-12-13 12:25:38 -07:00
Ryan Blue
e943424609 [build] Update shadow plugin (#7540) 2024-12-12 19:19:14 -08:00
Joseph Eng
4225b732fd Remove unnecessary boxing (#7539)
* Remove unnecessary boxing
Also remove unnecessary warning suppression

* Use more idiomatic functional interfaces in NumericalIntegration
2024-12-12 19:18:40 -08:00
Carl Hauser
39d05ebe7c [rtns] Capture exitCode from ssh_channel_get_exit_status (#7541) 2024-12-12 19:18:02 -08:00
Wispy
cc41a0ed24 [wpilib] Replace MecanumDriveMotorVoltages with a functional interface (#6760) 2024-12-08 17:05:06 -08:00
Tyler Veness
d5edb4060d [upstream_utils] Upgrade Sleipnir (#7512)
It now uses SQP for problems without inequality constraints, which is
faster.

main:
```
[ RUN      ] Ellipse2dTest.DistanceToPoint
0.203 ms
[       OK ] Ellipse2dTest.DistanceToPoint (0 ms)
[ RUN      ] Ellipse2dTest.FindNearestPoint
0.019 ms
[       OK ] Ellipse2dTest.FindNearestPoint (0 ms)
```

upgrade:
```
[ RUN      ] Ellipse2dTest.DistanceToPoint
0.197 ms
[       OK ] Ellipse2dTest.DistanceToPoint (0 ms)
[ RUN      ] Ellipse2dTest.FindNearestPoint
0.015 ms
[       OK ] Ellipse2dTest.FindNearestPoint (0 ms)
```
2024-12-07 23:02:39 -08:00
Tyler Veness
e08fdeba21 [wpimath] Rename FindNearestPoint() to Nearest() (#7513)
This is easier to type and follows the naming of Pose2d::Nearest().

Since Ellipse2d and Rectangle2d were added for the 2025 season, we don't
need to add deprecation notices.
2024-12-07 23:01:18 -08:00
Wispy
544553a58f [developerRobot] Add Epilogue and wpiunits to developerRobot (#7510) 2024-12-07 23:00:49 -08:00
Peter Johnson
838c5fbcd7 [ci] Fix labeler yaml (#7523) 2024-12-07 21:37:49 -08:00
Peter Johnson
38a239b531 [ci] Add labeler action to auto-label PRs (#7520) 2024-12-07 21:15:49 -08:00
Thad House
9a1b4245fa [build] Restore Windows constexpr mutex define on wpiutil (#7515) 2024-12-07 18:55:06 -08:00
Tyler Veness
e222efaa01 [wpimath] Add affine transformation constructors and getters to geometry API (#7430)
Fixes #7429.
2024-12-07 15:49:17 -08:00
shueja
f772bb141d [epilogue] Add extra parentheses around cast when using varhandle (#7428)
* [epilogue] Add extra parentheses around cast when using varhandle

* Fixed tests and added one for private suppliers

* Fix tests

* Formatting fixes

* Update epilogue-processor/src/test/java/edu/wpi/first/epilogue/processor/AnnotationProcessorTest.java

Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
Co-authored-by: Sam Carlberg <sam@slfc.dev>
2024-12-07 16:09:35 -05:00
Tyler Veness
278efa6384 [upstream_utils] Remove Sleipnir patches no longer needed with GCC 11 (#7491) 2024-12-07 12:36:25 -08:00
Tyler Veness
e876452967 [ci] Upgrade to wpiformat 2024.50 (#7506) 2024-12-07 11:40:24 -08:00
Sam Carlberg
5c95966d44 Fix epilogue loading optional types from the newcommands vendordep (#7505) 2024-12-07 13:56:05 -05:00
Tyler Veness
882233bede [wpimath] Improve SimpleMotorFeedforward argument names and deprecation message (#7489)
Also roll back SimpleMotorFeedforward unit API until 2027.
2024-12-06 22:32:40 -08:00
Peter Johnson
1921d019b7 [build] Update arm builds to bookworm (#7501)
Also bumps native-utils to 2025.9.0.
And upgrades OpenCV to -3; fixes some enum conversion deprecation warnings.
2024-12-06 22:19:00 -08:00
Peter Johnson
c3fc7c829d [build] Upgrade OpenCV to 4.10.0 (#7500) 2024-12-06 15:41:40 -08:00
Ryan Blue
4ce8930342 [developerRobot] Add instructions for developerRobot java sim (NFC) (#7498) 2024-12-06 00:24:26 -08:00
Daniel Chen
60198c0bec [epilogue] Improved opt-in logging support (#7437) 2024-12-03 20:30:55 -08:00
Gold856
54f0e11fc0 [build] Update OpenCV to 2025-4.8.0-2 (#7476) 2024-12-03 20:30:03 -08:00
sciencewhiz
de82ed434d [hal] Add usage reporting for TOF sensors (#7470) 2024-12-01 17:02:20 -08:00
Thad House
4dd3a36d2e [ci] Switch lint task to use base ubuntu image (#7471) 2024-12-01 17:01:19 -08:00
sciencewhiz
92f8c89267 [hal] Add usage reporting for 2025 legal motor controllers (#7467) 2024-11-30 22:25:04 -08:00
Thad House
1eecaaf337 [build] Update OpenCV to 2025 (#7468) 2024-11-30 22:21:41 -08:00
sciencewhiz
892e062316 [hal,wpilib,wpimath] Add Usage Reporting for Choreo and PathWeaver (#7464) 2024-11-30 20:33:09 -08:00
sciencewhiz
9807d60566 [hal,wpilib] Change Power Distribution usage reporting to Instances (#7465)
LabVIEW doesn't appear to report PDP. This should reduce the number of
Unknowns in the parsed UsageReporting.
2024-11-30 20:32:21 -08:00
Thad House
c387a7ecae [build] Update to 2025 compilers (#7462) 2024-11-30 10:07:53 -08:00
Peter Johnson
715cbb6b76 [sim] GUI: Update FMS widget when real DS is connected (#7456) 2024-11-30 09:49:09 -08:00
Ryan Blue
9d40b993f8 [wpiutil] Fix HasNestedStruct docs (NFC) (#7459) 2024-11-30 07:44:19 -08:00
Sam Carlberg
92ee5bc523 [epilogue] Add usage reporting (#7461) 2024-11-30 09:50:34 -05:00
Peter Johnson
5012ad7499 [epilogue] Fix missed EpilogueBackend renames (#7458) 2024-11-30 00:34:41 -08:00
Peter Johnson
145450b73d [ci] Disable processing of 2027 tags (#7457) 2024-11-29 23:51:27 -08:00
Nicholas Armstrong
b91864a5ec [wpilib] Fix acceleration getter for DCMotorSim (#7449) 2024-11-29 22:15:00 -08:00
sciencewhiz
0941251375 [wpilib] Add usage reporting for loggers (#7450) 2024-11-29 22:13:31 -08:00
Sam Carlberg
7d178615fa [epilogue] Allow custom loggers for generic types (#7452)
Support custom loggers for generic types
Improve error messaging for custom loggers with generic type arguments
Consistently start all epilogue processor prints with "[EPILOGUE]"
2024-11-29 22:11:46 -08:00
Sam Carlberg
806d56e564 [epilogue] Rename DataLogger to EpilogueBackend for clarity (#7453)
Update documentation and internal names correspondingly
2024-11-29 22:10:51 -08:00
Tyler Veness
65f3345407 [upstream_utils] Suppress protobuf warnings on GCC 12 too (#7451) 2024-11-29 18:19:59 -08:00
Sam Carlberg
5e1c6a84ce [wpilibj, wpilibc] Fix LED patterns not offsetting reads (#6948)
Was causing bugs when combined with patterns that need to read back from the buffer (eg masks and overlays)

Co-authored-by: Joseph Eng <s-engjo@bsd405.org>
2024-11-28 21:25:54 -08:00
Tyler Veness
a0af0fd572 [wpimath] Remove redundant internal DARE function (#7442) 2024-11-28 21:24:13 -08:00
Kavin Muralikrishnan
f377a9c573 [examples] Fix SysId example references to shooter subsystem (#7392) 2024-11-27 23:04:53 -08:00
Peter Johnson
62338c7287 [sim] Fix DS GUI System Joysticks window auto-hiding (#7431) 2024-11-27 23:03:55 -08:00
sciencewhiz
49e3e4a0be [wpiunits] Fix deprecation javadoc for units negate (#7436)
deprecated javadoc tags aren't inherited
2024-11-27 23:03:23 -08:00
Joseph Eng
59dbfc9c2d [wpimath] Improve C++ SimpleMotorFeedforward unit type support (#7440)
Allow using non-base types
Allow using angles for serde
2024-11-27 23:02:31 -08:00
Sam Carlberg
9607c6c10d [epilogue] Fix epilogue generating incorrect packages for inner classes (#7439) 2024-11-27 23:02:00 -08:00
sciencewhiz
6ef5b85758 [wpiunits] Restore and deprecate divide (#7438)
It was changed to div in #7387, but 2024 used divide.
2024-11-27 23:01:26 -08:00
Peter Johnson
b6de7acbdb [sim] GUI: Don't show Window menu if it has no contents (#7432) 2024-11-25 17:25:55 -08:00
Thad House
fe28fa1ded [wpilibj] Fix ADIS16470 Gyro (#7434) 2024-11-25 17:23:32 -08:00
Tyler Veness
b7eb9fb8f9 [upstream_utils] Add std::is_debugger_present() shim (#7423) 2024-11-22 09:17:23 -08:00
oh-yes-0-fps
1d58c5025e [wpilibj] Add procedural struct generator for enums and records (#7149) 2024-11-21 20:48:11 -08:00
Thad House
b4a8d33486 [ntcoreffi] Use static runtime for ntcoreffi (#7422)
This avoids requiring users of this library to keep up to date with the latest MSVC runtimes.
2024-11-21 16:14:12 -07:00
sciencewhiz
0a3ccf93c6 [wpimath] Add BangBangController Usage Reporting (#7411) 2024-11-20 17:00:54 -08:00
Matt
d92f17b014 [apriltag] Fix AprilTagDetector cols/stride mixup (#7415) 2024-11-20 17:00:08 -08:00
Gold856
4c225ef2c1 [wpimath] Add proto files back to JAR (#7414)
PhotonVision depends on these being in the JAR to generate quickbuf classes.
2024-11-20 07:59:37 -08:00
Thad House
561078ce29 [hal] Cache sim TCP data to update during HAL_RefreshDSData (#7360) 2024-11-18 20:56:32 -08:00
sciencewhiz
d312bccfeb [hal] Add Swerve Instances for RobotDrive usage reporting (#7410) 2024-11-18 20:51:50 -08:00
David Vo
9826539198 [hal] Add MagicBot framework to usage reporting (#7330)
Co-authored-by: sciencewhiz <sciencewhiz@users.noreply.github.com>
2024-11-18 20:51:16 -08:00
sciencewhiz
33f7067216 [hal] Add usage reporting for Rust (#7409)
Co-authored-by: itsmeft24 <57544858+itsmeft24@users.noreply.github.com>
2024-11-18 20:25:33 -08:00
Vignesh Balasubramaniam
ac1836ec44 [wpiunits] Add absolute value and copy sign functionality (#7358) 2024-11-18 17:46:15 -08:00
sciencewhiz
57e10755fd [wpilib] Add usage reporting for dashboards as instances (#7294)
Detects dashboards based on network tables client identity.
2024-11-18 10:16:29 -07:00
Tyler Veness
8ec22b7d5c [wpiutil] Remove unfinished ct_map class (#7406) 2024-11-17 21:31:25 -08:00
Tyler Veness
a04c40f589 Replace std::make_pair with std::pair CTAD (#7405) 2024-11-17 20:29:23 -08:00
Jade
b4bec566f0 [github] Fix templates not labelling (#7400) 2024-11-17 20:28:39 -08:00
sciencewhiz
d76827db48 [build] Update to Gradle 8.11 (#7402) 2024-11-17 20:28:12 -08:00
Tyler Veness
602c4caa02 [upstream_utils] Check patch files are up to date (#7401) 2024-11-17 20:27:53 -08:00
Peter Johnson
661c321fe2 [upstream_utils] Restore Eigen intellisense fix (#7404)
This reverts commit d1de7663d3.

Intellisense is still broken on Windows Athena target with the error
`incomplete type "Eigen::Matrix<double, 3, 3, 0, 3, 3>" is not allowed`.
2024-11-17 19:11:25 -08:00
Tyler Veness
d1de7663d3 [upstream_utils] Remove Eigen intellisense fix (#7397)
FRC Code intellisense continued to work in developerRobot with a QR
decomposition.
2024-11-16 22:16:11 -08:00
Peter Johnson
b040059108 [ntcore] Properly clean up time sync listeners (#7398) 2024-11-16 22:15:40 -08:00
sciencewhiz
0798ac53d0 [build] Generate NI Style UsageReporting header (#7331)
based on wplibsuite/ni-libraries src/include/FRC_NetworkCommunication/UsageReporting.h
2024-11-16 07:58:25 -08:00
Sam Carlberg
ded7c87d63 [wpimath] Remove units from trapezoid profile classes (#7276) 2024-11-16 07:57:38 -08:00
Joseph Eng
2acf111f56 [wpimath] Add 3D odometry and pose estimation (#7119) 2024-11-16 07:56:14 -08:00
Tyler Veness
aa7dd258c4 [wpimath] Replace constexpr coeff() and coeffRef() with operator() (#7391) 2024-11-16 07:44:20 -08:00
Jonah Bonner
ca51197486 [wpilib] Add timestamp getters with configurable time base (#7378) 2024-11-16 07:43:38 -08:00
Gold856
91142ba5fe [build] Remove Windows constexpr mutex define (#7375)
Since we ship a newer runtime, and we also have checks to ensure a valid runtime, we can remove this again.
2024-11-16 07:27:46 -08:00
Thad House
969664ceaa [wpiutil] Faster nanopb submessage encode (#7374)
Due to how submessages are encoded (with a length prefix), nanopb currently does the encoding twice. It encodes once to get the length to write, then writes the length, then reencodes the entire message a 2nd time.

This results in a requirement that each encode always encodes the same. Generally, this is fine, but it'd be nice to not make this a requirement.

The double encode also requires going through the entire set of fields again, which has the possibility to be slow.

Instead of doing this, write to a temporary SmallVector. Then we can just encode the length of that buffer, and do a memcpy into primary stream. Theoretically in most cases, this should be much faster.
2024-11-16 07:26:10 -08:00
Kavin Muralikrishnan
1e545c38a8 [romi] Update Romi for parity with XRP (#7389) 2024-11-16 07:24:58 -08:00
Kavin Muralikrishnan
6eb652e10e [xrp] Copy XRPReference docs from Java to C++ (NFC) (#7388) 2024-11-16 07:24:21 -08:00
Thad House
fff73ee6e1 [ci] Add basic Android build to CI (#7390) 2024-11-16 07:23:32 -08:00
Tim Winters
bade0a8716 [wpiunits] Use div instead of divide for kotlin compatibility (#7387) 2024-11-15 11:49:40 -07:00
Thad House
453335e354 [build] Remove java requirement from cmake (#7395)
It was leftover from the failed protoc stuff
2024-11-15 07:45:20 -07:00
Thad House
c289562a06 Allow compilation on android (#7386) 2024-11-12 16:39:41 -08:00
Kavin Muralikrishnan
07345712dc [wpimath] Document default tolerances of PIDController (#7377) 2024-11-12 18:19:55 -05:00
Joseph Eng
425bf83036 [wpimath] Add 2D to 3D geometry constructors (#7380) 2024-11-12 18:18:37 -05:00
David Vo
6adad7bad7 [wpiutil] Replace StringBuffer usage with StringBuilder (#7376)
This is a local variable that doesn't escape the method, so there's certainly no reason to have synchronization here.
2024-11-10 07:43:43 -08:00
Kavin Muralikrishnan
280d2c7e32 [examples] Update C++ XRP Code to use SI Units (#7366) 2024-11-08 20:24:13 -08:00
Thad House
edc3963955 [wpinet] Fix resolver thread on newer versions of macOS (#7372)
Implicit capture of this is deprecated.
2024-11-08 20:23:17 -08:00
Tyler Veness
c58be2580d [ntcore] Suppress warning false positive (#7370)
```
In copy constructor ‘std::function<_Res(_ArgTypes ...)>::function(const std::function<_Res(_ArgTypes ...)>&) [with _Res = void; _ArgTypes = {unsigned int}]’,
    inlined from ‘nt::server::ServerClient4Base::ServerClient4Base(std::string_view, std::string_view, bool, nt::server::SetPeriodicFunc, nt::server::ServerStorage&, int, wpi::Logger&)’ at /home/tav/frc/wpilib/allwpilib/ntcore/src/main/native/cpp/server/ServerClient4Base.h:24:77,
    inlined from ‘nt::server::ServerClientLocal::ServerClientLocal(nt::server::ServerStorage&, int, wpi::Logger&)’ at /home/tav/frc/wpilib/allwpilib/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp:18:75:
/usr/include/c++/14.2.1/bits/std_function.h:391:17: error: ‘<anonymous>’ may be used uninitialized [-Werror=maybe-uninitialized]
  391 |             __x._M_manager(_M_functor, __x._M_functor, __clone_functor);
      |             ~~~~^~~~~~~~~~
/usr/include/c++/14.2.1/bits/std_function.h: In constructor ‘nt::server::ServerClientLocal::ServerClientLocal(nt::server::ServerStorage&, int, wpi::Logger&)’:
/usr/include/c++/14.2.1/bits/std_function.h:267:7: note: by argument 2 of type ‘const std::_Any_data&’ to ‘static bool std::_Function_handler<_Res(_ArgTypes ...), _Functor>::_M_manager(std::_Any_data&, const std::_Any_data&, std::_Manager_operation) [with _Res = void; _Functor = nt::server::ServerClientLocal::ServerClientLocal(nt::server::ServerStorage&, int, wpi::Logger&)::<lambda(uint32_t)>; _ArgTypes = {unsigned int}]’ declared here
  267 |       _M_manager(_Any_data& __dest, const _Any_data& __source,
      |       ^~~~~~~~~~
/home/tav/frc/wpilib/allwpilib/ntcore/src/main/native/cpp/server/ServerClientLocal.cpp:18:75: note: ‘<anonymous>’ declared here
   18 |     : ServerClient4Base{"", "", true, [](uint32_t) {}, storage, id, logger} {
      |                                                                           ^
```
2024-11-08 20:22:47 -08:00
Peter Johnson
f40bd3593d [wpilib,wpimath] Don't use mutable units for return values (#7369)
It only saves a single allocation and can cause confusing behavior on the
caller (user) side.
2024-11-08 18:29:51 -08:00
Thad House
3cc541f261 Remove generated google protobuf support (#7371)
It's not used anymore, and cleans up the build.
2024-11-08 18:29:30 -08:00
Tyler Veness
811b130968 [docs] Link to Bazel build docs from main readme (#7367)
I had a really hard to finding them because the main readme didn't call
it out.
2024-11-08 14:05:50 -08:00
Thad House
d39dfd64ea [build] Fix cmake build with WITH_PROTOBUF off (#7368)
Protobuf.cpp only uses nanopb, which is fine to have even with WITH_PROTOBUF off.
2024-11-08 14:05:29 -08:00
Tyler Veness
661bae568f [wpimath] Add time-varying RKDP (#7362)
This makes the ground truth for the Taylor series AQ discretization more
accurate.
2024-11-07 23:46:52 -08:00
Peter Johnson
01f85abcfe [ntcore] Use Endian.h in WireEncoder3 2024-11-08 00:46:27 -07:00
Peter Johnson
396f8203ac [ntcore] HandleMap: Use concepts for T 2024-11-08 00:46:27 -07:00
Peter Johnson
4a43ddbacf [ntcore] Split LocalStorage implementation into separate files 2024-11-08 00:46:27 -07:00
Peter Johnson
0921054a28 [ntcore] Split ServerImpl implementation into separate files 2024-11-08 00:46:27 -07:00
Peter Johnson
f738fc92f0 [ntcore] Move ServerImpl to nt::server namespace 2024-11-08 00:46:27 -07:00
Peter Johnson
a0f38f83f9 [ntcore] NetworkOutgoingQueue: Move function defs inside class 2024-11-08 00:46:27 -07:00
Peter Johnson
876be30724 [ntcore] Value: Inline constructors 2024-11-08 00:46:27 -07:00
Peter Johnson
de318fab91 [ntcore] LocalStorage: Move template functions inside class definition 2024-11-08 00:46:27 -07:00
Thad House
8b8b634f65 [wpiutil] Change C++ protobuf to nanopb (#7309)
The Google C++ protobuf implementation has issues with dynamic linkage across DLL boundaries because it uses global variables.  It also has a compile-time dependency because the protoc version must exactly match the libprotobuf version.  Using nanopb with a customized generator fixes both of these issues.

Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
2024-11-07 22:42:50 -08:00
Thad House
fd2e0c0427 [ntcoreffi] Switch ntcoreffi DLM to WPI_String (#7359)
We forgot to do this originally.
2024-11-07 15:19:37 -07:00
Tyler Veness
a66fa339dc [wpimath] Make controllers and some trajectory classes constexpr (#7343) 2024-11-07 14:02:11 -07:00
Kavin Muralikrishnan
44a45d44e2 [xrp] Update XRP C++ Method/Class Descriptions for Java Parity (#7351)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2024-11-06 16:12:16 -07:00
Ryan Blue
af652817d9 [commands] Revert "WrappedCommand: Call wrapped command initSendable (#6471)" (#7353)
This reverts commit 7bc0380694.

Calling initSendable on the wrapped command is fundamentally flawed as the wrapper is the command being sent.
2024-11-06 16:10:37 -07:00
Ryan Blue
5a16b0e108 [wpilib] Refactor Alert (#7279)
This refactors Alert in both c++ and java to fix the issues with the current c++ implementation and improve performance.

Currently, constructing an Alert adds it to a list of Alerts with the same group and type. Activating an alert sets a flag on the alert. When the SendableAlerts is polled (GetStrings), the entire list is iterated over, filtered, and the filtered list is sorted by timestamp. This leads to a worst case O(m + nlog(n)) time complexity for GetStrings, where m and n are the count of total constructed alerts active alerts respectively. It also allocates intermediate data structures to hold the active alert strings for sorting.

This changes the implementation to improve the performance of GetStrings, by shifting the sorting overhead to Alert.Set
Constructing the Alert only initializes the alert's initial state, and initializes the SendableAlerts for the group if it is not already initialized.
Activating or deactivating an alert sets an internal flag for state tracking, and inserts or removes a structure containing the timestamp and text into a self-sorting data structure (std::set, TreeSet) containing other active alerts with the same group and type. (worst case O(log(n))
Now, SendableAlerts.GetStrings only has to iterate over the structure and copy the strings to the returned array. (amortized O(n))

This also fixes the c++ implementation by removing the need for SendableAlerts to directly access the Alert.

This also adds a helper method to SendableRegistry to force initialization of the instance to prevent static initialization ordering issues.
2024-11-06 16:09:06 -07:00
sciencewhiz
71c050389a [wpiunits] Restore and deprecate measure negate (#7345)
Delegate to unaryMinus.

This ensures there's a deprecation message to help users with migration, vs just a compile error.
2024-11-06 16:07:31 -07:00
Ryan Blue
83fa422338 [wpiutil] DynamicStruct: Fix decoding of signed integers (#7350)
Add tests for both C++ and Java.
2024-11-05 17:45:49 -07:00
Tyler Veness
3113627be6 [wpimath] Fix PIDController error tolerance getters (#7341) 2024-11-05 09:52:22 -07:00
Thad House
f2d2500d1d [wpiutil] Check MSVC Runtime (#7301) 2024-11-05 09:51:48 -07:00
Tyler Veness
63e623d70b [wpimath] Fix case and order of HolonomicDriveController PID getters (#7342) 2024-11-05 09:50:17 -07:00
Tyler Veness
9e8d37c03b [wpimath] Remove unhelpful test fixtures (#7344)
These test fixtures were adding complexity while only saving one line of
object initialization per test. Our other tests like this just make the
object at the top of each test.
2024-11-05 09:49:38 -07:00
truher
ad09d73dd6 [ntcore] Replace "ValueListenerPoller" with "NetworkTableListenerPoller" in docs (#7328) 2024-11-05 09:49:03 -07:00
Ryan Blue
3fd33b1f72 [wpiutil] DynamicStruct: Clear nested fields when updating/adding a schema (#7334) 2024-11-05 09:48:24 -07:00
Jade
043c155087 Fix a few clangd warnings (#7335) 2024-11-05 09:47:54 -07:00
Ryan Blue
7a6c7af412 [wpiutil] Fix dynamic struct decoding for nested structs (#7346)
After a struct-type field descriptor had offsets calculated more than once, IsBitField would return true, causing the second call to CalculateOffsets to calculate incorrect offsets.
2024-11-05 06:43:04 -07:00
Ryan Blue
8588b5e520 [glass] Revert "Storage: Store Value by value" (#7333)
This reverts commit 309b370223.

Storage::GetChildArray never initializes the child array when the entry is new, so it returns invalid references.
2024-11-04 23:34:18 -07:00
Jade
debb52156c [wpilib] Clamp sim battery voltage to 0 (#7325) 2024-11-03 10:37:44 -08:00
Kavin Muralikrishnan
23e71e10e4 [xrp] Add getter for XRP LED (#7327) 2024-11-03 10:32:03 -08:00
Sam Carlberg
44c0bbc4a9 [epilogue] Generate unique names for variables used in instanceof chains (#7323)
Fixes an issue where the variable names would clash with the field names of the associated VarHandles.
2024-11-02 19:11:22 -07:00
Tyler Veness
a48f3c35f4 Remove argv usage from Python scripts (#7311)
argparse will automatically read sys.argv, so we don't need to pass it
in manually. Furthermore, none of our scripts customize argv.
2024-11-02 19:09:32 -07:00
Tyler Veness
7c91b81906 [ci] Upgrade to wpiformat 2024.45 (#7326) 2024-11-02 17:56:55 -07:00
Jade
eb8583596c [ci] Remove parts of Bazel CI (#7324)
We were building huge amounts with bazel we were already building
otherwise. We've been getting heavily backlogged in CI because of the amount
of CI jobs we are running versus our maximum runners quota (particularly on Mac), so this really isn't worth it right now.
2024-11-02 07:05:24 -07:00
Tyler Veness
dfd1084526 [wpimath] Replace pi with symbol in docs (#7322) 2024-11-01 17:16:18 -07:00
Peter Johnson
2cfe114c78 [wpiutil] DynamicStruct: Store StructDescriptor by value 2024-10-31 22:04:13 -07:00
Peter Johnson
caae5357b7 [wpilibc] Mechanism2d: Store roots by value 2024-10-31 22:04:13 -07:00
Peter Johnson
22e91bfacd [wpilibc] ShuffleboardInstance: Store ShuffleboardTab by value 2024-10-31 22:04:13 -07:00
Peter Johnson
67e1b5fe95 [sim] halsim_ws_core: Store SimDeviceValueData by value 2024-10-31 22:04:13 -07:00
Peter Johnson
27e07d6787 [ntcore] ClientImpl3: Store Entry by value 2024-10-31 22:04:13 -07:00
Peter Johnson
e49d452e46 [glass] Context: Store storageRoots by value 2024-10-31 22:04:13 -07:00
Peter Johnson
5c0edc2410 [glass] Field2D: Store field objects by value 2024-10-31 22:04:13 -07:00
Peter Johnson
309b370223 [glass] Storage: Store Value by value
This is possible because std::map has stable value pointers.
2024-10-31 22:04:13 -07:00
Peter Johnson
f620141e0d [wpiutil] Replace LLVM StringMap impl with std::map
As string_view operations on std::map<std::string> won't be integrated
until C++26, placeholder implementations are used which are less efficient
in a couple of situations (e.g. insert with hint).
2024-10-31 22:04:13 -07:00
Ryan Blue
5f3cf517d3 [commands] C++: Allow CommandPtrs to be owned by the scheduler (#7310)
Previously users would have to keep track of dynamically created CommandPtrs. This adds an ownership-taking version of schedule which places the command in a temporary store in the scheduler. The command will be freed when the command's lifecycle ends.
2024-10-31 22:03:12 -07:00
Tyler Veness
328a781040 [wpimath] Port Rotation2d Java tests to C++ (#7318) 2024-10-31 20:40:14 -07:00
Thad House
ebf83e4340 [ntcoreffi] Add ntcoreffi headers zip (#7229) 2024-10-31 20:39:56 -07:00
Tyler Veness
9f6f267f5c [wpimath] DARE: Use wpi::expected instead of exceptions (#7312) 2024-10-31 20:37:57 -07:00
Tyler Veness
21980c7447 [sysid] Clamp feedback measurement delay to zero or higher (#7319)
LQR latency compensation applies exponential decay to the feedback
gains, so a negative latency causes them to exponentially grow.
2024-10-31 20:37:15 -07:00
David Vo
75fc4d18ef [bazel] Fix test attempting to upload to readonly cache (#7302) 2024-10-31 20:36:58 -07:00
Ryan Blue
8f81b7723d [ci] Disable caching for setup-go (#7320)
setup-go is warning because it can't find go.sum, which we don't have.
2024-10-31 20:36:35 -07:00
Sam Carlberg
fe45265a3a [epilogue] Log elements based on the most specific available logger (#7317)
Instead of only logging based on the declared type, loggers will be smarter and do instanceof checks to determine what logger should be used.

Note that diamond inheritance may cause unexpected behavior for non-logged classes that implement multiple logged interfaces.
2024-10-31 20:34:41 -07:00
Sam Carlberg
0f313c672f [epilogue] Autogenerate nicer data names by default, not just raw element names (#7167)
eg "getFoo()" will now be logged as "Foo", or "m_leftMotor" as "Left Motor"

It is now a compilation error to reuse the same logged name for multiple elements (since whatever is declared last would overwrite anything logged before it)

Do not log record fields (just use the accessors). This also fixes an issue where records could never be logged due to identical member and accessor names

Also skips toString, hashCode, and clone methods when generating loggers
2024-10-31 20:34:00 -07:00
Thad House
aaf139320e [upstream_utils] Fix protobuf GNUC_MINOR macro (#7316) 2024-10-30 22:42:24 -07:00
Ryan Blue
89c5d98fe9 [build] Use pathlib in wpiunits generation script (#7306)
Makes wpiunits more consistent with the other generation scripts.

Also sort imports, remove args from main.
2024-10-29 23:05:48 -07:00
Tyler Veness
defcc02806 [wpimath] Clean up LTV controller includes (#7313) 2024-10-29 23:03:17 -07:00
Ryan Blue
e6e928d670 [ci] Increase keychain timeout to 6 hours (#7314) 2024-10-29 23:02:47 -07:00
Ryan Blue
f03e0cdf6a [wpilib] Add explanation for HID GetBumper/Touchpad deprecations (#7304) 2024-10-28 19:29:42 -07:00
Ryan Blue
412c042c6c Use LF in generated files (#7305) 2024-10-28 19:28:58 -07:00
Ryan Blue
f44c3eda43 [ci] Update actions to python 3.12 (#7308) 2024-10-28 18:09:35 -07:00
Ryan Blue
018dcaea4f [ci] Check return code of subprocesses in pregen_all (#7307)
Previously errors were ignored.

Also makes the script more cross-platform by using the current python executable to run the subprocesses.
2024-10-28 18:07:30 -07:00
Jade
85ffb7814b [build] Update Gradle to 8.10.2 (#7164) 2024-10-28 00:44:30 -07:00
Brendan Raykoff
6207992709 [wpilibj] RobotController: Add Java unit support (#7278) 2024-10-27 23:41:15 -07:00
Tyler Veness
42a433b6fa [sysid] Remove unused includes and inline short functions (#7296) 2024-10-27 23:40:26 -07:00
sciencewhiz
2c857cd82a [ntcore] Use NT3 client identity in front of unique id (#7293)
This way all NT3 clients are not identified as just NT3.
2024-10-26 18:56:04 -07:00
Gold856
1c220ebc60 [build] CMake: add Doxygen doc generation (#7286) 2024-10-25 10:45:53 -07:00
Jade
1cfed736ce [build] CMake: Make Protobuf dependency actually optional (#7291) 2024-10-25 08:52:38 -07:00
Ryan Blue
46b5631ba7 [docs] Fix wpiutil thirdparty include roots in docs (#7288) 2024-10-25 06:52:14 -07:00
Jade
d2b19d8928 [docs] Add WITH_PROTOBUF to README-CMAKE (#7289) 2024-10-25 06:51:35 -07:00
Joseph Eng
9a5f73d787 [cscore] Add back VideoProperty handle member initializer (#7283) 2024-10-23 21:46:20 -07:00
Tyler Veness
db552317e7 [dlt, rtns] Fix libssh deprecation warnings (#7284)
```
/home/tav/frc/wpilib/allwpilib/roborioteamnumbersetter/src/main/native/cpp/SshSession.cpp: In member function ‘void rtns::SshSession::Execute(std::string_view)’:
/home/tav/frc/wpilib/allwpilib/roborioteamnumbersetter/src/main/native/cpp/SshSession.cpp:89:44: warning: ‘int ssh_channel_get_exit_status(ssh_channel)’ is deprecated [-Wdeprecated-declarations]
   89 |   INFO("{} {}", ssh_channel_get_exit_status(channel), cmd);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
```
```
/home/tav/frc/wpilib/allwpilib/roborioteamnumbersetter/src/main/native/cpp/SshSession.cpp:139:44: warning: ‘int ssh_channel_get_exit_status(ssh_channel)’ is deprecated [-Wdeprecated-declarations]
  139 |   INFO("{} {}", ssh_channel_get_exit_status(channel), cmd);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
```
```
/home/tav/frc/wpilib/allwpilib/roborioteamnumbersetter/src/main/native/cpp/SshSession.cpp:143:46: warning: ‘int ssh_channel_get_exit_status(ssh_channel)’ is deprecated [-Wdeprecated-declarations]
  143 |     *exitStatus = ssh_channel_get_exit_status(channel);
      |                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
```
```
/home/tav/frc/wpilib/allwpilib/datalogtool/src/main/native/cpp/Sftp.cpp:79:33: warning: ‘int sftp_async_read_begin(sftp_file, uint32_t)’ is deprecated [-Wdeprecated-declarations]
   79 |   int rv = sftp_async_read_begin(m_handle, len);
      |            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
```
```
/home/tav/frc/wpilib/allwpilib/datalogtool/src/main/native/cpp/Sftp.cpp: In member function ‘size_t sftp::File::AsyncRead(void*, uint32_t, AsyncId)’:
/home/tav/frc/wpilib/allwpilib/datalogtool/src/main/native/cpp/Sftp.cpp:87:28: warning: ‘int sftp_async_read(sftp_file, void*, uint32_t, uint32_t)’ is deprecated [-Wdeprecated-declarations]
   87 |   auto rv = sftp_async_read(m_handle, data, len, id);
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
```
2024-10-23 20:34:54 -06:00
Ryan Blue
03cb3c70b4 [epilogue] Set source and target java versions for epilogue-processor tests (#7282) 2024-10-23 17:17:19 -06:00
Nicholas Armstrong
ac907f755a [wpiunits] Add resistance units (#7168) 2024-10-23 08:20:17 -06:00
Nicholas Armstrong
a3b12b3bd9 [wpimath] ChassisSpeeds fromRelative and discretize methods made instance methods (#7115) 2024-10-22 17:23:17 -06:00
Tyler Veness
cbc9264468 [ci] Upgrade to wpiformat 2024.44 (#7256)
This makes the C identifier list scanner correctly handle single quotes
in numeric literals.
2024-10-22 17:19:12 -06:00
Jade
28ac2e3554 Update version in DevelopmentBuilds (#7077) 2024-10-22 09:18:37 -06:00
Jade
58c0cd46b1 [build] Remove cmake toolchains (#7254)
They aren't used and should instead be taken from https://github.com/wpilibsuite/opensdk
2024-10-22 08:36:42 -06:00
Peter Johnson
115a02211c [cscore] HttpCamera: Auto-detect mode from stream if not set (#7248) 2024-10-22 08:35:05 -06:00
Peter Johnson
f553dee6cb [cscore] HttpCamera: Send width/height/fps stream settings (#7247) 2024-10-22 08:33:23 -06:00
Peter Johnson
e8d2d1c39a [wpinet] HttpRequest: Keep params ordered (#7246) 2024-10-22 08:32:41 -06:00
Peter Johnson
7cc7fa1845 [cscore] Fix wakeup on sink destruction (#7245) 2024-10-22 08:02:20 -06:00
Peter Johnson
cbdb4e81f6 [cscore] GetNextFrame: Wake up even if no frames received (#7244) 2024-10-22 08:01:41 -06:00
Tyler Veness
05c7fd929b [wpimath] Make various classes constexpr (#7237) 2024-10-22 07:58:06 -06:00
Tyler Veness
0c824bd447 [wpimath] Take finite difference stencil points by const ref (#7238) 2024-10-21 22:33:56 -07:00
Tyler Veness
ed18b41198 [upstream_utils] Add Eigen geometry module (#7242)
WPICal needs it.
2024-10-21 22:29:35 -07:00
Joseph Eng
6745fc7c2f [wpimath] Fix C++ pose estimator poseEstimate initialization (#7249) 2024-10-21 22:29:04 -07:00
Gold856
40af8db28a [wpilibc] DataLogManager: Rename console log entry to "console" (#7240)
This matches Java.
2024-10-21 06:34:29 -06:00
Tyler Veness
5ac132f6a2 [wpiutil] Make circular buffer classes constexpr (#7232)
The circular buffer class that uses std::vector internally can be used
in a constant expression as long as it doesn't survive to runtime.
2024-10-20 15:33:40 -07:00
Tyler Veness
dd72a78aa4 [upstream_utils] Upgrade to libuv 1.49.2 (#7226) 2024-10-19 09:55:45 -07:00
PJ Reiniger
36e0c9d6db [build] MVP for building with bazel (#6994) 2024-10-19 09:54:49 -07:00
Tyler Veness
95b9bd880b [wpimath] Make geometry classes constexpr (#7222) 2024-10-18 16:08:41 -07:00
Joseph Eng
2054d0f57e [wpimath] Fix pose estimator reset methods (#7225) 2024-10-18 16:06:32 -07:00
Thad House
ee22482f4a [build] ntcoreffi: Don't link to chipobject (#7228) 2024-10-18 16:06:10 -07:00
Étienne Beaulac
796dbd3b86 [wpilib] Add Timer.isRunning() method (#7220) 2024-10-17 17:03:40 -07:00
Gold856
0424e5ba36 [build] Remove unnecessary symbol exclusions (#7221)
The symbol exporter in native-utils was updated and stopped exporting the excluded symbols.
2024-10-17 16:19:19 -07:00
Ryan Heuer
f7dddb8014 [glass] Add Alerts widget (#7219) 2024-10-16 13:45:56 -06:00
Ryan Blue
68715aa484 [wpilibc] SPI & I2C: Use handle wrapper to close port (#7217) 2024-10-16 11:08:44 -06:00
Tyler Veness
fad06ae1e7 Merge .inc files into headers (#7215) 2024-10-15 23:42:57 -07:00
Ryan Heuer
40caabea23 [glass] Align Field2d border and image padding (#7214) 2024-10-15 22:02:08 -07:00
Ryan Blue
59dc9ad8f4 [examples] Rename SysId example to SysIdRoutine (#7213)
CMake target output conflicts with sysid (the application) on windows
2024-10-15 22:01:05 -07:00
Ryan Blue
2b1c5aa4fc [wpilibc] Check for invalid handle in destructors (#7212)
Moved-from objects have invalid handles.
2024-10-15 19:56:13 -07:00
Peter Johnson
0bada2e102 [ntcore] Merge .inc files into headers (#7210) 2024-10-14 22:42:58 -07:00
Tyler Veness
ee281ea448 [wpimath] Merge .inc files into headers (#7209)
Splitting the files didn't help readability or save compilation time and
it confused contributors. Merging them is also in line with how C++
modules will be written.
2024-10-14 16:08:10 -07:00
Peter Johnson
bedfc09268 [ntcore] Add missing multi-subscribe C API functions (#7203)
Also export recently added C API functions.
2024-10-14 09:55:36 -06:00
Peter Johnson
4023cdc80a [ntcore] Fix EALREADY errors by tracking read state (#7202) 2024-10-13 00:14:16 -07:00
Gold856
12885015ed [cscore,hal] Remove VS 2019 16.4.0 workaround (#7201) 2024-10-11 22:18:12 -07:00
Gold856
f23bece791 [sysid] Remove unused dependency on libglassnt (#7200)
Also remove stale libuv references.
2024-10-11 22:05:32 -07:00
Gold856
7ebd45ef4d [sysid] Fix crash when all data is filtered out during analysis (#7199) 2024-10-11 21:51:56 -07:00
Peter Johnson
25c2e26ef8 [ntcore] Fix UID collisions between subscribers and multi-sub (#7198)
The changes in #7189 caused an ambiguity between multi-subscribers and
normal subscribers, because the handle type no longer is sent to the network.

Multi-subscribers now go to the network with negative UIDs, normal
subscribers are positive UIDs.  UID 0 is never used.
2024-10-11 21:39:55 -07:00
PJ Reiniger
f1e032f5e6 [examples] Fix cross project import (#7197) 2024-10-11 21:17:57 -07:00
Gold856
22a04bf470 [commands] Deprecate control commands and subsystems (#7143) 2024-10-11 19:48:47 -07:00
Peter Johnson
77ee9bdd30 [ntcore] Client: only connect to IPv4 addresses (#7195)
The server only binds to IPv6, so connection attempts to that are useless.
2024-10-11 17:05:09 -07:00
Peter Johnson
c6d801d2d6 [wpinet] ParallelTcpConnector: Add option to resolve only IPv4 addresses (#7194) 2024-10-11 16:42:59 -07:00
Peter Johnson
768fa5f973 [wpinet] libuv: Change GetAddrInfo hints parameter to optional (#7196)
This is clearer than passing a pointer.
2024-10-11 16:42:42 -07:00
Peter Johnson
a621cebbd6 [ntcore] Server round robin message processing (#7191)
Each client has an incoming queue of ClientMessage.

In the read callback:
- Parse and process only ping messages and a limited number of messages;
  anything else will get put into the queue and not processed
- If we queued some messages, we tell the network we stopped reading; this will
  result in back-pressure if we are reading too slowly.  We also start an idle
  handle to process the queued messages.

In the idle handle callback:
- For each client, process just a few pending messages.  This is performed in
  round-robin fashion across all clients with pending messages
- When a client's queue becomes empty, we re-enable the network read
- When all client queues are empty, we stop the idle handle (so we don't spin)

For local client processing, we use round-robin processing for most cases (including FlushLocal),
but still do batch processing of all local changes for explicit network Flush() calls.
2024-10-11 16:26:56 -07:00
Peter Johnson
8870d98f80 [upstream_utils] Revert upgrade to libuv 1.49.0
This reverts commit eab93f4fdc (#7129).

There's broken behavior in getaddrinfo.
2024-10-11 16:13:15 -07:00
Peter Johnson
2d6f02d15b [glass] Check for struct descriptor size 0 (#7192)
This avoids a potential divide by 0.
2024-10-11 16:09:32 -07:00
Peter Johnson
96f0b2482c [ntcore] Unify NetworkInterface and MessageHandler (#7190) 2024-10-11 14:38:02 -07:00
Peter Johnson
8ca99c7cb7 [ntcore] Change internal interfaces and messages to use UIDs (#7189)
Also make Handle functions constexpr.
2024-10-11 10:57:36 -07:00
Peter Johnson
59bc53b9b8 [ntcore] Add StopRead/StartRead to WireConnection (#7188) 2024-10-11 10:51:12 -07:00
Peter Johnson
94c62ed3ec [wpiutil] Add FastQueue (#7075)
This is a heavily modified version of https://github.com/cameron314/readerwriterqueue that removes
all atomics and barriers.
2024-10-11 10:49:29 -07:00
Gold856
28cb7cf757 [examples] Add ProfiledPID command to RapidReactCommandBot (#7030) 2024-10-11 08:43:24 -07:00
Peter Johnson
dcf5f55a30 [upstream_utils] Remove ConcurrentQueue (#7183)
It appears to be broken under stress testing (dropped/duplicate values).

This reverts commit 97c6c86f3b (#7066).
2024-10-10 23:41:41 -07:00
Peter Johnson
f65f9ed693 [wpiutil] Add rotated_span (#7111) 2024-10-10 23:36:26 -07:00
Jade
8f57e4c566 [documentation] Remove more outdated commands examples (#7054)
There are still some examples we'd like to remove here (eg Hatchbot
traditional) but this is a good start with not too many changes required
in frc-docs.
2024-10-10 23:09:11 -07:00
Gold856
37e7bfe4f9 [build] Add docs for generated files (#6878) 2024-10-10 22:20:45 -07:00
Jade
679892e8e1 [commands, documentation] Remove controller replaceme commands (#7053) 2024-10-10 22:12:02 -07:00
Nicholas Armstrong
4adfa8bf64 [wpimath] Fully discretized ElevatorFF and ArmFF (#7024)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-10-10 22:10:45 -07:00
Nicholas Armstrong
5d9a553104 [wpilib] DCMotorSim cleanup/enhancement (#7021)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-10-10 22:09:22 -07:00
Nicholas Armstrong
5acb4109ff [examples] Fix flaky ArmSimulationTest (#7170)
Co-authored-by: Starlight220 <53231611+Starlight220@users.noreply.github.com>
2024-10-10 22:07:52 -07:00
Ryan Blue
fc83d4868c [hal] Fix CAN ID validation and reporting for CTRE and REV devices (#7178)
REV: 1-63, 63 devices
CTRE: 0-62, 63 devices
2024-10-10 22:06:53 -07:00
Ryan Blue
a65f6b94ee [hal] Radio LED: Properly close files and improve error messages (#7181) 2024-10-10 22:06:19 -07:00
Bryce Roethel
d97a749d84 [wpimath] SwerveDrivePoseEstimator: Fix stationary module emitting error when calculating angle in ToSwerveModuleStates (#7175) 2024-10-10 22:05:49 -07:00
Sam Carlberg
2085ab3d47 [wpilib] Allow LED pattern gradients to be discontinuous (#7174) 2024-10-10 22:05:33 -07:00
Peter Johnson
0cfff31439 [ntcore] Fix use-after-free on connection termination (#7177)
The stream can close (e.g. due to an error) while in the middle of writing. The close callback would immediately destroy the connection object, resulting in the writing code having a use-after-free. Fix this by deferring the deletion to the loop main using a single-shot timer.
2024-10-10 22:03:55 -07:00
Thad House
a71cee1112 [build] Update to 2025 beta NI Libraries (#7182) 2024-10-10 22:03:29 -07:00
Nicholas Armstrong
968bdf0d06 [commands] Add deadband trigger methods to CommandGenericHID (#7085)
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
2024-10-10 22:03:01 -07:00
Gold856
f150b36108 [wpiutil] Fix FileLogger behavior and performance (#7150)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2024-10-08 12:55:16 -06:00
Ryan Blue
f856c05a08 [ci] Add no-cache build workflow to detect potential false-positive cache hits (#7027)
Duplicate of gradle.yml without docs, caching, and release configurations.
It's set up to run off-peak weekly.
2024-10-04 18:24:23 -07:00
Ryan Blue
09a93b86dc [wpilibc] Add RadioLEDState docs to C++ (NFC) (#7158)
Add RadioLEDState docs for consistency with Java.
2024-10-04 18:22:31 -07:00
Tyler Veness
8102516300 [ci] Upgrade to wpiformat 2024.42 (#7165) 2024-10-04 13:55:10 -06:00
Ryan Blue
b541174255 [wpilib] Alert: fix incorrect set docs (NFC) (#7163)
Console printing was removed when Alerts were added to wpilib.
2024-10-03 23:20:53 -06:00
Sam Carlberg
9a7710ebd3 [wpiunits] Make Velocity.mult(Time) return Measure<D> (#7162)
Update code generator to allow arbitrary implementations of multiplication methods.
2024-10-03 23:19:36 -06:00
Ryan Blue
bc6553cd2b [ci] Fix cmake CI (#7159) 2024-10-03 18:22:39 -06:00
Jade
dced751a72 [ci] Merge Windows into CMake matrix (#7153) 2024-10-03 14:26:49 -06:00
Ryan Blue
83615c6024 [wpiutil] DataLogBackgroundWriter: Normalize empty path name (#7151)
An empty path isn't valid on it's own, so fs::space always returns an error. This results in UINT_MAX bytes being used instead of the actual free space, which means a default constructed DataLogBackgroundWriter won't stop for low space.

Using "." instead makes the directory path the current working directory, which is the desired behavior
2024-10-03 13:32:09 -06:00
Jade
a8a5d1609b [build] Name CMake presets more consistently (#7154) 2024-10-03 13:29:27 -06:00
Gold856
f82e1c9d48 [build] CMake: fix Windows build when WITH_PROTOBUF is false (#7147) 2024-10-02 10:20:43 -06:00
Jade
466a4a52fa [wpilibc] Fix missing symbols on Windows (#7140)
Windows doesn't support direct static variable access across library boundaries in a mixed static/shared environment, so change to accessor functions.
2024-10-01 08:46:06 -06:00
Nicholas Armstrong
fe80d72fba [wpimath] Add cosineScale method to SwerveModuleState and instance optimize (#7114) 2024-09-30 13:23:30 -06:00
Peter Johnson
fde264b041 [thirdparty] Add Roboto fonts (#7138) 2024-09-28 10:58:47 -07:00
Peter Johnson
95da92db04 [wpigui] Add "deep dark" style (#7133) 2024-09-28 10:58:29 -07:00
Peter Johnson
d389317c3a [thirdparty] Upgrade imgui fonts to latest versions (#7137) 2024-09-28 10:35:16 -07:00
Peter Johnson
50db16c0c0 [wpigui] Add font selector (#7134) 2024-09-28 10:34:59 -07:00
Benjamin Hall
6b1e656659 [wpimath] Add DCMotor.getCurrent() overload accepting torque (#7132) 2024-09-28 09:33:15 -07:00
Tyler Veness
eab93f4fdc [upstream_utils] Upgrade to libuv 1.49.0 (#7129) 2024-09-27 12:00:54 -07:00
Gold856
f0a1955fd7 Move generated files to more consistent locations (#6906)
Java templates always go under src/generate/main/java. JSON files go to src/generate.
2024-09-24 22:13:49 -07:00
Ryan Blue
b8ff3fcee2 [upstream_utils] StringMap: fix structured bindings with move-only types (#7127) 2024-09-24 22:11:41 -07:00
Gold856
69af7785f6 [gitignore] Add .clangd file to gitignore (#7122) 2024-09-24 09:20:21 -07:00
Nicholas Armstrong
6281ec0810 [wpimath] PIDController: Update field and method names for error and errorDerivative (#7088) 2024-09-23 11:57:20 -06:00
Gold856
64e5e6db59 [ci] Use one script to pregenerate everything (#7121)
A pregen_all Python script was added that calls all the other pregen scripts. This prevents the generated file checks and pregen command from falling out of sync. This is meant to only run in CI, since the script is not portable across platforms.
2024-09-23 11:54:59 -06:00
oh-yes-0-fps
180349bd06 [commands] Improve isScheduled to be more performant when checking a single command (#7096) 2024-09-23 11:54:37 -06:00
Gold856
22f086aba8 Fix app icons on Windows (#7116)
The SysId icon has a bunch of weird artifacting and it's not transparent on Windows. Some of the other icons have issues as well and all of them are inconsistent. GIMP was used to regenerate all the icons from the PNGs, using PNG compression on all the layers.
2024-09-22 23:54:23 -07:00
Gold856
84075997c6 [cscore] Fix Java VideoSink class doc (NFC) (#7120) 2024-09-22 22:12:36 -07:00
Gold856
ba1b97cd78 [wpilib] ADIS IMUs: Add back null checks (#7117)
* Revert "Move creation of objects to ctor"

This reverts commit b1d8001652.

* [wpilib] ADIS IMUs: Add back null checks
2024-09-22 18:05:09 -07:00
Tyler Veness
f93bacc5c5 [upstream_utils] Remove unused clone_repo() function (#7091) 2024-09-20 20:12:48 -07:00
Tyler Veness
38e246c34f [ci] Upgrade to wpiformat 2024.41 (#7112) 2024-09-20 18:41:33 -07:00
sciencewhiz
a884863f19 [ci] Fix RobotBuilder tools build (#7107)
Build more dependencies added by GradleRIO 2025 Alpha 2
2024-09-20 17:44:22 -07:00
Tyler Veness
554024767e Fix errors from new cpplint.py (#7105) 2024-09-20 17:43:39 -07:00
Sam Carlberg
f1dde8895e [build] Use project configured groupId in generated output artifact names (#7095)
Instead of hardcoding to use the project name after edu_wpi_first, which broke epilogue publishing

This did not affect local maven publishing, since it does not use those specially named and configured artifacts
2024-09-18 20:44:01 -07:00
sciencewhiz
0df82da7e6 [build] Update vendordeps frcyear to 2025 (#7087) 2024-09-18 19:07:02 -07:00
Jade
cea8684895 [build] Update native utils (#7029) 2024-09-16 18:59:00 -07:00
Ryan Blue
777f07edfd [wpilibc] Solenoid classes: Make methods non-virtual (#7080) 2024-09-16 18:36:04 -07:00
Ryan Blue
b93160d7ba [wpiutil] Fix MSVC warning in parse_integer (#7082)
```
warning C4267: 'initializing': conversion from 'size_t' to 'unsigned int', possible loss of data
```
2024-09-14 14:49:08 -07:00
Ryan Blue
64df5e21c0 [build] cmake: Fix libssh search on windows (#7081)
This uses the package config files provided by libssh rather than the module file.
2024-09-14 14:47:12 -07:00
Peter Johnson
994af25fcf [wpiutil] StringLogEntry::Update(): Take string_view (#7074) 2024-09-12 23:45:57 -07:00
Joseph Eng
1f3ef019ce [wpiutil] Return wpi::expected from MemoryBuffer::GetFile (#7069) 2024-09-12 23:45:35 -07:00
Tyler Veness
d44b651558 [build] Make Protobuf optional in CMake build (#7061) 2024-09-12 23:44:19 -07:00
Jade
b9409a4bcf [xrp] Add GetRotation2d to Gyro (#7034) 2024-09-12 22:16:00 -07:00
Gold856
3bbbf86632 [wpiutil, wpilib] Add FileLogger and log console output (#6977) 2024-09-12 22:13:06 -07:00
Ryan Blue
32252f7d6a [upstream_utils] Import argparse to wpiutil (#7071) 2024-09-12 20:10:43 -07:00
Ryan Blue
97c6c86f3b [upstream_utils] Import ConcurrentQueue to wpiutil (#7066) 2024-09-10 23:12:22 -07:00
Peter Johnson
21cbb68465 [ci] Run expected.py as part of upstream-utils (#7068) 2024-09-10 19:56:15 -07:00
Jade
874d8a8dd4 [wpiutil] Remove ConcurrentQueue (#7063)
Its unused and mutexed which makes it less useful to future usecases
2024-09-10 07:08:25 -07:00
Thad House
dcce108b75 [hal] Correct maximum length of DS console send (#7057) 2024-09-08 22:00:04 -07:00
Ryan Blue
43c2409366 [ci] Add cmake cache repo to nightly cleanup (#7059) 2024-09-08 21:45:45 -07:00
Ryan Blue
5d68f0c11a [ci] Fix CMake caching to Artifactory (#7058) 2024-09-08 20:51:25 -07:00
Ryan Blue
34e4587121 [ci] Move nightly cleanup task to monorepo (#7050) 2024-09-08 17:31:55 -07:00
Peter Johnson
7c85c33666 [ntcore] Avoid duplicate addition of publishers in server (#7052)
We emitted a warning but went on to do unsafe things. This could cause a delayed crash.
2024-09-08 10:36:00 -07:00
Peter Johnson
306e190f78 [ntcore] Fix client unpublish outgoing queue (#7051)
The unpublish message must be sent on the outgoing queue before the handle
indicating which queue to use is erased.
2024-09-08 10:35:41 -07:00
Peter Johnson
7bdecab729 [ntcore] Fix unpublishing on client disconnect (#7042) 2024-09-08 10:35:05 -07:00
Jade
cd9922af49 [wpilib] Add getVoltage to PWMMotorController (#6044) 2024-09-07 22:24:51 -07:00
Wispy
6e8feb154c [wpimath] Add more support for wpiunits in the geometry classes (#6587) 2024-09-07 22:23:19 -07:00
Ryan Blue
7f6f19eef4 [ci] Use artifactory for sccache backend (#7049) 2024-09-07 22:21:56 -07:00
Ryan Blue
161dfefb4d [docs] Add romi and xrp to docs build (#7045) 2024-09-07 22:21:16 -07:00
Ryan Blue
0cab7b5204 [wpilibj] AnalogEncoder: fix documentation (#7043)
configureRolloverCounting was added and removed as part of the absolute encoder overhaul, this reference was left dangling
2024-09-07 20:43:15 -07:00
Ryan Blue
dc68576834 [docs] Exclude eigen/unsupported from docs build (#7046) 2024-09-07 20:42:41 -07:00
Bryce Roethel
115ffa3396 [epilogue] Add Epilogue.update() (#7047)
Currently, users can only invoke Epilogue via Epilogue.bind(TimedRobot). This PR adds a new method Epilogue.update(TimedRobot) so that Epilogue can manually called, in case a user is seeking more deterministic timing of their logs in reference to their control loops.
2024-09-07 19:59:49 -07:00
Joseph Eng
c8dab95ea7 [upstream_utils] Rename expected's detail namespace to detail_expected (#7048)
Previously, both wpi/expected and JSON's cpp_future.h would define enable_if_t and conjunction in wpi::detail, leading to conflicts if both were included in the same cpp source file. By renaming the namespace wpi/expected uses, there is no longer a conflict.
2024-09-07 19:59:20 -07:00
Sam Carlberg
a9b885070e [wpiunits] Java units API rewrite (#6958)
Java generics are too limited to do what we need. This refactors generic code previously in Unit and Measure into unit-specific classes that can have unit-safe math operations (notably, times and divide) that can return values in known units instead of a wildcarded Measure<?>.

Unit-specific measure implementations are automatically generated by ./wpiunits/generate_units.py, which generates generic interfaces and mutable and immutable implementations of those interfaces. These make up the bulk of the diff of this PR (approximately 9300 LOC).

This also adds units for angular and linear velocities, accelerations, and momenta; moment of inertia; and torque.
2024-09-07 10:59:29 -07:00
Ryan Blue
496e7c1bba [hal] Refactor C++ handle closing; check for invalid handle before closing (#7016)
Adds a close function pointer template parameter to hal::Handle.  This allows default destructors in many places.
The status parameter has been removed from close functions; in most places it was not used. Where it was, an error is printed instead.
2024-09-07 10:58:15 -07:00
Jade
80f3813908 [xrp] Cleanup gyro docs (#7033) 2024-09-07 10:53:49 -07:00
Ryan Blue
2aef60d49c [ci] Check for full repository name in actions (#7038)
This allows forks of allwpilib owned by wpilibsuite to exist without patching the workflows.
2024-09-07 10:53:23 -07:00
Ryan Blue
46e64e2dcb [ci] Bump MACOSX_DEPLOYMENT_TARGET to 13.3 (#7035) 2024-09-07 10:52:41 -07:00
Brandon Shen
3ad35a5753 [epilogue] Log internal debug data to the configured logger instead of NT (#7040) 2024-09-07 10:52:21 -07:00
Ryan Blue
b38e06c7cb [upstream_utils] Upgrade apriltag to latest master (take 2) (#7018) 2024-09-04 09:12:51 -05:00
Ryan Blue
86f1bfd710 [wpilibc] Make SPI methods non-virtual (#7019) 2024-09-04 09:12:06 -05:00
Thad House
0b0c7c88ee [build] cmake: Add 4324 to ignored MSVC warnings (#7028)
4324 is issued at /W4 if alignas forces padding. Makes it impossible to use SmallVector from something compiled in /W4. Add it to the warning exclusion list.
2024-09-03 14:31:38 -05:00
Jade
495c371ce7 [glass] NetworkTables provider: Add immediate flag to listener (#7013) 2024-08-31 09:44:52 -07:00
Ryan Blue
9d6bee1d1e [build] cmake: Add meta target for examples and example tests (#7015)
Also prefix example test targets with Example_ to make running tests easier
2024-08-29 14:03:41 -07:00
Ryan Blue
5f7b2aefb1 [ci] Check and free disk space on macos (#7014) 2024-08-29 06:30:17 -07:00
Ryan Blue
dc18f71004 [wpilibc] Refactor AnalogTrigger to use shared_ptr (#7010) 2024-08-28 21:34:28 -07:00
Ryan Blue
c9ad26b723 [hal] Remove incorrect parameter directions on a few functions (NFC) (#7011) 2024-08-28 06:30:39 -07:00
Ryan Blue
9f3da8de1b [hal] Correct warning suppression and note in SimDataValue.h (#7009) 2024-08-27 17:07:46 -07:00
Ryan Blue
9aef00340a [build] cmake: Put protobuf symbol export files in per-config directories (#6997) 2024-08-27 17:06:16 -07:00
Gold856
9c35aa6bbf [build] Remove redundant _M_ prefix from artifact file name (#6983) 2024-08-27 17:05:29 -07:00
David Vo
0352a60f38 Override getMessage in Exceptions instead of toString (#7002)
Fixes https://errorprone.info/bugpattern/OverrideThrowableToString
2024-08-26 17:32:32 -07:00
Gold856
1daff9193c [wpilibc] Add missing deprecated HID sim methods (#7005) 2024-08-26 17:32:09 -07:00
David Vo
dbeab8bdd7 Read text input streams as UTF-8 in Java (#6999)
Fixes https://errorprone.info/bugpattern/DefaultCharset for InputStreamReader instances.
2024-08-24 09:05:00 -07:00
Ryan Blue
1fd1dc31b7 [upstream_utils] Clean up and enable foonathan memory docs (#6990)
Group memory doxygen into one module.

Remove concept alias and add doxygen definitions for foonathan memory.

\concept was added as a doxygen command in 1.9.2 and is meant to be applied to concepts. Inserting them into standard comment paragraphs causes doxygen to interpret the following text as a concept name and add it to the documentation, as well as remove the text from the paragraph.
In the upstream repo, this alias links to markdown documentation, so it's not usable for us anyways.

That, plus adding the doxygen definitions/aliases from upstream cleans up most of the errors/weird output from doxygen for foonathan memory.
2024-08-24 06:54:32 -07:00
Ryan Blue
370e63ede6 [upstream_utils] Use os path separator when matching path (#6993) 2024-08-24 06:52:52 -07:00
Tyler Veness
96bd1e489f [wpilibj] Suppress JDK 21 this-escape warning (#6996) 2024-08-24 06:52:04 -07:00
Ryan Blue
ed86f0b6fe [build] Set CMAKE_BUILD_TYPE correctly (#6998)
It has to be set before project otherwise cmake defines it for you.
2024-08-24 06:51:22 -07:00
Ryan Blue
9eb8400f6c [upstream_utils] Revert “Upgrade apriltag to latest master (#6995)" (#7000)
This reverts commit ba200df8be.
2024-08-24 06:50:32 -07:00
David Vo
88fc46da22 Call reachabilityFence inside finally blocks (#7001) 2024-08-24 06:49:46 -07:00
David Vo
36ff22a439 [cscore, wpilibj] Use pattern matching in equals overrides (#7003)
Fixes https://errorprone.info/bugpattern/EqualsGetClass
2024-08-24 06:48:20 -07:00
Jonah
173ffca14a [wpilib] Add persistent alerts API (#6735) 2024-08-23 07:05:53 -07:00
Ryan Blue
ba200df8be [upstream_utils] Upgrade apriltag to latest master (#6995) 2024-08-23 07:04:29 -07:00
Ryan Blue
cf691f744f [glass] Use type string constant in NTStringChooser (#6992) 2024-08-22 23:36:07 -07:00
sciencewhiz
7a2604b299 [wpiutil] Update WPILib Logo (#6987) 2024-08-22 08:51:06 -07:00
Thad House
b76ccc3ab5 [build] cmake: Include our own copy of protobuf_generate to use with plugin (#6989)
The hacks we needed to do to get the existing commands required cmake 3.28. We didn't want that, so just make a local slimmed down copy of the function just for our use. Even better, its much simpler in what it does, no weird hacks.
2024-08-22 08:50:29 -07:00
Ryan Blue
88ea473c94 [wpilibc] AddressableLED: add move constructor/assignment operator (#6985) 2024-08-22 08:48:19 -07:00
Ryan Blue
c640fdc9a4 [docs] Update doxygen and add back sidebar-only theme (#6986)
Update doxygen gradle plugin, use template Doxyfile.
2024-08-22 08:43:10 -07:00
Jade
147e03ddd8 [build] CMake: Add CMakePresets.json for some common WPILib build settings (#6974) 2024-08-21 07:56:28 -07:00
Jade
a9ce3290b5 Fix Doxygen warnings for C++ code (#6608) 2024-08-21 07:55:03 -07:00
Thad House
a9ac5b8e24 Don't read protobuf static data across shared library lines directly (#6979)
Reading exported data from shared objects on windows is broken. It requires __declspec(dllimport). However, this is problematic, as we use the same static libraries both from a shared and static context. So we can't just blindly apply dllimport.

The linker should have caught this, as data members are exported in a different way. However, due to a bug in native-utils, data member symbols were exposed directly. However, interacting with those data member was completely broken.

The only way we can really solve this is to just not use static data members. We're pretty good about this in WPILib itself. However, protobuf is absolutely terrible at this. There are a ton of inline functions that access global data. For the protobuf library itself, we can solve this easily enough.

However, for the generated protobuf code, this is much more problematic. The member needed to bypass the global data is private. This means using just the stock protobuf code, this problem is not solvable. But, protobuf generated code has insertion points. Those insertion points let us add our own code into the generated code via a protoc plugin. And it just so happens that an insertion point exists to add extra public methodsto the generated protobuf header. There is also an insertion point to let us add to the cpp file.

The methods we need are the getters, for unpacking protobufs. For any protobuf that has a message as a member, we generate a new wpi_x() getter (the existing one is just x(), where x is the field name). We then implement this in the cpp file. A trick we can use is in the cpp file, we can safely call the x() function, as the cpp file is in the same library as the global. Thus we can call that inline method, and not actually need to directly access any internal private state of the protobuf object.

TL;DR, all protobuf classes that have messages as fields now have a wpi_x() accessor that must be used instead of x() if you want the code to work on windows. After wpilibsuite/native-utils#212, the bad code will fail to link, rather then just fail at runtime.
2024-08-21 07:53:20 -07:00
Jade
eef516fcc9 [wpimath] Fix pose estimator ResetRotation() in C++ (#6984) 2024-08-21 07:51:21 -07:00
sciencewhiz
f0c3610465 Fix various typos (#6980)
Found with misspell
2024-08-19 16:26:36 -07:00
sciencewhiz
8e52da330e [dlt] Update DataLogTool doc link (#6981) 2024-08-19 09:24:00 -07:00
sciencewhiz
32c4e56897 [docs] Downgrade Doxygen to 1.10.0 and update theme (#6978)
Fixes mobile
Requires re-excluding memory for search
Set new doxygen options required by doxygen-awesome theme
2024-08-19 08:14:04 -07:00
Jade
a325898311 [build] CMake: set CMAKE_EXPORT_COMPILE_COMMANDS to ON (#6973) 2024-08-17 20:58:14 -07:00
Gold856
b12b83aa89 Fix typos with cspell (#6972) 2024-08-17 07:44:34 -07:00
Gold856
780b1e0391 [build] CMake: disable Java components by default (#6975) 2024-08-16 06:46:14 -07:00
Gold856
dc25c13051 [build] CMake: remove redundant logic (#6971) 2024-08-15 21:36:45 -07:00
Gold856
0c58426f4c [sim] Add SendableChooserSim (#6763)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
2024-08-15 15:00:10 -07:00
sciencewhiz
477907e4cc [docs] Update to Doxygen 1.12.0 (#6970)
Fixes search when building with foonathan/memory
2024-08-15 14:58:53 -07:00
Tyler Veness
4d7c9edab3 [ci] Upgrade to wpiformat 2024.40 (#6969) 2024-08-15 09:09:13 -07:00
sciencewhiz
063409518e [docs] Delete param doc for func that lacks param (NFC) (#6964) 2024-08-15 07:46:01 -07:00
Jade
14af894711 [gitignore] Add testing files from ctest (#6966) 2024-08-15 07:45:39 -07:00
Tyler Veness
050eafd802 [upstream_utils] Shorten file copy command (#6965)
The new upstream_utils command-line API has been nice, but the
copy-upstream-to-thirdparty command has been annoying to type. Since it
already has documentation, we can shorten it to make it easier to
remember and type.
2024-08-15 07:44:50 -07:00
Tyler Veness
44311671f8 [upstream_utils] Use git to get repo root (#6967) 2024-08-15 07:44:22 -07:00
sciencewhiz
d3421a7c89 [build] Publish source and headers of all generated files (#6963)
Fixes #6962
Don't specially include ntcore generated files from build directory in doxygen, as they are now pregenerated in source
2024-08-14 14:26:38 -07:00
Gold856
112f536716 [epilogue] Remove dependency on Google AutoService (#6955)
This makes potential future compilation with CMake easier and reduces the amount of external code we depend on.
2024-08-14 10:44:50 -07:00
Tyler Veness
8e0d9ac805 Clean up unit UDL usage (#6961) 2024-08-14 10:44:00 -07:00
Jade
70fa41c69e [epilogue] Allow configuring logging period and logging period offset (#6893) 2024-08-14 09:26:48 -07:00
Jade
dece2391f5 [readme] Add note about building with Ninja in README-CMAKE (#6960) 2024-08-14 09:24:50 -07:00
Gold856
a2060feadc [commands] Fix and deprecate TrapezoidProfileCommand (#6722) 2024-08-13 21:01:17 -07:00
Ryan Blue
55c1c5396d [wpimath] Remove deprecated MatBuilder constructor (#6956) 2024-08-13 20:59:59 -07:00
Ryan Blue
e21e129f12 [wpimath, commands] Fix RamseteController deprecation year (#6953) 2024-08-13 16:55:26 -07:00
Gold856
05e955f87e [wpilib] Deprecate Resource (#6952) 2024-08-12 15:26:11 -07:00
Jade
b057044876 Remove ni-libraries from 3rd party licenses (#6902)
Its not in source anymore.
2024-08-11 15:59:03 -07:00
Gold856
2892733e33 [apriltag] Try loading debug OpenCV if release version fails (#6949) 2024-08-11 13:19:31 -07:00
Gold856
8e2cc51f95 [cscore] Try loading debug OpenCV if release version fails (#6928)
On some Linux systems, installing the OpenCV package will actually install a debug version with a d postfix. Try loading that version if the first load attempt failed.
2024-08-11 08:55:36 -07:00
Tyler Veness
e2143c4b5a [rtns] Fix namespace of DeploySession and SshSession (#6925) 2024-08-10 23:39:35 -07:00
Gold856
6b0aeb8e90 [build] CMake: consolidate and clean up include dirs (#6927)
Also remove the thirdparty AprilTag source directory from both CMake and Gradle header setup.
2024-08-10 23:39:17 -07:00
sciencewhiz
dc2112ba43 [wpiutil] Restore and deprecate RuntimeDetector (#6930) 2024-08-10 23:35:04 -07:00
Ryan Blue
008ebbfb77 [docs] Exclude clang-format and clang-tidy from doxygen (#6932) 2024-08-10 23:32:39 -07:00
Tyler Veness
830049b083 [upstream_utils] Upgrade to fmtlib 11.0.2 (#6933) 2024-08-10 23:31:49 -07:00
Ryan Blue
ceaac96ac8 [rtns] Fix crash when ssh error occurs during refresh (#6936) 2024-08-10 23:31:01 -07:00
Ryan Blue
dd99ff420c [wpilib, hal] DigitalGlitchFilter: Fix sim crash and clean up construction (#6937)
Fixes error when >3 are constructed- in java, m_filterAllocated[index] would be evaluated before the bounds check and throw IndexOutOfBounds, in c++ a vague assertion error would be thrown.

Makes DoAdd static in c++

Makes the error message when HAL_SetFilterSelect fails consistent with java
2024-08-10 23:30:02 -07:00
Ryan Blue
c13c512221 [build] Spotless: ignore test json files (#6938) 2024-08-10 23:27:47 -07:00
Ryan Blue
0a15049faa [wpilib] Deprecate setNetworkTablesFlushEnabled (#6940)
The function no longer flushes to network like it did originally, and users generally would not want to disable flushing locally.
2024-08-10 23:27:09 -07:00
Ryan Blue
d4dd2f8028 [hal] Counter/Encoder: use std::numeric_limits::infinity (#6941) 2024-08-10 23:26:07 -07:00
Ryan Blue
19b478a33b [hal] Expose more FPGA functionality (#6942)
- function to reset user rail fault counters
- function to get comms disable count
- correct docs for user rail count functions
2024-08-10 23:25:02 -07:00
Ryan Blue
59dc29e701 [units] Add default case for UNIT_ADD_IO (#6944) 2024-08-10 23:23:25 -07:00
Tyler Veness
79dfdb9dc5 [upstream_utils] Upgrade Sleipnir to support Eigen type specializations (#6924) 2024-08-04 06:26:05 -07:00
Tyler Veness
712db6711a [upstream_utils] Upgrade Eigen to fix warning suppression upstream (#6923) 2024-08-03 22:17:17 -07:00
David Vo
ed37bd5ab1 [wpiutil] Fix mismatching param names in DataLogJNI (NFC) (#6922) 2024-08-03 11:59:09 -07:00
Ryan Blue
5a6dd02ce9 [examples] Replace usages of SIMULATION macro with constexpr if (#6899) 2024-08-03 08:14:17 -07:00
Thad House
1a0efcf948 [wpiutil] Remove SetDllDirectory support in CombinedRuntimeLoader (#6914)
With the changes to all the windows DLLs for library load path, this functionality is no longer necessary.
2024-08-03 08:13:36 -07:00
Ryan Blue
7938d79648 [hal, wpilib] Expose sticky hardware and firmware faults in PDH and PH (#6900) 2024-08-02 19:13:43 -07:00
Ryan Blue
01c47e5bcc [wpilibc] Fix default properties for DS NT publisher (#6909) 2024-08-02 19:07:31 -07:00
Ryan Blue
ecfd3861e8 [hal] Fix Java sim timing on Windows (#6910)
Also set power throttling options correctly.
2024-08-02 18:56:58 -07:00
Tyler Veness
5ff68079e2 [wpimath] Make SplineParameterizer constants inline (#6920) 2024-08-02 18:47:27 -07:00
Thad House
9234590703 [build] Fix deprecation warning in wpilibjExamples (#6912) 2024-08-02 18:39:25 -07:00
Thad House
3e10f23cf3 [gitignore] Ignore .bck files it git (#6913) 2024-08-02 18:38:46 -07:00
Peter Johnson
caf424e09c [hal] Windows sim: enable High QOS and honor timer resolution requests (#6908)
By default on Windows 11, power throttling will increase timer resolution
if a window is occluded.  Disable that behavior.  Also enable high QOS to
achieve maximum performance and turn off power saving.

Also use internal APIs to set timer precision to 500 us if available.
2024-08-01 19:51:02 -07:00
Tyler Veness
685c732568 [wpimath] Make trajectory constraints use Rectangle2d and Ellipse2d (#6901) 2024-08-01 16:46:23 -07:00
Ryan Blue
ddd64aa70c [docs] Add documentation for various HAL/wpilib items (NFC) (#6898) 2024-08-01 16:45:20 -07:00
Ryan Blue
244be83d5d [ci] Disable check run and comments for robotbuilder CI (#6890)
It won't add them to PRs anyway because it doesn't have permissions, but the check run gets added to a random workflow in non-PR builds.
2024-08-01 16:44:16 -07:00
Gold856
1ccc4354b0 [build] Remove invalid MSVC warning suppression (#6907)
2220 is not a valid warning
2024-08-01 16:43:35 -07:00
Gold856
7adf048e83 [wpilib] Remove outdated note about axis conventions (#6905) 2024-08-01 16:42:10 -07:00
Gold856
2fc55b86a2 [wpimath] Fix API docs for DCMotorSim and LinearSystemId (#6904) 2024-08-01 16:41:57 -07:00
sciencewhiz
ad45dc89ef [ci] Uniquely name Robot Builder test results (#6895) 2024-07-30 07:39:07 -07:00
Ryan Blue
8c06ef64cb [hal] Fix potential race in CANAPI (#6819) 2024-07-29 08:00:39 -07:00
Ryan Blue
0e9c514ebf [hal, wpilib] Fix REV PH disabled solenoid list (#6887) 2024-07-29 07:59:49 -07:00
Gold856
3c2bdafd57 [wpilib, commands] Cache controller BooleanEvents/Triggers and directly construct Triggers (#6738)
This has been a common footgun for teams, due to calling the factory functions in periodic loops.
2024-07-29 07:58:23 -07:00
Joseph Eng
073192d513 [wpimath] Add remaining struct and protobuf implementations (#5953) 2024-07-29 07:55:44 -07:00
Gold856
3e1e3fb4ca [ci] Fix comment commands (#6889) 2024-07-29 07:54:17 -07:00
sciencewhiz
7093facced [examples] Correct comment about renaming Robot class (NFC) (#6892) 2024-07-29 07:52:40 -07:00
Gold856
24dd544825 [wpilib] Wait 0.5s after enabling interrupt in tests (#6891)
If the interrupt edge tests are running while under heavy CPU load (like building wpilib) they are prone to failure since the interrupt thread doesn't have enough time to set up callbacks. The interrupt edge tests now copy the original AsynchronousInterrupt test, which has a 0.5s delay after the interrupt is enabled. Running the new interrupt tests while building allwpilib causes far less failures than the old tests.
2024-07-29 07:51:25 -07:00
Gold856
6f6e8ee931 [ci] Bump wpiformat to 2024.39 (#6894) 2024-07-29 07:50:46 -07:00
Ryan Blue
4226d113f1 [hal] Update PCM/PH HAL bitmap function docs (NFC) (#6885) 2024-07-28 17:10:46 -07:00
Ryan Blue
96de39ac6a [gitignore] Add ntcore test persistent files to gitignore (#6886) 2024-07-28 17:09:46 -07:00
Dean Brettle
7aa100589d [wpilib] Fix sim javadocs to not say GC will cancel callbacks (#6665)
That behavior has not been present since PR #4158 was merged more than 2 years ago and imo should not be added back because it was surprising and not consistent with the most common use case of registering a callback permanently.
2024-07-28 14:30:19 -07:00
Ryan Blue
ea7c935bcb [wpilib] Improve bitmap function documentation in PneumaticsBase (NFC) (#6884) 2024-07-28 14:28:42 -07:00
Ryan Blue
143876dfa3 [hal] Add missing HAL CAN javadocs (NFC) (#6882) 2024-07-28 14:27:55 -07:00
Gold856
f142cec97b [ci] Fix /pregen (#6875)
It checked out the main branch instead of the PR branch. Now it checks out the PR branch.
2024-07-28 10:50:24 -07:00
Joseph Eng
158fb23072 [wpiutil] Struct: Change from GetTypeString() to GetTypeName() (#6872)
This makes it easier to define schemas when the type name is non-trivial (e.g., templated structs).

This is breaking for a) custom struct implementations and b) anything calling `wpi::Struct<T>::GetTypeString(info...)` in C++ directly. In both cases, it's a simple translation: For A, rename `GetTypeString()` to `GetTypeName()` and remove the struct: at the beginning, and for B, use `wpi::GetStructTypeString<T>(info...)` instead.
2024-07-27 20:23:45 -07:00
Jade
5dcaa6d671 [wpilibc] Add FRC_ReportWarning (#6681) 2024-07-27 20:20:08 -07:00
Gold856
aba82e6a6c [build] CMake: export fieldImages and install headers (#6876) 2024-07-27 20:16:34 -07:00
Wispy
02bf9a164e [docs] Document the /pregen command (#6874) 2024-07-27 16:30:57 -07:00
Ryan Blue
81ec66f05b [hal] Remove dangling periodic packet function from sim CANAPI (NFC) (#6879)
Removed from API in #1868, sim definition was left dangling.

Also adds extern "C" to the sim file.
2024-07-27 16:30:18 -07:00
Wispy
5a1417aeb9 [commands] Add Trigger.onChange() test (#6849) 2024-07-27 16:29:22 -07:00
Joseph Eng
e83a432731 [wpimath] Fix C++ feedforward constructors and add tests (#6873) 2024-07-27 16:28:59 -07:00
Gold856
03b332d3cf [gitignore] Add CMakeUserPresets.json to gitignore (#6877) 2024-07-27 16:28:40 -07:00
Ryan Blue
ed23b2889d [hal] Remove CANDeviceInterface (#6880) 2024-07-27 16:28:08 -07:00
Ryan Blue
784f0a033a [docs] Cleanup HAL CAN docs (NFC) (#6881) 2024-07-27 16:26:01 -07:00
Joseph Eng
cd39c5e2a1 [upstream_utils] Determine patch list from patch files (#6869) 2024-07-23 15:58:15 -07:00
Gold856
aa44b2fd1e [build] Don't build imgui for Athena (#6871) 2024-07-23 07:29:18 -07:00
Gold856
e3a5299552 [build] Always statically build Glass libraries (#6867)
Also don’t rename libglass on Windows to avoid PDB name collision.
2024-07-22 08:03:19 -07:00
Peter Johnson
4c7fe73f69 [wpiutil] DataLog: Add last value and change detection (#6674)
Update() checks/updates the last value and appends only if changed.
GetLastValue() gets the last value.

Also add OutputStream support to Java DataLogWriter.
2024-07-21 13:08:15 -07:00
Tyler Veness
57205c8d15 [upstream_utils] Disable glfw docs build by default (#6863)
Fixes #6862.
2024-07-21 07:15:22 -07:00
Brendan Raykoff
45f3e3a069 [wpimath] Add getAccumulatedError() to PIDController (#6813) 2024-07-20 23:17:13 -07:00
Jade
eda63dc162 [upstream_utils] Add AprilTag library (#6816)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-07-20 22:12:49 -07:00
PJ Reiniger
6922b9dd5e [upstream_utils] Add imgui and friends (#6822) 2024-07-20 22:11:54 -07:00
Peter Johnson
8548d83b03 [hal] SimDevice: Don't hold lock during callbacks (#6855)
This can cause lock inversions with other code (in particular with
the simulation WebSockets interface).
2024-07-20 22:09:09 -07:00
Joseph Eng
b4d42d8980 [wpimath] Make public final values in feedforwards private and add getters (#6851) 2024-07-20 07:01:56 -07:00
Tyler Veness
d827c84c5e [upstream_utils] Clean up package imports (#6857) 2024-07-20 07:01:06 -07:00
Tyler Veness
6ec8763eac [upstream_utils] Make .c file rename toggleable (#6858) 2024-07-20 07:00:13 -07:00
Tyler Veness
e9efb05cd3 [wpilibj] Fix this-escape warnings from JDK 21 (#6856) 2024-07-18 22:43:55 -07:00
PJ Reiniger
f561a77e75 [upstream_utils] Add googletest (#6820) 2024-07-18 21:10:26 -07:00
Gold856
289d45b081 [wpilib] Refactor and clean up ADIS IMU classes (#6719) 2024-07-18 21:09:11 -07:00
Christopher Mahoney
45823abe86 [wpilib] Synchronize C++ and Java versions of BooleanEvent (#6776) 2024-07-18 21:08:28 -07:00
Gold856
8d857cdb78 [apriltag] Improve AprilTagDetector default config (#6847) 2024-07-18 21:06:37 -07:00
Joseph Eng
602325d608 [wpilibc] Add missing includes to LEDPattern.cpp (#6852) 2024-07-18 21:05:45 -07:00
Gold856
e30440e2af .gitattributes: Mark more files as text with LF line endings (#6853) 2024-07-18 21:05:18 -07:00
Jade
19a5e0c49a Add factory path to .gitignore (#6850) 2024-07-18 11:55:17 -07:00
Jade
7663211819 [wpilib] Implement Sendable for HID classes (#6782) 2024-07-18 07:10:07 -07:00
Gold856
34b8b7a409 [wpilib] Increase time between interrupt operations (#6848) 2024-07-17 18:15:37 -07:00
Tyler Veness
15001afb31 [wpilib] Fix repeat TimedRobot callbacks on loop overrun (#4101)
If one of the *Init() functions takes several multiples of the nominal
loop time, the callbacks after that will run, then increment their
expiration time by the nominal loop time. Since the new expiration time
is still in the past, this will cause the callback to get repeatedly run
in quick succession until its expiration time catches up with the
current time.

This change keeps incrementing the expiration time until it's in the
future, which will avoid repeated runs. This doesn't delay other
callbacks, so they'll get a chance to run once before their expiration
times are corrected.

The other option is correcting all the expiration times at once, which
would starve the other callbacks even longer so that the callback
scheduling returns to a regular cadence sooner. The problem with this
approach is if a previous callback overruns the start of the next
callback, the next callback could potentially never get a chance to run.
2024-07-16 22:56:36 -07:00
Jade
57fa388724 [examples] Prepare for RobotInit deprecation by updating examples (#6623)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-07-16 20:22:39 -07:00
Tyler Veness
f62a055608 [epilogue] Add missing docs (#6844) 2024-07-16 20:20:22 -07:00
Gold856
e5b7cf4c76 [hal] Fix interrupt edges being flipped in sim (#6720) 2024-07-16 17:26:35 -07:00
Sam Carlberg
59256f0e00 [epilogue] Add an annotation-based logging framework for Java programs (#6584) 2024-07-16 17:25:43 -07:00
Nicholas Armstrong
30c7632ab8 [wpimath] Make SimpleMotorFeedforward only support discrete feedforward (#6647)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-07-16 17:23:11 -07:00
Joseph Eng
5f261a88af [upstream_utils] Rework upstream_utils scripts (#6829) 2024-07-16 17:20:07 -07:00
Matt
f9d32ad706 [wpiutil] Struct: Remove explicit span length from int8 (#6840) 2024-07-16 13:40:36 -07:00
Tyler Veness
8f60dc736d [wpimath] Fix build by removing a bad #include (#6843)
WheelPositions.h was removed in #6771.
2024-07-16 13:40:06 -07:00
Christopher Mahoney
6c0429c263 [wpimath] Remove WheelPositions interface/concept (#6771) 2024-07-16 12:39:24 -07:00
Wispy
7d64d4e24c [sim] Add GUI support for the REV PH (#6704) 2024-07-15 17:28:05 -07:00
Gold856
cd6b70af0e [docs] Add documentation for simulation extensions (#6729) 2024-07-15 17:26:25 -07:00
Joseph Eng
7b7d17ccd7 [wpimath] Add and use kinematics.copyInto() (#6789) 2024-07-15 17:19:31 -07:00
Ryan Blue
636450ab7b [build] Disable std::mutex constexpr constructor on Windows (#6791)
We will plan to re-enable this after we release an installer with an updated runtime.
2024-07-15 17:19:07 -07:00
Gold856
9703142ebe [build] CMake: simplify source JAR creation and install (#6831)
Bump required minimum CMake version to 3.21.
2024-07-15 15:12:41 -07:00
sciencewhiz
fc57f6a560 [ci] Filter python commands comment only for Java sources (#6832)
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2024-07-15 14:51:10 -07:00
Tyler Veness
912d9b2201 [upstream_utils] Fix LLVM's AlignedCharArrayUnion for C++23 (#6830)
C++23 deprecated std::aligned_union_t.
2024-07-15 14:50:19 -07:00
Tyler Veness
5825bf46d8 [upstream_utils] Suppress has_denorm deprecation in Eigen (#6833)
MSVC doesn't yet claim C++23 compliance for c++latest, so we have to be
less specific in the preprocessor check.
2024-07-15 14:41:40 -07:00
Jade
6b9d41182f [sim] Fix WS sending 1 and 0 instead of booleans (#6836) 2024-07-15 10:17:35 -07:00
Tyler Veness
fc44737a49 [commands] Suppress this-escape warnings (#6828) 2024-07-13 06:52:30 -07:00
Tyler Veness
deb5f3d7af [wpimath] Exit early when parameterizing malformed spline (#6827)
Currently, a max iteration heuristic is used to determine when a spline
is malformed. Instead, we can report a failure immediately if dx and dy
are too small, because the heading won't be accurate either.

Fixes #6826.
2024-07-12 21:52:28 -07:00
Gold856
e00bb2f07b [build] CMake: add some compiler flags from native-utils (#6825) 2024-07-12 21:51:55 -07:00
Jade
19c28c2a76 [commands] Make requirements private (#6769) 2024-07-12 07:51:21 -06:00
Jade
967105568c [commands] Update requirements consistently (#6304) 2024-07-11 16:01:54 -06:00
Gold856
bf75c03218 [build] Clean up CMake files (#6802)
Explicitly list required components when using FindJava and FindJNI
Consolidate find_package calls for Java, JNI, and OpenCV into the root CMakeLists.txt file
Remove references to main_lib_dest
Install missing generated headers
Flatten some if statements
Use LinkMacOSGUI macro instead of hand rolling it
Stop installing OpenCV libraries and an extra ntcorejni library; OpenCV JAR will still be installed to make it easy to use
Only print platform version on Windows
Prevent GUI modules from being built when wpimath is off, which would otherwise cause a build failure
Simplify build configuration checks
Clean up fieldImages JAR creation
Place built JARs in the same subdir as installed JARs
Remove unnecessary JAR includes
Remove extra directories in target_include_directories
Improve CMake docs
2024-07-11 16:01:05 -06:00
Tyler Veness
27a2e02b52 [upstream_utils] Upgrade Sleipnir to avoid pool allocator crash on Windows (#6821) 2024-07-10 07:39:30 -06:00
Jade
c62863cf74 [build] Fix CMake build for wpilibNewCommands (#6815) 2024-07-09 10:25:31 -06:00
Jade
cc02a948a0 [wpimath] Add Reset methods to PoseEstimator (#6751) 2024-07-08 18:26:08 -07:00
Jade
dc276b651b [wpimath] Add reset methods to Odometry (#6702) 2024-07-08 18:25:42 -07:00
Tyler Veness
7f6ba54b68 [wpimath] Report error when x and y components of Rotation2d are both zero (#6767)
Fixes #6766.
2024-07-08 12:23:36 -06:00
Joseph Eng
3d22eeca9d [wpiutil] Remove Protobuf.getNested() (#6812)
It was superseded by using FileDescriptor.getDependencies().
2024-07-08 07:59:05 -06:00
Tyler Veness
6478ba6e3f [upstream_utils] Upgrade Sleipnir to fix unused parameter warnings (#6803) 2024-07-07 06:43:44 -07:00
Tyler Veness
32ed9c5f0b [upstream_utils] Upgrade to fmt 11.0.1 (#6804) 2024-07-07 06:40:15 -07:00
Tyler Veness
0954ded60a [upstream_utils] Upgrade to libuv 1.48.0 (#6806) 2024-07-07 06:39:56 -07:00
Tyler Veness
1f92c59e20 [upstream_utils] Upgrade to GCEM 1.18.0 (#6805) 2024-07-07 06:39:11 -07:00
Tyler Veness
450fae3909 [upstream_utils] Upgrade to json 3.11.3 (#6807) 2024-07-07 06:38:56 -07:00
Thad House
1c42c1c920 [wpimath] Add a base JNI class for WPIMath (#6793)
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
2024-07-07 06:38:05 -07:00
Gold856
537976c426 [build] CMake: remove external HAL option (#6797) 2024-07-05 17:49:31 -07:00
Jade
f0f4bac680 [commands] Add setRumble and isConnected to CommandGenericHID (#6768) 2024-07-05 17:47:31 -07:00
Jade
b4645a30f6 [ci] Add /pregen to pregenerate files (#6786) 2024-07-05 17:43:50 -07:00
sciencewhiz
ba210fb560 [ci] Add dispatch to tag RobotBuilder (#6794) 2024-07-05 17:43:06 -07:00
Gold856
3b6f38d7de [build] Drop jinjava as a Gradle dependency (#6801) 2024-07-03 10:18:06 -07:00
Tyler Veness
19ea73ef69 [upstream_utils] Upgrade to fmtlib 11.0.0 (#6796) 2024-07-02 13:34:59 -07:00
Ryan Blue
6a5448322b [wpilib] Add metadata to all dashboard ".type" entries (#6799) 2024-07-02 13:31:50 -07:00
beardedone55
7366a03fc9 [xrp] Add Support for Encoder Period on XRP (#6795)
The XRP firmware has been updated to provide the
encoder period along with the encoder count.

This change allows WPILIB to use the encoder period
data from the XRP so that the GetRate function can
be used to determine the motor speed.
2024-07-02 13:29:52 -07:00
Chris Padwick
1ccd8d14f0 [build] cmake: Add check for protobuf compiler (#6792) 2024-06-30 20:25:10 -07:00
sciencewhiz
a2beb7510b [ci] Add dispatch to tag PathWeaver and Shuffleboard (#6788) 2024-06-29 13:58:09 -07:00
sciencewhiz
88658fb30b [ci] Patch tools builds to only use local artifacts (#6787) 2024-06-29 12:30:21 -07:00
Gold856
c3c1671cf7 [build] CMake: Fix find_package(wpilib) calls when some libraries are missing (#6784) 2024-06-29 06:55:04 -07:00
Jade
8ba9a55759 [commands] Remove deprecated C++ method TransferOwnership (#6780) 2024-06-29 05:37:29 -07:00
sciencewhiz
8e97587765 [ci] Update tools build year to 2025 (#6783)
Fixes robotbuilder build that failed after 2025 alpha tag
2024-06-28 20:16:48 -07:00
Jade
047eaac11e [wpinet] Remove non GP language (#6774) 2024-06-28 20:14:26 -07:00
Joseph Eng
512a4bfc12 [wpimath] Simplify pose estimator (#6705) 2024-06-28 20:12:12 -07:00
Ryan Blue
5e745bc5ef [ci] Add spotless diff to summary and artifacts (#6779) 2024-06-28 06:29:21 -07:00
Gold856
5ce72d43e4 [build] Fix CMake protobuf dependency handling (#6772)
Reverts #6609 since that fix didn't Just Work(tm) on Windows. (edit: or Ubuntu. Seems to have broken everything except macOS.) This PR configures CMake to try and find protobuf-config.cmake first, which allows protobuf to pull in abseil for us. If protobuf-config.cmake is not available (coprocessors which don't have a new enough protobuf installed are a common case), it will fallback to CMake's built-in FindProtobuf module, which is what we were using before.

Add wpi::CreateMessage, a wrapper with an ifdef to switch between Arena::CreateMessage and Arena::Create, since the former is deprecated in newer versions of protobuf. This allows forward compatibility with newer versions of protobuf.
2024-06-28 06:28:39 -07:00
Tyler Veness
a7173dbd3c [apriltag] Fix GCC 14 calloc() warning (#6773) 2024-06-23 20:24:45 -07:00
Tyler Veness
2ff7033edf [upstream_utils] Update to LLVM 18.1.8 (#6764) 2024-06-21 23:21:39 -07:00
Wispy
ca92ef89d3 [sim] Don't send joystick data during auto (#6732)
Testing on a Rio showed that the joystick inputs are not zeroed, they just don't update.
2024-06-21 20:56:23 -07:00
Tyler Veness
b8c2571638 [wpimath] Fix precondition violation messages in LQR and Kalman filters (#6731) 2024-06-21 20:55:01 -07:00
Tyler Veness
d2b1aa1869 [sysid] Remove CTRE v5 CANCoder preset (#6753)
Fixes #6466.
2024-06-21 20:54:29 -07:00
Gold856
76a3a60712 [ci] Bump actions versions to Node 20 (#6758)
Bump webfactory/ssh-agent to 0.9.0 (Node 20)
Switch to gradle/actions/wrapper-validation (Node 20)
Bump mozilla-actions/sccache-action to 0.0.5 (Node 20 for sanitizers only)
Bump actions/github-script to 7 (Node 20 for documentation only)
Bump wpilibsuite/import-signing-certificate to 2 (Node 20)
Bump JamesIves/github-pages-deploy-action to 4.6.1 (Node 20)
2024-06-21 20:53:51 -07:00
sciencewhiz
f5df6f88c8 [ci] Add dispatch actions task to ping tools on tag (#6755)
Allows automation of tagging of tools on allwpilib tag
Adapted from robotpy
2024-06-21 17:15:42 -07:00
Gold856
7f5970b27a [ci] Remove unused steps/package installs (#6756)
Removed steps/packages were used for protobuf/generated files
2024-06-21 11:15:42 -07:00
Tyler Veness
25865759f4 [upstream_utils] Upgrade Sleipnir and use wpi::SmallVector (#6748) 2024-06-21 11:14:19 -07:00
Tyler Veness
e2893fc1a3 [upstream_utils] Add wpi::SmallVector erase_if() (#6752) 2024-06-18 14:03:43 -06:00
PJ Reiniger
b6bd798f9e [wpilib] Pregenerate PWM motor controllers (#6742)
Co-authored-by: Gold856 <117957790+Gold856@users.noreply.github.com>
2024-06-18 08:43:08 -06:00
PJ Reiniger
66c0abb732 [build] Use pathlib in pre-generation scripts (#6745) 2024-06-18 08:40:37 -06:00
Brendan Raykoff
e884221a8d [wpilib] Propagate PWMMotorController stopMotor() and disable() to followers (#6750) 2024-06-18 07:40:32 -06:00
Gold856
3a0ee5c9a7 [build] cmake: Improve OpenCV file search (#6747) 2024-06-16 17:08:48 -07:00
Ryan Blue
bb8480c690 [wpilib] Include sendable type information in topic metadata (#6741) 2024-06-14 08:12:18 -06:00
Ryan Blue
d3aa7f85dd [ci] Revert disable std::mutex constexpr constructor on Windows (#6736) 2024-06-12 14:45:59 -06:00
Gold856
3d6b710293 [wpiutil] DataLog: Don't constantly retry log creation when low on space (#6730) 2024-06-10 20:22:50 -06:00
Gold856
ae6954c78f [wpiunits] Clarify return conditions for isEquivalent (NFC) (#6727) 2024-06-09 17:54:31 -06:00
Tyler Veness
a087544933 [upstream_utils] Disable spurious maybe-uninitialized warning from GCC 14 (#6728) 2024-06-09 17:53:38 -06:00
Gold856
b9935c9885 [ci] Fix robotpy PR commenting (#6723) 2024-06-09 06:37:30 -07:00
Ryan Blue
3617a95260 [ci] Disable std::mutex constexpr constructor on Windows (#6725)
Fixes cmake builds, works around issue with windows runners.

Revert when GitHub runner images are fixed.
2024-06-09 06:36:29 -07:00
Gold856
b0cc84a9c7 [build] Upgrade to PMD 7.2.0 (#6718) 2024-06-08 22:08:23 -07:00
Gold856
e2dcbd016d [wpimath] Remove deprecated TrapezoidProfile method in C++ header (#6721) 2024-06-08 22:05:17 -07:00
Tyler Veness
72ae751b9a [ci] Fix PathWeaver name typo (#6717) 2024-06-08 11:58:45 -07:00
Tyler Veness
27cbbfe2ab [upstream_utils] Update to LLVM 18.1.7 (#6715) 2024-06-08 11:24:42 -07:00
Gold856
65c6306047 [wpilib,commands] Use Jinja to generate HID classes (#6274) 2024-06-08 09:59:07 -07:00
sciencewhiz
a0efc9ca31 [ci] Add workflow to build java tools for PRs (#6698)
This can catch breaking changes earlier.
- Builds linux only for speed
- Builds and publishes artifacts in this file as it was actually faster
then reusing the artifacts from the gradle file as those need the
combiner run on them. It uploads the artifacts to Actions with a 1 day
retention, because that allows the tools to be built in parallel, which
overall sped things up. This also only allows relevant tasks in wpilib
to be run
- The tool builds are uploaded with a shorter retention time in case
someone wants to do more extensive tests.
2024-06-08 09:55:07 -07:00
Thad House
917b5dde66 [build] Update Native Utils, remove all rpath tricks (#6671)
With fixes to Windows and macOS library path handling, all the tricks we used in the past to make library loading work are no longer required.
2024-06-08 09:52:29 -07:00
Tyler Veness
300595da9e [upstream_utils] Update Sleipnir (#6709)
Upstream now uses std::format/std::print, so we have to backport it to
fmtlib.
2024-06-08 09:50:59 -07:00
Brendan Raykoff
0606da64c9 [wpimath] LinearFilter lastValue(): Fix runtime exception (#6713) 2024-06-07 17:24:34 -07:00
Gold856
1c884b2260 [ci] Use the comment command token for robotpy comment action (#6711) 2024-06-07 16:15:30 -07:00
Gold856
5b94421b5a [ci] Fix permissions for commenting on commands PRs (#6708) 2024-06-06 10:39:58 -07:00
Sam Carlberg
ad18fa62ee [wpilib] Add LED pattern API for easily animating addressable LEDs (#6344)
Add LEDReader and LEDWriter helper interfaces to facilitate composing simple patterns into more complex ones, e.g. LEDPattern.solid(Color.kBlue).breathe(Seconds.of(0.75)). Pattern composition relies on changing out the write behavior; for example, offsetBy increments the indexes to write to; while blink will switch between playing a base pattern and turning off all the LEDs.

Add a view class for splitting a single large buffer into smaller distinct sections, which is useful for dealing with long chained LED strips mounted on different parts of a robot. Views cannot be written directly to an LED strip (in fact, trying to do so won't even compile).

Adds some utility methods to the Color class for interpolating between two colors, and support color representations with 32-bit integers to avoid object allocations.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-06-05 19:41:10 -07:00
Tyler Veness
5221069bcc [wpimath] Disambiguate wpimath JNI functions (#6695)
Each collection of JNI functions now has its own class.
2024-06-05 12:26:58 -07:00
Wispy
df4694c9df [wpinet] Add indication of success/failure to PortForwarder (#6697) 2024-06-04 21:09:45 -07:00
Gold856
b99d9c1710 Use Java 17 features (#6691)
Uses enhanced instanceof (and simplify equals methods)
Uses switch expressions and arrow labels
Seal and finalize some Shuffleboard classes

Co-authored-by: Sam Carlberg <sam@slfc.dev>
2024-06-04 21:09:10 -07:00
Joseph Eng
d6b66bfa55 [wpiutil] Add remove_prefix() and remove_suffix() (#6118) 2024-06-04 21:01:52 -07:00
Brendan Raykoff
8def7b2222 [wpimath] Add geometry classes for Rectangle2d and Ellipse2d (#6555)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-06-04 18:27:32 -07:00
Tyler Veness
afaf7e2c3f [upstream_utils] Format Eigen patches with Eigen's clang-format config (#6699) 2024-06-04 18:26:20 -07:00
Wispy
5f8c842223 [wpilib] Compressor: Add more Sendable data (#6687) 2024-06-03 07:47:17 -07:00
Tyler Veness
bdc42532ed [wpimath] Make unit max and min constexpr (#6690) 2024-06-02 21:45:02 -07:00
sciencewhiz
21e970f2cd [fieldImages] Move Java fields to edu.wpi.first.fields (#6694)
Doesn't make sense in edu.wpi.fields, and resources are already in
edu.wpi.first.fields
This will require changes in Shuffleboard and Pathweaver
2024-06-02 21:44:39 -07:00
sciencewhiz
38ee6476f2 [ci] Update cmake actions to node 20 versions (#6692) 2024-06-02 21:00:43 -07:00
Tyler Veness
a97904ed1f [upstream_utils] Fix gcem min and max compilation (#6689) 2024-06-02 15:52:12 -07:00
Joseph Eng
1828fdaaa4 [commands] Define order of parallel groups (#6602) 2024-06-01 12:01:15 -07:00
Joseph Eng
7751f6d1d2 [wpimath] Remove swerve wrappers for odometry and pose estimation, move wheel positions operations to kinematics (#6673) 2024-06-01 11:59:54 -07:00
Peter Johnson
7c8a36f3eb [wpiutil] Add Struct and Protobuf clone and immutable checks (#6686) 2024-06-01 11:58:53 -07:00
Wispy
ae8e4289b9 [dlt] Fix build.gradle description (#6682) 2024-05-31 13:43:51 -07:00
CoolSpy3
c1fc86033a [sim] Clarify Sim CAN Device Documentation (#6679) 2024-05-30 05:32:45 -07:00
Dean Brettle
9782abbcb1 [wpilib] Add protected default constructor for CallbackStore (#6667)
This  is to allow 3rd party sim providers (eg vendors) to subclass this class so that the register methods of their sim classes can return CallbackStores like the builtin sims.

Although it was already possible to create such a subclass but passing dummy parameters to one of the other constructors, this eliminates the need to pass such dummy parameters and makes it clearer that subclassing is allowed.
2024-05-27 21:19:12 -07:00
Gold856
0ad4cd69d0 [hal] Initialize DIO to true in sim (#6670) 2024-05-27 21:18:19 -07:00
Avi
76685fe7e8 [wpilibj] Fix docs typo (NFC) (#6672) 2024-05-27 21:17:41 -07:00
Dean Brettle
3b8d8a367b [wpilibj] Make CallbackStore.close() idempotent (#6666)
This is "strongly recommended" in the javadocs for the AutoCloseable.close().
2024-05-27 07:58:03 -07:00
CoolSpy3
a6ac4228c3 [sim] WebSockets Documentation Fixes (#6668) 2024-05-27 06:52:25 -07:00
CoolSpy3
98fcbdb44e [sim] Update WebSockets API Specification (#6664)
Also update AddressableLED data to be output instead of input.
2024-05-26 14:58:32 -07:00
Thad House
958387ddd3 [wpiutil] Add method to skip SetDllDirectory for windows loading (#6662)
With DependentLoadFlags, we shouldn't need this function anymore. Add a way to test this easily without needing to modify allwpilib.
2024-05-26 14:22:29 -07:00
Thad House
a2f2502f70 [build] Bump Native Utils to 2025.0.0 (#6663)
Adds DependentLoadFlags
2024-05-26 11:55:55 -07:00
Thad House
fbfef85f45 [wpiutil] Fix CombinedRuntimeLoader default path (#6661) 2024-05-26 11:12:44 -07:00
Vasista Vovveti
cdbd64c3df [ci] Give comment action PR write permission (#6594) 2024-05-25 19:42:28 -07:00
Joseph Eng
eb3635e622 [commands] Make CommandGenericHID a public base class of CommandXboxController (#6658) 2024-05-25 11:44:41 -07:00
Joseph Eng
9ef6d13b27 [wpilibj] Suppress this-escape warning on SharpIR (#6659) 2024-05-25 11:43:27 -07:00
Wispy
e2545231b8 [glass] Save input after clicking away (#6657) 2024-05-25 09:19:52 -07:00
sciencewhiz
4252a36668 DevelopmentBuilds.md: Fix missing apostrophe (#6655) 2024-05-24 19:46:11 -07:00
Jade
f1e072fc98 [commands] GenericHIDController: use composition in C++ (#6296) 2024-05-24 16:36:05 -07:00
Theinatorinator
221d568bd9 [wpilibj] Add tests for ADIS16448 simulation (#6152) 2024-05-24 16:33:25 -07:00
scarmain
c62396ce4e [wpilib] Fix PowerDistribution.GetAllCurrents() (#6025) 2024-05-24 16:31:19 -07:00
Nicholas Armstrong
f42bc45ee8 [wpilib] FlywheelSim cleanup (#6629)
This is a cleanup of the FlywheelSim class with a few added features.

- One FlywheelSim constructor that takes a plant, DCMotor, and a optional number of measurementStdDevs. The documentation now states how to construct the plant either through LinearSystemId.createFlywheelSystem or identifyVelocitySystem.

- The gearbox, gearing and moment of Inertia (J) are now private final fields. The gearing is determined from the plant in the constructor as well as the moment of inertia. There are getter methods that allow the flywheelSim to return the gearbox, gearing, and moment of inertia.

- The getCurrentDrawAmps function now uses m_x instead of getAngularVelocityRadPerSec in accordance with more accuracy and matches the patter in other sims.

- Added getter methods for the InputVoltage, angularAcceleration and torque

- (Java only) A third getter method for returning the AngularVelocity of the flywheel using a MutableMeasure as a backing field that is set when getAngularVelocity is called. This summarily returns the angularVelocity as just a Measure object. This allows the user of this class to handle unit conversions with less numerical manipulation. Alterations in C++ for this feature were not needed.
2024-05-24 16:05:14 -07:00
Wispy
8c107e4b75 [wpilibj] Add TimedRobot.addPeriodic() measure overloads (#6654) 2024-05-24 16:02:36 -07:00
Peter Johnson
652c721895 [ci] Remove build-dir from Windows Gradle build (#6269)
This is no longer required due to increased disk space in Actions.
2024-05-24 14:03:00 -07:00
Peter Johnson
7e00f2d3eb [wpilib] Fix docs for Sharp IR simulation (NFC) (#6653) 2024-05-24 14:02:22 -07:00
Joseph Eng
5c5e5af0c6 [commands] Add missing C++ decorators (#6599) 2024-05-24 13:14:15 -07:00
Dean Brettle
237ebfd0f2 [sim] Add CAN message schema to wpilib-ws.yaml and add 2 CANMotor props (#6651)
Co-authored-by: CoolSpy3 <coolspythree@gmail.com>
2024-05-24 12:56:34 -07:00
Dustin Spicuzza
dc0e9712e6 [wpilib] Add support for Sharp IR sensors (#6023) 2024-05-24 12:55:30 -07:00
Thad House
d05c7c125b [wpilib] Rewrite DutyCycleEncoder and AnalogEncoder (#6398) 2024-05-24 11:53:56 -07:00
Carl Hauser
294c9946ae [wpimath] PIDController.setIntegratorRange documentation fix (#6489) 2024-05-24 11:49:00 -07:00
Jade
6220c6be4d [wpiutil] Remove RuntimeDetector and simplify RuntimeLoader (#6600) 2024-05-24 10:48:59 -07:00
Gold856
72a6d22d9a [build] Organize cmake files (#6617) 2024-05-24 10:48:05 -07:00
Jade
8834cb1de4 [wpimath] ChassisSpeeds: add equals method (#6414) 2024-05-24 10:42:32 -07:00
Tyler Veness
ae655a3a71 Rename myRobot to developerRobot and move docs to subproject (#6283) 2024-05-24 10:41:23 -07:00
Ryan Blue
65f4505e3c [wpimath] Add constraints support to ProfiledPIDController Sendable implementation (#6354) 2024-05-24 10:39:56 -07:00
bovlb
badd090538 [wpimath] Document example usage for InterpolatingDoubleTreeMap (NFC) (#6456) 2024-05-24 10:35:42 -07:00
Gold856
2fd8dae503 [ci] Use LF line endings for pregenerate.yml (#6650) 2024-05-23 08:23:54 -07:00
Tyler Veness
27efd37c52 [upstream_utils] Upgrade Eigen to include GCC 14 patches (#6646) 2024-05-23 06:49:20 -07:00
Tyler Veness
0c822b45ab [wpimath] Fix Eigen maybe-uninitialized warnings (#6636) 2024-05-20 16:53:22 -07:00
Jade
58751338ec [ci] Remove workaround for sanitizers (#6638)
It's been added to the base image.
2024-05-20 12:20:12 -07:00
ncorrea210
0b5aec82ff [wpimath] Add ChassisSpeeds::ToTwist2d() to ChassisSpeeds (#6634)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-05-20 12:19:17 -07:00
Wispy
820f68dc08 [wpimath] Add InterpolatingDoubleTreeMap.ofEntries() (#6635)
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2024-05-20 12:18:28 -07:00
Benjamin Hall
8c420fa4c1 [wpimath] Modify C++ LinearFilter::Reset(span<double>, span<double>) to take span<T> (#6628)
Previously, the overload took a span<double>. However, m_inputs and m_outputs store type T, so the function could not be called for any T that does not have an implicit constructor from double.
2024-05-15 14:46:10 -06:00
Nicholas Armstrong
ab315e24c8 [wpimath] LinearSystemSim Constructor and method cleanup (#6502)
Modified Java constructors to take a variable number of measurement std devs argument with checks in place to make sure the right amount (or none) are passed into the constructor. All changes passed down to classes utilizing LinearSystemSim.

Removed excess constructors

Removed Java and C++ CurrentDrawAmps method as it doesn't belong in a generic (non electrical) linear system. Kept a non override version in all derived electrical classes.

Also LinearSystemSim has now been made agnostic to electrical systems. Inputs don't have to be voltage. BatteryVoltage clamp function has been pushed down to electrical subclasses.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-05-15 11:40:30 -06:00
Tyler Veness
0f45fe9486 [upstream_utils] Fix Eigen macro name (#6627)
I've confirmed this fixes the build with GCC 14 in C++23 mode.
2024-05-15 07:42:53 -06:00
Nicholas Armstrong
7fc17811fa [wpimath] Add full state support to LinearSystemId functions (#6554)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-05-15 07:23:22 -06:00
Wispy
7fbbecb5b7 [wpiunits] Add Measure.divide(Measure<U2>) (#6611) 2024-05-15 07:22:38 -06:00
Michael Fisher
b0d3bf4ddf [build] cmake: add absl dependency for newer protobuf (#6609)
Works around a bug on some systems where protobuf does not correctly depend on required absl libraries.
2024-05-14 21:25:15 -06:00
Tyler Veness
40b35f0d51 [upstream_utils] Fix compilation failures on constexpr matrices with GCC 14 (#6626) 2024-05-14 21:22:32 -06:00
Tyler Veness
637647b941 [upstream_utils] Improve Eigen intellisense fix (#6621) 2024-05-14 18:47:51 -06:00
Tyler Veness
0a967e0e62 [upstream_utils] Suppress deprecation warnings for Eigen's has_denorm (#6619)
std::has_denorm and std::has_denorm_loss were deprecated in C++23.
This avoids deprecation warnings with Clang 18 set to C++23.
2024-05-14 16:33:57 -06:00
Thad House
4ce8f3f935 Change C APIs to a unified string implementation (#6299)
Currently in the entire C API of WPILib we have ~8 different ways of handling strings. The C API actually isn't built for pure C callers (We don't actually have any of those). Instead, they're built for interop between languages like LabVIEW and C# which can talk to C API's directly.

For output parameters, the choice was fairly obvious. An output struct containing a const string pointer and a length makes the most sense. Its easy to use these from most other languages, and doesn't require special null termination handling. Freeing these is also easy, as if you ever receive one of these string structures, theres just a single function call to free it.

Input parameters are a bit more complex. To be used from pure C, and from LabVIEW, a null terminated string is the best in most cases. However, null terminated strings in general have a lot of downsides. Additionally, from LabVIEW there are other considerations around encoding that having a wrapper struct helps make a bit easier. From a language like C#, a wrapper struct is by far the easiest, as custom marshalling can make it trivial to marshal both UTF8 and UTF16 strings down.

The final consideration is its nice to have an identical concept for both input and output. It makes the rules fairly easy to understand.

WPILib will not have any APIs that manipulate a string allocated externally. This means WPI_String can be const, as across the boundary it is always const.
If a WPILib API takes a const WPI_String*, WPILib will not manipulate or attempt to free that string, and that string is treated as an input. It is up to the caller to handle that memory, WPILib will never hold onto that memory longer than the call.
If a WPILib API takes a WPI_String*, that string is an output. WPILib will allocate that API with WPI_AllocateString(), fill in the string, and return to the caller. When the caller is done with the string, they must free it with WPI_FreeString().
If an output struct contains a WPI_String member, that member is considered read only, and should not be explicitly freed. The caller should call the free function for that struct.
If an array of WPI_Strings are returned, each individual string is considered read only, and should not be explicitly freed. The free function for that array should be called by the caller.
If an input struct containing a WPI_String, or an input array of WPI_Strings is passed to WPILib, the individual strings will not be manipulated or freed by WPILib, and the caller owns and should free that memory.
Callbacks also follow these rules. The most common is a callback either getting passed a const WPI_String* or a struct containing a WPI_String. In both of these cases, the callback target should consider these strings read only, and not attempt to free them or manipulate them.
2024-05-13 05:35:14 -07:00
Peter Johnson
178fe99f12 [wpiutil] Split DataLog background writer into different class (#6590)
DataLog is now a base class, with DataLogBackgroundWriter being the
background thread version and DataLogWriter being a non-threaded version.

Also split the C header into a separate file to make it more wpiformat friendly.
2024-05-12 14:09:43 -07:00
Gold856
305a0657e2 [cscore] Deprecate AxisCamera (#6579) 2024-05-12 10:28:51 -07:00
sciencewhiz
fb3e0e1ecb [docs] Update readme to say git clone is required (#6603) 2024-05-12 10:27:56 -07:00
Tyler Veness
2e828ae053 [upstream_utils] Fix fmtlib tautological-compare warning from GCC 14 (#6613)
The patch is from upstream.
2024-05-12 10:27:01 -07:00
Tyler Veness
d3af27be94 [wpiunits] Fix Javadoc warning (#6614) 2024-05-12 10:25:44 -07:00
sciencewhiz
4cb2edbb98 [docs] Run Doc lint with JDK 21 (#6612) 2024-05-12 07:55:15 -07:00
Tyler Veness
d88c71ffdc [wpiutil] Upgrade to fmt 10.2.1, add wpi::print (#6161)
We now use a wrapper (wpi::print) to catch exceptions since we can't patch
std::print() to not throw when we ultimately migrate to it.

fmtlib and std format/print throw the same exceptions and always have. We previously patched fmt::print() to not throw a write failure exception, but we can't do that for std::print(); wpi::print() is the migration plan.
2024-05-12 06:25:42 -07:00
Sam Carlberg
6c9dcc157e [wpiunits] Change units to track their base unit, instead of their base class (#6342)
Unit objects now have a reference to the base unit from which they're derived. Constructing a unit object without specifying a base unit implicitly signifies that it's its own base unit, eg new Angle(null, 1, "Radian", "rad") would be the base angle unit of radians, while new Angle(Radians, 2 * PI, "Rotation", "R") would be a new angle unit based on radians.

This fixes much of the hacky code surrounding the derived unit types Velocity, Per, and Mult, but is a breaking change for any user code that defines custom unit classes or uses the anonymous unit type.
2024-05-12 06:15:56 -07:00
Tyler Veness
dc00a13d83 [wpimath] Make cost and covariance matrix functions constexpr (#6444) 2024-05-07 15:32:14 -07:00
Tyler Veness
bdc7344df1 [upstream_utils] Upgrade Eigen to get more constexpr support (#6596) 2024-05-07 12:47:15 -07:00
Isaac Turner
a6dd95eb9e [wpilib] Remove deprecated Gyro interface (#6567) 2024-05-06 21:54:39 -07:00
Wispy
2563ff9f18 [wpimath] Add Pair.equals() (#6580) 2024-05-06 21:52:59 -07:00
sciencewhiz
f77d01c085 [docs] Build javadocs with JDK 17 (#6588)
Remove JDK 11 javadocs workarounds.
Also update readme to say to install JDK 17.
2024-05-06 21:52:22 -07:00
Kaya
408980462f [commands] CommandScheduler: Provide function to print watchdog epochs (#6582) 2024-05-06 15:53:14 -07:00
Ryan Blue
2e71e85b8d switch CI to temurin jdk (#6592) 2024-05-06 13:37:09 -07:00
Isaac Turner
6a73ca8c08 [build] Change source compatibility to Java 17 (#6585) 2024-05-05 07:52:42 -07:00
Tyler Veness
9ed2f66914 [build] Bump macOS deployment target to 13 (#6548)
macOS 12 is EOL in mid-October of 2024 based on when macOS 11 was
dropped last year.
2024-05-04 11:11:10 -07:00
Isaac Turner
d3060d8eba [wpilib] IterativeRobotBase: Provide function to print watchdog epochs (#6581) 2024-05-04 10:19:36 -07:00
Vasista Vovveti
27babe5584 [ci] Comment on command PRs to open a RobotPy PR (#6574) 2024-05-04 08:37:45 -07:00
Ryan Blue
7596aeda10 [wpilib] GenericHID.setRumble: Fix Java integer overflow (#6529) 2024-05-04 08:36:40 -07:00
Isaac Turner
c76b358290 [ci] Update gradle wrapper validation action version (#6335) 2024-05-03 12:41:47 -07:00
Tim Winters
bad56bcbe8 [commands] Add StartRun command factory (#6572) 2024-05-03 12:40:13 -07:00
Tyler Veness
e172aa66f7 [wpimath] Java: add static instantiations of common rotations (#6563)
C++ doesn't need this because it supports value types, which are much
cheaper to construct. constexpr is also available to make construction
zero-cost.
2024-05-03 12:39:35 -07:00
Isaac Turner
9c7120e6bf [wpilibc] Remove deprecated Joystick angle functions (#6569) 2024-05-03 12:38:58 -07:00
Drew Williams
0afc35f336 [commands] Fix C++ SysIdRoutine crashing when passed nullptr or {} (#6508)
Flattens parameter from a `std::optional<std::function<...>>` to just a `std::function<...>`.  This is a breaking change but a trivial one for teams to fix.
2024-05-01 09:09:15 -07:00
Tyler Veness
ae4bcefefc [wpimath] Fix incorrect docs for Rotation3d default constructor (#6571)
A Rotation3d is not defined by one angle.
2024-05-01 09:06:13 -07:00
Isaac Turner
513d1a0a15 [wpilib] Remove deprecated Accelerometer interface (#6568) 2024-05-01 09:04:50 -07:00
Tyler Veness
a85e7693de [examples] Use UDL for turns (#6570) 2024-05-01 09:02:18 -07:00
Tyler Veness
5359112b15 [wpimath] Deprecate RamseteController (#6494)
LTVUnicycleController is a drop-in replacement with better tuning knobs.

The RamseteCommand examples were removed instead of retrofitted with
LTVUnicycleController because we're planning on removing the command
controller classes anyway, so it would be wasted effort. The
SimpleDifferentialDriveSimulation example shows direct
LTVUnicycleController usage.
2024-04-29 22:01:42 -07:00
Tyler Veness
7601b7250a [upstream_utils] Upgrade Sleipnir to use a small vector type (#6565)
This sped up ArmFeedforward.Calculate() by up to 2x.
2024-04-29 22:00:32 -07:00
DeltaDizzy
a9cfd0d0f9 [commands] Deprecate proxy supplier constructor (#6553) 2024-04-29 21:11:29 -07:00
Isaac Turner
c71db8ea9c [wpiutil] Remove old InterpolatingTreeMap location (#6560) 2024-04-29 21:05:12 -07:00
Isaac Turner
70417f64da [wpimath] Remove deprecated TrapezoidProfile constructors (#6558) 2024-04-29 21:04:57 -07:00
Isaac Turner
f5e08652f8 [wpimath] Remove deprecated MatBuilder factory (#6557) 2024-04-29 21:04:43 -07:00
Thad House
eec99eb653 [wpilibj] Fix AsynchronousInterrupt (#6564) 2024-04-29 21:04:24 -07:00
Isaac Turner
9cae707065 [wpilib] Remove deprecated SetHandler function (#6556) 2024-04-29 21:03:45 -07:00
Isaac Turner
0f8aa8aedf [commands] Remove CommandBase (#6545) 2024-04-28 12:04:51 -07:00
Ryan Heuer
ac32f921f6 [glass] Add math expression input for NetworkTables numerical values (#6530) 2024-04-28 12:03:49 -07:00
Isaac Turner
67fe11f9cd [commands] Rename deadlineWith to deadlineFor (#6544)
Deprecate deadlineWith for backwards compatibility.
2024-04-28 12:02:29 -07:00
Nicholas Armstrong
1ec089c7f9 [wpimath] Add ArmFeedforward calculate() overload that takes current and next velocity instead of acceleration (#6540)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-04-28 12:01:08 -07:00
Isaac Turner
1727c74b80 [ntcore] remove deprecated flag (#6551) 2024-04-28 06:17:39 -07:00
Isaac Turner
890185acee [ntcore] Remove deprecated delete function (#6552) 2024-04-28 06:15:19 -07:00
Tyler Veness
fd363fdf5a [wpimath] Add Sleipnir (#6541)
This is useful for solving quadratic programs.
2024-04-27 22:42:42 -07:00
DeltaDizzy
1e4a647918 [commands] Disambiguate ProxyCommand and DeferredCommand (#6324) 2024-04-27 22:41:04 -07:00
Wispy
39d33bfca6 [wpiunits] Adds FeetPerSecondPerSecond (#6543) 2024-04-27 21:08:13 -07:00
Isaac Turner
5edc652c05 [commands] Fix multiple C++ warnings (#6546) 2024-04-27 21:07:50 -07:00
Isaac Turner
d9eb3691d8 [commands] Remove deprecated TrapzoidProfileCommand api (#6547) 2024-04-27 21:07:23 -07:00
Tyler Veness
a42ffb8fa4 [ci] Bump wpiformat to 2024.34 (#6549) 2024-04-27 21:06:57 -07:00
Joseph Eng
d4e6a068ac [apriltag] Deprecate loadAprilTagLayoutField() (#6550) 2024-04-27 21:04:30 -07:00
Joseph Eng
cdfa2ece6f [wpimath] Add PoseEstimator.sampleAt() (#6426) 2024-04-27 21:03:37 -07:00
Isaac Turner
962bf7ff10 [ntcore] Backup persistent file if it fails to parse (#6523) 2024-04-27 07:04:27 -07:00
DeltaDizzy
2cd3935aa8 [sysid] Remove obsolete WPILib presets, rename CTRE presets (#6460) 2024-04-27 06:55:19 -07:00
Isaac Turner
427b7dcc11 README: Add python to languages (#6542) 2024-04-26 10:38:34 -07:00
Tyler Veness
e73050a8fa [wpimath] Templatize formatters (#6535)
This is required for compatibility with libc++'s std::format.
2024-04-25 16:08:24 -07:00
Nicholas Armstrong
3e6c0d0b71 [wpiunits] Add Acceleration and MOI Units (#6495) 2024-04-22 19:09:18 -07:00
Jacob Hotz
dc4c63568a [commands] Add Trigger.onChange() (#6390) 2024-04-21 22:37:15 -07:00
Ryan Blue
b620b6a4dd [apriltag] Cache layout loaded from AprilTagFields resource json (#6385) 2024-04-21 22:36:22 -07:00
Isaac Turner
d7dfa63ae9 [commands] WaitCommand: add Measure<Time> overload (#6386)
Also add waitTime() factory.
2024-04-21 22:34:52 -07:00
vichik
e89c8c1008 [wpiunits] Add isNear function implementation (#6396)
This implementation uses a tolerance in the same units as the measure it checks.
2024-04-21 20:40:33 -07:00
Juan Jose Chong
abfe2488ff [wpilib] Add flash update capability to ADI IMUs (#6450) 2024-04-21 20:39:53 -07:00
Gold856
3e5187ff32 [wpilibj] DataLogManager: Fix behavior when low on space (#6486)
Uses getUsableSpace in Java, matching how C++ determines available space (C++ calls it available, but they mean the same thing.) This fixes a bug where logs wouldn't get deleted due to incorrect available space detection.

The DataLog thread now also checks if the state was marked as stopped after a call to StartLogFile.
2024-04-21 20:34:05 -07:00
DeltaDizzy
7bc0380694 [commands] WrappedCommand: Call wrapped command initSendable (#6471) 2024-04-21 20:30:43 -07:00
Starlight220
98d2f45fa9 [commands] Fix double composition error truncation (#6501) 2024-04-21 20:28:04 -07:00
Isaac Turner
d14dfed828 [wpimath] Rotation2d: add Measure<Angle> getter (Java) (#6492) 2024-04-21 20:23:36 -07:00
HarryXChen
f26adc556d [examples] Fix memory over-allocation in Apriltag examples (#6517)
Change hamming distance to 1, add comment about memory usage.
2024-04-21 20:21:48 -07:00
Gold856
3c14d87006 Update README-CMAKE.md (#6522) 2024-04-21 20:21:07 -07:00
Isaac Turner
77536e68f0 README.md: Link straight to contributing in contents (#6525)
Avoids need to click twice to get to contributing.md.
2024-04-21 20:19:53 -07:00
Peter Johnson
c88be31ec2 Merge branch 'development' 2024-04-21 20:15:51 -07:00
Tyler Veness
74f648689e [build] Add exports to CMake subprojects (#6505)
This allows consuming allwpilib via FetchContent.
2024-04-10 22:04:22 -07:00
Tyler Veness
2def62a1ef [wpimath] Document ChassisSpeeds::Discretize() math (NFC) (#6509) 2024-04-10 22:03:44 -07:00
Tyler Veness
3a5d24ab1d [ci] Revert "Use mirror repository for liblzma (#6499)" (#6506)
This reverts commit c46847b32a.
2024-04-10 10:04:15 -07:00
Isaac Turner
02c78bc9b6 MAINTAINERS.md: Remove reference to marketplace (#6470) 2024-04-04 09:21:53 -07:00
Carl Hauser
998340296d [wpilibj] Fix EncoderSim.setDistancePerPulse parameter name and comment (NFC) (#6481) 2024-04-04 09:21:05 -07:00
Tyler Veness
d26e6d9ecc [wpimath] Support formatting Eigen array types (#6496) 2024-04-04 09:19:50 -07:00
Nicholas Armstrong
fbb3669546 [wpilib] LinearSystemSim: Add missing clamp function and getInput() (#6493) 2024-04-04 09:19:13 -07:00
Ryan Blue
c46847b32a [ci] Use mirror repository for liblzma (#6499)
Uses https://github.com/bminor/xz to work around suspended repository.

We will revert this once vcpkg updates to point to an accessible repo.
2024-04-04 09:18:06 -07:00
Peter Johnson
33f12f0e31 Revert "[commands] Cache button and POV triggers"
Also revert the associated formatting commit.  This was an accidental merge.
This reverts commit ff929d4a5f.
This reverts commit 2392c9f278.
2024-03-26 00:08:07 -07:00
sciencewhiz
25ad6eafd5 Add reference to development to CONTRIBUTING.md (#6467) 2024-03-24 23:52:36 -07:00
Isaac Turner
84a55d13f3 [ci] Fix 2023 docker image usage (#6459) 2024-03-24 23:51:38 -07:00
Wispy
4a548935d3 [wpimath] Add Pair.toString() (#6463) 2024-03-24 23:51:08 -07:00
Tyler Veness
85ea5f8497 [wpimath] Make more LinearSystemId functions not throw if Kv = 0 (#6465) 2024-03-24 23:50:41 -07:00
Gold856
c32e7db8e3 [wpiutil] DataLog: Don't constantly retry creating logs when low on space (#6468)
When low on space, a log file won't be created. This is detected as a "deletion", and the DataLog thread will continously try to create a log, fail to do so because of low space, detect it as a "deletion", and do so in a loop.

If there's not enough space, the DataLog will be marked as stopped, preventing this infinite loop. Calls to start() will hit this code path and mark it as stopped again.
2024-03-24 23:50:18 -07:00
Tyler Veness
2392c9f278 Run java format (#6462) 2024-03-22 09:50:28 -07:00
Peter Johnson
0dbdbb2aac Merge branch 'main' into development 2024-03-20 22:54:42 -07:00
Tyler Veness
b38540e1af [ci] Pin wpiformat version in comment command (#6458) 2024-03-20 22:53:52 -07:00
Peter Johnson
ff929d4a5f [commands] Cache button and POV triggers
This is a common footgun for teams.
2024-03-20 22:52:12 -07:00
Tyler Veness
b2113d3a9a [ci] Pin wpiformat version in comment command (#6457) 2024-03-20 22:50:55 -07:00
Tyler Veness
5370f249a1 [build] Upgrade to wpiformat 2024.33 (#6449)
This upgrades to clang-format and clang-tidy 18.1.1. This has the
constructor attribute formatting fix, so we can remove our
WPI_DEPRECATED macro.
2024-03-18 23:11:20 -07:00
Peter Johnson
74057543aa [glass] Don't limit window name+label to 128 chars (#6447) 2024-03-18 14:28:00 -07:00
Tyler Veness
b4674bacb9 [wpiutil] Upgrade to LLVM 18.1.1 (#6405) 2024-03-17 18:39:03 -07:00
Peter Johnson
fd4424eb89 Merge branch 'main' into development 2024-03-16 11:06:44 -07:00
Peter Johnson
c10f7d91b7 [ci] Work around asan actions bug (#6442) 2024-03-16 11:06:01 -07:00
person4268
0b13459469 [commands] Trigger: pass m_loop to new Trigger in composition functions (#6441) 2024-03-15 12:05:48 -07:00
Sam Richter
a1af2357e8 [ntcore] Fix memory leak in WebSocketConnection (#6439) 2024-03-15 11:50:30 -07:00
Dean Brettle
3116f790ea [sysid] Fix wrong position Kd with unnormalized time (#6433) 2024-03-12 21:49:28 -07:00
Tyler Veness
0e013dc021 [sysid] Fix "Sample" docs typo (NFC) (#6435) 2024-03-11 20:23:03 -07:00
sciencewhiz
f74f6f1d42 [docs] Add docs for features not supported on PDH (NFC) (#6436) 2024-03-11 20:22:33 -07:00
Peter Johnson
11c60df3e0 [hal] Use SIGKILL instead of SIGILL (#6431)
Fix typo.
2024-03-11 09:43:33 -07:00
Peter Johnson
3d9152a461 [hal] Raise SIGKILL instead of calling abort() (#6427)
We don't need to generate a core dump here if core dumps are enabled.
2024-03-10 20:32:54 -07:00
Peter Johnson
fbd239d15e [sim] GUI: Use shift to enable docking features (#6429) 2024-03-10 20:29:20 -07:00
Tyler Veness
7cd4a75323 [sysid] Fix crash on negative feedforward gains (#6425)
LinearSystemId's linear system factories throw on negative feedforward
gains, but SysId can compute the feedback gains just fine in that case.
Now we construct the system manually instead.

Fixes #6423.
2024-03-10 17:43:02 -07:00
Tyler Veness
973bb55e66 [wpimath] LinearSystemId: Don't throw if Kv = 0 (#6424)
That's just a system with no back-EMF.
2024-03-10 08:11:18 -07:00
DeltaDizzy
7bd8c44570 [wpimath] Add structured data support for DifferentialDriveWheelPositions (#6412) 2024-03-09 10:09:02 -08:00
Peter Johnson
38c128fe6a Merge branch 'main' into development 2024-03-09 09:57:55 -08:00
Peter Johnson
18e57f7872 [wpilibj] Call abort() on Rio on caught Java exception (#6420)
On Rio, we simply want to restart the robot program as quickly as possible,
and don't want to risk a hang somewhere that will keep that from happening.

The main downside of this is it won't wait for threads to finish (e.g. data logs won't get a final flush).
2024-03-09 09:55:49 -08:00
Tyler Veness
ccb4cbed63 [sysid] Fix arm characterization crash (#6422)
Fixes #6421.
2024-03-09 09:54:37 -08:00
Thad House
c19ee8b0fe [wpiutil, hal] Crash on failure for SetupNowRio() and wpi::Now() when not configured (#6417)
This is an unrecoverable condition, so always terminate.
2024-03-08 00:26:53 -08:00
Tyler Veness
e64c20346d [examples] Remove unused private variables (#6403) 2024-02-28 19:58:15 -08:00
Peter Johnson
f1a1ffd7fc [wpiutil] Rate-limit FPGA error from Now() (#6394) 2024-02-25 11:25:46 -08:00
Peter Johnson
c27ddf5ef9 [ci] Windows cmake: update vcpkg version (#6397)
We need fmtlib 10.2.1 to work around a compiler bug.

Also, reducing the number of jobs is no longer required with Actions runner upgrades.
2024-02-24 18:55:10 -08:00
Dean Brettle
8b669330eb [sysid] Fix position feedback latency compensation (#6392) 2024-02-23 14:13:43 -08:00
Tyler Veness
ca6e307ea5 [ci] Upgrade wpiformat (#6395) 2024-02-23 14:12:28 -08:00
DeltaDizzy
607682b687 [wpiunits] Fix Distance class javadocs to state the correct dimension (NFC) (#6363) 2024-02-19 12:58:56 -08:00
Peter Johnson
4b94a64b06 [glass] Fix FMS game data display and editing (#6381)
Also don't require Enter for editing game data or match time.
2024-02-18 16:29:58 -08:00
Thad House
63d9e945b8 [hal] HAL_RefreshDSData: Zero out control word on DS disconnect, use cache in sim (#6380) 2024-02-18 14:30:40 -08:00
Joseph Eng
0ad6b3acb3 [apriltag] Add AprilTagFieldLayout.loadField() (#6377) 2024-02-17 21:12:59 -08:00
Eli Barnett
02aed35c6e [sysid] Relax peak acceleration search (#6378) 2024-02-17 21:12:00 -08:00
Peter Johnson
a8a352ed8c [ntcore] Add hidden subscribe option (#6376)
This allows creating subscribers that aren't communicated with the network.
2024-02-17 00:40:14 -08:00
Peter Johnson
0cdab55e5b [ntcore] Don't send value update to client setting value (#6375) 2024-02-16 14:18:07 -08:00
Thad House
ba15844c28 [hal,wpiutil] Error out of HAL_Initialize if SetupRioNow fails (#6374) 2024-02-15 22:57:06 -08:00
shueja
6afff99640 [wpimath] ExponentialProfile: Return copy of input state (#6370)
As State is mutable, this avoids accidental modification of the passed-in object by the caller modifying the return value.
2024-02-15 16:32:51 -08:00
Tyler Veness
d4d0545dc1 [apriltag] Fix field length in 2024 JSON (#6373)
Fixes #6371
2024-02-15 10:42:03 -08:00
Thad House
9ed0631ec9 [cscore] Add BGRA support (#6365) 2024-02-12 23:42:17 -08:00
Thad House
fb947fe998 [cscore] Use Raw for CvSink and CvSource (#6364)
Eventually we want to get to a point where we can remove OpenCV from the internals of cscore. The start to doing that is converting the existing CvSource and CvSink methods to RawFrame.

For CvSource, this is 100% a free operation. We can do everything the existing code could have done (with one small exception we can fairly easily fix).

For CvSink, by defaut this change would incur one extra copy, but no extra allocations. A set of direct methods were added to CvSink to add a method to avoid this extra copy.
2024-02-12 22:33:03 -08:00
Joe Wildfong
6b6a55b72e [build] Fix tcpsockets header publishing (#6367) 2024-02-12 19:44:31 -08:00
fodfodfod
1e168f363e [wpimath] Feed forwards: Use correct 'k' value in error message (#6360) 2024-02-11 10:42:04 -08:00
DeltaDizzy
da3abade83 [examples] Add angular subsystem to SysIdRoutine example (#6297)
Co-authored-by: Tim Winters <twinters@wpi.edu>
2024-02-10 10:44:57 -08:00
Asa Paparo
62cba9a4d3 [wpimath] Add vector projection and geometry vector conversions (#6343) 2024-02-10 10:43:58 -08:00
N0tACyb0rg
3207795d0d [wpimath] Add lastValue() method to filters (#6351) 2024-02-10 10:43:23 -08:00
Joseph Eng
e506e09a06 [wpilibc] Const-qualify SendableChooser::GetSelected() (#6356) 2024-02-10 10:42:53 -08:00
Joseph Eng
163f7ee704 [wpilibc] SendableChooser: Remove unusable std::unique_ptr case (#6357) 2024-02-10 10:41:57 -08:00
Thad House
e9c744c456 [wpimath] Quaternion::Log(): Remove duplicate calls to norm() (#6358) 2024-02-10 10:41:19 -08:00
Kython89
300419c151 [wpilibc] SysIdRoutineLog: Initialize m_stateInitialized (#6359)
This caused non-deterministic behavior as to if the `sysid-test-state-` will appear in the log.
2024-02-10 10:40:38 -08:00
Tyler Veness
1db3936965 [wpimath] Remove unused include from RamseteController.cpp (#6346) 2024-02-05 22:43:50 -08:00
Tyler Veness
4f9d73783b [wpimath] Make units math functions constexpr (#6345) 2024-02-05 22:43:12 -08:00
Tyler Veness
3b2a2381b6 [ci] Upgrade to new macOS runner (#6328) 2024-02-04 10:38:23 -08:00
Ryan Blue
6cc7e52de7 [commands] TrapezoidProfileSubsystem: Fix incorrect ordering of parameters (#6338) 2024-02-01 20:24:43 -08:00
Sam Carlberg
d4533a8900 [wpilibj] AddressableLEDBuffer: Add methods for reading individual RGB values (#6333)
This avoids the allocation/GC overhead of returning a Color8 value.

Also add an indexed iterator forEach to loop over the entire buffer.
2024-02-01 14:01:53 -08:00
vichik
90bb6cfffa [wpiunits] Fix measure isNear function (#6313)
Now the function allows comparison between negative numbers, positive numbers or both.
2024-01-31 13:18:47 -08:00
Ryan Blue
cb094e4ff6 [examples] Don't reset encoders when resetting odometry (#6329) 2024-01-31 13:18:07 -08:00
Isaac Turner
60c6ed9812 [ci] Bump python, java and react script versions (#6325) 2024-01-31 13:17:41 -08:00
Tim Winters
ee15cc172a [commands] Reset timer in quasistatic SysIdRoutine test (#6322) 2024-01-27 23:51:00 -08:00
Joseph Eng
1016e95242 [examples] Fix memory leak in C++ controller command examples (#6306) 2024-01-27 23:49:41 -08:00
Sam Carlberg
19f1903959 [wpiunits] Add singularized aliases for built in units (#6323) 2024-01-27 23:47:59 -08:00
DeltaDizzy
53ebb6679e [examples] Move triggers to subsystem fields (#6318) 2024-01-27 23:47:06 -08:00
Tyler Veness
177132fa2a Replace C++ unit .to<double>() with .value() (#6317)
The latter is shorter and is what we use everywhere else.
2024-01-27 07:58:25 -08:00
Thad House
bbb230491a Force cpp files to be LF line endings (#6319)
Just marking a file as text will cause git to override the local core.autocrlf setting, and assume you want it to be true, which isn't what you want.
2024-01-26 23:20:51 -08:00
Tyler Veness
84ef71ace0 [wpimath] Make Rotation2d implicitly convert from any angle unit (#6316)
Add unit category concepts to support this.
2024-01-26 12:49:22 -08:00
Tyler Veness
68736d802d [wpimath] Clean up profile classes (#6311)
* Reorder functions so they match between languages
* Copy more complete JavaDocs to C++
* Fix incorrect description for time parameter of
  TrapezoidProfile.calculate()
2024-01-25 22:22:42 -08:00
Tyler Veness
d895a0c09f [wpiutil] Add std::expected shim (#6310)
Its tests use Catch2 instead of GoogleTest, so we can't import them.
2024-01-25 22:21:37 -08:00
sciencewhiz
64a9d413bf Update contributing for addition of Python (NFC) (#6307) 2024-01-25 21:31:57 -08:00
Chris Gerth
a70e83ae2e [glass] Update field size defaults in Field2D.cpp (#6298)
Looks like the field length is longer in 2024. Used the onshape model to measure the size.
2024-01-23 21:28:17 -08:00
Isaac Turner
47652d7a3c [commands] Remove unused headers (#6300) 2024-01-23 21:27:24 -08:00
Tyler Veness
be78552db7 [sysid] Fix SSTO calculation (#6301) 2024-01-23 21:26:49 -08:00
Peter Johnson
3acae550d6 [ntcore] StructArrayTopic: Publish schema in span-taking setters (#6303) 2024-01-23 21:26:06 -08:00
Thad House
9d55941ce5 [build] Fix macOS apps not always being an application (#6286) 2024-01-21 20:41:08 -08:00
Peter Johnson
51d92c7027 [build] Fix compilation with musl (#6289) 2024-01-21 20:32:56 -08:00
Peter Johnson
9206b47d67 [wpilibc] ADIS16448, ADIS16470: Initialize member pointers (#6282) 2024-01-21 11:49:32 -08:00
Dustin Spicuzza
6fc16264ce [ntcore] NetworkTable: Actually use the I parameter for structs (#6280) 2024-01-21 10:57:11 -08:00
Peter Johnson
ad18f35477 [ntcore] Map int[] to int64[] for DataLog (#6279) 2024-01-21 00:50:27 -08:00
Thad House
0c6bd846bc [hal] Use 64 bit timestamp in DMA (#6278) 2024-01-20 22:34:03 -08:00
Asa Paparo
19c1556472 [commands] Fix SysIdRoutine naming (#6277)
Previously, this used mechanism.m_subsystem.getName(), instead of mechanism.m_name, meaning differently named SysId routines from the same subsystem would clobber each other when logged.
2024-01-20 22:10:19 -08:00
Peter Johnson
3928ed5647 [sim] Sim GUI DS: Add "Disconnected" state and start in it (#6218)
The default state for the DS in the simulated HAL is changed to disconnected.

The FMS view is now only editable in DS disconnected state.

This enables more robot and field-like testing of robot code, as the
alliance color and other parameters start in invalid states and are
only set when the DS connects.
2024-01-20 21:10:02 -08:00
Thad House
e408f3ad27 [rtns] Add functionality to enable and disable webserver (#6270) 2024-01-20 20:15:30 -08:00
Thad House
7957f4a625 [hal] Don't write a 0 length led string to the FPGA (#6271)
Due to something weird in the FPGA, calling strobeLoad() with a string length of 0 causes both CPUs to spin at 100%, basically shutting down everything else on the robot.

If a 0 length string happens to be passed, just bail out early.
2024-01-20 09:32:16 -08:00
Peter Johnson
1241dfdf68 [outlineviewer] Reduce NT log level 2024-01-20 07:24:16 -08:00
Peter Johnson
4d109309c9 [glass] Reduce NT log level 2024-01-20 07:24:16 -08:00
Peter Johnson
7560d18e09 [ntcore] Enable uv/WS debugging 2024-01-20 07:24:16 -08:00
Peter Johnson
f518e143d0 [wpinet] WebSocket: Utilize uv::Handle logging 2024-01-20 07:24:16 -08:00
Peter Johnson
6fab87fa4c [wpinet] uv::Stream: Add logging for Write and TryWrite 2024-01-20 07:24:16 -08:00
Peter Johnson
42c41785ac [wpinet] uv::Handle: Add wpi::Logger support
This allows the uv wrappers and any related classes to log directly to
a wpi::Logger.
2024-01-20 07:24:16 -08:00
Peter Johnson
1a7eeb6282 [ntcore] Enhance WebSocketConnection debug logging 2024-01-20 07:24:16 -08:00
Peter Johnson
98c0827236 [wpinet] WebSocket: serializer bugfixes (#6264) 2024-01-20 00:38:56 -08:00
Peter Johnson
57aa8ca0dd [ci] Unlimit Windows Gradle workers (#6268)
With the GitHub upgrade to 16 GB RAM, this should no longer be needed.
2024-01-19 23:56:00 -08:00
Peter Johnson
789af2ad26 [ntcore] Use last received time instead of last ping response
This relaxes the timeout constraint for long message transmissions.
2024-01-19 23:45:01 -08:00
Peter Johnson
9a5366bb83 [wpiutil] WebSocket: Add GetLastReceivedTime
This allows getting the timestamp that any data has been received.
2024-01-19 23:45:01 -08:00
Tyler Veness
77c09b9ce2 [docs] Build with JavaDoc 17 and add missing docs (#6220)
Co-authored-by: Sam Carlberg <sam.carlberg@gmail.com>
2024-01-19 23:42:09 -08:00
Peter Johnson
9ec27c1202 [ntcore] Don't disconnect with 1005 error code (#6265) 2024-01-19 23:34:25 -08:00
Peter Johnson
d653408873 [ntcore] Fix large text message splitting (#6263)
The written amount wasn't being tracked in the common case, so bulk
announcements after a subscribe would result in a very large WebSocket
frame.
2024-01-19 23:15:25 -08:00
Peter Johnson
24a24c9051 [wpinet] WebSocket: Improve disconnect reason reporting (#6262)
Add "remote close:" to messages coming from the remote end.
Previously it was impossible to tell if the error was on the local side
or communicated by the remote side.
2024-01-19 23:13:38 -08:00
Thad House
0e5eb3f35c [wpiutil] Fix DynamicStruct string handling (#6253)
Dynamic structs had a few major issues.

In C++, if the string was the last definition in the schema, attempting to set a string would trigger an assertion. This has been fixed

Setting a string value could truncate the string actually stored in the struct, if the definition was shorter than the string to set.
There was no way to detect if this case occurred. The set string function now returns a bool if the string was fully written or not.

Reading a string that had a value shorter than the schema definition would result in embedded trailing nulls in the string. This would make comparing string equality basically impossible, as those embedded nulls count for the length of the string.

The above truncating didn't take into account UTF8 code points. This means a truncation could happen in the middle of a unicode character. Depending on the language this had different behavior, but unpaired code points are problematic to detect in any case. On the decoding side, detect if a split UTF8 code point has occurred by the writer, and if so just ignore it and treat it as not part of the string. Doing this on the receive side means a newer receive side is all that is needed to fix this, which is generally a better option then requiring all senders to update.

Actual DynamicStruct instances have 0 units tests for them. Added a bunch of unit tests around strings to ensure things work properly.
2024-01-19 22:24:54 -08:00
Tyler Veness
4b15c73f64 [sysid] Rename motion threshold to velocity threshold to match GUI field name (#6240) 2024-01-19 22:23:51 -08:00
David Vo
a274e297cd Fix trivial errorprone warnings (NFC) (#6135) 2024-01-19 20:46:38 -08:00
David Vo
d198605562 [wpilibc] SysIdRoutineLog: Fix state log entry name typo (#6261)
The Java version has a hyphen between test-state and the mechanism name.
2024-01-19 20:42:57 -08:00
Thad House
dfaad7ca22 [ntcore] Add typed C GetEntryValue and ReadQueueValue functions (#6256) 2024-01-19 20:38:01 -08:00
Tyler Veness
2df82ec957 [sysid] Document using AdvantageScope for troubleshooting (#6247) 2024-01-19 20:37:27 -08:00
Thad House
3661f485af [wpilibj] Don't automatically pull in cscore for all robot projects (#6245) 2024-01-19 20:37:02 -08:00
Thad House
7f9389f101 [wpiutil] DataLog: Remove extra entry parameter from C AddSchema functions (#6246) 2024-01-19 20:35:44 -08:00
Tyler Veness
ca35bcd827 [wpimath] Use tolerance in rotation interpolation tests (#6237) 2024-01-19 20:35:13 -08:00
Tyler Veness
9227d09960 [wpilib] Fix outdated DifferentialDrive docs (#6249)
They accidentally got reverted when undeprecating MotorController in the
review process for #6053.
2024-01-19 20:34:58 -08:00
swirl
370126db38 [build] cmake: add wpinet dependency to cscore-config.cmake (#6242)
Attempting to build with cscore results in the project being unable to find wpinet unless explicitly found with `find_package` earlier.
2024-01-19 20:34:36 -08:00
HarryXChen
1330235918 [sysid] Show warning tooltips next to bad feedforward gains instead of throwing (#6251)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-01-19 20:33:56 -08:00
Jonah
d392570659 [wpilib] SysIdRoutineLog: Defer creation of state log entry (#6259) 2024-01-19 17:43:18 -08:00
Thad House
a2d45dbca4 [wpiutil] DataLog: Add AddSchema functions to C API (#6232) 2024-01-15 23:34:18 -08:00
Isaac Turner
30965b20cf [wpilibc] Use std::atomic in ADIS classes (#6217) 2024-01-15 22:42:19 -08:00
Thad House
5bc942f532 [wpiutil] StructArrayLogEntry: Use the same lock everywhere (#6231) 2024-01-15 22:41:31 -08:00
Tyler Veness
97828bd325 [sysid] Remove unused "gains to encoder counts" checkbox (#6234) 2024-01-15 22:40:45 -08:00
sciencewhiz
6da21c4943 [examples] Fix typo in AprilTag example (NFC) (#6230) 2024-01-14 20:51:52 -08:00
Peter Johnson
ecf1755e3e [glass] Default to 2024 field image (#6225)
Also relax field scale check a bit so 2024 field image passes.
2024-01-14 14:47:54 -08:00
sciencewhiz
154d920e67 [examples] Limit error bit correction in April Tag examples (#6224)
Values >3 are not supported. 64be6ab26a/apriltag.c (L261-L266)
2024-01-13 23:03:58 -08:00
sciencewhiz
d2ee423749 [fieldImages] Use Miklast high resolution field render (#6185)
Image from https://www.chiefdelphi.com/t/2024-crescendo-top-down-field-renders/447764

Imaged cropped to use less space.
2024-01-13 22:28:58 -08:00
Peter Johnson
7e3678b0a4 [glass] Fix Field2d position and scaling (#6222)
Also adds some border padding for the non-image case.
2024-01-13 21:09:02 -08:00
Tyler Veness
4a55d830e4 [wpilibcExamples] Remove redundant initializer (#6212) 2024-01-13 14:09:26 -08:00
Ben Goldberg
420020c0d5 [wpimath] Remove unused include in Quaternion.cpp (#6219) 2024-01-13 08:48:43 -08:00
Eli Barnett
077c8f4092 [sysid] Fix test duration slider responsiveness (#6216) 2024-01-12 23:05:46 -08:00
HarryXChen
84e3a22baa [sysid] Fix peak acceleration filtering behavior in dynamic velocity test (#6207) 2024-01-12 17:05:50 -08:00
Tyler Veness
b482321c0d [commands] Replace SysId hash map with if statements (#6209)
This is much more efficient.
2024-01-12 12:36:59 -08:00
Isaac Turner
d181e353a0 [wpilib] ADIS16470: Add no-param GetAngle and GetRate (#6184)
This helps with backwards compatibility.
2024-01-12 11:00:42 -08:00
Peter Johnson
2386e44f3a [sysid] Filter valid test names (#6200)
Currently the analysis portion only supports quasistatic and dynamic,
forward and reverse. Check for anything not matching and remove it,
along with providing diagnostics of what is being loaded.
2024-01-12 10:58:57 -08:00
Isaac Turner
fa5b604f16 [wpilibc] Remove unused includes (#6208) 2024-01-12 10:58:35 -08:00
Tyler Veness
67e8306819 gitattributes: Mark C++ source files as text (#6210)
Some C++ files had been checked in with CRLF line endings.
This fixes those and also fixes future commits.
2024-01-12 10:53:56 -08:00
Thad House
1981b8debd Fix multiple Java warnings (#6201) 2024-01-12 08:46:21 -08:00
Tyler Veness
ba9c21cf38 [wpilib] Fix SysId log key for acceleration (#6196)
Also add to docs that logging acceleration and current is optional.
2024-01-10 20:48:23 -08:00
Tyler Veness
211c2a375c [build] Run formatter on generate_usage_reporting.py (#6197) 2024-01-10 20:47:54 -08:00
Peter Johnson
75b2fa1cc3 [sysid] Data selector: use timestamps instead of ranges (#6193)
This is somewhat slower, but handles data files that are organized
differently (e.g. entries grouped instead of purely sorted by time).
2024-01-10 20:13:19 -08:00
Chris Gerth
84b089b209 [ntcore] Update alloy-model.adoc (NFC) (#6191)
URL changed
2024-01-10 11:11:35 -08:00
Peter Johnson
ce550705d7 [ntcore] Fix client "received unknown id -1" (#6186)
This was caused by not swallowing id=-1 messages after processing the
first one.
2024-01-09 14:13:05 -08:00
Peter Johnson
3989617bde [ntcore] NetworkTable::GetStruct: Add I template param (#6183) 2024-01-09 12:39:47 -08:00
sciencewhiz
f1836e1321 [fieldImages] Fix 2024 field json (#6179)
Field corners and field size were identical to 2023.
2024-01-08 19:27:55 -08:00
David Vo
d05f179a9a [build] Fix running apriltagsvision Java example (#6173) 2024-01-07 22:51:55 -08:00
sciencewhiz
b1b03bed85 [wpilib] Update MotorControllerGroup deprecation message (#6171)
The current message could be read as encouraging the use of CAN motor
controllers. This tries to make it more clear.
2024-01-07 17:06:26 -08:00
Michael Leong
fa63fbf446 LICENSE.md: Bump year to 2024 (#6169) 2024-01-07 07:17:41 -08:00
Tyler Veness
4809f3d0fc [apriltag] Add 2024 AprilTag locations (#6168) 2024-01-06 12:50:27 -08:00
Peter Johnson
dd90965362 [wpiutil] Fix RawFrame.setInfo() NPE (#6167) 2024-01-06 12:50:11 -08:00
sciencewhiz
8659372d08 [fieldImages] Add 2024 field image (#6166) 2024-01-06 12:06:15 -08:00
Eli Barnett
a2e4d0b15d [docs] Fix docs for SysID routine (#6164) 2024-01-05 22:05:09 -08:00
Tyler Veness
0a46a3a618 [wpilib] Make ADXL345 default I2C address public (#6163)
pybind needs it.
2024-01-05 16:59:30 -08:00
Peter Johnson
7c26bc70ab [sysid] Load DataLog files directly for analysis (#6103)
Co-authored-by: Oblarg <emichaelbrnett@gmail.com>
2024-01-05 16:24:31 -08:00
Tyler Veness
f94e3d81b9 [docs] Fix SysId routine JavaDoc warnings (#6159) 2024-01-05 16:03:52 -08:00
Tyler Veness
6bed82a18e [wpilibc] Clean up C++ SysId routine (#6160) 2024-01-05 15:22:52 -08:00
Starlight220
4595f84719 [wpilib] Report LiveWindow-enabled-in-test (#6158) 2024-01-05 11:57:14 -08:00
Eli Barnett
707cb06105 [wpilib] Add SysIdRoutine logging utility and command factory (#6033)
Co-authored-by: Drew Williams <williams.r.drew@gmail.com>
Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-01-05 11:50:23 -08:00
Starlight220
3e40b9e5da [wpilib] Correct SmartDashboard usage reporting (#6157) 2024-01-05 11:18:29 -08:00
Tyler Veness
106518c3f8 [docs] Fix wpilibj JavaDoc warnings (#6154) 2024-01-05 07:35:59 -08:00
Tyler Veness
19cb2a8eb4 [wpilibj] Make class variables private to match C++ (#6153) 2024-01-05 00:59:34 -08:00
m10653
13f4460e00 [docs] Add missing docs to enum fields (NFC) (#6150)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2024-01-04 21:36:26 -08:00
Tyler Veness
4210f5635d [docs] Fix warnings about undocumented default constructors (#6151) 2024-01-04 13:57:21 -08:00
Peter Johnson
0f060afb55 [ntcore] Disable WebSocket fragmentation (#6149)
There seems to be a latent bug in the fragmentation code that we've not
been able to isolate.
2024-01-04 12:09:31 -08:00
Tyler Veness
f29a7d2e50 [docs] Add missing JavaDocs (#6146) 2024-01-04 08:38:06 -08:00
Tyler Veness
6e58db398d [commands] Make Java fields private (#6148)
They were already private in C++ and probably shouldn't be exposed. This
also means we don't need to write redundant documentation for them.
2024-01-04 00:57:52 -08:00
Gold856
4ac0720385 [build] Clean up CMake files (#6141) 2024-01-04 00:47:47 -08:00
Tyler Veness
44db3e0ac0 [sysid] Make constexpr variables outside class scope inline (#6145) 2024-01-03 14:27:51 -08:00
Peter Johnson
73c7d87db7 [glass] NTStringChooser: Properly set retained (#6144) 2024-01-03 09:38:10 -08:00
David Vo
25636b712f [build] Remove unnecessary native dependencies in wpilibjExamples (#6143)
These dependencies don't have any JNI, so there's no need to link them.
2024-01-02 20:14:37 -08:00
m10653
01fb98baaa [docs] Add Missing JNI docs from C++ (NFC) (#6139) 2024-01-02 20:13:46 -08:00
David Vo
5c424248c4 [wpilibj] Remove unused AnalogTriggerException (#6142) 2024-01-02 20:10:51 -08:00
Tyler Veness
c486972c55 [wpimath] Make ExponentialProfile.State mutable (#6138)
It was already mutable in the C++ ExponentialProfile and
TrapezoidProfile in both languages.
2024-01-02 11:39:55 -08:00
David Vo
783acb9b72 [wpilibj] Store long preferences as integers (#6136) 2024-01-01 23:38:02 -08:00
m10653
99ab836894 [wpiutil] Add missing JavaDocs (NFC) (#6132) 2024-01-01 23:37:39 -08:00
Tyler Veness
ad0859a8c9 [docs] Add missing JavaDocs (#6125) 2024-01-01 22:56:23 -08:00
Gold856
5579219716 [docs] Exclude quickbuf files and proto/struct packages from doclint (#6128) 2024-01-01 21:23:09 -08:00
Tyler Veness
98f06911c7 [sysid] Use eigenvector component instead of eigenvalue for fit quality check (#6131)
They're usually close, but this is a better metric.
2024-01-01 21:22:34 -08:00
Braykoff
e1d49b975c [wpimath] Add LinearFilter reset() overload to initialize input and output buffers (#6133) 2024-01-01 21:20:53 -08:00
m10653
8a0bf2b7a4 [hal] Add CANAPITypes to java (#6121) 2024-01-01 16:51:17 -08:00
Tyler Veness
91d8837c11 [wpilib] Make protected fields in accelerometers/gyros private (#6134)
This avoids needing add redundant JavaDocs to them, and better reflects
how we design our modern classes (the classes modified here were around
with minimal changes since 2008 or so).
2024-01-01 16:49:50 -08:00
Tyler Veness
e7c9f27683 [wpilib] Add functional interface equivalents to MotorController (#6053)
This does not deprecate any current functionality, but prepares the way for future deprecation.

The drive classes now accept void(double) functions, which makes them more flexible.

The C++ API ended up a bit more verbose, but the Java API is really concise with method references, which is >80% of our userbase. For example:

`DifferentialDrive drive = new DifferentialDrive(m_leftMotor::set, m_rightMotor::set);`

Lambdas can be passed to interoperate with vendor motor controller APIs that don't have e.g., set(double), so CTRE doesn't have to maintain their WPI_ classes anymore.

MotorControllerGroup was replaced with PWMMotorController.addFollower() for PWM motor controllers. Users of CAN motor controllers should use their vendor's follower functionality.
2024-01-01 13:37:51 -08:00
m10653
8aca706217 [glass] Add type information to SmartDashboard menu (#6117) 2024-01-01 11:58:13 -08:00
sciencewhiz
7d3e4ddba9 [docs] Add warning about using user button to docs (NFC) (#6129) 2024-01-01 11:53:21 -08:00
Tyler Veness
ec3cb3dcba [build] Disable clang-tidy warning about test case names (#6127)
These are the warnings being disabled:
```
== clang-tidy /__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp ==
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:51:16: warning: avoid using "_" in test name "NonInvertibleA_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
   51 | TEST(DARETest, NonInvertibleA_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:67:16: warning: avoid using "_" in test name "NonInvertibleA_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
   67 | TEST(DARETest, NonInvertibleA_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:89:16: warning: avoid using "_" in test name "InvertibleA_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
   89 | TEST(DARETest, InvertibleA_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:101:16: warning: avoid using "_" in test name "InvertibleA_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  101 | TEST(DARETest, InvertibleA_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:118:16: warning: avoid using "_" in test name "FirstGeneralizedEigenvalueOfSTIsStable_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  118 | TEST(DARETest, FirstGeneralizedEigenvalueOfSTIsStable_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:132:16: warning: avoid using "_" in test name "FirstGeneralizedEigenvalueOfSTIsStable_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  132 | TEST(DARETest, FirstGeneralizedEigenvalueOfSTIsStable_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:151:16: warning: avoid using "_" in test name "IdentitySystem_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  151 | TEST(DARETest, IdentitySystem_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:163:16: warning: avoid using "_" in test name "IdentitySystem_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  163 | TEST(DARETest, IdentitySystem_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:176:16: warning: avoid using "_" in test name "MoreInputsThanStates_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  176 | TEST(DARETest, MoreInputsThanStates_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:188:16: warning: avoid using "_" in test name "MoreInputsThanStates_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  188 | TEST(DARETest, MoreInputsThanStates_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:201:16: warning: avoid using "_" in test name "QNotSymmetricPositiveSemidefinite_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  201 | TEST(DARETest, QNotSymmetricPositiveSemidefinite_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:210:16: warning: avoid using "_" in test name "QNotSymmetricPositiveSemidefinite_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  210 | TEST(DARETest, QNotSymmetricPositiveSemidefinite_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:220:16: warning: avoid using "_" in test name "RNotSymmetricPositiveDefinite_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  220 | TEST(DARETest, RNotSymmetricPositiveDefinite_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:232:16: warning: avoid using "_" in test name "RNotSymmetricPositiveDefinite_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  232 | TEST(DARETest, RNotSymmetricPositiveDefinite_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:245:16: warning: avoid using "_" in test name "ABNotStabilizable_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  245 | TEST(DARETest, ABNotStabilizable_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:254:16: warning: avoid using "_" in test name "ABNotStabilizable_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  254 | TEST(DARETest, ABNotStabilizable_ABQRN) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:264:16: warning: avoid using "_" in test name "ACNotDetectable_ABQR" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  264 | TEST(DARETest, ACNotDetectable_ABQR) {
      |                ^
/__w/allwpilib/allwpilib/wpimath/src/test/native/cpp/DARETest.cpp:273:16: warning: avoid using "_" in test name "ACNotDetectable_ABQRN" according to Googletest FAQ [google-readability-avoid-underscore-in-googletest-name]
  273 | TEST(DARETest, ACNotDetectable_ABQRN) {
      |                ^
```
2023-12-31 23:25:05 -08:00
sciencewhiz
495585b25d [examples] Update april tag family to 36h11 (#6126)
Changes size to 6.5 inches per https://www.firstinspires.org/robotics/frc/blog/2023-technology-updates-past-present-future-and-beyond
Uses 7 error bit correction as recommended in PhotonVision docs.
2023-12-31 22:46:31 -08:00
Thad House
f9aabc5ab2 [wpilib] Throw early when EventLoop is modified while running (#6115) 2023-12-31 22:45:10 -08:00
m10653
c16946c0ec [hal] Add CANJNI docs (NFC) (#6120) 2023-12-31 22:44:27 -08:00
sciencewhiz
b7f4eb2811 [doc] Update maven artifacts for units and apriltags (NFC) (#6123) 2023-12-31 22:43:43 -08:00
sciencewhiz
f419a62b38 [doc] Update maintainers.md (NFC) (#6124)
Update third party artifacts
Update installer publishing
Fixes #6106
2023-12-31 22:43:20 -08:00
Joseph Eng
938bf45fd9 [wpiutil] Remove type param from ProtobufSerializable and StructSerializable (#6122) 2023-12-31 14:36:11 -08:00
Tyler Veness
c34debe012 [docs] Link to external OpenCV docs (#6119)
This avoids thousands of warnings from JavaDoc 17 parsing the OpenCV
source.
2023-12-30 21:09:07 -06:00
David Vo
07183765de [hal] Fix formatting of HAL_ENUM enums (NFC) (#6114) 2023-12-30 09:22:46 -06:00
Thad House
af46034b7f [wpilib] Document only first party controllers are guaranteed to have correct mapping (#6112) 2023-12-30 09:16:59 -06:00
Thad House
636ef58d94 [hal] Properly error check readCANStreamSession (#6108) 2023-12-29 23:57:00 -06:00
Thad House
cc631d2a69 [build] Fix generated source set location in the HAL (#6113) 2023-12-29 23:56:38 -06:00
Tyler Veness
09f76b32c2 [wpimath] Compile with UTF-8 encoding (#6111)
This allows using Greek letters in variable names, which is helpful to
make implemented equations follow their source paper more closely.
2023-12-29 23:56:06 -06:00
Tyler Veness
47c5fd8620 [sysid] Check data quality before OLS (#6110) 2023-12-29 23:31:27 -06:00
Thad House
24a76be694 [hal] Add method to detect if the CAN Stream has overflowed (#6105) 2023-12-29 09:10:48 -08:00
Thad House
9333951736 [hal] Allocate CANStreamMessage in JNI if null (#6107) 2023-12-29 00:50:57 -06:00
Peter Johnson
6a2d3c30a6 [wpiutil] Struct: Add info template parameter pack (#6086)
This allows using Struct in a dynamically typed environment by passing
additional information to the Struct serialization functions.
2023-12-27 09:52:18 -06:00
Tyler Veness
e07de37e64 [commands] Mark ParallelDeadlineGroup.setDeadline() final (#6102)
Suppress this-escape warning.
2023-12-27 09:51:16 -06:00
Gold856
141241d2d6 [wpilib] Fix usage reporting for static classes (#6090) 2023-12-26 23:16:55 -06:00
Tyler Veness
f2c2bab7dc [sysid] Fix adjusted R² calculation (#6101)
It hardcoded p to 2.
2023-12-26 22:06:10 -06:00
Peter Johnson
5659038443 [wpiutil,cscore,apriltag] Fix RawFrame (#6098) 2023-12-26 22:05:02 -06:00
Joseph Eng
8aeee03626 [commands] Improve error message when composing commands twice in same composition (#6091)
Also disallow deadline command from also appearing in other commands.
2023-12-26 18:07:16 -08:00
Peter Johnson
55508706ff [wpiutil,cscore] Move VideoMode.PixelFormat to wpiutil (#6097)
This tracks the RawFrame move.
2023-12-26 16:47:17 -06:00
Bryce Roethel
ab78b930e9 [wpilib] ADIS16470: Add access to all 3 axes (#6074) 2023-12-26 13:39:37 -08:00
Tyler Veness
795d4be9fd [wpilib] Fix precision issue in Color round-and-clamp (#6100) 2023-12-26 13:38:15 -08:00
Joseph Eng
7aa9ad44b8 [commands] Deprecate C++ TransferOwnership() (#6095)
It has been completely replaced with ToPtr().
2023-12-26 15:14:34 -06:00
David Vo
92c81d0791 [ci] Update pregenerate workflow to actions/checkout@v4 (#6094) 2023-12-25 08:03:03 -06:00
David Vo
1ce617be07 [ci] Update artifact actions to v4 (#6092) 2023-12-24 11:51:53 -06:00
sciencewhiz
2441b57156 [wpilib] Add PWMSparkFlex MotorController (#6089) 2023-12-24 01:47:38 -06:00
Peter Johnson
21d1972d7a [wpiutil] DataLog: Ensure file is written on shutdown (#6087)
Previously the thread could end without the file being written.
2023-12-23 15:40:51 -06:00
Peter Johnson
c29e8c66cf [wpiutil] DataLog: Fix UB in AppendImpl (#6088) 2023-12-23 15:39:39 -06:00
truher
ab309e34ef [glass] Fix order of loading window settings (#6056) 2023-12-23 13:12:09 -08:00
Tyler Veness
22a322c9f3 [wpimath] Report error on negative PID gains (#6055)
Defaults PID gains to zero if any are invalid.
2023-12-23 12:15:29 -08:00
Asa Anderson
1dba26c937 [wpilib] Add method to get breaker fault at a specific channel in PowerDistribution[Sticky]Faults (#5521)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2023-12-23 12:14:13 -08:00
Ryan Blue
ef1cb3f41e [commands] Fix compose-while-scheduled issue and test all compositions (#5581) 2023-12-23 12:12:13 -08:00
Peter Johnson
aeb1a4aa33 [wpiutil] Add serializable marker interfaces (#6060) 2023-12-23 08:20:26 -08:00
NC GEARS FRC 1918
c1178d5add [wpilib] Add StadiaController and command wrapper (#6083) 2023-12-23 08:15:05 -08:00
ncorrea210
4e4a468d4d [wpimath] Make feedforward classes throw exceptions for negative Kv or Ka (#6084) 2023-12-23 08:12:46 -08:00
swirl
d1793f077d [build] cmake: Add NO_WERROR option to disable -Werror (#6071) 2023-12-22 14:38:38 -06:00
m10653
43fb6e9f87 [glass] Add Profiled PID controller support & IZone Support (#5959) 2023-12-22 11:29:25 -08:00
Drew Williams
bcef6c5398 [apriltag] Fix Java generation functions (#6063) 2023-12-22 11:03:02 -08:00
Ryan Blue
4059e0cd9f [hal,wpilib] Add function to control "Radio" LED (#6073) 2023-12-22 10:57:52 -08:00
Ryan Blue
0b2cfb3abc [dlt] Change datalogtool default folder to logs folder (#6079)
Also fix straggling documentation.
2023-12-22 10:54:17 -08:00
Tyler Veness
df5e439b0c [wpilib] PS4Controller: enable usage reporting (#6081) 2023-12-22 12:33:03 -06:00
Thad House
0ff7478968 [cscore] Fix RawFrame class not being loaded in JNI (#6077) 2023-12-21 19:58:12 -06:00
sciencewhiz
6f23d32fe1 [wpilib] AddressableLED: Update warning about single driver (NFC) (#6069)
Say that multiple strips can be used in series.
2023-12-20 22:32:16 -06:00
Isaac Turner
35a1c52788 [build] Upgrade quickbuf to 1.3.3 (#6072) 2023-12-20 22:30:45 -06:00
Tyler Veness
e4e2bafdb1 [sysid] Document timestamp units (#6065) 2023-12-19 22:37:41 -08:00
Peter Johnson
3d201c71f7 [ntcore] Fix overlapping subscriber handling (#6067) 2023-12-19 22:37:16 -08:00
Peter Johnson
f02984159f [glass] Check for null entries when updating struct/proto (#6059) 2023-12-18 11:31:08 -08:00
Eli Barnett
a004c9e05f [commands] SubsystemBase: allow setting name in constructor (#6052) 2023-12-16 11:05:53 -08:00
Tyler Veness
0b4c6a1546 [wpimath] Add more docs to SimulatedAnnealing (NFC) (#6054) 2023-12-16 11:03:54 -08:00
Tyler Veness
ab15dae887 [wpilib] ArcadeDrive: Fix max output handling (#6051) 2023-12-15 09:18:45 -08:00
Guinea Wheek
9599c1f56f [hal] Add usage reporting ids from 2024v2 image (#6041) 2023-12-14 20:53:40 -08:00
Gold856
f87c64af8a [wpimath] MecanumDriveWheelSpeeds: Fix desaturate() (#6040) 2023-12-14 20:52:45 -08:00
ncorrea210
8798700cec [wpilibcExamples] Add inline specifier to constexpr constants (#6049) 2023-12-14 20:52:02 -08:00
Thad House
85c9ae6eff [wpilib] Fix PS5 Controller mappings (#6050) 2023-12-14 20:51:32 -08:00
Thad House
7c8b7a97ad [wpiutil] Zero out roborio system timestamp (#6042)
There was also an issue where the clock zero offset would be incorrect due to the system time updating. This solves that issue for the Rio.
2023-12-13 15:20:24 -08:00
Peter Johnson
d9b504bc84 [wpilib] DataLogManager: Change sim location to logs subdir (#6039) 2023-12-11 20:21:06 -08:00
Peter Johnson
906b810136 [build] cmake: Fix ntcore generated header install (#6038) 2023-12-11 20:02:29 -08:00
Thad House
56e5b404d1 Update to final 2024 V2 image (#6034)
Update myRobot java command args
2023-12-10 23:52:28 -08:00
Joseph Eng
8723ee5c39 [ntcore] Add cached topic property (#5494) 2023-12-10 23:23:36 -08:00
Tyler Veness
192a28af47 Fix JDK 21 warnings (#6028) 2023-12-09 21:45:02 -08:00
Tyler Veness
d40bdd70ba [build] Upgrade to spotbugs Gradle plugin 6.0.2 (#6027) 2023-12-09 15:34:29 -08:00
Isaac Turner
7bfadf32e5 [wpilibj] Joystick: make remainder of get axis methods final (#6024) 2023-12-09 09:47:10 -08:00
Starlight220
a770110438 [commands] CommandCompositionError: Include stacktrace of original composition (#5984) 2023-12-09 09:45:02 -08:00
Thad House
54a55b8b53 [wpiutil,hal] Update image; init Rio Now() HMB with a FPGA session (#6016) 2023-12-08 23:22:59 -08:00
Tyler Veness
7d4e515a6b [wpimath] Simplify calculation of C for DARE precondition (#6022) 2023-12-08 20:25:03 -08:00
Peter Johnson
5200316c14 [ntcore] Update transmit period on topic add/remove (#6021)
- Correctly handle the first subscription being a send all
- Don't restart outgoing timer if period didn't change
2023-12-08 14:19:18 -08:00
Sam Carlberg
ddf79a25d4 [wpiunits] Overload Measure.per(Time) to return Measure<Velocity> (#6018)
As opposed to returning Measure<Per<U, Time>>
Now matches the overload on Unit
2023-12-08 13:39:28 -08:00
Tyler Veness
a71adef316 [wpiutil] Clean up circular_buffer iterator syntax (#6020) 2023-12-08 13:38:56 -08:00
Elliot Scher
39a0bf4b98 [examples] Call resetOdometry() when controller command is executed (#5905)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-12-06 22:14:54 -08:00
Gold856
f5fc101fda [build] cmake: Export jars and clean up jar installs (#6014) 2023-12-06 18:28:38 -08:00
Isaac Turner
38bf024c96 [build] Update to Gradle 8.5 (#6007) 2023-12-06 09:29:41 -08:00
Ashray._.g
9d11544c18 [wpimath] Rotate traveling salesman solution so input and solution have same initial pose (#6015) 2023-12-05 23:21:28 -08:00
Gold856
28deba20f5 [wpimath] Commit generated quickbuf Java files (#5994)
This removes a build dependency on the quickbuf generator being available for the build platform.

It's safe to generate Java because the quickbuf version is defined by the project.

C++ protobufs can't be committed because the protoc version must
match the library version (this is a particular issue for cmake builds).
2023-12-05 17:02:29 -08:00
Gold856
c2971c0bb3 [build] cmake: Export apriltag and wpimath (#6012) 2023-12-05 13:31:27 -08:00
Peter Johnson
41cfc961e4 gitattributes: Add linguist-generated locations (#6004) 2023-12-05 13:30:54 -08:00
Joseph Eng
14c3ade155 [wpimath] Struct cleanup (#6011) 2023-12-04 22:40:18 -08:00
Tyler Veness
90757b9e90 [wpilib] Make Color::HexString() constexpr (#5985)
Related improvements to wpi::ct_string:
* Implicitly convert to std::string
* Add operator== for std::string, std::string_view, and const Char*
2023-12-04 21:20:49 -08:00
PJ Reiniger
2676b77873 Fix compilation issues that occur when building with bazel (#6008) 2023-12-04 21:18:26 -08:00
ncorrea210
d32c10487c [examples] Update C++ examples to use CommandPtr (#5988)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-12-03 21:39:29 -08:00
Peter Johnson
9bc5fcf886 [build] cmake: Default WITH_JAVA_SOURCE to WITH_JAVA (#6005) 2023-12-03 20:14:34 -08:00
Tyler Veness
d431abba3b [upstream_utils] Fix GCEM namespace usage and add hypot(x, y, z) (#6002) 2023-12-03 16:40:08 -08:00
Tyler Veness
2bb1409b82 Clean up Java style (#5990)
Also make equivalent changes in C++ where applicable.

Co-authored-by: Sriman Achanta <68172138+srimanachanta@users.noreply.github.com>
2023-12-03 16:21:32 -08:00
Gold856
66172ab288 Remove submodule (#6003) 2023-12-03 16:18:45 -08:00
Tyler Veness
e8f8c0ceb0 [upstream_utils] Update to latest Eigen HEAD (#5996)
There hasn't been a release in 2.5 years.

There's performance improvements for some NEON instructions, UB fixes, a lot of internal cleanup with the jump from C++11 to C++14, and more constexpr.
2023-12-03 16:18:19 -08:00
Gold856
890992a849 [hal] Commit generated usage reporting files (#5993) 2023-12-03 15:53:24 -08:00
Peter Johnson
a583ca01e1 [wpiutil] Change Struct to allow non-constexpr implementation (#5992)
This required changing the constant values (e.g. kSize) into functions
(e.g. GetSize()).

Fixed implementations of ForEachNested to be inline (as these are actually
templates).

Also added a ntcore Struct test.
2023-12-02 23:36:44 -08:00
Tyler Veness
ca272de400 [build] Fix Gradle compile_commands.json and clang-tidy warnings (#5977) 2023-12-02 21:20:43 -08:00
Peter Johnson
76ae090570 [wpiutil] type_traits: Add is_constexpr() (#5997) 2023-12-02 20:54:22 -08:00
Starlight220
5172ab8fd0 [commands] C++ CommandPtr: Prevent null initialization (#5991) 2023-12-02 16:45:04 -08:00
Tyler Veness
96914143ba [build] Bump native-utils to fix compile_commands.json (#5989) 2023-12-01 23:08:47 -08:00
Austin Shalit
464e6121ef [ci] Report failed status to Azure on failed tests (#2654) 2023-12-01 20:53:57 -08:00
PJ Reiniger
5dad46cd45 [wpimath] Commit generated files (#5986) 2023-12-01 20:52:38 -08:00
PJ Reiniger
54ab65a63a [ntcore] Commit generated files (#5962) 2023-12-01 15:31:06 -08:00
Sriman Achanta
7ed900ae3a [wpilib] Add hex string constructor to Color and Color8Bit (#5063)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-12-01 10:26:58 -08:00
Tyler Veness
74b85b76a9 [wpimath] Make gcem call std functions if not constant-evaluated (#5983)
The one exception is macOS, which doesn't support std::beta().
2023-12-01 09:08:04 -08:00
Tyler Veness
30816111db [wpimath] Fix TimeInterpolatableBuffer crash (#5972)
Don't decrement buffer iterator if it's at the beginning of the
container.
2023-11-30 23:18:38 -08:00
Peter Johnson
5cc923de33 [wpilib] DataLogManager: Use logs subdirectory on USB drives (#5975) 2023-11-30 23:13:51 -08:00
Ryan Blue
1144115da0 [commands] Add GetName to Subsystem, use in Scheduler tracer epochs (#5836) 2023-11-30 23:10:53 -08:00
Tyler Veness
ac7d726ac3 [wpimath] Add simulated annealing (#5961)
Co-authored-by: Ashray._.g <ashray.gupta@gmail.com>
2023-11-30 22:57:50 -08:00
Tyler Veness
e09be72ee0 [wpimath] Remove unused SimpleMatrixUtils class (#5979)
It looks like it was gradually replaced by JNI wrappers around Eigen.
2023-11-30 21:12:43 -08:00
Tyler Veness
0f9ebe92d9 [wpimath] Add generic circular buffer class to Java (#5969)
The original is now called DoubleCircularBuffer.
2023-11-30 21:12:23 -08:00
David Vo
9fa28eb07a [ci] Bump actions/checkout to v4 (#5736)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2023-11-30 21:09:56 -08:00
Thad House
ca684ac207 [hal] Add capability to read power distribution data as a stream (#4983) 2023-11-30 21:09:14 -08:00
Prateek Machiraju
51eecef2bd [wpimath] Optimize 2nd derivative of quintic splines (#3292)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-11-30 21:07:52 -08:00
Gold856
4fcf0b25a1 [build] Apply a formatter for CMake files (#5973) 2023-11-30 16:52:21 -08:00
Tyler Veness
9b8011aa67 [build] Pin wpiformat version (#5982) 2023-11-30 13:37:07 -08:00
swirl
e00a0e84c1 [build] cmake: fix protobuf dependency finding for certain distributions (#5981) 2023-11-30 13:36:41 -08:00
Tyler Veness
23dd591394 [upstream_utils] Remove libuv patch that adjusts whitespace (#5976) 2023-11-29 12:22:28 -08:00
Peter Johnson
b0719942f0 [wpiutil] Timestamp: Report errors on Rio HMB init failure (#5974) 2023-11-29 10:10:07 -08:00
Tyler Veness
7bc89c4322 [wpilib] Update getAlliance() docs (NFC) (#5971)
kInvalid was replaced with an optional.
2023-11-28 10:03:12 -08:00
Tyler Veness
841ea682d1 [upstream_utils] Upgrade to LLVM 17.0.5 (#5970) 2023-11-28 10:01:48 -08:00
Joseph Farkas
a74db52dae [cameraserver] Add getVideo() pixelFormat overload (#5966) 2023-11-27 09:51:42 -08:00
Thad House
a7eb422662 [build] Update native utils for new compile commands files (#5968) 2023-11-27 09:47:49 -08:00
Tyler Veness
544b231d4d [sysid] Add missing cassert include (#5967) 2023-11-26 21:01:40 -08:00
Tyler Veness
31cd015970 [wpimath] Add SysId doc links to LinearSystemId in C++ (NFC) (#5960)
They already exist in Java.
2023-11-24 23:46:09 -08:00
Thad House
9280054eab Revert "[build] Export wpimath protobuf symbols (#5952)"
This reverts commit c80b2d2017.
2023-11-23 22:40:47 -08:00
Thad House
2aba97c610 Export pb files from wpimath 2023-11-23 22:40:47 -08:00
Peter Johnson
c80b2d2017 [build] Export wpimath protobuf symbols (#5952) 2023-11-23 11:27:54 -08:00
Tyler Veness
3c0652c18a [cscore] Replace CS_PixelFormat with WPI_PixelFormat (#5954)
This fixes a compilation error introduced by #5923.
2023-11-23 11:27:30 -08:00
Andrew Gasser
95716eb0cb [wpiunits] Documentation improvements (#5932) 2023-11-23 10:57:58 -08:00
Starlight220
423fd75fa8 [wpilib] Default LiveWindowEnabledInTest to false (#5950) 2023-11-23 10:56:47 -08:00
Tyler Veness
dfdea9c992 [wpimath] Make KalmanFilter variant for asymmetric updates (#5951) 2023-11-23 10:56:15 -08:00
Drew Williams
ca81ced409 [wpiutil] Move RawFrame to wpiutil; add generation of RawFrame for AprilTags (#5923) 2023-11-23 10:55:10 -08:00
Joseph Farkas
437cc91af5 [cscore] CvSink: Allow specifying output PixelFormat (#5943) 2023-11-22 11:35:42 -08:00
Gold856
25b7dca46b [build] Remove CMake flat install option (#5944) 2023-11-21 11:48:32 -08:00
PJ Reiniger
bb05e20247 [wpimath] Add protobuf/struct for trivial types (#5935)
This implements de/serialization for the types that aren't templated (SwerveDriveKinematics) in C++ or where there is no trivial way to go round-trip (Splines) for the messages.
2023-11-21 10:14:06 -08:00
PJ Reiniger
35744a036e [wpimath] Move struct/proto classes to separate files (#5918)
Also add unit tests.
2023-11-21 10:11:57 -08:00
Ryan Blue
80d7ad58ea [build] Declare platform launcher dependency explicitly (#5909) 2023-11-21 10:09:20 -08:00
Peter Johnson
f8d983b154 [ntcore] Protobuf/Struct: Use atomic_bool instead of atomic_flag (#5946)
Some older compilers don't have atomic_flag::test().
2023-11-21 09:57:55 -08:00
Peter Johnson
4a44210ee3 [ntcore] NetworkTableInstance: Suppress unused lambda capture warning (#5947)
Clang warns that the "this" capture is not required, even though a
member function is being called.
2023-11-21 09:45:16 -08:00
Peter Johnson
bdc8620d55 [upstream_utils] Fix fmt compilation errors on Windows (#5948)
Using `this->` in decltype doesn't work in the latest MSVC.
2023-11-21 08:16:30 -08:00
Sam Carlberg
0ca1e9b5f9 [wpimath] Add basic wpiunits support (#5821)
To reduce the need for users to manually perform unit conversions, this allows Measure objects from wpiunits to be passed into most places in wpimath that currently expect doubles in terms of SI units like meters.

For example, users would need to know that unit conversion is required - and what the correct units are. Using units would be more difficult to write code for than just hardcoding a value or using Units.inchesToMeters.

Now, using units has no more developer overhead than using raw numbers.
2023-11-17 10:45:04 -06:00
Peter Johnson
cc30824409 [ntcore] Increase client meta-topic decoding limit (#5934) 2023-11-17 10:42:09 -06:00
Tyler Veness
b1fad062f7 [wpilib] Use RKDP in DifferentialDrivetrainSim (#5931) 2023-11-17 10:41:18 -06:00
Peter Johnson
ead9ae5a69 [build] Add generateProto dependency to test and dev (#5933) 2023-11-17 10:39:28 -06:00
Peter Johnson
cfbff32185 [wpiutil] timestamp: Fix startup race on Rio (#5930)
Note this doesn't use a full mutex, so there is still a shutdown race.
2023-11-15 21:58:51 -08:00
Tyler Veness
7d90d0bcc3 [wpimath] Clean up StateSpaceUtil (#5891) 2023-11-15 21:13:12 -08:00
Peter Johnson
7755e45aac [build] Add generated protobuf headers to C++ test include path (#5926) 2023-11-15 21:05:04 -08:00
Matt
3985c031da [ntcore] ProtobufSubscriber: Fix typos (#5928) 2023-11-15 05:20:40 -08:00
Peter Johnson
7a87fe4b60 [ntcore] ProtobufSubscriber: Make mutex and msg mutable (#5927) 2023-11-14 21:07:38 -08:00
DeltaDizzy
09f3ed6a5f [commands] Add static Trigger factories for robot mode changes (#5902) 2023-11-14 15:54:43 -08:00
Joseph Eng
79dd795bc0 [wpimath] Clean up VecBuilder and MatBuilder (#5906) 2023-11-14 12:23:50 -08:00
Peter Johnson
e117274a67 [wpilib] Change default Rio log dir from /home/lvuser to /home/lvuser/logs (#5899) 2023-11-14 12:20:51 -08:00
Tyler Veness
a8b80ca256 [upstream_utils] Update to libuv 1.47.0 (#5889) 2023-11-14 12:12:56 -08:00
Tyler Veness
b3a9c3e96b [build] Bump macOS deployment target to 12 (#5890) 2023-11-14 08:26:21 -08:00
Peter Johnson
0f8129677b [build] Distribute wpimath protobuf headers (#5925) 2023-11-13 19:50:42 -08:00
Peter Johnson
d105f9e3e9 [wpiutil] ProtobufBuffer: Fix buffer reallocation (#5924) 2023-11-13 15:49:41 -08:00
sciencewhiz
c5f2f6a0fb [fieldImages] Fix typo in field images artifact name (#5922)
Nothing appears to be using the existing name
2023-11-12 23:16:52 -08:00
Tyler Veness
c1a57e422a [commands] Clean up make_vector.h (#5917) 2023-11-12 20:23:34 -08:00
DeltaDizzy
78ebc6e9ec [wpimath] change G to gearing in LinearSystemId factories (#5834) 2023-11-12 20:22:39 -08:00
Isaac Turner
9ada181866 [hal] DriverStation.h: Add stddef.h include (#5897) 2023-11-11 21:30:23 -08:00
Peter Johnson
95fa5ec72f [wpilibc,ntcoreffi] DataLogManager: join on Stop() call (#5910)
This ensures the thread has finished prior to returning from Stop().
2023-11-10 21:03:30 -08:00
Ryan Blue
b6f2d3cc14 [build] Remove usage of Version.parse (#5911) 2023-11-10 21:02:08 -08:00
Elliot Scher
cc2cbeb04c [examples] Replace gyro rotation with poseEstimator rotation (#5900) 2023-11-10 15:12:54 -08:00
Tyler Veness
fa6b171e1c [wpiutil] Suppress protobuf warning false positives on GCC 13 (#5907) 2023-11-10 15:12:18 -08:00
Gold856
d504639bbe [apriltag] Improve AprilTag docs (#5895) 2023-11-08 12:48:52 -08:00
Tyler Veness
3a1194be40 Replace static_cast<void>() with [[maybe_unused]] attribute (#5892)
This clarifies intent. Not done for thirdparty libraries or
structured binding variables.
2023-11-08 12:47:23 -08:00
swirl
70392cbbcb [build] cmake: Add protobuf dependency to wpiutil-config (#5886)
Signed-off-by: swirl <swurl@swurl.xyz>
2023-11-06 12:47:35 -08:00
Peter Johnson
17c1bd5a83 [ntcore] Use json_fwd (#5881)
Also fix ProtobufEntry construction.
2023-11-05 09:55:40 -08:00
Peter Johnson
e69a9efeba [wpilibcExamples] Match array parameter bounds (#5880)
Required by newer versions of clang.
2023-11-04 23:55:13 -07:00
Peter Johnson
14dcd0d26f Use char instead of uint8_t for json::parse (#5877)
The uint8_t usage causes warnings on newer clang versions.

Add GetCharBuffer() to MemoryBuffer classes to make this easy.
2023-11-04 22:18:42 -07:00
Thad House
ec1d261984 [hal] Fix garbage data for match info before DS connection (#5879)
NetComm writes garbage data before the DS connects. Make sure this doesn't make it up to the user.
2023-11-04 22:15:24 -07:00
Peter Johnson
63dbf5c614 [wpiutil] MemoryBuffer: Fix normal read and file type check (#5875) 2023-11-04 18:41:39 -07:00
Peter Johnson
b2e7be9250 [ntcore] Only datalog meta-topics if specifically requested (#5873) 2023-11-04 18:40:52 -07:00
Tyler Veness
201a42a3cd [wpimath] Reorder TrapezoidProfile.calculate() arguments (#5874)
ProfiledPIDController and ExponentialProfile use current, then goal.
This isn't a breaking change because this overload of calculate() is
new for 2024.
2023-11-04 16:28:55 -07:00
Drew Williams
04a781b4d7 [apriltag] Add GetTags to C++ version of AprilTagFieldLayout (#5872) 2023-11-04 10:26:07 -07:00
Ryan Blue
87a8a1ced4 [docs] Exclude eigen and protobuf from doxygen (#5871)
They take up a significant portion of the generated output (protobuf ~55MB, eigen ~119MB).
2023-11-04 07:54:48 -07:00
Peter Johnson
f1a82828fe [wpiutil] Add DataLog and DataLogManager Stop() (#5860)
Restarting a stopped log results in creating a new log file with fresh copies of the same start records and schema data records.

Also check to see if the file has been deleted or if the log file exceeds 1.8 GB, and start a new one.
2023-11-03 20:34:43 -07:00
Ryan Blue
2a04e12c6f [apriltag] AprilTagFieldLayout: Add accessors for origin and field dimensions (#5869) 2023-11-03 20:24:23 -07:00
Ryan Blue
33e0089afb Cleanup usages of std::function<void(void)> (#5864) 2023-11-03 18:22:47 -07:00
Ryan Blue
d06fa633d5 [build] Fix protobuf generation when building with make (#5867) 2023-11-03 18:22:34 -07:00
Ryan Blue
049732afb8 [cscore] Make camera connection logging clearer (#5866) 2023-11-03 16:03:23 -07:00
Bryce Roethel
87f7c19f90 [wpimath] Make InterpolatingDoubleTreeMap constructor public (#5865) 2023-11-03 15:34:14 -07:00
Tyler Veness
6b53ef47cf [wpimath] Don't recreate TrapezoidProfile in ProfiledPIDController calculate() (#5863) 2023-11-03 15:21:58 -07:00
shueja-personal
8a3a268ae6 [commands] Add finallyDo with zero-arg lambda (#5862) 2023-11-03 15:21:21 -07:00
Tyler Veness
1c35d42cd0 [wpilib] Pop diagnostic for deprecated function use (#5859) 2023-11-03 08:34:08 -07:00
narmstro2020
ddc8db6c26 [wpimath] Add feedforward constant constructor to ElevatorSim (#5823)
Adds a subclass of ElevatorSim that uses kG, kV, and kA from sysId to simulate an Elevator.
2023-11-02 09:10:57 -07:00
Tyler Veness
c6aff2c431 [upstream_utils] Update to LLVM 17.0.4 (#5855) 2023-11-01 16:45:32 -07:00
Peter Johnson
a9c5b18a39 [build] Update OpenCV to 2024-4.8.0-2 (#5854)
This fixes rpath on cross-build targets to properly include $ORIGIN.
2023-11-01 09:45:40 -07:00
Kevin-OConnor
9540b6922d [hal] Add CAN IDs for AndyMark and Vivid Hosting (#5852) 2023-10-31 15:59:42 -07:00
Peter Johnson
83a7d33c47 [glass] Improve display of protobuf/struct type strings (#5850) 2023-10-30 20:29:29 -07:00
Ryan Blue
a4a8ad9c75 [commands] Make Java SelectCommand generic (#5849)
This allows users to use any type of map and selector without needing to explicitly match
Map<Object, Command>
2023-10-30 11:09:14 -07:00
Gold856
9eecf2a456 [build] Add CMake option to build Java sources jars (#5768) 2023-10-30 09:57:28 -07:00
David Baucum
9536a311cb [wpilib] Add support for the PS5 DualSense controller (#5257)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-10-30 08:25:16 -07:00
Dustin Spicuzza
8d5e6737fc [wpilibc] SolenoidSim: Add virtual destructor (#5848) 2023-10-30 08:24:11 -07:00
Peter Johnson
07e13d60a2 [ntcore] Fix write_impl (#5847)
The previous fix didn't handle all cases correctly. Instead, add a new
function to raw_ostream (SetNumBytesInBuffer) to allow always using the
full buffer size, and revamp write_impl to more cleanly handle all
cases.
2023-10-30 08:23:33 -07:00
Peter Johnson
1713386869 [wpiutil] ProtobufMessageDatabase: Fix out-of-order Add() rebuild (#5845) 2023-10-29 16:50:01 -07:00
Peter Johnson
35472f5fc9 [ntcore] Fix a use-after-free in client close (#5844) 2023-10-29 16:49:45 -07:00
Peter Johnson
ed168b522c [ntcore] Disable buf pool when asan is enabled (#5843)
This helps asan catch more errors.
2023-10-29 16:49:31 -07:00
Peter Johnson
3e7ba2cc6f [wpinet] WebSocket: Fix write behavior (#5841)
On Windows, TryWrite will always return 0 if there is a Write in progress. The previous behavior for SendFrames and SendControl just used a normal Write, which caused issues with code that combined these with TrySendFrames. Instead, have SendFrames and SendControl also use TryWrite under the hood if possible, and create write requests if not. The implementation preserves the priority of SendControl against an existing write request with multiple frames.
2023-10-29 16:48:25 -07:00
Gold856
80c47da237 [sim] Disable the robot program when DS disconnects (#5818) 2023-10-28 10:10:23 -07:00
sciencewhiz
abe1cec90c [wpilib] Update Usage Reporting ResourceType from NI Libraries (#5842)
Disable PS4 controller reporting until added by NI
2023-10-27 20:21:46 -07:00
Oliver
cdf981abba [glass] Fix position of data type in NT view (#5840) 2023-10-27 17:41:42 -07:00
Thad House
04dcd80adb [build] Publish unit tests for examples (#5838) 2023-10-27 16:57:38 -07:00
Jordan McMichael
49920234ac [build] Fix checkstyle rules to allow Windows paths (#5839) 2023-10-27 16:56:58 -07:00
Ryan Blue
366b715942 [wpilib] Fix SendableChooser test (#5835)
Using unique NT keys for each test seems to resolve the failure on Linux. Changed Java as well, for completeness.
2023-10-26 20:47:04 -07:00
Ryan Blue
3ba501f947 [commands] Java: Fix CommandXboxController.leftTrigger() parameter order (#5831) 2023-10-26 19:18:36 -07:00
Tyler Veness
ec569a58ef [wpimath] Make KalmanTypeFilter interface public (#5830) 2023-10-26 19:18:02 -07:00
Peter Johnson
b91317fd36 [wpiutil] DataLog.addSchema(): Don't add into a set view (#5829) 2023-10-26 19:17:47 -07:00
Peter Johnson
2ab4fcbc24 [wpiutil] ProtobufMessageDatabase: Clear messages first (#5827)
The message destructor appears to call something on the descriptor.
2023-10-26 19:17:29 -07:00
Tyler Veness
98c14f1692 [wpimath] Add EKF/UKF u-y-R correct overload (#5832)
Also clean up comments on other overloads and fix a typo.
2023-10-26 19:17:15 -07:00
Ryan Blue
60bcdeded9 [ci] Disable java in sanitizer builds (#5833) 2023-10-26 19:16:58 -07:00
Ryan Blue
c87f8fd538 [commands] Add DeferredCommand (#5566)
Allows commands to be constructed at runtime without proxying.
2023-10-26 19:16:33 -07:00
Ryan Blue
ad80eb3a0b [ci] Update actions for comment-command (#5824) 2023-10-25 14:33:22 -07:00
Peter Johnson
c7d6ad5a0b [ntcore] WebSocketConnection: Use weak capture (#5822)
Fixes a potential use-after-free on connection close.
2023-10-25 10:22:43 -07:00
Zhiquan Yeo
8a8e220792 [simgui] Add 'Invalid' option for AllianceStation (#5820) 2023-10-24 11:51:39 -07:00
Gold856
cfc6a47f76 [sim] DS plugin: Fix off-by-one error when setting alliance station (#5819) 2023-10-24 09:15:40 -07:00
Peter Johnson
8efa586ace [ntcore] Don't check type string on publishing an entry (#5816)
Only check the raw type value.
2023-10-24 00:12:02 -07:00
Peter Johnson
23ea188e60 [glass] Add protobuf decode error log message (#5812) 2023-10-23 23:36:23 -07:00
Ryan Blue
928e87b4f4 [build] Add combined test meta-task (#5813) 2023-10-23 23:35:44 -07:00
Benjamin Hall
63ef585d4b [wpiutil] Fix compilation of MathExtras.h on Windows with /sdl (#5809)
Fix copied from the LLVM main branch.
2023-10-23 21:35:13 -07:00
Ryan Blue
b03a7668f9 [build] Windows CMake/vcpkg fixes (#5807)
- Add builtin registry baseline (fixes building locally with msvc builtin vcpkg)
- Add protobuf as an explicit dependency (previously was installed as a dependency of opencv)
- In windows CI, checkout repository before running vcpkg (silences warning that vcpkg.json was not found)
2023-10-23 21:33:28 -07:00
Thad House
3f08bcde54 [hal] Fix HAL AllianceStation on rio (#5811) 2023-10-23 21:32:21 -07:00
Peter Johnson
196d963dc4 [ntcore] Fix off-by-one error in stream write (#5810) 2023-10-23 21:31:36 -07:00
sciencewhiz
f4cbcbc984 Fix typos (NFC) (#5804) 2023-10-23 09:15:58 -07:00
Thad House
ec0f7fefb0 [myrobot] Update the myRobot JRE (#5805) 2023-10-23 09:14:50 -07:00
Jonah
3d618bdbfd [wpiutil] Fix Java struct array unpacking (#5801) 2023-10-21 20:13:50 -07:00
Peter Johnson
1fa7445667 [ntcore] Check for valid client in incoming text and binary (#5799) 2023-10-20 23:25:05 -07:00
Ryan Blue
269b9647da [ci] Update JDK for combine step (#5794)
Also frees disk space from the combiner step.
2023-10-20 18:18:04 -07:00
Tyler Veness
bee32f080e [docs] Add wpiunits to JavaDocs (#5793)
Co-authored-by: Sam Carlberg <sam.carlberg@gmail.com>
2023-10-20 18:14:14 -07:00
Peter Johnson
25dad5a531 [wpinet] TCPConnector_parallel: Don't use thread_local (#5791)
Thread_local causes issues with LabVIEW, which makes calls on a thread
pool.
2023-10-20 16:45:07 -07:00
Tyler Veness
4a93581f1a [build] cmake: use default library type for libglassnt, libglass, wpigui, and imgui (#5797)
On Windows, imgui and wpigui need to be static.  On Mac, they must be dynamic.
2023-10-20 16:44:26 -07:00
Ryan Blue
abb2857e03 [wpilib] Counter: Fix default distance per pulse, add distance and rate to C++ (#5796)
- Default distance per pulse in java was 0; 1 is a more reasonable default
- C++ was missing this functionality
2023-10-19 23:42:53 -07:00
Peter Johnson
b14a61e1c0 [readme] Add link to QuickBuffers release page (#5795) 2023-10-19 22:07:40 -07:00
Peter Johnson
cf54d9ccb7 [wpiutil, ntcore] Add structured data support (#5391)
This adds support for two serialization formats for complex data types:

- Protobuf for complex objects with variable length internals that need forward and backward wire compatibility (lower speed, more flexible)
- Raw struct (ByteBuffer-style) for fixed-length objects (higher speed, less flexible)

Deserialization can be done either by creating a new object (for immutable objects) or overwriting the contents of an existing object (for mutable objects).

Implementing classes should provide inner classes that implement the Protobuf or Struct interface (in Java) or specialize the wpi::Protobuf or wpi::Struct struct (in C++). It is possible for classes to implement both. If the class itself does not implement serialization, it's possible for third parties/users to provide an implementation instead.

Uses the Google protobuf implementation for C++ and the QuickBuffers alternative protobuf implementation for Java.
2023-10-19 21:41:47 -07:00
Jordan McMichael
ecb7cfa9ef [wpimath] Add Exponential motion profile (#5720) 2023-10-19 17:26:32 -07:00
Peter Johnson
7c6fe56cf2 [ntcore] Fix crash on disconnect (#5788)
The object was being destroyed due to the error handling path.
Instead, defer to the next loop cycle using a one-shot timer.

Properly handle error return values from Send functions.

Fix UB in accessing one past the end of a vector.
2023-10-19 14:36:22 -07:00
Peter Johnson
85147bf69e [wpinet] WebSocketSerializer: Fix UB (#5787) 2023-10-19 00:14:23 -07:00
Peter Johnson
244163acad [wpinet] uv::Stream::TryWrite(): Return 0 on EAGAIN (#5784)
EAGAIN is a normal return value, but we want to just map it to 0 rather than handling it as an error.
2023-10-19 00:12:34 -07:00
Gold856
820728503d [hal] Remove extra semicolon in RoboRioData (#5786) 2023-10-18 23:12:05 -07:00
Tyler Veness
45f307d87e [upstream_utils] Upgrade to LLVM 17.0.3 (#5785) 2023-10-18 19:18:35 -07:00
Peter Johnson
4ce4d63efc [wpilibj] Fix RobotBase.isSimulation() (#5783)
#3534 changed it from returning !isReal() to checking against a numeric value, but #3565 (merged earlier) had changed the value to an enum.
2023-10-18 14:15:35 -07:00
Ryan Blue
579007ceb3 [commands] Add requirements parameter to Commands.idle() (#5774) 2023-10-17 19:52:48 -07:00
Tyler Veness
3f3a169149 [wpilib] Make physics sim setState() functions public (#5779) 2023-10-17 19:52:02 -07:00
Tyler Veness
7501e4ac88 [wpilib] Close sim device in ADIS IMUs (#5776)
Fixes #5775.
2023-10-17 19:51:35 -07:00
Tyler Veness
99630d2e78 [wpimath] Upgrade to EJML 0.43.1 (#5778)
https://github.com/lessthanoptimal/ejml/blob/v0.43.1/change.txt
2023-10-17 19:51:17 -07:00
Tyler Veness
02cbbc997d [wpimath] Make Vector-Vector binary operators return Vector (#5772)
Fixes #5741.
2023-10-17 16:44:30 -07:00
Tyler Veness
ed93889e17 [examples] Fix typo in TimesliceRobot example name (#5773) 2023-10-17 16:44:18 -07:00
Tyler Veness
da70e4c262 [docs] Add jinja2 to CMake prerequisites (#5771)
Fixes #5769.
2023-10-17 11:05:34 -07:00
Brayden Zee
e814595ea7 [wpimath] Add ChassisSpeeds.fromRobotRelativeSpeeds() (#5744) 2023-10-17 10:13:04 -07:00
narmstro2020
f98c943445 [wpimath] LinearSystemId: Add DCMotorSystem overload (#5770)
The goal of this addition is to allow LinearSystemId.createDCMotorSystem to use kV and KA instead of the moment of inertia, DCMotor object, and gearing.
2023-10-17 10:11:34 -07:00
Peter Johnson
b3eb64b0f7 [wpiutil] ct_string: Use inline namespace for literals (#5767)
This avoids a conflict with json.
2023-10-15 07:53:08 -07:00
Peter Johnson
7d9ba256c2 Revert "[build] Add CMake option to build Java source jars (#5756)" (#5766)
This reverts commit 1c724884ca.

This commit broke local builds on the second run of cmake configure.
2023-10-14 23:53:27 -07:00
Tyler Veness
1f6492e3d8 [sysid] Update JSON library usage (#5765) 2023-10-14 23:52:50 -07:00
Peter Johnson
638f04f626 [wpiutil] Add protobuf to thirdparty sources (#5746) 2023-10-14 21:54:17 -07:00
PJ Reiniger
210255bfff [wpiutil] Update json to 3.11.2 (#5680) 2023-10-14 21:53:56 -07:00
Jordan McMichael
896772c750 [wpimath] Add DCMotor functions for Kraken X60 and Neo Vortex (#5759) 2023-10-14 21:52:01 -07:00
Tyler Veness
fd427f6c82 [wpimath] Fix hardcoded module count in SwerveDriveKinematics.resetHeading() (#5762)
Fixes #5761.
2023-10-14 21:51:15 -07:00
Anit Mangal
c0b4c6cce6 [wpimath] Add overloads for Transform2d and Transform3d (#5757)
Adds overloads for Transform2d() constructor to accept x, y, and heading and for Transform3d() to accept x, y, z and rotation as a shorthand for the normal constructors.
2023-10-12 23:21:39 -07:00
kully
9a0aafd8ab [examples] Make swerve examples multiply desired module speeds by cosine of heading error (#5758)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-10-12 23:20:57 -07:00
Gold856
1c724884ca [build] Add CMake option to build Java source jars (#5756) 2023-10-11 12:50:54 -07:00
Peter Johnson
5b0db6b93e [ci] Forward CI as well (#5755) 2023-10-10 22:59:17 -07:00
Peter Johnson
f8cbbbac12 [ci] Take 2 on passing GITHUB_REF (#5754) 2023-10-10 22:48:35 -07:00
Peter Johnson
b9944be09c [ci] Pass GITHUB_REF to docker container (#5753) 2023-10-10 22:03:44 -07:00
Peter Johnson
de5e4eda6c [build] Update apriltag, libssh, googletest for 2024 (#5752) 2023-10-10 20:35:30 -07:00
Tyler Veness
227e660e20 [upstream_utils] Upgrade to LLVM 17.0.2 (#5750) 2023-10-10 16:30:31 -07:00
Peter Johnson
36f94c9f21 [commands,romi,xrp] Add frcYear to vendordep (#5747)
Required by wpilibsuite/native-utils#170.
Also see wpilibsuite/native-utils#168.
2023-10-10 09:12:49 -07:00
Peter Johnson
741d166457 [glass] NT view: enhance array support (#5732)
- Break out array elements; this makes it easier to see array contents and
  allows plotting individual array elements
- Provide array editor
2023-10-10 00:28:54 -07:00
Peter Johnson
1d23513945 [ntcore] Fix string array value comparison (#5745)
It did not correctly check size prior to checking size=0.
2023-10-10 00:27:56 -07:00
Gold856
ff1849052e [commands] Make command scheduling order consistent (#5470) 2023-10-09 23:52:26 -07:00
Peter Johnson
58e8474368 [build] Disable armsimulation unit test (#5739)
This test regularly fails on Win64Debug in CI.
2023-10-09 20:11:51 -07:00
Zhiquan Yeo
fb07b0da49 [examples] Add XRP C++ Examples and Templates (#5743) 2023-10-09 16:55:54 -07:00
Tyler Veness
81893ad73d Run wpiformat with clang-format 17 (#5740) 2023-10-09 11:22:45 -07:00
narmstro2020
faa1e665ba [wpimath] Add ElevatorFeedforward.calculate(currentV, nextV) overload (#5715)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-10-09 08:16:45 -07:00
Peter Johnson
a789632052 [build] Update to native utils 2024.3.1 (#5738)
Also switch to 2024 docker images.
2023-10-08 20:16:08 -07:00
Peter Johnson
8f60ab5182 [build] Update OpenCV to 2024-4.8.0-1 (#5737) 2023-10-08 16:43:15 -07:00
Jordan McMichael
33243f982b [wpimath] Expand Quaternion class with additional operators (#5600)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-10-08 16:42:53 -07:00
Peter Johnson
420f2f7c80 [ntcore] Add RTT-only subprotocol (#5731)
This is useful for aliveness checking by clients that can't send
WebSocket PING messages.
2023-10-08 00:35:10 -07:00
Peter Johnson
2b63e35ded [ntcore] Fix moving outgoing queue to new period (#5735)
std::remove_if() is destructive--it can assume the removed elements are
not used, but NetworkOutgoingQueue needs them to stay intact to be moved
to a different queue. Use std::stable_partition() instead.
2023-10-08 00:34:36 -07:00
Peter Johnson
be939cb636 [ntcore] Fix notification of SetDefaultEntryValue (#5733) 2023-10-07 20:42:55 -07:00
Thad House
69a54de202 [build] Update enterprise plugin (#5730)
Removes a deprecation warning
2023-10-05 10:39:11 -07:00
Ryan Blue
fef03a3ff5 [commands] Clean up C++ includes after Requirements was added (#5719) 2023-10-04 22:09:28 -07:00
Peter Johnson
8b7c6852cf [ntcore] Networking improvements (#5659)
- Utilize TrySend to properly backpressure network traffic
- Split updates into reasonable sized frames using WS fragmentation
- Use WS pings for network aliveness (requires 4.1 protocol revision)
- Measure RTT only at start of connection, rather than periodically
  (this avoids them being affected by other network traffic)
- Refactor network queue
- Refactor network ping, ping from server as well
- Improve meta topic performance
- Implement unified approach for network value updates (currently client and server use very different approaches) that respects requested subscriber update frequency

This adds a new protocol version (4.1) due to WS bugs in prior versions.
2023-10-04 22:02:42 -07:00
Dustin Spicuzza
1d19e09ca9 [wpiutil] Set WPI_{UN}IGNORE_DEPRECATED to empty when all else fails (#5728) 2023-10-04 21:49:07 -07:00
Gold856
58141d6eb5 [wpilib] Make BooleanEvent more consistent (#5436)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: Joseph Eng <91924258+KangarooKoala@users.noreply.github.com>
2023-10-04 21:22:57 -07:00
Gold856
6576d9b474 [wpilib] SendableChooser: implement Sendable instead of NTSendable (#5718) 2023-10-04 21:15:34 -07:00
Thad House
a4030c670f [build] Update to gradle 8.4, enable win arm builds (#5727) 2023-10-04 19:31:25 -07:00
Tyler Veness
0960f11eba [wpinet] Revert removal of uv_clock_gettime() (#5723)
GetSystemTimePreciseAsFileTime() is supposed to be available, and
wpiutil already uses it.
2023-10-03 20:39:09 -07:00
Peter Johnson
cb1bd0a3be [wpiutil] Get more precise system time on Windows (#5722)
Windows 8 added GetSystemTimePreciseAsFileTime().
2023-10-03 20:38:48 -07:00
Oliver
4831277ffe [wpigui] Fix loading a maximized window on second monitor (#5721) 2023-10-03 11:50:28 -07:00
Starlight220
3eb372c25a [wpiutil] SendableBuilder: Add PublishConst methods (#5158) 2023-10-02 08:23:11 -07:00
Peter Johnson
1fec8596a4 [ci] Fix -dirty version (#5716) 2023-10-01 22:44:12 -07:00
Gold856
f7e47d03f3 [build] Remove unnecessary CMake config installs (#5714) 2023-10-01 20:08:09 -07:00
Tyler Veness
a331ed2374 [sysid] Add SysId (#5672)
The source is copied from this commit:
625ff04784.
2023-10-01 15:09:09 -07:00
Peter Johnson
8d2cbfce16 [wpiutil] DataLog: Stop logging if insufficient free space (#5699)
The threshold is set to 5 MB.
2023-10-01 14:01:49 -07:00
Peter Johnson
48facb9cef [ntcoreffi] Add DataLogManager (#5702)
This is a copy of wpilibc's DataLogManager with shims for the HAL and
wpilibc functionality for LabView use.
2023-10-01 13:59:15 -07:00
Peter Johnson
aecbcb08fc [ntcore] Correctly start DataLog for existing publishers (#5703) 2023-10-01 06:43:18 -07:00
Peter Johnson
5e295dfbda [wpiutil] DataLog: Limit total buffer allocation (#5700)
Pause logging if more than 1 MB of outgoing buffers are allocated.
Limit free buffer list to 256 KB.
2023-09-30 20:19:28 -07:00
Peter Johnson
c7c7e05d9d [ci] Unbreak combiner (#5698) 2023-09-30 10:19:32 -07:00
Peter Johnson
c92bad52cb [wpilib] DataLogManager: Use system time valid function (#5697) 2023-09-30 09:24:06 -07:00
Peter Johnson
d404af5f24 [wpilib] RobotController: Add isSystemTimeValid() (#5696)
This returns true when the system date/time (wall clock) is valid.
2023-09-30 09:22:51 -07:00
Tyler Veness
e56f1a3632 [ci] Run combine but skip all steps (#5695)
This makes it show up as passed instead of skipped so the result
aggregator collapses.
2023-09-29 23:38:16 -07:00
Peter Johnson
8f5bcad244 [ci] Use sccache for cmake builds (#5692) 2023-09-29 23:38:01 -07:00
Tyler Veness
703dedc4a6 [ci] Upgrade get-cmake action to fix node12 deprecation warning (#5694) 2023-09-29 21:20:27 -07:00
Tyler Veness
c69a0d7504 [ci] Don't run example unit test that segfaults (#5693) 2023-09-29 17:26:03 -07:00
Tyler Veness
66358d103e Add menu items for online docs to GUI tools (#5689) 2023-09-29 17:25:28 -07:00
Tyler Veness
4be8384a76 [ci] Disable combine on PR builds (#5691)
It takes 30 minutes, and the artifacts aren't used. The combine step
changes so infrequently that it's unlikely to break in PRs, so it's a
net benefit to speed up PR builds.
2023-09-29 09:59:09 -07:00
Peter Johnson
90288f06a6 [ci] Fix Gradle disk space issues (#5688)
- Free up disk space on Linux by deleting unused packages
- Move build to C drive on Windows
2023-09-29 00:50:15 -07:00
Tyler Veness
9e9583412e [wpigui] Make wpi::gui::OpenURL() fork the process first (#5687)
execlp() replaces the current process image, which isn't desirable.
2023-09-28 13:01:56 -07:00
Peter Johnson
d4fcd80b7b [ci] Gradle: Use container only for build step (#5684) 2023-09-27 23:56:20 -07:00
Tyler Veness
7b70e66772 [outlineviewer] Fix thirdparty library include sorting (#5683) 2023-09-27 21:45:46 -07:00
Tyler Veness
5f651df5d5 [build] Clean up Gradle configs (#5685)
Putting an early exit if statement at the top instead of wrapping the
whole file contents unbreaks unit test configs, as was discovered for
SysId. It reduces nesting as well.

Unused plugins were removed from the beginnings of files as well.
2023-09-27 21:45:25 -07:00
Ryan Blue
65b26738d5 Add CMakeSettings.json to gitignore (#5682) 2023-09-26 20:57:44 -07:00
Tyler Veness
d0305951ad Fix GitHub inline warnings (#5681) 2023-09-23 19:57:18 -07:00
Ryan Blue
e8d4a20331 [build][cmake] Fix windows tests and re-enable CI tests (#5674) 2023-09-22 15:39:35 -07:00
Zhiquan Yeo
2b58bbde0b [xrp] Add Reflectance sensor and rangefinder classes (#5673)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-09-22 13:03:43 -07:00
PJ Reiniger
dd5612fbee [json] Add forward definition header (#5676) 2023-09-22 13:01:27 -07:00
Tyler Veness
eab44534c3 [wpimath] Remove unused SmallString include (#5677) 2023-09-22 08:01:01 -07:00
Tyler Veness
5ab54ff760 Replace wpi::raw_istream with wpi::MemoryBuffer (#5675)
Instances of wpi::raw_istream were left that are reading incrementally
from file descriptors like USB devices.
2023-09-21 23:20:09 -07:00
Tyler Veness
1b6ec5a95d [wpiutil] Upgrade to LLVM 17.0.1 (#5482) 2023-09-21 19:54:33 -07:00
Tyler Veness
07a0d22fe6 [build] Build examples in CMake CI (#5667) 2023-09-20 21:03:55 -07:00
Tyler Veness
97021f074a [build] Upgrade imgui and implot (#5668)
Upgrade implot to fix deprecation warning for sprintf(), and upgrade
imgui docking branch to match.
2023-09-19 23:38:17 -07:00
Gold856
87ce1e3761 [build] Fix wpilibNewCommands CMake install (#5671) 2023-09-19 21:19:35 -07:00
Colin Finn
6ef94de9b5 [wpimath] Add tests for ArmFeedforward and ElevatorFeedforward (#5663) 2023-09-18 22:25:08 -07:00
Peter Johnson
c395b29fb4 [wpinet] Add WebSocket::TrySendFrames() (#5607)
This takes advantage of the underlying byte-level TryWrite() functionality to minimize blocking behavior and enable higher layers to do things smartly when the network blocks.

Also:
- Fix handling of control packets in middle of fragmented
- Clean up debugging features
2023-09-18 19:49:54 -07:00
Zhiquan Yeo
c4643ba047 [romi/xrp] Fix version typo in vendordep json (#5664) 2023-09-18 19:42:27 -07:00
Zhiquan Yeo
51dcb8b55a [examples] Make Romi/XRP Examples use appropriate vendordeps (#5665) 2023-09-18 19:42:10 -07:00
Starlight220
daf7702007 [build] Test each example in a new environment (#5662)
In C++ each example is a separate source set, but in Java they were one source set and tested as one with the test task. Example-specific test tasks exist for Java, but they weren't used.
This modifies the test task to exclude the example tests, instead depending on each example's test task. The advantage of this is that each example is tested in a separate environment, so leftover state from one example isn't carried over.
2023-09-18 11:03:39 -07:00
Starlight220
e67df8c180 [wpilib] Const-qualify EncoderSim getters (#5660) 2023-09-18 08:18:18 -07:00
Peter Johnson
7be290147c [wpiutil] Refactor SpanMatcher and TestPrinters from ntcore (#5658) 2023-09-18 00:11:36 -07:00
Ryan Blue
9fe258427a [commands] Add proxy factory to Commands (#5603) 2023-09-17 20:49:02 -07:00
Joseph Eng
633c5a8a22 [commands] Add C++ Requirements struct (#5504) 2023-09-17 20:48:39 -07:00
Joseph Eng
b265a68eea [commands] Add interruptor parameter to onCommandInterrupt callbacks (#5461) 2023-09-17 20:47:37 -07:00
Peter Johnson
e93c233d60 [ntcore] Compute Value memory size when creating value (#5657)
This avoids a later switch-based computation in NetworkLoopQueue.
2023-09-17 20:01:57 -07:00
Peter Johnson
5383589f99 [wpinet] uv::Request: Return shared_ptr from Release() (#5656)
Use this in Stream to allow the finish() callback to reuse the request.
2023-09-17 20:01:43 -07:00
Peter Johnson
40b552be4a [wpinet] uv::Stream: Return error from TryWrite() (#5655) 2023-09-17 20:01:24 -07:00
Peter Johnson
202a75fe08 [wpinet] RequestImpl: Avoid infinite loop in shared_from_this() (#5654) 2023-09-17 20:01:10 -07:00
Peter Johnson
8896515eb7 [wpinet] uv::Buffer: Add bytes() accessor (#5653)
Also add uint8_t constructors.
2023-09-17 20:00:56 -07:00
Peter Johnson
ae59a2fba2 [wpinet] uv::Error: Change default error to 0 (#5652)
Was previously UV_UNKNOWN, which meant a default-constructed uv::Error
was actually an error.
2023-09-17 20:00:44 -07:00
Peter Johnson
3b51ecc35b [wpiutil] SpanExtras: Add take_back and take_front (#5651)
Also allow sized spans as input (return is always dynamic size).
2023-09-17 20:00:31 -07:00
Tyler Veness
17f1062885 Replace std::snprintf() with wpi::format_to_n_c_str() (#5645)
fmtlib uses consteval format string processing, which makes it more
efficient than std::snprintf().

snprintf()s in libuv, mpack, processstarter, and wpigui were left alone.
processstarter uses stdlib only, and wpigui only depends on imgui.

fmt::format_to_n() is analogous to std::format_to_n()
(https://en.cppreference.com/w/cpp/utility/format/format_to_n)

wpi::format_to_n_c_str() is a wrapper which adds the trailing NUL.
2023-09-17 20:00:16 -07:00
Zhiquan Yeo
bb39900353 [romi/xrp] Add Romi and XRP Vendordeps (#5644) 2023-09-17 16:20:06 -07:00
autoantwort
cb99517838 [build] cmake: Use default install location on windows for dlls (#5580) 2023-09-17 16:17:32 -07:00
autoantwort
25b0622d4c [build] Add Windows CMake CI (#5516) 2023-09-17 16:16:52 -07:00
Ryan Blue
34e7849605 Add warning to development builds instructions (NFC) (#5646)
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2023-09-16 22:08:47 -07:00
Ryan Blue
e9e611c9d8 [cameraserver] Remove CameraServer.SetSize() (#5650) 2023-09-16 22:05:02 -07:00
Ryan Blue
94f58cc536 [wpilib] Remove Compressor.Enabled() (#5649)
Deprecated in #4147
2023-09-16 22:04:46 -07:00
Ryan Blue
4da5aee88a [wpimath] Remove SlewRateLimiter 2 argument constructor (#5648)
Deprecated in #4377
2023-09-16 22:04:29 -07:00
Ryan Blue
2e3ddf5502 Update versions in development builds instructions to 2024 (#5647) 2023-09-16 21:12:18 -07:00
Tyler Veness
19a8850fb1 [examples] Add TimesliceRobot templates (#3683) 2023-09-15 20:42:21 -07:00
Zhiquan Yeo
9047682202 [sim] Add XRP-specific plugin (#5631)
Provides an implementation of a XRP-specific plugin that sends binary messages over UDP (to account for the less performant hardware on the XRP).

This plugin leverages the work already done for the WebSocket protocol and does a translation to/from JSON/binary.
2023-09-15 20:08:02 -07:00
Tyler Veness
575348b81c [wpilib] Use IsSimulation() consistently (#3534) 2023-09-15 20:05:16 -07:00
Tyler Veness
12e2043b77 [wpilib] Clean up Notifier (#5630)
The user-facing docs were simplified, SetHandler() was renamed to
SetCallback(), and the internal documentation was synchronized.
2023-09-15 19:59:03 -07:00
Tyler Veness
4bac4dd0f4 [wpimath] Move PIDController from frc2 to frc namespace (#5640)
The old PIDController class in the frc namespace was removed for the
2023 season.
2023-09-15 19:57:31 -07:00
Tyler Veness
494cfd78c1 [wpiutil] Fix deprecation warning in LLVM for C++23 (#5642) 2023-09-15 19:57:14 -07:00
Ryan Blue
43a727e868 [apriltag] Make loadAprilTagFieldLayout throw an unchecked exception instead (#5629)
This eliminates the need for users to wrap initialization of the fields in a try/catch.
2023-09-15 14:25:21 -07:00
autoantwort
ad4b017321 [ci] Use Ninja for faster builds (#5626) 2023-09-15 10:42:57 -07:00
Tyler Veness
4f2114d6f5 Fix warnings from GCC 13 release build (#5637) 2023-09-15 10:37:52 -07:00
Tyler Veness
e7e927fe26 [build] Also compress debug info for CMake RelWithDebInfo build type (#5638) 2023-09-15 10:36:39 -07:00
Tyler Veness
205a40c895 [build] Specify zlib for debug info compression (#5636)
This is required to make compression actually occur.
2023-09-14 23:51:04 -07:00
Tyler Veness
707444f000 [apriltag] Suppress -Wtype-limits warning in asserts from GCC 13 (#5635) 2023-09-14 20:57:20 -07:00
Ryan Blue
3b79cb6ed3 [commands] Revert SubsystemBase deprecation/removal (#5634) 2023-09-14 20:56:48 -07:00
Tyler Veness
bc7f23a632 [build] Compress Linux debug info (#5633) 2023-09-14 20:46:44 -07:00
Thad House
57b2d6f254 [build] Update to image 2024 v1.0 (#5625) 2023-09-12 09:44:25 -07:00
Ryan Blue
339ef1ea39 [wpilib] DataLogManager: Warn user if logging to RoboRIO 1 internal storage (#5617) 2023-09-11 15:47:31 -07:00
autoantwort
7a9a901a73 [build] Fix cmake config files (#5624) 2023-09-11 13:27:00 -07:00
Gold856
298f8a6e33 [wpilib] Add Mechanism2d tests and make Java impl match C++ (#5527) 2023-09-10 22:01:33 -07:00
Ryan Blue
d7ef817bae [apriltag] Update apriltag library (#5619) 2023-09-10 22:00:50 -07:00
Ryan Blue
c3fb31fd0e [docs] Switch to Java 17 api docs (#5613) 2023-09-10 21:59:32 -07:00
Thad House
bd64f81cf9 [build] Run Google tests in release mode in CI (#5615)
This reduces disk space usage in CI. Local builds still use debug mode.
2023-09-10 08:08:28 -07:00
Joseph Eng
66e6bd81ea [wpimath] Cleanup wpimath/algorithms.md (NFC) (#5621) 2023-09-10 06:26:53 -07:00
autoantwort
4fa56fd884 [build] Add missing find_dependency call (#5623) 2023-09-09 18:57:12 -07:00
Thad House
f63d958995 [build] Update to native utils 2024.2.0 (#5601) 2023-09-08 20:15:24 -07:00
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
8e05983a4a [wpimath] Add math docs to plant inversion feedforward internals (NFC) (#5618) 2023-09-08 20:14:24 -07:00
Tyler Veness
3a33ce918b [ntcore] Add missing StringMap include (#5620) 2023-09-08 20:13:57 -07:00
Peter Johnson
a6157f184d [wpiutil] timestamp: Add ShutdownNowRio (#5610) 2023-09-07 09:59:39 -07:00
Tyler Veness
e9f612f581 [build] Guard policy setting for CMake versions below 3.24 (#5612) 2023-09-07 09:58:22 -07:00
Tyler Veness
1a6df6fec6 [wpimath] Fix DARE Q decomposition (#5611) 2023-09-05 10:48:43 -07:00
Ryan Blue
9b3f7fb548 [build] Exclude IntelliJ folders from spotless XML (#5602) 2023-09-05 08:59:12 -07:00
Tyler Veness
814f18c7f5 [wpimath] Fix computation of C for DARE (A, C) detectability check (#5609)
If Q has off-diagonal entries, C and Cᵀ are different.
2023-09-04 21:12:25 -07:00
Ryan Blue
ac23f92451 [hal] Add GetTeamNumber (#5596) 2023-09-01 23:34:18 -07:00
Tyler Veness
a750bee54d [wpimath] Use std::norm() in IsStabilizable() (#5599) 2023-08-31 22:52:18 -07:00
Gold856
8e2465f8a0 [wpimath] Add arithmetic functions to wheel speeds classes (#5465) 2023-08-31 11:57:24 -07:00
Tyler Veness
10d4f5b5df [wpimath] Clean up notation in DARE precondition docs (#5595) 2023-08-31 11:56:41 -07:00
Ryan Blue
b2dd59450b [hal] Fix unfinished/incorrect GetCPUTemp functions (#5598) 2023-08-31 11:51:57 -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
Tyler Veness
383289bc4b [build] Make custom CMake macros use lowercase (#5594)
Most of them already do use lowercase, and uppercase is like screaming
at the user.
2023-08-30 21:17:09 -07:00
Ryan Blue
45e7720ec1 [build] Add error message when downloading files in CMake (#5593)
CMake's file(DOWNLOAD) function fails silently, leading to an error occurring due to a missing file later in the build. This fails quickly and produces a better error message.
2023-08-30 21:16:48 -07:00
Gold856
4e0d785356 [wpimath] ChassisSpeeds: document that values aren't relative to the robot (NFC) (#5551) 2023-08-30 13:22:42 -07:00
Ryan Blue
3c04580a57 [commands] ProxyCommand: Use inner command name in unique_ptr constructor (#5570) 2023-08-30 13:21:49 -07:00
Ryan Blue
cf19102c4a [commands] SelectCommand: Fix leakage and multiple composition bug (#5571) 2023-08-30 13:21:17 -07:00
Peter Johnson
171375f440 [ntcoreffi] Link to NI libraries (#5589)
This is required because wpiutil depends on these libraries and is
statically linked.
2023-08-29 17:47:17 -07:00
Tyler Veness
89add5d05b Disable flaky tests (#5591) 2023-08-29 17:46:50 -07:00
Tyler Veness
a8d4b162ab [ntcore] Remove RPC manual tests (#5590)
NT4 doesn't support RPC.
2023-08-29 16:25:54 -07:00
Ryan Blue
39a73b5b58 [commands] C++: Add CommandPtr supplier constructor to ProxyCommand (#5572)
Co-authored-by: Starlight220 <53231611+Starlight220@users.noreply.github.com>
2023-08-29 13:23:00 -07:00
Ryan Blue
36d514eae7 [commands] Refactor C++ ScheduleCommand to use SmallSet (#5568)
Remove SetUtilities.h
2023-08-29 13:16:15 -07:00
Shai Grossman
52297ffe29 [commands] Add idle command (#5555) 2023-08-29 13:00:40 -07:00
Omar Zrien
67043a8eeb [wpimath] Add angular jerk unit (#5582) 2023-08-29 12:53:14 -07:00
Tyler Veness
51b0fb1492 [wpimath] Fix incorrect header inclusion in angular_acceleration.h (#5587)
Specific unit headers should only include units they use. In this case,
that's angle and time.
2023-08-29 12:52:39 -07:00
Tyler Veness
b7657a8e28 [wpimath] Split WPIMathJNI into logical chunks (#5552)
This makes things easier to find, and speeds up compilation.
2023-08-29 09:00:19 -07:00
Thad House
ea17f90f87 [build] Fix tool builds with multiple arm platforms installed (#5586) 2023-08-29 08:57:33 -07:00
Tyler Veness
f1d7b05723 [wpimath] Clean up unit formatter (#5584) 2023-08-29 08:56:48 -07:00
Tyler Veness
d7264ff597 Replace wpi::errs() usage with fmtlib (#5560)
This will make migration to C++23's std::print() easier later.

Fixes #5556.
2023-08-29 08:56:07 -07:00
Tyler Veness
ab3bf39e0e [wpiutil] Upgrade to fmt 10.1.1 (#5585)
This fixes a partial template specialization error internal to fmt that
was encountered in #5560.
2023-08-28 21:16:53 -07:00
Tyler Veness
165ebe4c79 Upgrade to fmt 10.1.0 (#5326) 2023-08-28 15:15:14 -07:00
Tyler Veness
8e2a7fd306 Include thirdparty libraries with angle brackets (#5578) 2023-08-28 15:13:34 -07:00
Tyler Veness
e322ab8e46 [wpimath] Fix docs for DARE ABQRN stabilizability check (NFC) (#5579) 2023-08-28 15:10:42 -07:00
Tyler Veness
360fb835f4 [upstream_utils] Handle edge case in filename matches (#5576)
endswith() leaves files out from subdirectories, which means projects
that add new subdirectories won't have those files included when they
probably should be.
2023-08-28 15:07:13 -07:00
Tyler Veness
9d86624c00 [build] Fix CMake configure warnings (#5577)
FetchContent requires CMake 3.11 (released Mar 28, 2018).

Fixed this warning:
```
CMake Warning (dev) at /usr/share/cmake/Modules/FetchContent.cmake:1316 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  imgui/CMakeLists.txt:23 (FetchContent_Declare)
```
2023-08-28 15:06:51 -07:00
Tyler Veness
969979d6c7 [wpiutil] Update to foonathan memory 0.7-3 (#5573) 2023-08-28 15:03:36 -07:00
Tyler Veness
0d2d989e84 [wpimath] Update to gcem 1.17.0 (#5575) 2023-08-28 15:03:06 -07:00
Tyler Veness
cf86af7166 [wpiutil] Update to mpack 1.1.1 (#5574) 2023-08-28 15:02:36 -07:00
Ryan Blue
a0c029a35b [commands] Fix dangling SelectCommand documentation (NFC) (#5567) 2023-08-25 09:41:25 -07:00
Tyler Veness
349141b91b [upstream_utils] Document adding a patch (NFC) (#5432)
Co-authored-by: autoantwort <41973254+autoantwort@users.noreply.github.com>
2023-08-24 15:00:07 -07:00
Tyler Veness
7889b35b67 [wpimath] Add RamseteController comparison to LTV controller docs (NFC) (#5559) 2023-08-24 00:04:54 -07:00
Ryan Blue
b3ef536677 [build] Ignore nt/sim json files in spotless (#5565) 2023-08-24 00:04:28 -07:00
Tyler Veness
ed895815b5 [build] Compile Java with UTF-8 encoding (#5564) 2023-08-24 00:03:38 -07:00
Joseph Eng
2e4ad35e36 [wpiutil] jni_util: Add JSpan and CriticalJSpan (#5554)
These replace JArrayRef et al and support statically sized arrays similar to std::span.
2023-08-24 00:02:56 -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
Peter Johnson
89e738262c [ntcore] Limit buffer pool size to 64KB per connection (#5485)
Previously this was unlimited, which could result in holding on to a
large amount of memory if the connection got backlogged or a burst of
data transmission occurred.
2023-08-20 13:53:52 -07:00
Tyler Veness
96f7fa662e Upgrade Maven dependencies (#5553)
The following source code changes were required:

* Whitespace changes from spotless
* PMD warning suppressions for utility class tests
* PMD warning rename from "BeanMembersShouldSerialize" to
  "NonSerializableClass"
* Declared more class members as final
2023-08-18 19:18:33 -07:00
Thad House
7a2d336d52 [wpinet] Leak multicast handles during windows shutdown (#5550)
Destructing either of the multicast objects during process shutdown will result in a crash due to attempting to start a task on the non-existent thread pool.

Solve this by just leaking all the handles upon destruction of the static multicast manager. This won't solve the case where the user statically allocates the object, but solves Java and C access, and most cases wouldn't be statically allocating the service announcer anyway in C++.
2023-08-18 19:15:16 -07:00
Tyler Veness
f9e2757d8f [wpimath] Use JDoubleArrayRef in all JNI functions (#5546) 2023-08-17 13:57:06 -07:00
Tyler Veness
0cf6e37dc1 [wpimath] Make LTV controller constructors use faster DARE solver (#5543)
Made JNI modifications to expose the faster function, made the API use
the typesafe Matrix API, and synchronized the documentation with C++.

Sped up C++ LTV diff drive test from 20 ms to 15 ms.
Sped up C++ LTV unicycle test from 15 ms to 10 ms.
2023-08-17 13:56:15 -07:00
autoantwort
6953a303b3 [build] Fix the windows build with fmt (#5544) 2023-08-16 17:07:23 -07:00
Joseph Eng
7a37e3a496 [wpimath] Correct Rotation3d::RotateBy doc comment (NFC) (#5541)
Improve transform doc comment consistency
2023-08-15 13:12:09 -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
Ryan Blue
a4b7fde767 [wpilib] Add mechanism specific SetState overloads to physics sims (#5534) 2023-08-12 15:21:07 -07:00
amquake
8121566258 [wpimath] Fix CoordinateSystem.convert() Transform3d overload (#5532) 2023-08-12 15:20:22 -07:00
Peter Johnson
b542e01a0b [glass] Fix array crash when clearing existing workspace (#5535) 2023-08-12 15:17:43 -07:00
Oliver
e2e1b763b2 [wpigui] Fix PFD file dialogs not closing after window closing (#5530)
Also applies samhocevar/portable-file-dialogs#91 to properly retrieve the HWND on Windows.
2023-08-12 09:07:35 -07:00
Zhiquan Yeo
86d7bbc4e4 [examples] Add Java Examples and Templates for the XRP (#5529) 2023-08-11 23:31:35 -07:00
Tyler Veness
e8b5d44752 [wpimath] Make Java Quaternion use doubles instead of Vector (#5525)
This avoids allocation overhead on construction. times() was also
rewritten to not allocate any temporary objects.

Getter calls in the C++ Quaternion class were modified for parity.
2023-08-11 23:27:29 -07:00
Ryan Blue
38c198fa64 [myRobot] Add apriltags to myRobot build (#5528) 2023-08-11 23:26:05 -07:00
Tyler Veness
00450c3548 [wpimath] Upgrade to EJML 0.42 (#5531) 2023-08-11 23:25:43 -07:00
Joseph Eng
faf3cecd83 [wpimath] Don't copy Matrix and underlying storage in VecBuilder (#5524) 2023-08-09 22:15:39 -07:00
autoantwort
6b896a38dc [build] Don't enforce WITH_FLAT_INSTALL with MSVC (part 2) (#5517) 2023-08-07 08:57:34 -07:00
Peter Johnson
c01814b80e [wpiutil] Add C API for DataLog (#5509) 2023-08-06 20:18:50 -07:00
Joseph Eng
b5bd0771eb [wpimath] Document extrinsic vs intrinsic rotations (NFC) (#5508) 2023-08-06 19:59:42 -07:00
autoantwort
84ed8aec05 [build] Don't enforce WITH_FLAT_INSTALL with MSVC (#5515) 2023-08-06 19:58:41 -07:00
Peter Johnson
999f677d8c [ntcoreffi] Add WPI_Impl_SetupNowRio to exported symbols (#5510) 2023-08-05 20:18:27 -07:00
Tyler Veness
338f37d302 Fix header sorting of libssh (#5507) 2023-08-05 14:16:55 -07:00
Ryan Blue
75cbd9d6d0 [glass] Add background color selector to glass plots (#5506) 2023-08-05 14:16:04 -07:00
m10653
e2c190487b [examples] Add flywheel bang-bang controller example (#4071)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-08-05 14:15:05 -07:00
Peter Johnson
c52dad609e [wpinet] WebSocket: Send pong in response to ping (#5498)
This is required by the spec (RFC 6455 section 5.5.2).
2023-08-04 16:27:08 -07:00
Ryan Blue
e2d17a24a6 [hal] Expose power rail disable and cpu temp functionality (#5477) 2023-08-03 23:48:29 -07:00
Thad House
3ad5d2e42d [hal,wpiutil] Use HMB for FPGA Timestamps (#5499)
Current timestamp read code uses FPGA register reads. Through testing,
this read was slower then clock_gettime by about 4-5x. However, another
method of reading the FPGA time is available, using HMB. HMB
is memory mapped IO from RAM to the FPGA. So to code side,
reading the value is just a memory barrier and a memory read.

There is some latency on the write side, so a very small artifical delay
(5us) is added to avoid register reads such as interrupts being ahead
of current timestamps, which could cause issues.

Below is read times for 1000 calls to clock_gettime, register reads and
hmb reads.
```
Clock: Rise 1.72939400 s Fall 1.72990700 s Delta 0.00051300 s
FPGA : Rise 1.72999000 s Fall 1.73429300 s Delta 0.00430300 s
HMB  : Rise 1.73466800 s Fall 1.73481900 s Delta 0.00015100 s
```

Also add full HMB struct to HAL for future usage.
2023-08-03 23:46:55 -07:00
Peter Johnson
b46a872494 [ntcore] Remove pImpl from implementation (#5480)
Also change Timestamped into a template.
2023-08-03 23:43:55 -07:00
Tyler Veness
d8c59ccc71 [wpimath] Add tests for MathUtil clamp() and interpolate() (#5501) 2023-08-03 23:43:20 -07:00
Ryan Blue
0552c8621d [glass,ov] Improve Glass and OutlineViewer title bar message (#5502)
Detect changes to mode and update based on mode change and connection events.
2023-08-03 23:43:03 -07:00
Ryan Blue
90e37a129f [wpiutil,wpimath] Add generic InterpolatingTreeMap (#5372) 2023-08-03 21:46:17 -07:00
Thad House
d83a6edc20 [wpilib] Update GetMatchTime docs and units (#5232) 2023-08-03 21:45:26 -07:00
Tyler Veness
6db2c42966 [wpimath] Trajectory: Throw on empty lists of States (#5497)
Fixes #4141.
2023-08-03 08:24:20 -07:00
Tyler Veness
21439b606c [wpimath] Disallow LTV controller max velocities above 15 m/s (#5495)
15 m/s is about 50 ft/s, which is way above what FRC robots should be
able to achieve. This limit lets us catch user errors from bad unit
conversions immediately instead of the LUT generation in the LTV
controllers hanging for a really long time.

Fixes #5027.
2023-08-02 23:37:49 -07:00
Peter Johnson
7496e0d208 [ntcore] Value: More efficiently store arrays (#5484) 2023-08-01 22:26:36 -07:00
Joseph Eng
0c93aded8a [wpimath] Change kinematics.ToTwist2d(end - start) to kinematics.ToTwist2d(start, end) (#5493) 2023-08-01 22:25:26 -07:00
Tyler Veness
815a8403e5 [wpimath] Give infeasible trajectory constraints a better exception message (#5492)
Fixes #3146.
2023-07-31 21:43:22 -07:00
Tyler Veness
35a8b129d9 [wpimath] Add RotateBy() function to pose classes (#5491)
Fixes #5472.
2023-07-31 21:16:44 -07:00
Tyler Veness
26d6e68c8f [upstream_utils] Add GCEM to CI (#5483) 2023-07-31 19:18:32 -07:00
Tyler Veness
6aa469ae45 [wpilib] Document how to create LinearSystem object for physics sim classes (NFC) (#5488)
Fixes #4372.
2023-07-31 19:18:17 -07:00
Tyler Veness
a01b6467d3 [wpimath] Link to docs on LQR and KF tolerances (#5486)
Fixes #4151.
2023-07-31 19:17:44 -07:00
Tyler Veness
d814f1d123 [wpimath] Fix copy-paste error from Pose2d docs (NFC) (#5490) 2023-07-31 19:17:17 -07:00
Tyler Veness
98f074b072 [wpimath] Add folder prefix to geometry includes (#5489) 2023-07-31 19:17:02 -07:00
Ryan Blue
e9858c10e9 [glass] Add tooltips for NT settings (#5476) 2023-07-28 16:32:07 -07:00
Thad House
12dda24f06 [examples] Fix C robot template not correctly looping (#5474)
- The event wouldn't reset, causing infinite looping
- Refresh ds data was missing
2023-07-27 08:46:51 -07:00
Peter Johnson
fc75d31755 [apriltag] Update apriltaglib (#5475) 2023-07-26 22:48:09 -07:00
Peter Johnson
a95994fff6 [wpiutil] timestamp: Call FPGA functions directly (#5235)
This works around an exit race with wpi::Now() on Rio; it was overridden
to call HAL_GetFPGATime(), which calls chipobject, but on exit, because
there was not a library dependency, the chipobject could be destroyed
prior to wpiutil/wpinet being shut down.
2023-07-24 23:03:28 -07:00
Joseph Eng
2ba8fbb6f4 [wpimath] Improve documentation for SwerveModulePosition::operator- (#5468) 2023-07-24 22:46:59 -07:00
Thad House
b8cdf97621 [build] Prepare for Windows arm64 builds (#5390)
Builds aren't actually enabled yet due to a bug in Gradle.
2023-07-24 22:46:25 -07:00
Mihir Patankar
552f4b76b5 [wpimath] Add FOC-enabled Falcon constants to the DCMotor class (#5469) 2023-07-24 20:16:48 -07:00
Joseph Ruan
1938251436 [examples] Add Feedforward to ElevatorProfiledPid (#5300)
Co-authored-by: Ryan Blue <ryanzblue@gmail.com>
2023-07-23 21:40:34 -07:00
Gold856
873c2a6c10 [examples] Update ElevatorTrapezoidProfile example (#5466) 2023-07-23 21:36:47 -07:00
Gold856
99b88be4f3 [wpilib] Reduce usage of NTSendable (#5434) 2023-07-23 21:34:49 -07:00
Peter Johnson
d125711023 [hal] Fix Java REVPH faults bitfield (take 2) (#5464)
The previous PR had a typo in one of the bitmasks.
Change to using 1 << N.
2023-07-23 17:37:27 -07:00
Carl Hauser
c3fab7f1f2 [ntcore] Don't update timestamp when value is unchanged (#5356)
This fixes an issue with commands run/cancel.
2023-07-23 17:36:26 -07:00
Gold856
5ec7f18bdc [wpilib] EventLoop docs: Remove BooleanEvent references (NFC) (#5463) 2023-07-23 14:22:04 -07:00
Sam Carlberg
c065ae1fcf [wpiunits] Add subproject for a Java typesafe unit system (#5371)
# Background

Unit safety has always been a problem in WPILib. Any value corresponding to a physical measurement, such as current draw or distance traveled, is represented by a bare number with no unit tied to it; it's up to the programmer to know what units they're working and take care to remember that while working on their robot program. This leads to bugs when programmers accidentally mix units without knowing, or measure something (such as a wheel diameter) in one unit and program using another. `wpiunits` is intended to eliminate that class of bugs.

Another source of friction is the controllers and models in `wpimath` that expect all inputs to be in terms of SI units (meter, kilogram, and so on), while most FRC teams are US-based and most commonly use imperial units. wpimath does a good job of noting unit types in method names and argument names; however, it still relies on users properly converting values (and knowing they even have to do so).

# API

There are really only two core classes in this library: `Unit` and `Measure`. A `Unit` represents some dimension like distance or time. `Unit` is subclassed to define specific dimensions (eg `Distance` and `Time`) and those subclasses are instantiated to defined particular units in those dimensions, such as `Meters` and `Feet` being instances of the `Distance` class.

A `Measure` is a value tied to a particular dimension like distance and knows what unit that value is tied to. `Measure` has two implementations - one immutable and one mutable. The `Measure` interface only defines *read-only* operations; any API working with measurements should use the interface. The default implementation is `ImmutableMeasure`, which only implements those read-only operations and is useful for tracking constants. `MutableMeasure` also adds some methods that will allow for mutation of its internal state; this class is intended for use for things like sensors and controllers that track internal state and don't want to allocate new `Measure` objects every time something like `myEncoder.getDistance()` is called. However, the APIs for those methods should still only expose the read-only `Measure` interface so users can't (without casting or reflection) change the internal values.

A `Units` class provides convenient definitions for most of the commonly used unit types, such as `Meters`, `Feet`, and `Milliseconds`. I recommend static importing these units eg `import static edu.wpi.first.units.Units.Meters`) so they can be used like `Meters.of(1.234)` instead of `Units.Meters.of(1.234)`


# Examples

These examples are admittedly contrived. Users shouldn't be interacting much with measure objects themselves, since wpimath and wpilibj classes will be updated to support working with them; users will often just have to take a `Measure` output from one place (such as an encoder) and feed it as input to something else (such as a PID controller or kinematics model)

```java
// Using raw units
Encoder encoder = ...

int kPulsesPerRev = 2048;
double kWheelDiameterMeters = Units.inchesToMeters(6);
double kGearRatio = 10.86;
 // always have to remember this encoder will output in meters!
encoder.setDistancePerPulse(kWheelDiameterMeters * Math.PI / (kGearRatio * kPulsesPerRev));

Command driveDistance(double distance) {
  // have to know the distance argument needs to be in meters!
  return run(this::driveStraight).until(() -> encoder.getDistance() >= distance);
}

// Oops! This will go 16 feet, not 5!
Command driveFiveFeet = driveDistance(5);
Command driveOneMeter = driveDistance(1);
```
```java
// Using wpiunits

Encoder encoder = ...

int kPulsesPerRev = 2048;
Measure<Distance> kWheelDiameter = Inches.of(6);
double kGearRatio = 10.86;
encoder.setDistancePerPulse(kWheelDiameter.times(Math.PI).divide(kGearRatio * kPulsesPerRev));

Command driveDistance(Measure<Distance> distance) {
  // Measure#gte automatically handles unit conversions
  return run(this::driveStraight).until(() -> encoder.getDistance().gte(distance));
}

// Users HAVE to be explicit about their units
Command driveFiveFeet = driveDistance(Feet.of(5));
Command driveOneMeter = driveDistance(Meters.of(1));
```

```java
SmartDashboard.putNumber("Temperature (C)", pdp.getTemperature().in(Celsius));
SmartDashboard.putNumber("Temperature (F)", pdp.getTemperature().in(Fahrenheit));
```

```java
var InchSecond = Inch.mult(Second); // new combined unit types can be user-defined
var InchPerSecond = Inch.per(Second);

PIDController<Distance, ElectricPotential> heightController = new PIDController<>(
  /* kP */ Volts.of(0.2).per(Inch),
  /* kI */ Volts.of(0.002).per(InchSecond),
  /* kD */ Volts.of(0.008).per(InchPerSecond)
);

var elevatorTop = Feet.of(4).plus(Inches.of(6.125));
elevatorMotor.setVoltage(heightController.calculate(encoder.getDistance(), elevatorTop));
```
2023-07-23 14:18:17 -07:00
Peter Johnson
44acca7c00 [wpiutil] Add ClassPreloader (#5365)
This provides an easy-to-use way to preload classes by name at startup to
avoid later delays due to lazy classloading.
2023-07-23 11:18:38 -07:00
Starlight220
88b11832ec [hal] Fix Java REVPH faults bitfield (#5148) 2023-07-22 17:20:48 -07:00
Peter Johnson
fb57d82e52 [ntcore] Enhance Java raw value support
Add support for start, length, and ByteBuffers
2023-07-22 17:17:52 -07:00
Peter Johnson
3a6e40a44b [wpiutil] Enhance DataLog Java raw value support
Add support for start, length, and ByteBuffers
2023-07-22 17:17:52 -07:00
Peter Johnson
8dae5af271 [wpiutil] Add compile-time string utilities (ct_string) (#5462) 2023-07-22 17:16:37 -07:00
Thad House
fc56f8049a [wpilib] DriverStation: Change alliance station to use optional (#5229)
Many teams have issues trying to read the DS too early. By switching to an optional, we cause teams to check 2 things. Either 1) they explicitly check, and their code is correct, or 2) they just read .value() and their code reboots in a loop. However, because the DS will eventually connect, this 2nd case is ok, and should theoretically be undetectable on the field.
2023-07-22 15:19:28 -07:00
autoantwort
ef155438bd [build] Consume libuv via cmake config instead of via pkg-config (#5438)
The problem is that you have to use a different pkg-config file if you want to use a static variant of libuv, but the buildsystem should not care which variant of libuv should be used. This is not a problem with the cmake config.
2023-07-20 00:30:56 -07:00
Gold856
86e91e6724 [wpimath] Refactor TrapezoidProfile API (#5457) 2023-07-19 17:25:10 -07:00
Gold856
72a4543493 [wpilib] DutyCycleEncoderSim: Expand API (#5443) 2023-07-19 17:24:09 -07:00
Joseph Eng
657338715d [wpimath] Add ChassisSpeeds method to fix drifting during compound swerve drive maneuvers (#5425) 2023-07-18 21:19:55 -07:00
Tyler Veness
1af224c21b Add missing <functional> includes (#5459) 2023-07-18 21:18:32 -07:00
Gold856
0b91ca6d5a [wpilib] SendableChooser: Add onChange listener (#5458) 2023-07-18 16:33:45 -07:00
Joseph Eng
6f7cdd460e [wpimath] Pose3d: Switch to JNI for exp and log (#5444)
The pure Java implementations allocate a lot of temporary objects, and the JNI implementation is substantially more performant.
2023-07-18 16:32:11 -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
Sriman Achanta
335e7dd89d [wpilib] Simulation: Add ctor parameter to set starting state of mechanism sims (#5288)
- Add a constructor parameter to configure the initial angle of the arm
- Also reorganizes cascading constructors for Java
2023-07-18 13:00:27 -07:00
Tyler Veness
14f30752ab [wpilib] Deprecate Accelerometer and Gyro interfaces (#5445)
Accelerometer is hyper-specific to ADXL accelerometers, and Gyro is
less useful now that 3D IMUs are prevalent, and if those IMUs want to
support the Gyro interface, they also need to provide a way to set the
axis used for the Gyro interface, which is confusing. Higher-order
functions (e.g., lambdas) are a more flexible interface boundary than
interfaces, but they didn't exist when these interfaces were
created.
2023-07-18 12:52:43 -07:00
Gold856
70b60e3a74 [commands] Trigger: Fix method names in requireNonNullParam (#5454) 2023-07-18 08:12:50 -07:00
Joseph Eng
593767c8c7 [wpimath] Improve Euler angle calculations in gimbal lock (#5437) 2023-07-17 17:19:42 -07:00
Joseph Eng
daf022d3da [build] Make devImplementation inherit from implementation (#5450)
Remove manually adding dependencies to devImplementation.
Fix wpilibNewCommands devMain package.
2023-07-17 17:19:03 -07:00
Jason
9b8d90b852 [examples] Convert the unitless joystick inputs to actual physical units (#5451)
Taking the joystick inputs from -1 to 1, multiply them by the max speed (as defined in Constants.java) to get the target speed, rather than using the unitless raw joystick inputs.
2023-07-17 17:18:34 -07:00
Gold856
1f6428ab63 [ntcore] Fix undefined comparison behavior when array is empty (#5448)
If both arrays are empty, it returns true, avoiding UB with memcmp potentially getting a nullptr.
2023-07-17 17:16:54 -07:00
sciencewhiz
17eb9161cd Update code owners for removal of old commands (#5447) 2023-07-14 21:18:38 -07:00
Tyler Veness
3c4b58ae1e [wpinet] Upgrade to libuv 1.46.0 (#5446) 2023-07-14 18:55:32 -07:00
Ryan Blue
aaea85ff16 [commands] Merge CommandBase into Command and SubsystemBase into Subsystem (#5392)
Moves all CommandBase functionality into Command and deprecates CommandBase for removal.
Moves all SubsystemBase functionality into Subsystem and deprecates SubsystemBase for removal.
Adds a function to CommandScheduler to remove all registered Subsystems.
2023-07-13 22:12:01 -07:00
Peter Johnson
7ac932996a [ci] Use PAT for workflow dispatch (#5442) 2023-07-12 23:53:21 -07:00
Peter Johnson
efe1987e8b [ci] Trigger pages repo workflow (#5441) 2023-07-12 23:29:56 -07:00
Tyler Veness
828bc5276f [wpiutil] Upgrade to LLVM 16.0.6 (#5435)
Fixes #5332.
2023-07-12 22:50:13 -07:00
Peter Johnson
701df9eb87 [ci] Change documentation publish to single-commit (#5440)
Push to different branches for beta/release/development.
The pages repo workflow will do the combine for publishing.
2023-07-12 22:20:22 -07:00
Thad House
e5452e3f69 [wpiutil] Add WPICleaner and an example how to use it (#4850) 2023-07-10 09:59:36 -07:00
Ryan Blue
7a099cb02a [commands] Remove deprecated classes and functions (#5409)
Removes:
- PerpetualCommand
- Command.perpetually()
- CommandGroupBase
- Command.IsGrouped() (C++ only)
- Command.SetGrouped() (C++ only)
- Command.withInterrupt()
- ProxyScheduleCommand
- Button
- InternalButton, JoystickButton, NetworkButton and POVButton now subclass Trigger
- Old style Trigger functions:
    - Trigger.whenActive
    - Trigger.whileActiveOnce
    - Trigger.whileActiveContinuous
    - Trigger.whenInactive
    - Trigger.toggleWhenActive
    - Trigger.cancelWhenActive
- CommandScheduler.clearButtons()
- CommandScheduler.addButtons() (Java only)
- Command supplier constructor of SelectCommand
2023-07-10 09:56:18 -07:00
Thad House
b250a03944 [wpilib] Add function to wait for DS Connection (#5230) 2023-07-10 09:53:16 -07:00
autoantwort
a6463ed761 [wpiutil] Fix unused variable warning in release build (#5430) 2023-07-10 09:48:51 -07:00
Peter Johnson
f031513470 [ntcore] NetworkTable::GetSubTables(): Remove duplicates (#5076)
In Java, a set is used. Use a two-stage approach in C++ to achieve the
same result.
2023-07-09 21:31:58 -07:00
sciencewhiz
f8e74e2f7c [hal] Unify PWM simulation Speed, Position, and Raw (#5277)
Setting one will set the others, like it does in real hardware.
Add tests for boundary conditions and conversions.
Update PWM sendable implementation to include all forms.
Fixes #5264
Fixes #3606
2023-07-09 21:28:50 -07:00
Tyler Veness
fd5699b240 Remove references to Drake (#5427)
Fixes #5426.
2023-07-09 21:25:14 -07:00
autoantwort
e2d385d80a [build] cmake: Respect USE_SYSTEM_FMTLIB (#5429) 2023-07-09 21:24:46 -07:00
Ryan Blue
d37f990ce3 [hal] Fix HAL Relay/Main doc module (NFC) (#5422) 2023-07-05 21:21:59 -07:00
Ryan Blue
a7a8b874ac [docs] Expand HAL_ENUM in doxygen docs (#5421) 2023-07-05 21:20:21 -07:00
Peter Johnson
3a61deedde [wpimath] Rotation2d: Only use gcem::hypot when constexpr evaluated (#5419) 2023-07-04 12:05:55 -06:00
Peter Johnson
96145de7db [examples] Fix formatting (NFC) (#5420) 2023-07-04 07:14:06 -07:00
Starlight220
fffe6a7b9a [examples] Improve Pneumatics example coverage in Solenoid and RapidReactCmdBot examples (#4998) 2023-07-03 21:23:18 -07:00
Vasista Vovveti
6b5817836d [wpimath] Add tolerance for some tests (#5416) 2023-06-27 14:22:46 -07:00
Vasista Vovveti
3233883f3e [cscore] Fix warnings on macos arm (#5415) 2023-06-27 14:22:19 -07:00
Starlight220
c4fc21838f [commands] Add ConditionalCommand getInterruptionBehavior (#5161) 2023-06-23 08:21:05 -07:00
Starlight220
89fc51f0d4 Add tests for SendableChooser and Command Sendable functionality (#5179) 2023-06-23 08:18:38 -07:00
Ryan Blue
663bf25aaf [docs] Generate docs for symbols in __cplusplus (#5412) 2023-06-22 20:58:38 -07:00
Joseph Eng
fe32127ea8 [command] Clean up Command doc comments (NFC) (#5321) 2023-06-22 19:43:51 -07:00
Thad House
c1a01569b4 [wpilib][hal] PWM Raw using microseconds (#5283)
Co-authored-by: Joe <sciencewhiz@users.noreply.github.com>
2023-06-22 19:43:16 -07:00
Ryan Blue
1fca519fb4 [wpiutil] Remove remnants of ghc fs and tcb_span libraries (#5411) 2023-06-22 19:42:44 -07:00
sciencewhiz
90602cc135 [github] Update issue template to collect more project info (#5090) 2023-06-22 15:26:22 -07:00
sciencewhiz
34412ac57e [build] Exclude files in bin from Spotless (#5410)
Was causing failures in fieldImages.
2023-06-22 15:25:01 -07:00
Thad House
61aa60f0e3 [wpilib] Add robot callback that is called when the DS is initially connected (#5231) 2023-06-21 14:53:34 -07:00
Ryan Blue
ebae341a91 [commands] Add test for subsystem registration and periodic (#5408) 2023-06-20 20:29:59 -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
Tyler Veness
eb3810c765 [wpiutil] Fix clang-tidy warnings (#5406) 2023-06-20 10:55:05 -07:00
Zhiquan Yeo
c4dc697192 [hal] WS Simulation: Add message filtering capability (#5395) 2023-06-20 08:26:03 -07:00
Tyler Veness
0eccc3f247 [ntcore] Fix clang-tidy warnings (#5405) 2023-06-20 08:21:44 -07:00
sciencewhiz
f4dda4bac0 [hal] Add javadocs for JNI (NFC) (#5298)
Docs are copied from the HAL and add references to the HAL files/methods
to aid discoverability.
2023-06-19 23:36:56 -07:00
Tyler Veness
1c20c69793 [cscore] Fix clang-tidy warnings (#5404) 2023-06-19 23:35:13 -07:00
Tyler Veness
1501607e48 [commands] Fix clang-tidy warnings (#5402) 2023-06-19 23:01:46 -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
Tyler Veness
2ce248f66c [hal] Fix clang-tidy warnings (#5401) 2023-06-19 22:59:07 -07:00
Gold856
5fc4aee2d2 [wpimath] SwerveDriveKinematics: Rename currentChassisSpeed to desiredChassisSpeed (#5393) 2023-06-19 22:58:38 -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
Joseph Eng
316cd2a453 [commands] Notify DriverStationSim in CommandTestBaseWithParam (#5400) 2023-06-19 22:56:56 -07:00
Sriman Achanta
d4ea5fa902 [cscore] VideoMode: Add equals override (Java) (#5397) 2023-06-19 17:12:07 -07:00
Ryan Blue
d6bd72d738 [wpimath] ProfiledPIDController: Add getConstraints (#5399) 2023-06-19 17:11:20 -07:00
Joseph Eng
25ad5017a9 [wpimath] Refactor kinematics, odometry, and pose estimator (#5355) 2023-06-19 17:10:39 -07:00
sciencewhiz
5c2addda0f [doc] Add missing pneumatics docs (NFC) (#5389)
Add missing HAL docs for PCM and PH
Fix references to PCM
Document different one shot durations for PCM and PH
2023-06-15 08:14:35 -07:00
Thad House
c3e04a6ea2 Fix loading tests on macos 12 (#5388) 2023-06-09 23:40:20 -07:00
Thad House
d5ed9fb859 [wpimath] Create separate archive with just units headers (#5383)
This will allow very low level deps to use the same units library we ship with wpilib
2023-06-08 21:11:51 -07:00
Ryan Blue
901ab693d4 [wpimath] Use UtilityClassTest for more utility classes (#5384) 2023-06-08 21:11:26 -07:00
Gold856
9d53231b01 [wpilib] DataLogManager: Add warning for low storage space (#5364) 2023-06-08 20:02:21 -07:00
Ryan Blue
d466933963 [wpiutil] Group doxygen into MPack module (#5380) 2023-06-08 20:00:16 -07:00
Tyler Veness
652d1c44e3 [wpiutil] Upgrade to macOS 12 to remove concept shims (#5379)
The macOS deployment target has been upgraded from 10.15 to 11. Also, a
deprecation warning for sprintf() in libuv was suppressed.
2023-06-08 19:59:54 -07:00
Ryan Blue
6414be0e5d [wpimath] Group units doxygen modules (#5382) 2023-06-08 19:58:55 -07:00
Ryan Blue
7ab5800487 [wpiutil] Fix docs typo in SmallVector (#5381) 2023-06-08 19:58:21 -07:00
Tyler Veness
59905ea721 Replace WPI_DEPRECATED() macro with [[deprecated]] attribute (#5373)
Continue to use WPI_DEPRECATED macro for constructors until clang-format is fixed.
2023-06-08 00:01:06 -07:00
Ryan Blue
753cb49a5e [ntcore] Fix doxygen module in generated C types (NFC) (#5374) 2023-06-07 09:56:20 -07:00
Ryan Blue
1c00a52b67 [hal] Expose CAN timestamp base clock (#5357) 2023-06-07 09:54:03 -07:00
Tyler Veness
91cbcea841 Replace SFINAE with concepts (#5361)
Concepts are cleaner to use and result in much better error messages for incorrect template use.
2023-06-07 09:50:09 -07:00
Tyler Veness
d57d1a4598 [wpimath] Remove unnecessary template argument from unit formatter (#5367) 2023-06-07 09:47:46 -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
Ryan Blue
d3c9316a97 extend shuffleboard test timeout (#5377) 2023-06-03 06:47:08 -07:00
Gold856
1ea868081a [ci] Fix /format command (#5376) 2023-06-03 06:43:08 -07:00
Tyler Veness
5fac18ff4a Update formatting to clang-format 16 (#5370) 2023-05-31 22:10:53 -07:00
Tyler Veness
a94a998002 [wpimath] Generalize Eigen formatter (#5360) 2023-05-30 23:35:15 -07:00
Tyler Veness
125f6ea101 [wpimath] Make SwerveDriveKinematics::ToChassisSpeeds() take const-ref argument (#5363) 2023-05-30 23:34:39 -07:00
Tyler Veness
51066a5a8a [wpimath] Move unit formatters into units library (#5358) 2023-05-26 01:05:27 -07:00
Ryan Blue
282c032b60 [wpilibc] Add unit-aware Joystick.GetDirection() (#5319) 2023-05-25 21:43:52 -07:00
Tyler Veness
073d19cb69 [build] Fix CMake warning (#5359)
```
CMake Warning (dev) at CMakeLists.txt:14 (project):
  cmake_minimum_required() should be called prior to this top-level project()
  call.  Please see the cmake-commands(7) manual for usage documentation of
  both commands.
This warning is for project developers.  Use -Wno-dev to suppress it.
```
2023-05-25 21:39:35 -07:00
Gold856
01490fc77b [wpiutil] DataLog: Add documentation for append methods (NFC) (#5348) 2023-05-18 21:56:21 -07:00
Tyler Veness
c9b612c986 [wpilibcExamples] Make C++ state-space elevator KF and LQR match Java (#5346) 2023-05-18 10:09:48 -07:00
Tyler Veness
eed1e6e3cb [wpimath] Replace DiscretizeAQTaylor() with DiscretizeAQ() (#5344)
Until #5339 is fixed, we have to use the slower, more accurate version.
2023-05-18 07:13:20 -07:00
Tyler Veness
c976f40364 [readme] Document how to run examples in simulation (#5340) 2023-05-17 21:09:22 -07:00
Ryan Blue
4d28bdc19e [ci] Update Github Pages deploy action parameters (#5343) 2023-05-17 21:02:43 -07:00
Ryan Blue
e0f851871f [ci] Fix github pages deploy version (#5342) 2023-05-17 20:42:52 -07:00
Tyler Veness
063c8cbedc Run wpiformat (NFC) (#5341) 2023-05-17 18:00:26 -07:00
sciencewhiz
96e41c0447 [ci] Update deploy and sshagent actions (#5338)
Fixes node deprecations
2023-05-16 20:50:03 -07:00
Tyler Veness
fd294bdd71 [build] Fix compilation with GCC 13 (#5322) 2023-05-16 13:31:58 -07:00
Peter Johnson
d223e4040b [dlt] Add delete without download functionality (#5329) 2023-05-16 09:42:06 -07:00
Tyler Veness
abc19bcb43 [upstream_utils] Zero out commit hashes and show 40 digits in index hashes (#5336) 2023-05-16 09:41:46 -07:00
Austin Shalit
e909f2e687 [build] Update gradle cache repo name (#5334)
Artifactory now does not allow repos that end in -cache. Update virtual repo naming to track this new limitation
2023-05-16 00:47:34 -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
3876a2523a [wpimath] Remove unused MatrixImpl() function (#5330)
It's an implementation detail left over from MakeMatrix().
2023-05-14 22:22:28 -07:00
Thad House
c82fcb1975 [wpiutil] Add reflection based cleanup helper (#4919)
Co-authored-by: Starlight220 <53231611+Starlight220@users.noreply.github.com>
2023-05-12 21:35:39 -07:00
Tyler Veness
15ba95df7e [wpiutil] Use std::filesystem (#4941) 2023-05-12 21:34:09 -07:00
Tyler Veness
77c2124fc5 [wpimath] Remove Eigen's custom STL types (#4945)
In C++20, overaligned types are handled properly, so Eigen's STL types
with custom allocators are no longer needed.
2023-05-12 21:32:58 -07:00
Peter Johnson
27fb47ab10 [glass] Field2D: Embed standard field images (#5159) 2023-05-12 21:31:38 -07:00
sciencewhiz
102e4f2566 [wpilib] Remove deprecated and broken SPI methods (#5249) 2023-05-12 21:30:53 -07:00
Ryan Blue
463a90f1df [wpilib, hal] Add function to read the RSL state (#5312) 2023-05-12 21:30:19 -07:00
Ryan Blue
7a90475eec [wpilib] Update RobotBase documentation (NFC) (#5320) 2023-05-12 21:29:39 -07:00
Ryan Blue
218cfea16b [wpilib] DutyCycleEncoder: Fix reset behavior (#5287)
reset should set the offset to the properly scaled position provided by getAbsolutePosition, not the raw duty cycle.
2023-05-12 21:28:32 -07:00
Thad House
91392823ff [build] Update to gradle 8.1 (#5303) 2023-05-12 21:27:31 -07:00
sciencewhiz
258b7cc48b [wpilibj] Filesystem.getDeployDirectory(): Strip JNI path from user.dir (#5317)
Fixes
https://www.chiefdelphi.com/t/filesystem-getdeploydirectory-returning-wrong-location-how-to-fix/427292
when unit tests are run with VS Code's java test runner due to VS Code
extension setting working directory which changes user.dir.
2023-05-12 21:26:52 -07:00
Ryan Blue
26cc43bee1 [wpilib] Add documentation to SPI mode enum (NFC) (#5324) 2023-05-12 21:26:10 -07:00
sciencewhiz
ac4da9b1cb [hal] Add HAL docs for Addressable LED (NFC) (#5304) 2023-05-07 22:56:40 -07:00
Tyler Veness
21d4244cf7 [wpimath] Fix DCMotor docs (NFC) (#5309) 2023-05-07 22:56:05 -07:00
sciencewhiz
1dff81bea7 [hal] Miscellaneous HAL doc fixes (NFC) (#5306) 2023-05-07 22:55:48 -07:00
Tyler Veness
7ce75574bf [wpimath] Upgrade to Drake v1.15.0 (#5310) 2023-05-07 22:54:58 -07:00
sciencewhiz
576bd646ae [hal] Add CANManufacturer for Redux Robotics (#5305)
Matches wpilibsuite/frc-docs#2225
2023-05-07 22:53:57 -07:00
Joseph Eng
ee3b4621e5 [commands] Add onlyWhile and onlyIf (#5291) 2023-04-30 14:09:02 -07:00
Joseph Eng
40ca094686 [commands] Fix RepeatCommand calling end() twice (#5261) 2023-04-28 20:57:33 -07:00
Cory
9cbeb841f5 [rtns] Match imaging tool capitalization (#5265) 2023-04-28 20:57:12 -07:00
Josiah Hamm
a63d06ff77 [examples] Add constants to java gearsbot example (#5248) 2023-04-28 20:56:14 -07:00
wmgrove
b6c43322a3 [wpilibc] XboxController: Add return tag to docs (NFC) (#5246) 2023-04-28 20:55:39 -07:00
Thad House
5162d0001c [hal] Fix and document addressable LED timings (#5272)
HAL_SetAddressableLEDBitTiming swapped high and low timings for whatever
was written to it. This fixes that bug.

Additionally, the API has been updated to take high time first, and then
low time. This is due to this being the physical data format, so having
the API match is clearer.

Additionally, update the docs with the defaults.
2023-04-28 20:54:58 -07:00
Tyler Veness
90fabe9651 [wpilibj] Use method references in drive class initSendable() (#5251) 2023-04-28 20:53:42 -07:00
Gold856
24828afd11 [wpimath] Fix desaturateWheelSpeeds to account for negative speeds (#5269) 2023-04-28 20:53:20 -07:00
Tyler Veness
e099948a77 [wpimath] Clean up rank notation in docs (NFC) (#5274) 2023-04-28 20:52:29 -07:00
Tyler Veness
fd2d8cb9c1 [hal] Use std::log2() for base-2 logarithm (#5278) 2023-04-28 20:52:03 -07:00
Sriman Achanta
ba8c64bcff [wpimath] Fix misspelled Javadoc parameters in pose estimators (NFC) (#5292) 2023-04-28 20:51:47 -07:00
Tyler Veness
f53c6813d5 [wpimath] Patch Eigen warnings (#5290) 2023-04-28 20:51:22 -07:00
Thad House
663703d370 [gitattributes] Mark json files as lf text files (#5256)
* Mark json files as lf text files

Otherwise spotless complains

* Formatting
2023-04-06 18:46:18 -07:00
Starlight220
aa34aacf6e [wpilib] Shuffleboard: Keep duplicates on SelectTab() (#5198) 2023-03-26 20:12:55 -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
Peter Johnson
9227b2166e [wpilibj] DriverStation: Fix joystick data logs (#5240)
Was logging relative to cached value rather than previously logged value.
Was also logging cached value instead of current loop value.
C++ implementation is correct.
2023-03-26 16:17:13 -07:00
Peter Johnson
fbf92e9190 [wpinet] ParallelTcpConnector: don't connect to duplicate addresses (#5169)
There can be duplicate addresses coming out of name resolution; if we
already started connecting to an address, don't start another connection
attempt.
2023-03-25 16:28:39 -07:00
Peter Johnson
2108a61362 [ntcore] NT4 client: close timed-out connections (#5175)
Pings are sent every 3 seconds.  If we don't see a response to the last
ping before it's time to send the next one, close the connection.
2023-03-25 16:27:40 -07:00
Peter Johnson
0a66479693 [ntcore] Optimize scan of outgoing messages (#5227)
The algorithm being used for scanning outgoing messages was O(n^2)
because it did a full linear search and then appended. This scan is
performed for each client. If there is a burst of outgoing changes, the
outgoing queue can get quite deep all at once and this scan can be very
slow. Replacing with a map fixes this.
2023-03-25 15:20:22 -07:00
Ryan Blue
b510c17ef6 [hal] Fix RobotController.getComments() mishandling quotes inside the comments string (#5197)
Previously, the comment would end at any quote, escaped or unescaped. This allows UnescapeCString to handle the unescaping of quotes and properly end the string.
2023-03-20 13:50:25 -07:00
Starlight220
e7a7eb2e93 [commands] WaitCommand: Remove subclass doc note (NFC) (#5200) 2023-03-20 13:46:26 -07:00
Starlight220
a465f2d8f0 [examples] Shuffleboard: Correct parameter order (#5204) 2023-03-20 13:45:34 -07:00
Mansour Quddus
a3364422fa LICENSE.md: Bump year to 2023 (#5195) 2023-03-18 07:12:08 -07:00
Tyler Veness
df3242a40a [wpimath] Fix NaN in C++ MakeCostMatrix() that takes an array (#5194)
Java's makeCostMatrix() and the C++ MakeCostMatrix() overload that takes
a parameter pack already do the right thing.
2023-03-17 07:05:28 -07:00
Peter Johnson
00abb8c1e0 [commands] RamseteCommand: default-initialize m_prevSpeeds (#5188) 2023-03-13 23:12:17 -07:00
Ryan Blue
c886273fd7 [wpilibj] DutyCycleEncoder.setDistancePerRotation(): fix simulation (#5147) 2023-03-13 21:28:55 -07:00
Peter Johnson
53b5fd2ace [ntcore] Use int64 for datalog type string (#5186)
There's a spec difference between NT4 and datalog for integers; NT4 uses
"int", datalog uses "int64". We were using "int" for datalog as well.

Also add backwards compatibility support to datalogtool for treating
"int" as "int64".
2023-03-13 21:28:07 -07:00
Peter Johnson
56b758320f [wpilib] DataLogManager: increase time for datetime to be valid (#5185)
There's no signal from NetComm as to when it is valid, and 1 second
seems to be marginal.  Increase to 6 seconds for just DS, 5 seconds for
FMS attached.
2023-03-13 21:27:52 -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
Jeffrey Morris
6d0c5b19db [commands] CommandScheduler.isComposed: Remove incorrect throws clause (NFC) (#5183) 2023-03-13 21:27:08 -07:00
Ryan Blue
0d22cf5ff7 [wpilib] Fix enableLiveWindowInTest crashing in disabled (#5173) 2023-03-10 19:24:40 -08:00
Ryan Blue
32ec5b3f75 [wpilib] Add isTestEnabled and minor docs cleanup (#5172) 2023-03-10 19:23:57 -08:00
Dustin Spicuzza
e5c4c6b1a7 [wpimath] Fix invalid iterator access in TimeInterpolatableBuffer (#5138) 2023-02-26 16:42:24 -08: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
Tyler Veness
ce3686b80d [wpimath] Check LTV controller max velocity precondition (#5142) 2023-02-26 15:05:41 -08:00
Colin Wong
4b0eecaee0 [commands] Subsystem: Add default command removal method (#5064) 2023-02-24 19:58:53 -08:00
Noah Andrews
edf4ded412 [wpilib] PH: Revert to 5V rail being fixed 5V (#5122) 2023-02-24 19:55:50 -08:00
Gabor Szita
4c46b6aff9 [wpilibc] Fix DataLogManager crash on exit in sim (#5125) 2023-02-23 20:13:20 -08:00
David Vo
490ca4a68a [wpilibc] Fix XboxController::GetBackButton doc (NFC) (#5131) 2023-02-23 20:11:10 -08:00
superpenguin612
cbb5b0b802 [hal] Simulation: Fix REV PH solenoids 8+ (#5132) 2023-02-23 20:10:44 -08:00
Thad House
bb7053d9ee [hal] Fix HAL_GetRuntimeType being slow on the roboRIO (#5130)
HAL_GetRuntimeType used to be a free call before the roboRIO2 was added. However, nLoadOut::getTargetClass() is not a free call, and it may hit the IPC layer. Cache this value so it is not called every time.
2023-02-23 00:59:59 -08:00
sciencewhiz
9efed9a533 Update .clang-format to c++20 (#5121)
This does not result in any reformatting
2023-02-20 10:54:55 -08:00
sciencewhiz
dbbfe1aed2 [wpilib] Use PH voltage to calc Analog pressure switch threshold (#5115)
The calculated trigger voltages were calculated with a hard coded 5v.
This introduces error when the 5V provided to the Analog pressure
sensor is not exactly 5v, as the pressure is a ratio of the analog
voltage and provided voltage.

This should improve
https://www.chiefdelphi.com/t/rev-pressure-sensor-enablecompressoranalog-not-reaching-configured-pressure/426868
where the 5v voltage was 4.92 volts, which introduces ~8 PSI of error.
2023-02-19 23:13:22 -08:00
Ryan Blue
de65a135c3 [wpilib] DutyCycleEncoderSim: Add channel number constructor (#5118) 2023-02-19 23:12:48 -08:00
sciencewhiz
3e9788cdff [docs] Strip path from generated NT docs (#5119)
Fixes #5117
2023-02-19 23:12:05 -08:00
Peter Johnson
ecb072724d [ntcore] Client::Disconnect(): actually close connection (#5113) 2023-02-17 23:56:49 -08:00
Peter Johnson
0d462a4561 [glass] NT view: Change string/string array to quoted (#5111) 2023-02-17 18:01:54 -08:00
Peter Johnson
ba37986561 [ntcore] NetworkClient::Disconnect: Add null check (#5112) 2023-02-17 16:48:34 -08:00
Peter Johnson
25ab9cda92 [glass,ov] Provide menu item to create topic from root (#5110) 2023-02-17 16:46:02 -08:00
Peter Johnson
2f6251d4a6 [glass] Set default value when publishing new topic (#5109) 2023-02-17 16:45:38 -08:00
Jonah
e9a7bed988 [wpimath] Add timestamp getter to MathShared (#5091)
This makes it possible to mock the timestamp for wpimath without affecting the rest of the library.

Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
2023-02-17 14:53:17 -08:00
Peter Johnson
9cc14bbb43 [ntcore] Add stress test to dev executable (#5107) 2023-02-16 22:49:36 -08:00
Peter Johnson
8068369542 [wpinet] uv: Stop creating handles when closing loop (#5102)
This prevents EventLoopRunner::Stop() from hanging in the case when
new handles are created after the async walk closes all the handles.
2023-02-16 22:49:14 -08:00
Peter Johnson
805c837a42 [ntcore] Fix use-after-free in server (#5101)
The client name deduplication didn't properly deduplicate.  Instead,
always append the client index to guarantee a unique name.
2023-02-16 22:45:50 -08:00
bovlb
fd18577ba0 [commands] Improve documentation of addRequirements (NFC) (#5103) 2023-02-16 22:08:46 -08:00
Tyler Veness
74dea9f05e [wpimath] Fix exception for empty pose buffer in pose estimators (#5106)
Fixes #5100.
2023-02-16 22:00:21 -08:00
sciencewhiz
9eef79d638 [wpilib] PneumaticHub: Document range of enableCompressorAnalog (NFC) (#5099) 2023-02-15 20:25:12 -08:00
Peter Johnson
843574a810 [ntcore] Use wpi::Now instead of loop time for transmit time
As the send function is called after local processing, there can be a
substantial delay between the loop time and the actual send.
2023-02-13 23:00:03 -08:00
Peter Johnson
226ef35212 [wpinet] WebSocket: Reduce server send frame overhead
Avoid allocating 4K buffer to send a 10-byte header per frame.
2023-02-13 23:00:03 -08:00
Peter Johnson
b30664d630 [ntcore] Reduce initial connection overhead
Mixing the announce and value messages causes significant downstream
inefficiency in both time and space.
2023-02-13 23:00:03 -08:00
sciencewhiz
804e5ce236 [examples] MecanumDrive: Fix axis comment in C++ example (NFC) (#5096) 2023-02-13 22:18:23 -08:00
Starlight220
49af88f2bb [examples] ArmSimulation: Fix flaky test (#5093) 2023-02-13 12:59:27 -08:00
Peter Johnson
d56314f866 [wpiutil] Disable mock time on the Rio (#5092) 2023-02-12 22:38:34 -08:00
Starlight220
43975ac7cc [examples] ArmSimulation, ElevatorSimulation: Extract mechanism to class (#5052) 2023-02-12 06:50:57 -08:00
Starlight220
5483464158 [examples, templates] Improve descriptions (NFC) (#5051) 2023-02-12 06:49:20 -08:00
Starlight220
785e7dd85c [wpilibc] SendableChooser: static_assert copy- and default-constructibility (#5078)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2023-02-12 06:24:00 -08:00
Peter Johnson
e57ded8c39 [ntcore] Improve disconnect error reporting (#5085)
Also fix memory leak in WebSocketConnection destructor.
2023-02-11 22:56:29 -08:00
Peter Johnson
01f0394419 [wpinet] Revert WebSocket: When Close() is called, call closed immediately (#5084)
This caused crashes in ntcore.

This reverts commit b879a6f8c6 (#5047).
2023-02-11 22:56:01 -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
Tyler Veness
37f065032f [wpilib] Refactor TimedRobot tests (#5068) 2023-02-07 23:00:46 -08:00
Ryan Blue
22a170bee7 [wpilib] Add Notifier test (#5070) 2023-02-07 23:00:17 -08:00
5623 changed files with 866821 additions and 205666 deletions

20
.bazelignore Normal file
View File

@@ -0,0 +1,20 @@
build_cmake
build-cmake
# Auto generated by vscode
apriltag/bin
cameraserver/bin
cameraserver/multiCameraServer/bin
cscore/bin
fieldImages/bin
hal/bin
developerRobot/bin
ntcore/bin
romiVendordep/bin
wpilibNewCommands/bin
wpilibj/bin
wpimath/bin
wpinet/bin
wpiutil/bin
wpiunits/bin
xrpVendordep/bin

57
.bazelrc Normal file
View File

@@ -0,0 +1,57 @@
try-import %workspace%/bazel_auth.rc
try-import %workspace%/user.bazelrc
common --noenable_bzlmod
build --java_language_version=17
build --java_runtime_version=roboriojdk_17
build --tool_java_language_version=17
build --tool_java_runtime_version=remotejdk_17
test --test_output=errors
test --test_verbose_timeout_warnings
import shared/bazel/compiler_flags/sanitizers.rc
import shared/bazel/compiler_flags/base_linux_flags.rc
import shared/bazel/compiler_flags/linux_flags.rc
import shared/bazel/compiler_flags/osx_flags.rc
import shared/bazel/compiler_flags/roborio_flags.rc
import shared/bazel/compiler_flags/systemcore_flags.rc
import shared/bazel/compiler_flags/windows_flags.rc
import shared/bazel/compiler_flags/coverage_flags.rc
# Alias toolchain names to what wpilibsuite uses for CI/Artifact naming
build:athena --config=roborio
build:linuxarm32 --config=raspibookworm32
build:linuxarm64 --config=bookworm64
build:build_java --test_tag_filters=allwpilib-build-java --build_tag_filters=allwpilib-build-java
build:build_cpp --test_tag_filters=+allwpilib-build-cpp --build_tag_filters=+allwpilib-build-cpp
build:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example
test:no_example --test_tag_filters=-wpi-example --build_tag_filters=-wpi-example
# Build Buddy Cache Setup
build:build_buddy --bes_results_url=https://app.buildbuddy.io/invocation/
build:build_buddy --bes_backend=grpcs://remote.buildbuddy.io
build:build_buddy --remote_cache=grpcs://remote.buildbuddy.io
build:build_buddy --remote_timeout=3600
# Additional suggestions from buildbuddy for speed
build:build_buddy --experimental_remote_cache_compression
build:build_buddy --experimental_remote_cache_compression_threshold=100
build:build_buddy --noslim_profile
build:build_buddy --experimental_profile_include_target_label
build:build_buddy --experimental_profile_include_primary_output
build:build_buddy --nolegacy_important_outputs
common:build_buddy_readonly --noremote_upload_local_results
# This config should be used locally. It downloads more than the CI version
build:remote_user --config=build_buddy
build:remote_user --config=build_buddy_readonly
build:remote_user --remote_download_toplevel
build:ci --config=build_buddy
build:ci --remote_download_minimal
build --build_metadata=REPO_URL=https://github.com/wpilibsuite/allwpilib.git

1
.bazelversion Normal file
View File

@@ -0,0 +1 @@
7.3.1

View File

@@ -1,111 +1,179 @@
---
Language: Cpp
BasedOnStyle: Google
AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: false
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterAttributes: Always
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*\.h>'
Priority: 1
SortPriority: 0
CaseSensitive: false
- Regex: '^<.*'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 3
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '([-_](test|unittest))?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
Macros:
- 'HAL_ENUM(name)=enum name'
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: NextLine
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
PPIndentWidth: -1
QualifierAlignment: Leave
RawStringFormats:
- Language: Cpp
Delimiters:
@@ -132,34 +200,72 @@ RawStringFormats:
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
- ParseTestProto
- ParsePartialTestProto
CanonicalDelimiter: pb
BasedOnStyle: google
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: false
SortUsingDeclarations: true
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: c++17
SpaceInEmptyBlock: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: c++20
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...

View File

@@ -35,7 +35,6 @@ Checks:
bugprone-unhandled-self-assignment,
bugprone-unused-raii,
bugprone-virtual-near-miss,
cert-dcl58-cpp,
cert-err52-cpp,
cert-err60-cpp,
cert-mem57-cpp,
@@ -50,7 +49,6 @@ Checks:
google-build-namespaces,
google-explicit-constructor,
google-global-names-in-headers,
google-readability-avoid-underscore-in-googletest-name,
google-readability-casting,
google-runtime-operator,
misc-definitions-in-headers,

6
.gersemirc Normal file
View File

@@ -0,0 +1,6 @@
color: false
definitions: [cmake/modules]
line_length: 100
list_expansion: favour-inlining
quiet: false
unsafe: false

26
.gitattributes vendored
View File

@@ -1,4 +1,30 @@
*.adoc text eol=lf
*.c text eol=lf
*.cmake text eol=lf
*.clang-format text eol=lf
*.clang-tidy text eol=lf
*.cpp text eol=lf
*.gradle text eol=lf
*.groovy text eol=lf
*.h text eol=lf
*.hpp text eol=lf
*.in text eol=lf
*.inc text eol=lf
*.java text eol=lf
*.jinja text eol=lf
*.json text eol=lf
*.m text eol=lf
*.md text eol=lf
*.mm text eol=lf
*.patch text eol=lf
*.plist text eol=lf
*.proto text eol=lf
*.py text eol=lf
*.styleguide text eol=lf
*.txt text eol=lf
*.xml text eol=lf
*.yaml text eol=lf
*.yml text eol=lf
# Generated files
*/src/generated/** linguist-generated

2
.github/CODEOWNERS vendored
View File

@@ -29,8 +29,6 @@
/wpilibNewCommands/ @wpilibsuite/commandbased
/wpilibOldCommands/ @wpilibsuite/commandbased
/wpilibcExamples/ @wpilibsuite/wpilib @wpilibsuite/documentation
/wpilibjExamples/ @wpilibsuite/wpilib @wpilibsuite/documentation

View File

@@ -2,7 +2,7 @@
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
labels: 'type: bug'
assignees: ''
---
@@ -15,6 +15,8 @@ Steps to reproduce the behavior:
1. ...
2. ...
- Link to code:
**Expected behavior**
A clear and concise description of what you expected to happen.
@@ -22,10 +24,8 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- WPILib Version: [e.g. 2021.3.1]
- OS: [e.g. Windows 11]
- Java version [e.g. 1.10.2]
- C++ version [e.g. 17]
- Project Information: [In Visual Studio Code, press the WPILib button and choose WPILib: Open Project Information. Press the copy button and paste the data here. If not using VS Code, please include WPILib version, Gradle version, Java version, C++ version (if applicable), and any third party libraries and versions]
**Additional context**
Add any other context about the problem here.

View File

@@ -2,7 +2,7 @@
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
labels: 'type: feature'
assignees: ''
---

View File

@@ -2,7 +2,7 @@
name: Question
about: Ask about features or parts of this project
title: ''
labels: ''
labels: 'type: support'
assignees: ''
---

65
.github/actions/pregen/action.yml vendored Normal file
View File

@@ -0,0 +1,65 @@
name: 'Setup and run pregeneration'
description: 'Sets up the dependencies needed to generate generated files and runs all generation scripts'
runs:
using: "composite"
steps:
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install jinja and protobuf
run: python -m pip install jinja2 protobuf grpcio-tools
shell: bash
- name: Install protobuf and perl dependencies
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler liblist-moreutils-perl
wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.3/protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
chmod +x protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
shell: bash
- name: Regenerate hal
run: ./hal/generate_usage_reporting.py
shell: bash
- name: Regenerate ntcore
run: ./ntcore/generate_topics.py
shell: bash
- name: Regenerate imgui
run: |
./thirdparty/imgui_suite/generate_fonts.sh
./thirdparty/imgui_suite/generate_gl3w.py
shell: bash
- name: Regenerate HIDs
run: |
./wpilibc/generate_hids.py
./wpilibj/generate_hids.py
./wpilibNewCommands/generate_hids.py
shell: bash
- name: Regenerate PWM motor controllers
run: |
./wpilibc/generate_pwm_motor_controllers.py
./wpilibj/generate_pwm_motor_controllers.py
shell: bash
- name: Regenerate mrcal minimath
run: ./wpical/generate_mrcal.py
shell: bash
- name: Regenerate wpimath
run: |
./wpimath/generate_nanopb.py
./wpimath/generate_numbers.py
./wpimath/generate_quickbuf.py --quickbuf_plugin protoc-gen-quickbuf-1.3.3-linux-x86_64.exe
shell: bash
- name: Regenerate wpiunits
run: ./wpiunits/generate_units.py
shell: bash
- name: Regenerate wpiutil nanopb
run: ./wpiutil/generate_nanopb.py
shell: bash

View File

@@ -0,0 +1,27 @@
name: 'Setup BuildBuddy acache'
description: 'Sets up the build buddy cache to be readonly / writing based on the presence of environment variables'
inputs:
token:
description: 'Build Buddy API token'
runs:
using: "composite"
steps:
- name: Setup without key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY == '' }}
shell: bash
run: |
echo "No API key secret detected, will setup readonly cache"
echo "build:ci --config=build_buddy_readonly" > bazel_auth.rc
- name: Set with key
env:
API_KEY: ${{ inputs.token }}
if: ${{ env.API_KEY != '' }}
shell: bash
run: |
echo "API Key detected!"
echo "build:build_buddy --remote_header=x-buildbuddy-api-key=${{ env.API_KEY }}" > bazel_auth.rc

65
.github/labeler.yml vendored Normal file
View File

@@ -0,0 +1,65 @@
'2027':
- base-branch: '2027'
'component: apriltag':
- changed-files:
- any-glob-to-any-file: apriltag/**
'component: command-based':
- changed-files:
- any-glob-to-any-file: wpilibNewCommands/**
'component: cscore':
- changed-files:
- any-glob-to-any-file: cscore/**
'component: datalogtool':
- changed-files:
- any-glob-to-any-file: datalogtool/**
'component: epilogue':
- changed-files:
- any-glob-to-any-file: epilogue-*/**
'component: examples':
- changed-files:
- any-glob-to-any-file: wpilib*Examples/**
'component: glass':
- changed-files:
- any-glob-to-any-file: glass/**
'component: hal':
- changed-files:
- any-glob-to-any-file: hal/**
'component: ntcore':
- changed-files:
- any-glob-to-any-file: ntcore/**
'component: outlineviewer':
- changed-files:
- any-glob-to-any-file: outlineviewer/**
'component: sysid':
- changed-files:
- any-glob-to-any-file: sysid/**
'component: teamnumbersetter':
- changed-files:
- any-glob-to-any-file: roborioteamnumbersetter/**
'component: wpilibc':
- changed-files:
- any-glob-to-any-file: wpilibc/**
'component: wpilibj':
- changed-files:
- any-glob-to-any-file: wpilibj/**
'component: wpimath':
- changed-files:
- any-glob-to-any-file: wpimath/**
'component: wpinet':
- changed-files:
- any-glob-to-any-file: wpinet/**
'component: wpiunits':
- changed-files:
- any-glob-to-any-file: wpiunits/**
'component: wpiutil':
- changed-files:
- any-glob-to-any-file: wpiutil/**
'component: wpical':
- changed-files:
- any-glob-to-any-file: wpical/**
'component: usage reporting':
- changed-files:
- any-glob-to-any-file: hal/src/generate/**
'attn: NI':
- changed-files:
- any-glob-to-any-file: hal/src/generate/**

View File

@@ -0,0 +1,23 @@
{
"files": [
{
"aql": {
"items.find": {
"$or":[
{ "repo": "wpilib-generic-gradlecache" },
{ "repo": "wpilib-generic-cache-cmake" }
],
"$or":[
{
"stat.downloaded": { "$before":"1mo" }
},
{
"stat.downloaded": { "$eq":null }
}
],
"created": { "$before":"1mo" }
}
}
}
]
}

View File

@@ -0,0 +1,29 @@
{
"files": [
{
"aql": {
"items.find": {
"repo": "wpilib-mvn-development-local",
"path": { "$nmatch":"*edu/wpi/first/thirdparty*" },
"$or":[
{
"artifact.module.build.name": { "$eq":"allwpilib" }
},
{
"artifact.module.build.name": { "$eq":"combiner" }
}
],
"$or":[
{
"stat.downloaded": { "$before":"3mo" }
},
{
"stat.downloaded": { "$eq":null }
}
],
"created": { "$before":"3mo" }
}
}
}
]
}

View File

@@ -0,0 +1,33 @@
name: Artifactory Nightly Cleanup
on:
workflow_dispatch:
schedule:
- cron: '15 2 * * *'
jobs:
wpilib-mvn-development_unused_cleanup:
runs-on: ubuntu-latest
if: github.repository == 'wpilibsuite/allwpilib' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: jfrog/setup-jfrog-cli@v4
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_CLI_SECRET }}
- name: Cleanup
run: jf rt del --spec=.github/workflows/aql/wpilib-mvn-development_unused.aql
wpilib-generic-gradle-cache_unused_cleanup:
runs-on: ubuntu-latest
if: github.repository == 'wpilibsuite/allwpilib' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: jfrog/setup-jfrog-cli@v4
env:
JF_ENV_1: ${{ secrets.ARTIFACTORY_CLI_SECRET }}
- name: Cleanup
run: jf rt del --spec=.github/workflows/aql/wpilib-generic-gradle-cache_unused.aql

109
.github/workflows/bazel.yml vendored Normal file
View File

@@ -0,0 +1,109 @@
name: Bazel
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
build-windows:
strategy:
fail-fast: false
matrix:
include:
- { name: "Windows (native)", os: windows-2022, action: "test", config: "--config=windows", }
- { name: "Windows (arm)", os: windows-2022, action: "build", config: "--config=windows_arm", }
name: "Build ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 17
architecture: x64
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build Release
run: bazel --output_user_root=C:\\bazelroot ${{ matrix.action }} -k ... --config=ci -c opt ${{ matrix.config }} --verbose_failures
shell: bash
build-mac:
name: "Mac"
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build Release
run: bazel test -k ... --config=ci -c opt --config=macos --nojava_header_compilation --verbose_failures
shell: bash
build-linux:
strategy:
fail-fast: false
matrix:
include:
- { name: "Linux (native)", os: ubuntu-22.04, action: "test", config: "--config=linux", }
- { name: "Linux (roborio)", os: ubuntu-22.04, action: "build", config: "--config=roborio", }
name: "${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: bazelbuild/setup-bazelisk@v3
- id: Setup_build_buddy
uses: ./.github/actions/setup-build-buddy
with:
token: ${{ secrets.BUILDBUDDY_API_KEY }}
- name: Build and Test Release
run: bazel ${{ matrix.action }} ... --config=ci -c opt ${{ matrix.config }} -k --verbose_failures
buildifier:
name: "buildifier"
runs-on: ubuntu-22.04
steps:
- name: Set up Go 1.15.x
uses: actions/setup-go@v5
with:
cache: false
go-version: 1.15.x
id: go
- name: Install Buildifier
run: |
cd $(mktemp -d)
GO111MODULE=on go get github.com/bazelbuild/buildtools/buildifier@6.0.0
- uses: actions/checkout@v4
with: { fetch-depth: 0 }
- name: Run buildifier
run: buildifier -warnings all --lint=fix -r .
- name: Check Output
run: git --no-pager diff --exit-code HEAD
- name: Generate diff
run: git diff HEAD > bazel-lint-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-bazel-lint-fixes
path: bazel-lint-fixes.patch
if: ${{ failure() }}

51
.github/workflows/cmake-android.yml vendored Normal file
View File

@@ -0,0 +1,51 @@
name: CMake Android
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
SCCACHE_WEBDAV_ENDPOINT: "https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-cmake-local"
SCCACHE_WEBDAV_KEY_PREFIX: "sccache"
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-22.04
name: Android Arm64
abi: arm64-v8a
- os: ubuntu-22.04
name: Android X64
abi: "x86_64"
name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r27c
add-to-path: false
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.5
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y ninja-build
- name: configure
run: cmake --preset with-sccache -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_WPILIB=OFF -DWITH_GUI=OFF -DWITH_CSCORE=OFF -DWITH_TESTS=OFF -DWITH_SIMULATION_MODULES=OFF -DWITH_PROTOBUF=OFF -DWITH_JAVA=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_TOOLCHAIN_FILE=${{ steps.setup-ndk.outputs.ndk-path }}/build/cmake/android.toolchain.cmake -DANDROID_ABI="${{ matrix.abi }}" -DANDROID_PLATFORM=android-24
- name: build
run: cmake --build build-cmake --parallel $(nproc)

View File

@@ -6,6 +6,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
SCCACHE_WEBDAV_ENDPOINT: "https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-cmake-local"
SCCACHE_WEBDAV_KEY_PREFIX: "sccache"
jobs:
build:
strategy:
@@ -14,43 +18,68 @@ jobs:
include:
- os: ubuntu-22.04
name: Linux
container: wpilib/roborio-cross-ubuntu:2023-22.04
flags: ""
- os: macOS-11
container: wpilib/roborio-cross-ubuntu:2025-22.04
flags: "--preset with-java-and-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
- os: macOS-14
name: macOS
container: ""
flags: "-DWITH_JAVA=OFF"
env: "PATH=\"/opt/homebrew/opt/protobuf@3/bin:$PATH\""
flags: "--preset with-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DCMAKE_LIBRARY_PATH=/opt/homebrew/opt/protobuf@3/lib -DProtobuf_INCLUDE_DIR=/opt/homebrew/opt/protobuf@3/include -DProtobuf_PROTOC_EXECUTABLE=/opt/homebrew/opt/protobuf@3/bin/protoc"
- os: windows-2022
name: Windows
container: ""
flags: '--preset with-sccache -DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=OFF -DCMAKE_TOOLCHAIN_FILE="$Env:RUNNER_WORKSPACE/vcpkg/scripts/buildsystems/vcpkg.cmake" -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release'
name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java libprotobuf-dev protobuf-compiler ninja-build
- name: Install opencv (macOS)
run: brew install opencv
- name: Install dependencies (macOS)
if: runner.os == 'macOS'
run: brew install opencv protobuf@3 ninja
- name: Set up Python 3.8 (macOS)
if: runner.os == 'macOS'
uses: actions/setup-python@v4
- uses: ilammy/msvc-dev-cmd@v1.13.0
if: runner.os == 'Windows'
- name: Install CMake (Windows only)
if: runner.os == 'Windows'
uses: lukka/get-cmake@v3.29.3
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.5
- uses: actions/checkout@v4
- name: Run vcpkg (Windows only)
if: runner.os == 'Windows'
uses: lukka/run-vcpkg@v11.5
with:
python-version: 3.8
- name: Install jinja
run: python -m pip install jinja2
vcpkgDirectory: ${{ runner.workspace }}/vcpkg
vcpkgGitCommitId: 37c3e63a1306562f7f59c4c3c8892ddd50fdf992 # HEAD on 2024-02-24
- name: configure
run: mkdir build && cd build && cmake ${{ matrix.flags }} ..
run: cmake ${{ matrix.flags }}
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: build
working-directory: build
run: cmake --build . --parallel $(nproc)
run: cmake --build build-cmake --parallel $(nproc)
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: test
working-directory: build
if: runner.os != 'Windows'
working-directory: build-cmake
run: ctest --output-on-failure
- name: test (windows)
if: runner.os == 'Windows'
working-directory: build-cmake
# UnitTest_test segfaults on exit occasionally
run: ctest --output-on-failure -E 'UnitTest'

View File

@@ -0,0 +1,27 @@
name: Comment on PR for robotpy
on:
pull_request_target:
types:
- opened
paths:
- 'wpilibNewCommands/src/**/*.java'
jobs:
comment:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Comment on PR
if: github.repository == 'wpilibsuite/allwpilib'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'This PR modifies commands. Please open a corresponding PR in [Python Commands](https://github.com/robotpy/robotpy-commands-v2/) and include a link to this PR.'
})

View File

@@ -1,64 +0,0 @@
name: Comment Commands
on:
issue_comment:
types: [ created ]
jobs:
format:
if: github.event.issue.pull_request && startsWith(github.event.comment.body, '/format')
runs-on: ubuntu-22.04
steps:
- name: React Rocket
uses: actions/github-script@v4
with:
script: |
const {owner, repo} = context.issue
github.reactions.createForIssueComment({
owner,
repo,
comment_id: context.payload.comment.id,
content: "rocket",
});
- uses: actions/checkout@v3
with:
token: ${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}
- name: Fetch all history and metadata
run: |
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Checkout PR
run: |
gh pr checkout $NUMBER
env:
GITHUB_TOKEN: "${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}"
NUMBER: ${{ github.event.issue.number }}
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'zulu'
java-version: 11
- name: Install clang-format
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-format-14
- name: Install wpiformat
run: pip3 install wpiformat
- name: Run wpiformat
run: wpiformat -clang 14
- name: Run spotlessApply
run: ./gradlew spotlessApply
- name: Commit
run: |
# Set credentials
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Commit
git commit -am "Formatting fixes"
git push

View File

@@ -13,52 +13,55 @@ jobs:
publish:
name: "Documentation - Publish"
runs-on: ubuntu-22.04
if: github.repository_owner == 'wpilibsuite' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
if: github.repository == 'wpilibsuite/allwpilib' && (github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
concurrency: ci-docs-publish
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-java@v3
- uses: gradle/actions/wrapper-validation@v4
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 13
distribution: 'temurin'
java-version: 17
- name: Set environment variables (Development)
run: |
echo "TARGET_FOLDER=$BASE_PATH/development" >> $GITHUB_ENV
echo "BRANCH=development" >> $GITHUB_ENV
if: github.ref == 'refs/heads/main'
- name: Set environment variables (Tag)
run: |
echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
echo "TARGET_FOLDER=$BASE_PATH/beta" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
echo "BRANCH=beta" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')
- name: Set environment variables (Release)
run: |
echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
echo "TARGET_FOLDER=$BASE_PATH/release" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta')
echo "BRANCH=release" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, 'alpha') && !contains(github.ref, 'beta') && !contains(github.ref, '2027')
- name: Build with Gradle
run: ./gradlew docs:generateJavaDocs docs:doxygen -PbuildServer ${{ env.EXTRA_GRADLE_ARGS }}
- name: Install SSH Client 🔑
uses: webfactory/ssh-agent@v0.7.0
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.GH_DEPLOY_KEY }}
- name: Deploy Java 🚀
uses: JamesIves/github-pages-deploy-action@3.7.1
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4.6.1
with:
SSH: true
REPOSITORY_NAME: wpilibsuite/wpilibsuite.github.io
BRANCH: main
CLEAN: true
FOLDER: docs/build/docs/javadoc
TARGET_FOLDER: ${{ env.TARGET_FOLDER }}/java
- name: Deploy C++ 🚀
uses: JamesIves/github-pages-deploy-action@3.7.1
ssh-key: true
repository-name: wpilibsuite/wpilibsuite.github.io
branch: allwpilib-${{ env.BRANCH }}
clean: true
single-commit: true
folder: docs/build/docs
- name: Trigger Workflow
uses: actions/github-script@v7
with:
SSH: true
REPOSITORY_NAME: wpilibsuite/wpilibsuite.github.io
BRANCH: main
CLEAN: true
FOLDER: docs/build/docs/doxygen/html
TARGET_FOLDER: ${{ env.TARGET_FOLDER }}/cpp
github-token: ${{ secrets.DISPATCH_PAT_TOKEN }}
script: |
github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: 'wpilibsuite.github.io',
workflow_id: 'static.yml',
ref: 'main',
})

45
.github/workflows/fix_compile_commands.py vendored Executable file
View File

@@ -0,0 +1,45 @@
#!/usr/bin/env python3
import argparse
import json
def main():
parser = argparse.ArgumentParser(
description="Fix compile_commands.json generated by Gradle"
)
parser.add_argument("filename", help="compile_commands.json location")
cmd_args = parser.parse_args()
# Read JSON
with open(cmd_args.filename) as f:
data = json.load(f)
for obj in data:
out_args = []
iter_args = iter(obj["arguments"])
for arg in iter_args:
# Filter out -isystem flags that cause false positives
if arg == "-isystem":
next_arg = next(iter_args)
# /usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include/xmmintrin.h:54:1:
# error: conflicting types for '_mm_prefetch' [clang-diagnostic-error]
if not next_arg.startswith("/usr/lib/gcc/"):
out_args += ["-isystem", next_arg]
# Replace GCC warning argument with one Clang recognizes
elif arg == "-Wno-maybe-uninitialized":
out_args.append("-Wno-uninitialized")
else:
out_args.append(arg)
obj["arguments"] = out_args
# Write JSON
with open(cmd_args.filename, "w") as f:
json.dump(data, f, indent=2)
if __name__ == "__main__":
main()

View File

@@ -1,14 +0,0 @@
name: "Validate Gradle Wrapper"
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: gradle/wrapper-validation-action@v1

View File

@@ -7,18 +7,25 @@ concurrency:
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
build-docker:
strategy:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2023-22.04
- container: wpilib/roborio-cross-ubuntu:2025-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
- container: wpilib/raspbian-cross-ubuntu:bookworm-22.04
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bullseye-22.04
- container: wpilib/aarch64-cross-ubuntu:bookworm-22.04
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/ubuntu-base:22.04
@@ -26,27 +33,43 @@ jobs:
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ubuntu-22.04
container: ${{ matrix.container }}
needs: [validation]
steps:
- uses: actions/checkout@v3
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set release environment variable
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')
- name: Build with Gradle
run: ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e ARTIFACTORY_PUBLISH_USERNAME -e ARTIFACTORY_PUBLISH_PASSWORD -e GITHUB_REF -e CI
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
env:
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- uses: actions/upload-artifact@v3
- name: Check free disk space
run: df .
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: build/allOutputs
build-host:
env:
MACOSX_DEPLOYMENT_TARGET: 10.15
MACOSX_DEPLOYMENT_TARGET: 13.3
strategy:
fail-fast: false
matrix:
@@ -55,56 +78,94 @@ jobs:
artifact-name: Win64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly --max-workers 1"
build-options: "-PciDebugOnly"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win64Release
architecture: x64
build-options: "-PciReleaseOnly --max-workers 1"
build-options: "-PciReleaseOnly"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: macOS-11
artifact-name: macOS
- os: windows-2022
artifact-name: WinArm64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly -Pbuildwinarm64 -Ponlywindowsarm64"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: WinArm64Release
architecture: x64
build-options: "-PciReleaseOnly -Pbuildwinarm64 -Ponlywindowsarm64"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: macOS-14
artifact-name: macOS
architecture: aarch64
task: "build"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win32
artifact-name: Win32FFI
architecture: x86
task: ":ntcoreffi:build"
build-options: "-Pntcoreffibuild \"-Dorg.gradle.jvmargs=-Xmx1096m\""
outputs: "ntcoreffi/build/outputs"
- os: windows-2022
artifact-name: Win64FFI
architecture: x64
task: ":ntcoreffi:build"
build-options: "-Pntcoreffibuild -Pbuildwinarm64"
outputs: "ntcoreffi/build/outputs"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
needs: [validation]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: 17
architecture: ${{ matrix.architecture }}
- name: Import Developer ID Certificate
uses: wpilibsuite/import-signing-certificate@v1
uses: wpilibsuite/import-signing-certificate@v2
with:
certificate-data: ${{ secrets.APPLE_CERTIFICATE_DATA }}
certificate-passphrase: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
keychain-password: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
matrix.artifact-name == 'macOS' && (github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027'))))
- name: Set Keychain Lock Timeout
run: security set-keychain-settings -lut 3600
run: security set-keychain-settings -lut 21600
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
matrix.artifact-name == 'macOS' && (github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027'))))
- name: Set release environment variable
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
shell: bash
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')
- name: Set Java Heap Size
run: sed -i 's/-Xmx2g/-Xmx1g/g' gradle.properties
if: matrix.artifact-name == 'Win32'
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space pre-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Cleanup disk space
# CodeQL: 5G
# go: 748M
# Android: 12G
run: |
rm -rf /Users/runner/hostedtoolcache/CodeQL
rm -rf /Users/runner/hostedtoolcache/go
rm -rf /Users/runner/Library/Android
if: matrix.os == 'macOS-14'
- name: Check disk free space post-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Build with Gradle
run: ./gradlew ${{ matrix.task }} --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
env:
@@ -113,9 +174,15 @@ jobs:
- name: Sign Libraries with Developer ID
run: ./gradlew copyAllOutputs --build-cache -PbuildServer -PskipJavaFormat -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
- uses: actions/upload-artifact@v3
matrix.artifact-name == 'macOS' && (github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027'))))
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.outputs }}
@@ -123,23 +190,24 @@ jobs:
build-documentation:
name: "Build - Documentation"
runs-on: ubuntu-22.04
needs: [validation]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 13
distribution: 'temurin'
java-version: 17
- name: Set release environment variable
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')
- name: Build with Gradle
run: ./gradlew docs:zipDocs --build-cache -PbuildServer ${{ env.EXTRA_GRADLE_ARGS }}
env:
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: Documentation
path: docs/build/outputs
@@ -149,30 +217,53 @@ jobs:
needs: [build-docker, build-host, build-documentation]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Free Disk Space
if: |
github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/checkout@v4
if: |
github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
with:
repository: wpilibsuite/build-tools
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
if: |
github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
with:
path: combiner/products/build/allOutputs
- name: Flatten Artifacts
if: |
github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
run: rsync -a --delete combiner/products/build/allOutputs/*/* combiner/products/build/allOutputs/
- name: Check version number exists
if: |
github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
run: |
cat combiner/products/build/allOutputs/version.txt
test -s combiner/products/build/allOutputs/version.txt
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
if: |
github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
with:
distribution: 'zulu'
java-version: 11
- name: Combine
distribution: 'temurin'
java-version: 17
- name: Combine (Main)
if: |
!startsWith(github.ref, 'refs/tags/v') &&
github.ref != 'refs/heads/main'
run: cd combiner && ./gradlew publish -Pallwpilib
- name: Combine (Master)
if: |
github.repository_owner == 'wpilibsuite' &&
github.repository == 'wpilibsuite/allwpilib' &&
github.ref == 'refs/heads/main'
run: cd combiner && ./gradlew publish -Pallwpilib
env:
@@ -181,14 +272,35 @@ jobs:
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: Combine (Release)
if: |
github.repository_owner == 'wpilibsuite' &&
startsWith(github.ref, 'refs/tags/v')
github.repository == 'wpilibsuite/allwpilib' &&
startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')
run: cd combiner && ./gradlew publish -Pallwpilib -PreleaseRepoPublish
env:
RUN_AZURE_ARTIFACTORY_RELEASE: "TRUE"
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
if: |
github.repository == 'wpilibsuite/allwpilib' &&
(github.ref == 'refs/heads/main' || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')))
with:
name: Maven
path: ~/releases
dispatch:
name: dispatch
needs: [combine]
strategy:
matrix:
repo: ['SmartDashboard', 'PathWeaver', 'Shuffleboard', 'RobotBuilder']
runs-on: ubuntu-22.04
steps:
- uses: peter-evans/repository-dispatch@v3
if: |
github.repository == 'wpilibsuite/allwpilib' &&
startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '2027')
with:
token: ${{ secrets.TOOL_REPO_ACCESS_TOKEN }}
repository: wpilibsuite/${{ matrix.repo }}
event-type: tag
client-payload: '{"package_name": "allwpilib", "package_version": "${{ github.ref_name }}"}'

14
.github/workflows/labeler.yml vendored Normal file
View File

@@ -0,0 +1,14 @@
name: "Pull Request Labeler"
on:
- pull_request_target
jobs:
labeler:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v5
with:
sync-labels: true

View File

@@ -11,37 +11,40 @@ concurrency:
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
wpiformat:
name: "wpiformat"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all history and metadata
run: |
git config --global --add safe.directory /__w/allwpilib/allwpilib
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Set up Python 3.8
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install clang-format
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-format-14
python-version: '3.12'
- name: Install wpiformat
run: pip3 install wpiformat
run: |
python -m venv ${{ runner.temp }}/wpiformat
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2024.51
- name: Run
run: wpiformat -clang 14
run: ${{ runner.temp }}/wpiformat/bin/wpiformat
- name: Check output
run: git --no-pager diff --exit-code HEAD
- name: Generate diff
run: git diff HEAD > wpiformat-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: wpiformat fixes
path: wpiformat-fixes.patch
@@ -57,43 +60,48 @@ jobs:
tidy:
name: "clang-tidy"
runs-on: ubuntu-22.04
container: wpilib/roborio-cross-ubuntu:2023-22.04
needs: [validation]
container: wpilib/ubuntu-base:22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all history and metadata
run: |
git config --global --add safe.directory /__w/allwpilib/allwpilib
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Set up Python 3.8
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Install clang-tidy
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-tidy-14 clang-format-14
python-version: '3.12'
- name: Install wpiformat
run: pip3 install wpiformat
run: |
python -m venv ${{ runner.temp }}/wpiformat
${{ runner.temp }}/wpiformat/bin/pip3 install wpiformat==2024.51
- name: Create compile_commands.json
run: ./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
run: |
./gradlew generateCompileCommands -Ptoolchain-optional-roboRio
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64release/compile_commands.json
./.github/workflows/fix_compile_commands.py build/TargetedCompileCommands/linuxx86-64debug/compile_commands.json
- name: List changed files
run: wpiformat -list-changed-files
- name: Run clang-tidy
run: wpiformat -clang 14 -no-format -tidy-changed -compile-commands=build/compile_commands/linuxx86-64 -vv
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -list-changed-files
- name: Run clang-tidy release
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64release -vv
- name: Run clang-tidy debug
run: ${{ runner.temp }}/wpiformat/bin/wpiformat -no-format -tidy-changed -compile-commands=build/TargetedCompileCommands/linuxx86-64debug -vv
javaformat:
name: "Java format"
runs-on: ubuntu-22.04
needs: [validation]
container: wpilib/ubuntu-base:22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all history and metadata
run: |
git config --global --add safe.directory /__w/allwpilib/allwpilib
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Run Java format
@@ -103,16 +111,30 @@ jobs:
- name: Generate diff
run: git diff HEAD > javaformat-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v4
with:
name: javaformat fixes
path: javaformat-fixes.patch
if: ${{ failure() }}
- name: Write to job summary
run: |
echo '```diff' >> $GITHUB_STEP_SUMMARY
cat javaformat-fixes.patch >> $GITHUB_STEP_SUMMARY
echo '' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
if: ${{ failure() }}
documentation:
name: "Documentation"
runs-on: ubuntu-22.04
needs: [validation]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: 13
distribution: 'temurin'
java-version: 21
- name: Build with Gradle
run: ./gradlew docs:zipDocs -PbuildServer -PdocWarningsAsErrors ${{ env.EXTRA_GRADLE_ARGS }}

34
.github/workflows/pregenerate.yml vendored Normal file
View File

@@ -0,0 +1,34 @@
name: Check Pregenerated Files
on:
pull_request:
push:
branches-ignore:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
update:
name: "Update"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run pregen
uses: ./.github/actions/pregen
- name: Add untracked files to index so they count as changes
run: git add -A
- name: Check output
run: git --no-pager diff --exit-code HEAD
- name: Generate diff
run: git diff HEAD > pregenerated-files-fixes.patch
if: ${{ failure() }}
- uses: actions/upload-artifact@v4
with:
name: pregenerated-files-fixes
path: pregenerated-files-fixes.patch
if: ${{ failure() }}

View File

@@ -6,6 +6,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
SCCACHE_WEBDAV_ENDPOINT: "https://frcmaven.wpi.edu/artifactory/wpilib-generic-cache-cmake-local"
SCCACHE_WEBDAV_KEY_PREFIX: "sccache"
jobs:
build:
strategy:
@@ -25,23 +29,29 @@ jobs:
ctest-env: ""
ctest-flags: ""
name: "${{ matrix.name }}"
runs-on: ubuntu-22.04
container: wpilib/roborio-cross-ubuntu:2023-22.04
runs-on: ubuntu-24.04
container: wpilib/roborio-cross-ubuntu:2025-24.04
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3 clang-14
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv-java clang-17 libprotobuf-dev protobuf-compiler ninja-build
- name: Install jinja
run: python -m pip install jinja2
- name: Install sccache
uses: mozilla-actions/sccache-action@v0.0.5
- uses: actions/checkout@v4
- name: configure
run: mkdir build && cd build && cmake -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 ${{ matrix.cmake-flags }} ..
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-17 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-17 -DWITH_JAVA=OFF ${{ matrix.cmake-flags }} ..
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: build
working-directory: build
run: cmake --build . --parallel $(nproc)
env:
SCCACHE_WEBDAV_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
SCCACHE_WEBDAV_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: test
working-directory: build

170
.github/workflows/sentinel-build.yml vendored Normal file
View File

@@ -0,0 +1,170 @@
name: Sentinel Build (No Cache)
on:
workflow_dispatch:
schedule:
- cron: "15 3 * * Sat" # 11:15PM EST every Friday
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
jobs:
validation:
name: "Validation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v4
build-docker:
if: (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main') || github.event_name != 'schedule'
strategy:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2025-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bookworm-22.04
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bookworm-22.04
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/ubuntu-base:22.04
artifact-name: Linux
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ubuntu-22.04
needs: [validation]
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build with Gradle
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Check free disk space
run: df .
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: build/allOutputs
build-host:
if: (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main') || github.event_name != 'schedule'
env:
MACOSX_DEPLOYMENT_TARGET: 13.3
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
artifact-name: Win64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win64Release
architecture: x64
build-options: "-PciReleaseOnly"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: WinArm64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly -Pbuildwinarm64 -Ponlywindowsarm64"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: WinArm64Release
architecture: x64
build-options: "-PciReleaseOnly -Pbuildwinarm64 -Ponlywindowsarm64"
task: "copyAllOutputs"
outputs: "build/allOutputs"
- os: macOS-14
artifact-name: macOS
architecture: aarch64
task: "build"
outputs: "build/allOutputs"
- os: windows-2022
artifact-name: Win32
architecture: x86
task: ":ntcoreffi:build"
outputs: "ntcoreffi/build/outputs"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
needs: [validation]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
architecture: ${{ matrix.architecture }}
- name: Import Developer ID Certificate
uses: wpilibsuite/import-signing-certificate@v2
with:
certificate-data: ${{ secrets.APPLE_CERTIFICATE_DATA }}
certificate-passphrase: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
keychain-password: ${{ secrets.APPLE_KEYCHAIN_PASSWORD }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Set Keychain Lock Timeout
run: security set-keychain-settings -lut 21600
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Set Java Heap Size
run: sed -i 's/-Xmx2g/-Xmx1g/g' gradle.properties
if: matrix.artifact-name == 'Win32'
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space pre-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Cleanup disk space
# CodeQL: 5G
# go: 748M
# Android: 12G
run: |
rm -rf /Users/runner/hostedtoolcache/CodeQL
rm -rf /Users/runner/hostedtoolcache/go
rm -rf /Users/runner/Library/Android
if: matrix.os == 'macOS-14'
- name: Check disk free space post-cleanup (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- name: Build with Gradle
run: ./gradlew ${{ matrix.task }} -PbuildServer -PskipJavaFormat ${{ matrix.build-options }}
- name: Sign Libraries with Developer ID
run: ./gradlew copyAllOutputs -PbuildServer -PskipJavaFormat -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} ${{ matrix.build-options }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' && github.ref == 'refs/heads/main')
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Check disk free space (macOS)
run: df -h .
if: matrix.os == 'macOS-14'
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.outputs }}

206
.github/workflows/tools.yml vendored Normal file
View File

@@ -0,0 +1,206 @@
name: Tools
on: [pull_request, push]
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
YEAR: 2025
jobs:
build-artifacts:
name: "Build - WPILib"
runs-on: ubuntu-22.04
env:
DISPLAY: ':10'
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: gradle/actions/wrapper-validation@v4
- name: Build WPILib with Gradle
uses: addnab/docker-run-action@v3
with:
image: wpilib/roborio-cross-ubuntu:2025-22.04
options: -v ${{ github.workspace }}:/work -w /work -e GITHUB_REF -e CI -e DISPLAY
run: df . && rm -f semicolon_delimited_script && ./gradlew :wpilibc:publish :wpilibj:publish :wpilibNewCommands:publish :hal:publish :cameraserver:publish :ntcore:publish :cscore:publish :wpimath:publish :wpinet:publish :wpiutil:publish :apriltag:publish :wpiunits:publish :simulation:halsim_gui:publish :simulation:halsim_ds_socket:publish :simulation:halsim_ws_server:publish :simulation:halsim_ws_client:publish :simulation:halsim_xrp:publish :fieldImages:publish :romiVendordep:publish :xrpVendordep:publish :epilogue-processor:publish :epilogue-runtime:publish :thirdparty:googletest:publish -x test -x Javadoc -x doxygen --build-cache && cp -r /root/releases/maven/development /work
- uses: actions/upload-artifact@v4
with:
name: MavenArtifacts
path: |
development
retention-days: 1
Robotbuilder:
name: "Build - RobotBuilder"
needs: [build-artifacts]
runs-on: ubuntu-22.04
env:
DISPLAY: ':10'
steps:
- uses: actions/checkout@v4
with:
repository: wpilibsuite/robotbuilder
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: MavenArtifacts
- name: Patch RobotBuilder to use local development
run: cd src/main/resources/export && echo "wpi.maven.useLocal = false" >> java/build.gradle && echo "wpi.maven.useFrcMavenLocalDevelopment = true" >> java/build.gradle && echo "wpi.versions.wpilibVersion = '$YEAR.424242.+'" >> java/build.gradle && echo "wpi.versions.wpimathVersion = '$YEAR.424242.+'" >> java/build.gradle && echo "wpi.maven.useLocal = false" >> cpp/build.gradle && echo "wpi.maven.useFrcMavenLocalDevelopment = true" >> cpp/build.gradle && echo "wpi.versions.wpilibVersion = '$YEAR.424242.+'" >> cpp/build.gradle && echo "wpi.versions.wpimathVersion = '$YEAR.424242.+'" >> cpp/build.gradle
- name: Install and run xvfb
run: sudo apt-get update && sudo apt-get install -y xvfb && Xvfb $DISPLAY &
- name: Move artifacts
run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Build RobotBuilder with Gradle
run: ./gradlew build test --tests 'robotbuilder.exporters.*' -x htmlSanityCheck -PbuildServer -PreleaseMode ; cat build/test-results/test/TEST-robotbuilder.exporters.*.xml ;
- name: Summarize RobotBuilder Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: |
build/test-results/test/TEST*.xml
check_run: false
comment_mode: off
- uses: actions/upload-artifact@v4
if: always()
with:
name: RobotBuilderTestResults
path: |
build/reports/
- uses: actions/upload-artifact@v4
with:
name: RobotBuilder Build
path: |
build/libs/
retention-days: 7
Shuffleboard:
name: "Build - Shuffleboard"
needs: [build-artifacts]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: wpilibsuite/shuffleboard
fetch-depth: 0
- name: Patch Shuffleboard to use local development
run: sed -i "s/wpilibTools.deps.wpilibVersion.*/wpilibTools.deps.wpilibVersion = \'$YEAR\.424242\.+\'/" app/app.gradle && sed -i "s/wpilibTools.deps.wpilibVersion.*/wpilibTools.deps.wpilibVersion = \'$YEAR\.424242\.+\'/" plugins/cameraserver/cameraserver.gradle && sed -i "s/wpilibTools.deps.wpilibVersion.*/wpilibTools.deps.wpilibVersion = \'$YEAR\.424242\.+\'/" plugins/networktables/networktables.gradle
- uses: actions/download-artifact@v4
with:
name: MavenArtifacts
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Move artifacts
run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
- name: Install dependencies
run: sudo apt-get install -y libgtk2.0-0
- name: Build with Gradle
run: ./gradlew build -x Javadoc
- uses: actions/upload-artifact@v4
with:
name: Shuffleboard Build
path: |
build/allOutputs/
retention-days: 7
PathWeaver:
name: "Build - PathWeaver"
needs: [build-artifacts]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: wpilibsuite/PathWeaver
fetch-depth: 0
- name: Patch PathWeaver to use local development
run: sed -i "s/wpilibTools.deps.wpilibVersion.*/wpilibTools.deps.wpilibVersion = \'$YEAR\.424242\.+\'/" dependencies.gradle
- uses: actions/download-artifact@v4
with:
name: MavenArtifacts
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: 'temurin'
- name: Move artifacts
run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
- name: Build with Gradle
run: ./gradlew build
- uses: actions/upload-artifact@v4
with:
name: PathWeaver Build
path: |
build/allOutputs/
retention-days: 7
Robotpy:
name: "Build - Robotpy"
needs: [build-artifacts]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
repository: robotpy/mostrobotpy
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: MavenArtifacts
- name: Move artifacts
run: mkdir -p ~/releases/maven/development && cp -r edu ~/releases/maven/development
- uses: actions/setup-python@v5
with:
python-version: 3.13
#
# Setup build caching
#
- name: Set ccache size
shell: bash
id: ccache
run: echo "MAX_SIZE=500M" >> $GITHUB_OUTPUT
- name: Setup ccache
# uses: hendrikmuhs/ccache-action@v1.2.10
uses: robotpy/ccache-action@fork
with:
key: ubuntu-22.04-3.13
variant: ccache
max-size: ${{ steps.ccache.outputs.max_size }}
- name: Install deps
shell: bash
run: |
python -m pip --disable-pip-version-check install -r rdev_requirements.txt
- name: Install numpy (needed for stubgen but broken in raspbian CI)
shell: bash
run: |
python -m pip --disable-pip-version-check install numpy
- name: Patch RobotPy rdev to use local development
run: git config user.name github-actions && git config user.email github-actions@github.com && set -- ~/releases/maven/development/edu/wpi/first/wpiutil/wpiutil-cpp/*/ ; wpilibversion=$(basename $1) && echo $wpilibversion && sed --regexp-extended -i 's@(wpilib_bin_url =).*@\1 \"file:\/\/'"$HOME"'\/releases\/maven\/development"@' rdev.toml && sed --regexp-extended -i 's/(wpilib_bin_version =).*/\1 \"'"$wpilibversion"'\"/' rdev.toml && ./rdev.sh update-pyproject --commit
- name: Build + test wheels
shell: bash
run: |
./rdev.sh ci run
env:
RPYBUILD_STRIP_LIBPYTHON: "1"
RPYBUILD_CC_LAUNCHER: ccache

View File

@@ -15,53 +15,136 @@ jobs:
name: "Update"
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch all history and metadata
run: |
git fetch --prune --unshallow
git checkout -b pr
git branch -f main origin/main
- name: Set up Python 3.9
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.12'
- name: Configure committer identity
run: |
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
- name: Run update_drake.py
- name: Run apriltag.py
run: |
cd upstream_utils
./update_drake.py
- name: Run update_eigen.py
./apriltag.py clone
./apriltag.py copy-src
./apriltag.py format-patch
- name: Run argparse_lib.py
run: |
cd upstream_utils
./update_eigen.py
- name: Run update_fmt.py
./argparse_lib.py clone
./argparse_lib.py copy-src
./argparse_lib.py format-patch
- name: Run eigen.py
run: |
cd upstream_utils
./update_fmt.py
- name: Run update_libuv.py
./eigen.py clone
./eigen.py copy-src
./eigen.py format-patch
- name: Run expected.py
run: |
cd upstream_utils
./update_libuv.py
- name: Run update_llvm.py
./expected.py clone
./expected.py copy-src
./expected.py format-patch
- name: Run fmt.py
run: |
cd upstream_utils
./update_llvm.py
- name: Run update_mpack.py
./fmt.py clone
./fmt.py copy-src
./fmt.py format-patch
- name: Run gcem.py
run: |
cd upstream_utils
./update_mpack.py
- name: Run update_stack_walker.py
./gcem.py clone
./gcem.py copy-src
./gcem.py format-patch
- name: Run gl3w.py
run: |
cd upstream_utils
./update_stack_walker.py
- name: Run update_memory.py
./gl3w.py clone
./gl3w.py copy-src
./gl3w.py format-patch
- name: Run glfw.py
run: |
cd upstream_utils
./update_memory.py
./glfw.py clone
./glfw.py copy-src
./glfw.py format-patch
- name: Run googletest.py
run: |
cd upstream_utils
./googletest.py clone
./googletest.py copy-src
./googletest.py format-patch
- name: Run imgui.py
run: |
cd upstream_utils
./imgui.py clone
./imgui.py copy-src
./imgui.py format-patch
- name: Run implot.py
run: |
cd upstream_utils
./implot.py clone
./implot.py copy-src
./implot.py format-patch
- name: Run json.py
run: |
cd upstream_utils
./json.py clone
./json.py copy-src
./json.py format-patch
- name: Run libuv.py
run: |
cd upstream_utils
./libuv.py clone
./libuv.py copy-src
./libuv.py format-patch
- name: Run llvm.py
run: |
cd upstream_utils
./llvm.py clone
./llvm.py copy-src
./llvm.py format-patch
- name: Run mpack.py
run: |
cd upstream_utils
./mpack.py clone
./mpack.py copy-src
./mpack.py format-patch
- name: Run memory.py
run: |
cd upstream_utils
./memory.py clone
./memory.py copy-src
./memory.py format-patch
- name: Run protobuf.py
run: |
cd upstream_utils
./protobuf.py clone
./protobuf.py copy-src
./protobuf.py format-patch
- name: Run sleipnir.py
run: |
cd upstream_utils
./sleipnir.py clone
./sleipnir.py copy-src
./sleipnir.py format-patch
- name: Run stb.py
run: |
cd upstream_utils
./stb.py clone
./stb.py copy-src
./stb.py format-patch
- name: Add untracked files to index so they count as changes
run: git add -A
- name: Check output
run: git --no-pager diff --exit-code HEAD
run: git --no-pager diff --exit-code HEAD ':!*.bazel'

20
.gitignore vendored
View File

@@ -10,6 +10,12 @@ simgui-window.json
simgui.json
networktables.json
*.bck
ntcore/connectionlistenertest.json
ntcore/timesynctest.json
nanopb_pb2.py
# Created by the jenkins test script
test-reports
@@ -24,6 +30,9 @@ out/
# Fleet
.fleet
# jdtls
.factorypath
# Created by http://www.gitignore.io
### Linux ###
@@ -130,6 +139,7 @@ CMakeCache.txt
CMakeFiles
cmake_install.cmake
install_manifest.txt
CMakeUserPresets.json
### Gradle ###
@@ -205,6 +215,7 @@ NO
*.user
*.userosscache
*.sln.docstates
CMakeSettings.json
# Visual C++ cache files
ipch/
@@ -230,7 +241,7 @@ compile_commands.json
# clang configuration and clangd cache
.clang
.clangd/
.clangd
.cache/
imgui.ini
@@ -240,3 +251,10 @@ imgui.ini
/bazel-*
user.bazelrc
coverage_report/
bazel_auth.rc
# ctest
/Testing/
# Meson
.meson-subproject*

View File

@@ -10,6 +10,8 @@ cppSrcFileInclude {
}
modifiableFileExclude {
cmake/toolchains/
thirdparty/
\.patch$
gradlew
}
@@ -19,6 +21,7 @@ generatedFileExclude {
simulation/gz_msgs/src/include/simulation/gz_msgs/msgs\.h$
fieldImages/src/main/native/resources/
apriltag/src/test/resources/
wpilibc/src/generated/
}
repoRootNameOverride {
@@ -29,8 +32,10 @@ includeOtherLibs {
^Eigen/
^cameraserver/
^cscore
^drake/
^fmt/
^glass/
^google/
^gtest/
^hal/
^imgui
^implot

View File

@@ -1,207 +1,162 @@
# Disable in-source builds to prevent source tree corruption.
if(" ${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL " ${CMAKE_CURRENT_BINARY_DIR}")
message(FATAL_ERROR "
message(
FATAL_ERROR
"
FATAL: In-source builds are not allowed.
You should create a separate directory for build files.
")
"
)
endif()
if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
set(CMAKE_SYSTEM_VERSION 10.0.18362.0 CACHE STRING INTERNAL FORCE)
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 10.0.18362.0 CACHE STRING INTERNAL FORCE)
message(STATUS "Platform version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
endif()
# Set default build type to release with debug info (i.e. release mode optimizations
# are performed, but debug info still exists).
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
endif()
cmake_minimum_required(VERSION 3.21)
project(allwpilib)
cmake_minimum_required(VERSION 3.3.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
message(STATUS "Platform version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
# Make timestamps of extracted files from FetchContent the time of extraction
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
set(WPILIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
INCLUDE(CPack)
include(CMakeDependentOption)
include(CPack)
include(OptionValidation)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if(MSVC)
add_compile_options(/Zc:__cplusplus)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${WPILIB_BINARY_DIR}/bin)
set(CMAKE_JAVA_TARGET_OUTPUT_DIR ${WPILIB_BINARY_DIR}/jar)
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Options for building certain parts of the repo. Everything is built by default.
option(BUILD_SHARED_LIBS "Build with shared libs (needed for JNI)" ON)
option(WITH_JAVA "Include java and JNI in the build" ON)
option(WITH_JAVA "Include Java and JNI in the build" OFF)
option(WITH_JAVA_SOURCE "Build Java source jars" ${WITH_JAVA})
option(WITH_DOCS "Build Doxygen docs (needs Git for versioning)" OFF)
cmake_dependent_option(
DOCS_WARNINGS_AS_ERRORS
"Make docs warnings into errors"
OFF
WITH_DOCS
OFF
)
option(WITH_CSCORE "Build cscore (needs OpenCV)" ON)
option(WITH_NTCORE "Build ntcore" ON)
option(WITH_WPICAL "Build wpical" OFF)
option(WITH_WPIMATH "Build wpimath" ON)
option(WITH_WPILIB "Build hal, wpilibc/j, and myRobot (needs OpenCV)" ON)
cmake_dependent_option(
WITH_WPIUNITS
"Build wpiunits"
ON
WITH_JAVA
OFF
)
option(WITH_WPILIB "Build hal, wpilibc/j, and developerRobot (needs OpenCV)" ON)
option(WITH_EXAMPLES "Build examples" OFF)
option(WITH_TESTS "Build unit tests (requires internet connection)" ON)
option(WITH_GUI "Build GUI items" ON)
option(WITH_SIMULATION_MODULES "Build simulation modules" ON)
# Options for external HAL.
option(WITH_EXTERNAL_HAL "Use a separately built HAL" OFF)
set(EXTERNAL_HAL_FILE "" CACHE FILEPATH "Location to look for an external HAL CMake File")
option(WITH_PROTOBUF "Build protobuf support" ON)
# Options for using a package manager (e.g., vcpkg) for certain dependencies.
option(USE_SYSTEM_FMTLIB "Use system fmtlib" OFF)
option(USE_SYSTEM_LIBUV "Use system libuv" OFF)
option(USE_SYSTEM_EIGEN "Use system eigen" OFF)
# Options for installation.
option(WITH_FLAT_INSTALL "Use a flat install directory" OFF)
# Options for location of OpenCV Java.
set(OPENCV_JAVA_INSTALL_DIR "" CACHE PATH "Location to search for the OpenCV jar file")
# Set default build type to release with debug info (i.e. release mode optimizations
# are performed, but debug info still exists).
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
endif()
# Options for compilation flags.
option(NO_WERROR "Disable -Werror flag during compilation" OFF)
# We always want flat install with MSVC.
if (MSVC)
set(WITH_FLAT_INSTALL ON)
endif()
if (WITH_JAVA AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "
FATAL: Cannot build static libs with Java enabled.
Static libs requires both BUILD_SHARED_LIBS=OFF and
WITH_JAVA=OFF
")
endif()
if (WITH_SIMULATION_MODULES AND NOT BUILD_SHARED_LIBS)
message(FATAL_ERROR "
FATAL: Cannot build static libs with simulation modules enabled.
Static libs requires both BUILD_SHARED_LIBS=OFF and
WITH_SIMULATION_MODULES=OFF
")
endif()
if (NOT WITH_JAVA OR NOT WITH_CSCORE)
if(NOT WITH_JAVA OR NOT WITH_CSCORE)
if(NOT "${OPENCV_JAVA_INSTALL_DIR}" STREQUAL "")
message(WARNING "
message(
WARNING
"
WARNING: OpenCV Java dir set but java is not enabled!
It will be ignored.
")
"
)
endif()
endif()
if (NOT WITH_WPILIB AND WITH_SIMULATION_MODULES)
message(FATAL_ERROR "
FATAL: Cannot build simulation modules with wpilib disabled.
Enable wpilib by setting WITH_WPILIB=ON
")
wpilib_config(OPTIONS WITH_JAVA REQUIRES BUILD_SHARED_LIBS)
wpilib_config(OPTIONS WITH_SIMULATION_MODULES REQUIRES BUILD_SHARED_LIBS WITH_WPILIB WITH_NTCORE)
wpilib_config(OPTIONS WITH_CSCORE REQUIRES WITH_NTCORE)
wpilib_config(OPTIONS WITH_GUI REQUIRES WITH_NTCORE WITH_WPIMATH)
wpilib_config(OPTIONS WITH_WPILIB REQUIRES WITH_NTCORE WITH_WPIMATH)
wpilib_config(OPTIONS WITH_WPIMATH WITH_JAVA REQUIRES WITH_WPIUNITS)
set(include_dest include)
set(java_lib_dest java)
if(WITH_JAVA OR WITH_JAVA_SOURCE)
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked")
find_package(Java REQUIRED COMPONENTS Development)
if(NOT ANDROID)
find_package(JNI REQUIRED COMPONENTS JVM)
endif()
endif()
if (NOT WITH_NTCORE AND WITH_CSCORE)
message(FATAL_ERROR "
FATAL: Cannot build cameraserver without ntcore.
Enable ntcore by setting WITH_NTCORE=ON
")
if(WITH_DOCS)
find_package(Doxygen REQUIRED)
find_package(Git REQUIRED)
include(AddDoxygenDocs)
add_doxygen_docs()
endif()
if (NOT WITH_NTCORE AND WITH_GUI)
message(FATAL_ERROR "
FATAL: Cannot build GUI modules without ntcore.
Enable ntcore by setting WITH_NTCORE=ON
")
if(WITH_WPICAL)
find_package(Ceres CONFIG REQUIRED)
endif()
if (NOT WITH_NTCORE AND WITH_SIMULATION_MODULES)
message(FATAL_ERROR "
FATAL: Cannot build simulation modules without ntcore.
Enable ntcore by setting WITH_NTCORE=ON
")
find_package(LIBSSH CONFIG 0.7.1)
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
if(WITH_PROTOBUF)
set(protobuf_MODULE_COMPATIBLE ON CACHE BOOL "" FORCE)
find_package(Protobuf REQUIRED)
find_program(PROTOC_COMPILER protoc REQUIRED)
endif()
if (NOT WITH_NTCORE AND WITH_WPILIB)
message(FATAL_ERROR "
FATAL: Cannot build wpilib without ntcore.
Enable ntcore by setting WITH_NTCORE=ON
")
endif()
if (NOT WITH_WPIMATH AND WITH_WPILIB)
message(FATAL_ERROR "
FATAL: Cannot build wpilib without wpimath.
Enable wpimath by setting WITH_WPIMATH=ON
")
endif()
set( wpilib_dest "")
set( include_dest include )
set( main_lib_dest lib )
set( java_lib_dest java )
set( jni_lib_dest jni )
if (WITH_FLAT_INSTALL)
set (wpilib_config_dir ${wpilib_dest})
else()
set (wpilib_config_dir share/wpilib)
endif()
if (USE_SYSTEM_LIBUV)
set (LIBUV_SYSTEM_REPLACE "
find_package(PkgConfig REQUIRED)
pkg_check_modules(libuv REQUIRED IMPORTED_TARGET libuv)
")
endif()
if (USE_SYSTEM_EIGEN)
set (EIGEN_SYSTEM_REPLACE "find_package(Eigen3 CONFIG)")
endif()
find_package(LIBSSH 0.7.1)
if (WITH_FLAT_INSTALL)
set(WPIUTIL_DEP_REPLACE "include($\{SELF_DIR\}/wpiutil-config.cmake)")
set(WPINET_DEP_REPLACE "include($\{SELF_DIR\}/wpinet-config.cmake)")
set(NTCORE_DEP_REPLACE "include($\{SELF_DIR\}/ntcore-config.cmake)")
set(CSCORE_DEP_REPLACE_IMPL "include(\${SELF_DIR}/cscore-config.cmake)")
set(CAMERASERVER_DEP_REPLACE_IMPL "include(\${SELF_DIR}/cameraserver-config.cmake)")
set(HAL_DEP_REPLACE_IMPL "include(\${SELF_DIR}/hal-config.cmake)")
set(WPIMATH_DEP_REPLACE "include($\{SELF_DIR\}/wpimath-config.cmake)")
set(WPILIBC_DEP_REPLACE_IMPL "include(\${SELF_DIR}/wpilibc-config.cmake)")
set(WPILIBNEWCOMMANDS_DEP_REPLACE "include(\${SELF_DIR}/wpilibNewcommands-config.cmake)")
else()
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
set(WPINET_DEP_REPLACE "find_dependency(wpinet)")
set(NTCORE_DEP_REPLACE "find_dependency(ntcore)")
set(CSCORE_DEP_REPLACE_IMPL "find_dependency(cscore)")
set(CAMERASERVER_DEP_REPLACE_IMPL "find_dependency(cameraserver)")
set(HAL_DEP_REPLACE_IMPL "find_dependency(hal)")
set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)")
set(WPILIBC_DEP_REPLACE_IMPL "find_dependency(wpilibc)")
set(WPILIBNEWCOMMANDS_DEP_REPLACE "find_dependency(wpilibNewCommands)")
endif()
set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)")
set(SELF_DIR "$\{SELF_DIR\}")
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG OFF)
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
@@ -216,7 +171,15 @@ if(isMultiConfig)
list(APPEND CMAKE_CONFIGURATION_TYPES Ubsan)
endif()
else()
set(allowedBuildTypes Asan Tsan Ubsan Debug Release RelWithDebInfo MinSizeRel)
set(allowedBuildTypes
Asan
Tsan
Ubsan
Debug
Release
RelWithDebInfo
MinSizeRel
)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${allowedBuildTypes}")
if(CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE IN_LIST allowedBuildTypes)
@@ -225,109 +188,180 @@ else()
endif()
set(CMAKE_C_FLAGS_ASAN
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C compiler for Asan build type or configuration." FORCE)
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer"
CACHE STRING
"Flags used by the C compiler for Asan build type or configuration."
FORCE
)
set(CMAKE_CXX_FLAGS_ASAN
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C++ compiler for Asan build type or configuration." FORCE)
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=address -fno-omit-frame-pointer"
CACHE STRING
"Flags used by the C++ compiler for Asan build type or configuration."
FORCE
)
set(CMAKE_EXE_LINKER_FLAGS_ASAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING
"Linker flags to be used to create executables for Asan build type." FORCE)
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address"
CACHE STRING
"Linker flags to be used to create executables for Asan build type."
FORCE
)
set(CMAKE_SHARED_LINKER_FLAGS_ASAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address" CACHE STRING
"Linker lags to be used to create shared libraries for Asan build type." FORCE)
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address"
CACHE STRING
"Linker flags to be used to create shared libraries for Asan build type."
FORCE
)
set(CMAKE_C_FLAGS_TSAN
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C compiler for Tsan build type or configuration." FORCE)
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer"
CACHE STRING
"Flags used by the C compiler for Tsan build type or configuration."
FORCE
)
set(CMAKE_CXX_FLAGS_TSAN
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C++ compiler for Tsan build type or configuration." FORCE)
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=thread -fno-omit-frame-pointer"
CACHE STRING
"Flags used by the C++ compiler for Tsan build type or configuration."
FORCE
)
set(CMAKE_EXE_LINKER_FLAGS_TSAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread" CACHE STRING
"Linker flags to be used to create executables for Tsan build type." FORCE)
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread"
CACHE STRING
"Linker flags to be used to create executables for Tsan build type."
FORCE
)
set(CMAKE_SHARED_LINKER_FLAGS_TSAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread" CACHE STRING
"Linker lags to be used to create shared libraries for Tsan build type." FORCE)
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=thread"
CACHE STRING
"Linker flags to be used to create shared libraries for Tsan build type."
FORCE
)
set(CMAKE_C_FLAGS_UBSAN
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C compiler for Ubsan build type or configuration." FORCE)
"${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
CACHE STRING
"Flags used by the C compiler for Ubsan build type or configuration."
FORCE
)
set(CMAKE_CXX_FLAGS_UBSAN
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer" CACHE STRING
"Flags used by the C++ compiler for Ubsan build type or configuration." FORCE)
"${CMAKE_CXX_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all -fno-omit-frame-pointer"
CACHE STRING
"Flags used by the C++ compiler for Ubsan build type or configuration."
FORCE
)
set(CMAKE_EXE_LINKER_FLAGS_UBSAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all" CACHE STRING
"Linker flags to be used to create executables for Ubsan build type." FORCE)
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined -fno-sanitize-recover=all"
CACHE STRING
"Linker flags to be used to create executables for Ubsan build type."
FORCE
)
set(CMAKE_SHARED_LINKER_FLAGS_UBSAN
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined" CACHE STRING
"Linker lags to be used to create shared libraries for Ubsan build type." FORCE)
"${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=undefined"
CACHE STRING
"Linker flags to be used to create shared libraries for Ubsan build type."
FORCE
)
if (WITH_TESTS)
if(WITH_TESTS)
enable_testing()
add_subdirectory(googletest)
add_subdirectory(thirdparty/googletest)
include(GoogleTest)
endif()
if(USE_SYSTEM_LIBUV)
set(LIBUV_SYSTEM_REPLACE "find_dependency(libuv CONFIG)")
endif()
if(USE_SYSTEM_EIGEN)
set(EIGEN_SYSTEM_REPLACE "find_package(Eigen3 CONFIG)")
endif()
set(FILENAME_DEP_REPLACE "get_filename_component(SELF_DIR \"$\{CMAKE_CURRENT_LIST_FILE\}\" PATH)")
set(SELF_DIR "$\{SELF_DIR\}")
set(WPIUNITS_DEP_REPLACE_IMPL "find_dependency(wpiunits)")
set(WPIUTIL_DEP_REPLACE "find_dependency(wpiutil)")
add_subdirectory(wpiutil)
if (WITH_NTCORE)
if(WITH_NTCORE)
set(NTCORE_DEP_REPLACE "find_dependency(ntcore)")
set(WPINET_DEP_REPLACE "find_dependency(wpinet)")
add_subdirectory(wpinet)
add_subdirectory(ntcore)
endif()
if (WITH_WPIMATH)
if(WITH_WPIMATH)
if(WITH_JAVA)
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
add_subdirectory(wpiunits)
endif()
set(WPIMATH_DEP_REPLACE "find_dependency(wpimath)")
add_subdirectory(wpimath)
endif()
if (WITH_GUI)
if(WITH_WPIUNITS AND NOT WITH_WPIMATH)
# In case of building wpiunits standalone
set(WPIUNITS_DEP_REPLACE ${WPIUNITS_DEP_REPLACE_IMPL})
add_subdirectory(wpiunits)
endif()
if(WITH_GUI)
add_subdirectory(fieldImages)
add_subdirectory(imgui)
add_subdirectory(thirdparty/imgui_suite)
add_subdirectory(wpigui)
add_subdirectory(glass)
add_subdirectory(outlineviewer)
if (LIBSSH_FOUND)
add_subdirectory(sysid)
if(WITH_WPICAL)
add_subdirectory(wpical)
endif()
if(LIBSSH_FOUND)
add_subdirectory(roborioteamnumbersetter)
add_subdirectory(datalogtool)
endif()
endif()
if (WITH_WPILIB OR WITH_SIMULATION_MODULES)
set(HAL_DEP_REPLACE ${HAL_DEP_REPLACE_IMPL})
if(WITH_WPILIB OR WITH_SIMULATION_MODULES)
set(HAL_DEP_REPLACE "find_dependency(hal)")
add_subdirectory(hal)
endif()
if (WITH_CSCORE)
set(CSCORE_DEP_REPLACE ${CSCORE_DEP_REPLACE_IMPL})
set(CAMERASERVER_DEP_REPLACE ${CAMERASERVER_DEP_REPLACE_IMPL})
if(WITH_CSCORE)
set(CAMERASERVER_DEP_REPLACE "find_dependency(cameraserver)")
set(CSCORE_DEP_REPLACE "find_dependency(cscore)")
find_package(OpenCV REQUIRED)
add_subdirectory(cscore)
add_subdirectory(cameraserver)
endif()
if (WITH_WPILIB)
set(WPILIBC_DEP_REPLACE ${WPILIBC_DEP_REPLACE_IMPL})
if(WITH_WPILIB)
set(APRILTAG_DEP_REPLACE "find_dependency(apriltag)")
set(WPILIBC_DEP_REPLACE "find_dependency(wpilibc)")
set(WPILIBJ_DEP_REPLACE "find_dependency(wpilibj)")
set(WPILIBNEWCOMMANDS_DEP_REPLACE "find_dependency(wpilibNewCommands)")
add_subdirectory(apriltag)
add_subdirectory(wpilibj)
add_subdirectory(wpilibc)
add_subdirectory(wpilibNewCommands)
if (WITH_EXAMPLES)
add_subdirectory(romiVendordep)
add_subdirectory(xrpVendordep)
if(WITH_EXAMPLES)
add_subdirectory(wpilibcExamples)
endif()
add_subdirectory(myRobot)
add_subdirectory(developerRobot)
endif()
if (WITH_SIMULATION_MODULES AND NOT WITH_EXTERNAL_HAL)
if(WITH_SIMULATION_MODULES)
add_subdirectory(simulation)
endif()
configure_file(wpilib-config.cmake.in ${WPILIB_BINARY_DIR}/wpilib-config.cmake )
install(FILES ${WPILIB_BINARY_DIR}/wpilib-config.cmake DESTINATION ${wpilib_config_dir})
configure_file(wpilib-config.cmake.in ${WPILIB_BINARY_DIR}/wpilib-config.cmake)
install(FILES ${WPILIB_BINARY_DIR}/wpilib-config.cmake DESTINATION share/wpilib)

50
CMakePresets.json Normal file
View File

@@ -0,0 +1,50 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "default",
"displayName": "Default Config",
"description": "Default build using Ninja generator",
"binaryDir": "build-cmake",
"generator": "Ninja",
"cacheVariables": {}
},
{
"name": "with-sccache",
"displayName": "",
"description": "Ninja config with sccache",
"generator": "Ninja",
"binaryDir": "build-cmake",
"cacheVariables": {
"CMAKE_C_COMPILER_LAUNCHER": "sccache",
"CMAKE_CXX_COMPILER_LAUNCHER": "sccache"
}
},
{
"name": "with-java",
"displayName": "",
"description": "Ninja config with Java",
"generator": "Ninja",
"binaryDir": "build-cmake",
"cacheVariables": {
"WITH_JAVA": "ON"
}
},
{
"name": "with-java-and-sccache",
"displayName": "",
"description": "Ninja config with Java and sccache",
"generator": "Ninja",
"inherits": "with-sccache",
"binaryDir": "build-cmake",
"cacheVariables": {
"WITH_JAVA": "ON"
}
}
]
}

View File

@@ -1,69 +1,47 @@
# Contributor Covenant Code of Conduct
# Contributor Community Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
As members, contributors, and leaders, we commit to fostering a community where everyone feels safe, respected, and valued. We are dedicated to ensuring that participation in this community is harassment-free, inclusive, and welcoming, regardless of age, body type, abilities (visible or invisible), ethnicity, gender identity or expression, sexual orientation, socioeconomic background, education, nationality, personal appearance, race, or religion.
Above all, we pledge to act with integrity, kindness, and empathy—striving to be not only good participants but also good humans.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
Positive and respectful behavior is essential to creating a thriving community. This includes:
* Exhibiting Gracious Professionalism® at all times. Gracious Professionalism
* Practicing **Gracious Professionalism®** at all times. Gracious Professionalism
is a way of doing things that encourages high-quality work, emphasizes the
value of others, and respects individuals and the community.
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
* Showing empathy, kindness, and patience.
* Respecting diverse perspectives and experiences.
* Giving and receiving constructive feedback with openness and humility.
* Owning mistakes, apologizing when necessary, and learning from them.
* Prioritizing the well-being and success of the entire community over individual interests.
Examples of unacceptable behavior include:
Unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Using sexualized language, imagery, or making inappropriate advances
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
* Harassment in any form, whether public or private.
* Sharing private information (e.g., email or physical addresses) without explicit consent.
* Any behavior that is unprofessional, harmful, or exclusionary.
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
Community leaders are responsible for maintaining these standards and will take appropriate action to address any behavior deemed harmful, threatening, or inappropriate. Actions may include removing content, issuing warnings, or, when necessary, banning individuals. Moderation decisions will be communicated transparently where appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
This Code of Conduct applies to all community spaces, events, and instances where individuals represent the community (e.g., official email accounts, social media posts, or in-person/virtual events).
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[conduct@wpilib.org](mailto:conduct@wpilib.org).
[wpilib@wpi.edu](mailto:wpilib@wpi.edu).
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
@@ -115,6 +93,9 @@ individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## A Note on Kindness
Building a community isnt just about rules—its about connection. Every interaction is an opportunity to be understanding, compassionate, and supportive. Being a good human is the key to our ethos.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],

View File

@@ -12,11 +12,11 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont
## General Contribution Rules
- Everything in the library must work for the 3000+ teams that will be using it.
- Everything in the library must work for the 4000+ teams that will be using it.
- We need to be able to maintain submitted changes, even if you are no longer working on the project.
- Tool suite changes must be generally useful to a broad range of teams
- Excluding bug fixes, changes in one language generally need to have corresponding changes in other languages.
- Some features, such the addition of C++11 for WPILibC or Functional Interfaces for WPILibJ, are specific to that version of WPILib only.
- Some features, such the addition of C++23 for WPILibC or Functional Interfaces for WPILibJ, are specific to that version of WPILib only. New language features added to C++ must be wrappable in Python for [RobotPy](https://github.com/robotpy).
- Substantial changes often need to have corresponding LabVIEW changes. To do this, we will work with NI on these large changes.
- Changes should have tests.
- Code should be well documented.
@@ -27,7 +27,8 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont
- Bug reports and fixes
- We will generally accept bug fixes without too much question. If they are only implemented for one language, we will implement them for any other necessary languages. Bug reports are also welcome, please submit them to our GitHub issue tracker.
- While we do welcome improvements to the API, there are a few important rules to consider:
- Features must be added to both WPILibC and WPILibJ, with rare exceptions.
- Features must be added to Java (WPILibJ), C++ (WPILibC), with rare exceptions.
- Most of Python (RobotPy) is created by wrapping WPILibC with pybind11 via robotpy-build. However, new features to the command framework should also be submitted to [robotpy-commands-v2](https://github.com/robotpy/robotpy-commands-v2) as the command framework is reimplemented in Python.
- During competition season, we will not merge any new feature additions. We want to ensure that the API is stable during the season to help minimize issues for teams.
- Ask about large changes before spending a bunch of time on them! You can create a new issue on our GitHub tracker for feature request/discussion and talk about it with us there.
- Features that make it easier for teams with less experience to be more successful are more likely to be accepted.
@@ -79,6 +80,8 @@ xₖ₊₁ = Axₖ + Buₖ
Changes should be submitted as a Pull Request against the main branch of WPILib. For most changes, commits will be squashed upon merge. For particularly large changes, multiple commits are ok, but assume one commit unless asked otherwise. We may ask you to break a PR into multiple standalone PRs or commits for rebase within one PR to separate unrelated changes. No change will be merged unless it is up to date with the current main branch. We do this to make sure that the git history isn't too cluttered.
Particularly large and/or breaking changes should be targeted to the 2027 branch, which targets the [SystemCore Robot Controller](https://community.firstinspires.org/introducing-the-future-mobile-robot-controller). The intent is minimize changes for 2026, to allow development to focus on preparing for 2027.
### Merge Process
When you first submit changes, GitHub Actions will attempt to run `./gradlew check` on your change. If this fails, you will need to fix any issues that it sees. Once Actions passes, we will begin the review process in more earnest. One or more WPILib team members will review your change. This will be a back-and-forth process with the WPILib team and the greater community. Once we are satisfied that your change is ready, we will allow our hosted instance to test it. This will run the full gamut of checks, including integration tests on actual hardware. Once all tests have passed and the team is satisfied, we will merge your change into the WPILib repository.

View File

@@ -4,17 +4,22 @@ This article contains instructions on building projects using a development buil
**Note:** This only applies to Java/C++ teams.
> [!WARNING]
> **There are no stability or compatibility guarantees for builds outside of [tagged releases](https://github.com/wpilibsuite/allwpilib/releases). Changes may not be fully documented. Use them at your own risk!**
>
> Development builds may be non-functional between the end of the season and the start of beta testing. Development builds are also likely to be incompatible with vendor libraries during this time.
## Development Build
Development builds are the per-commit build hosted every time a commit is pushed to the [allwpilib](https://github.com/wpilibsuite/allwpilib/) repository. These builds are then hosted on [artifactory](https://frcmaven.wpi.edu/artifactory/webapp/#/home).
To build a project using a development build, find the build.gradle file and open it. Then, add the following code below the plugin section and replace YEAR with the year of the development version. It is also necessary to use a 2023 GradleRIO version, ie `2023.0.0-alpha-1`
To build a project using a development build, find the build.gradle file and open it. Then, add the following code below the plugin section and replace YEAR with the year of the development version. It is also necessary to use a 2025 GradleRIO version, ie `2025.1.1-beta-1`
```groovy
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = 'YEAR.+'
wpi.versions.wpimathVersion = 'YEAR.+
wpi.versions.wpimathVersion = 'YEAR.+'
```
The top of your ``build.gradle`` file should now look similar to the code below. Ignore any differences in versions.
@@ -23,13 +28,13 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = '2023.+'
wpi.versions.wpimathVersion = '2023.+'
wpi.versions.wpilibVersion = '2025.+'
wpi.versions.wpimathVersion = '2025.+'
```
C++
@@ -37,13 +42,13 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = '2023.+'
wpi.versions.wpimathVersion = '2023.+'
wpi.versions.wpilibVersion = '2025.+'
wpi.versions.wpimathVersion = '2025.+'
```
### Development Build Documentation
@@ -59,7 +64,7 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
wpi.maven.useLocal = false
@@ -73,7 +78,7 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2025.1.1-beta-1"
}
wpi.maven.useLocal = false
@@ -84,15 +89,4 @@ wpi.versions.wpimathVersion = 'YEAR.424242.+'
# roboRIO Development
This repo contains a myRobot project built in way to do full project development without needing to do a full publish into GradleRIO. These also only require building the minimum amount of binaries for the roboRIO, so the builds are much faster as well.
The setup only works if the roboRIO is USB connected. If an alternate IP address is preferred, the `address` block in myRobot\build.gradle can be changed to point to another address.
The following 3 tasks can be used for deployment:
* `:myRobot:deployShared` deploys the C++ project using shared dependencies. Prefer this one for most C++ development.
* `:myRobot:deployStatic` deploys the C++ project with all dependencies statically linked.
* `:myRobot:deployJava` deploys the Java project and all required dependencies. Also installs the JRE if not currently installed.
Deploying any of these to the roboRIO will disable the current startup project until it is redeployed.
From here, ssh into the roboRIO using the `lvuser` account and run `frcRunRobot.sh` (It's in path).
See the [developerRobot](developerRobot/README.md) subproject.

25
GeneratedFiles.md Normal file
View File

@@ -0,0 +1,25 @@
# Maintaining Generated Files
WPILib extensively uses [metaprogramming](https://en.wikipedia.org/wiki/Metaprogramming#Code_generation) to generate code that would otherwise be tedious and error-prone to maintain. We use [Jinja](https://jinja.palletsprojects.com), a templating engine with a Python API, alongside JSON files that contain data to generate code. This document explains how to maintain these generated files and create new ones.
## File hierarchy
The Python script used to generate a subproject's files will always be located in the subproject's directory, e.g. wpilibc. It will always be called `generate_<thing>.py` where `<thing>` is the name for what you're generating.
The templates will be located under `subproject/src/generate/main`, and generated files will be located under `subproject/src/generated/main`.
If the generated file is for C++, the hierarchy should be symmetrical, so if a generated header is located under `subproject/src/generated/main/native/include/frc/header.h`, the template to generate it should be located under `subproject/src/generate/main/native/include/frc/template.h.jinja`. You should pretend like `subproject/src/generate/main` is just like `subproject/src/main`, in that the file hierarchy must make sense if the files weren't generated, e.g, headers that would go in `subproject/src/main/native/include/blah` should be in `subproject/src/generated/main/native/include/blah`.
If the generated file is for Java, templates should be located under `subproject/src/generate/main/java`, and the hierarchy for output files should reflect the declared package of the output Java files. For example, a Jinja template at `subproject/src/main/java/template.java.jinja` with the package `edu.wpi.first.wpilibj` would be used to generate Java files located at `subproject/src/generated/main/java/edu/wpi/first/wpilibj`
The JSON files live under `subproject/src/generate` since they apply to both languages. One unique case is JSON files that are used by multiple subprojects, currently only JSON files shared by wpilibc and wpilibj. In that specific case, the JSON files will always be located in wpilibj since Java is the most used language.
## Using code generation
If you've identified a set of files which are extremely similar, one file with lots of repetitive code, or both, you can create Jinja templates, a JSON file, and a Python script to automatically generate the code instead.
### Preparing files for codegen
Once you've identified the files you want to codegen, you will need to identify parts of code that are similar, and extract the data that's different. Code needs to go into your Jinja template, while data that will be used to fill in the template goes into a JSON file. Using game controllers as an example, they have lots of similar methods to read the value of a button, check if a button has been pressed since the last check, and check if a button has been released since the last check. Those methods are code that goes in a Jinja template, with the specific button replaced with a Jinja expression. The buttons, both the name and value, go into a JSON file.
### Writing a Python script
To maintain consistency with other Python scripts, copy an existing `generate_*.py` script. [generate_pwm_motor_controllers.py](./wpilibj/generate_pwm_motor_controllers.py) is a good start, since it's relatively basic. Modify the script to reference your templates and JSON file, modify the paths so the files end up in the right place, and rename the functions so they match what you're generating. An important part of the script is to give the files the correct name. Depending on files you're generating, this could be the name of the template itself (see [ntcore/generate_topics.py](./ntcore/generate_topics.py)) or it could be part of the data in the JSON file.
### (Re)Generating files and committing them
Once your Python script is complete, you can run `python generate_<thing>.py` to generate the files. Once you're finished with your files, commit these files to Git. If you regenerated the files and Git indicates the files have changed, but the diff doesn't show any changes, only the line endings have changed. If you expected changes to the generated code, you didn't correctly make changes. If you didn't expect changes, you can ignore this and discard the changes. Also ensure that you've marked the Python script as executable, since this is necessary for CI workflows to run your scripts. To add your script to the CI workflows, edit [.github/workflows/pregen_all.py](.github/workflows/pregen_all.py), and add your script alongside the rest of the scripts.

View File

@@ -1,4 +1,4 @@
Copyright (c) 2009-2022 FIRST and other WPILib contributors
Copyright (c) 2009-2025 FIRST and other WPILib contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,5 +1,5 @@
## Publishing Third Party Dependencies
Currently the 3rd party deps are imgui, opencv, and google test
Currently the 3rd party deps are imgui, opencv, google test, libssh, and apriltaglib
For publishing these dependencies, the version needs to be manually updated in the publish.gradle file of their respective repository.
Then, in the azure build for the dependency you want to build for, manually start a pipeline build (As of current, this is the `Run Pipeline` button).
@@ -18,10 +18,10 @@ Desktop tools publish to the development repo on every push to main. To publish
## Publishing VS Code
Before publishing, make sure to update the gradlerio version in `vscode-wpilib/resources/gradle/version.txt` Also make sure the gradle wrapper version matches the wrapper required by gradlerio.
Upon pushing a tag, a release will be built, and the files will be uploaded to the releases on GitHub. For publishing to the marketplace, you need a Microsoft account and to be added as a maintainer.
Upon pushing a tag, a release will be built, and the files will be uploaded to the releases on GitHub.
## Publishing GradleRIO
Before publishing, make sure to update the version in build.gradle. Publishing must happen locally, using the command `./gradlew publishPlugin`. This does require your API key for publishing to be set.
## Building the installer
Update the GradleRIO version in gradle.properties, and in the scripts folder in vscode, update the vscode extension. Then push, it will build the installer on azure.
Update the GradleRIO version in gradle.properties, and in the scripts folder in vscode, update the vscode extension. To publish a release build, upload a new tag, and a release will automatically be built and published to artifactory and cloudflare.

View File

@@ -16,7 +16,7 @@ We provide two base types of artifacts.
The first types are Java artifacts. These are usually published as `jar` files. Usually, the actual jar file is published with no classifier. The sources are published with the `-sources` classifier, and the javadocs are published with the `-javadoc` classifier.
The second types are native artifacts. These are usually published as `zip` files (except for the `JNI` artifact types, which are `jar` files. See below for information on this). The `-sources` and `-headers` classifiers contain the sources and headers respecively for the library. Each artifact also contains a classifier for each platform we publish. This platform is in the format `{os}{arch}`. The platform artifact only contains the binaries for a specific platform. In addition, we provide a `-all` classifier. This classifer combines all of the platform artifacts into a single artifact. This is useful for tools that cannot determine what version to use during builds. However, we recommend using the platform specific classifier when possible. Note that the binary artifacts never contain the headers, you always need the `-headers` classifier to get those.
The second types are native artifacts. These are usually published as `zip` files (except for the `JNI` artifact types, which are `jar` files. See below for information on this). The `-sources` and `-headers` classifiers contain the sources and headers respectively for the library. Each artifact also contains a classifier for each platform we publish. This platform is in the format `{os}{arch}`. The platform artifact only contains the binaries for a specific platform. In addition, we provide a `-all` classifier. This classifier combines all of the platform artifacts into a single artifact. This is useful for tools that cannot determine what version to use during builds. However, we recommend using the platform specific classifier when possible. Note that the binary artifacts never contain the headers, you always need the `-headers` classifier to get those.
## Artifact Names
@@ -145,6 +145,11 @@ All artifacts are based at `edu.wpi.first.artifactname` in the repository.
* wpinet
* wpiutil
* wpiunits
* apriltag
* wpiutil
* wpimath
### Third Party Artifacts
@@ -152,6 +157,7 @@ This repository provides the builds of the following third party software.
All artifacts are based at `edu.wpi.first.thirdparty.frcYEAR` in the repository.
* apriltaglib
* googletest
* imgui
* opencv

25
README-Bazel.md Normal file
View File

@@ -0,0 +1,25 @@
# WPILib Bazel Support
WPILib is normally built with Gradle, but [Bazel](https://www.bazel.build/) can also be used to increase development speed due to the superior caching ability and the ability to use remote caching and remote execution (on select platforms)
## Prerequisites
- Install [Bazelisk](https://github.com/bazelbuild/bazelisk/releases) and add it to your path. Bazelisk is a wrapper that will download the correct version of bazel specified in the repository. Note: You can alias/rename the binary to `bazel` if you want to keep the familiar `bazel build` vs `bazelisk build` syntax.
## Building
To build the entire repository, simply run `bazel build //...`. To run all of the unit tests, run `bazel test //...`
Other examples:
- `bazel build //wpimath/...` - Builds every target in the wpimath folder
- `bazel test //wpiutil:wpiutil-cpp-test` - Runs only the cpp test target in the wpiutil folder
- `bazel coverage //wpiutil/...` - (*Nix only) - Runs a code coverage report for both C++ and Java on all the targets under wpiutil
## User settings
When invoking bazel, it will check if `user.bazelrc` exists for additional, user specified flags. You can use these settings to do things like always ignore buildin a specific folder, or limiting the CPU/RAM usage during a build.
Examples:
- `build --build_tag_filters=-wpi-example` - Do not build any targets tagged with `wpi-example` (Currently all of the targets in wpilibcExamples and wpilibjExamples contain this tag)
- `build -c opt` - Always build optimized targets. The default compiler flags were chosen to build as fast as possible, and thus don't contain many optimizations
- `build -k` - `-k` is analogous to the MAKE flag `--keep-going`, so the build will not stop on the first error.
- ```
build --local_ram_resources=HOST_RAM*.5 # Don't use more than half my RAM when building
build --local_cpu_resources=HOST_CPUS-1 # Leave one core alone
```

View File

@@ -1,157 +0,0 @@
# WPILib CMake Support
WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although it is supported on Windows, these docs will only go over Linux builds.
## Libraries that get built
* wpiutil
* ntcore
* cscore
* cameraserver
* hal
* wpilib
* halsim
* wpigui
* wpimath
By default, all libraries except for the HAL and WPILib get built with a default CMake setup. The libraries are built as shared libraries, and include the JNI libraries as well as building the Java JARs.
## Prerequisites
The most common prerequisite is going to be OpenCV. OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
In addition, if you want JNI and Java, you will need a JDK of at least version 11 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
If you are building with unit tests or simulation modules, you will also need an Internet connection for the initial setup process, as CMake will clone google-test and imgui from GitHub.
## Build Options
The following build options are available:
* `WITH_JAVA` (ON Default)
* This option will enable Java and JNI builds. If this is on, `WITH_SHARED_LIBS` must be on. Otherwise CMake will error.
* `WITH_SHARED_LIBS` (ON Default)
* This option will cause cmake to build static libraries instead of shared libraries. If this is off, `WITH_JAVA` must be off. Otherwise CMake will error.
* `WITH_CSCORE` (ON Default)
* This option will cause cscore to be built. Turning this off will implicitly disable cameraserver, the hal and wpilib as well, irrespective of their specific options. If this is off, the OpenCV build requirement is removed.
* `WITH_NTCORE` (ON Default)
* This option will cause ntcore to be built. Turning this off will implicitly disable wpinet and wpilib as well, irrespective of their specific options.
* `WITH_WPIMATH` (ON Default)
* This option will build the wpimath library. This option must be on to build wpilib.
* `WITH_WPILIB` (ON Default)
* This option will build the hal and wpilibc/j during the build. The HAL is the simulator hal, unless the external hal options are used. The cmake build has no capability to build for the RoboRIO.
* `WITH_EXAMPLES` (ON Default)
* This option will build C++ examples.
* `WITH_TESTS` (ON Default)
* This option will build C++ unit tests. These can be run via `make test`.
* `WITH_GUI` (ON Default)
* This option will build GUI items.
* `WITH_SIMULATION_MODULES` (ON Default)
* This option will build simulation modules, including wpigui and the HALSim plugins.
* `WITH_EXTERNAL_HAL` (OFF Default)
* TODO
* `EXTERNAL_HAL_FILE`
* TODO
* `OPENCV_JAVA_INSTALL_DIR`
* Set this option to the location of the archive of the OpenCV Java bindings (it should be called opencv-xxx.jar, with the x'es being version numbers). NOTE: set it to the LOCATION of the file, not the file itself!
## Build Setup
The WPILib CMake build does not allow in source builds. Because the `build` directory is used by Gradle, we recommend a `build-cmake` directory in the root. This folder is included in the gitignore.
Once you have a build folder, run CMake configuration in that build directory with the following command.
```
cmake path/to/allwpilib/root
```
If you want to change any of the options, add `-DOPTIONHERE=VALUE` to the `cmake` command. This will check for any dependencies. If everything works properly this will succeed. If not, please check out the troubleshooting section for help.
If you want, you can also use `ccmake` in order to visually set these properties as well. [Here](https://cmake.org/cmake/help/v3.0/manual/ccmake.1.html) is the link to the documentation for that program.
## Building
Once you have cmake setup. run `make` from the directory you configured CMake in. This will build all libraries possible. If you have a multicore system, we recommend running `make` with multiple jobs. The usual rule of thumb is 1.5x the number of cores you have. To run a multiple job build, run the following command with x being the number of jobs you want.
```
make -jx
```
The `ninja` generator is also supported, and can be enabled by passing `-GNinja` to the initial `cmake` command.
## Installing
After build, the easiest way to use the libraries is to install them. Run the following command to install the libraries. This will install them so that they can be used from external cmake projects.
```
sudo make install
```
## Using the installed libraries for C++.
Using the libraries from C++ is the easiest way to use the built libraries.
To do so, create a new folder to contain your project. Add the following code below to a `CMakeLists.txt` file in that directory.
```
cmake_minimum_required(VERSION 3.5)
project(vision_app) # Project Name Here
find_package(wpilib REQUIRED)
add_executable(my_vision_app main.cpp) # executable name as first parameter
target_link_libraries(my_vision_app cameraserver ntcore cscore wpiutil)
```
If you are using them, `wpilibc` and `hal` should be added before the `cameraserver` declaration in the `target_link_libraries` function.
Add a `main.cpp` file to contain your code, and create a build folder. Move into the build folder, and run
```
cmake /path/to/folder/containing/CMakeLists
```
After that, run `make`. That will create your executable. Then you should be able to run `./my_vision_app` to run your application.
## Using the installed libraries for Java
TODO
## Troubleshooting
Below are some common issues that are run into when building.
#### Missing OpenCV
If you are missing OpenCV, you will get an error message similar to this.
```
CMake Error at cscore/CMakeLists.txt:3 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
```
If you get that, you need make sure opencv was installed, and then reattempt to configure. If that doesn't work, set the `OpenCV_DIR` variable to the directory where you built OpenCV.
#### Missing Java
If you are missing Java, you will get a message like the following.
```
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE
Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
```
If this happens, make sure you have a JDK of at least version 8 installed, and that your JAVA_HOME variable is set properly to point to the JDK.
In addition, if you do not need Java, you can disable it with `-DWITH_JAVA=OFF`.

240
README-CMake.md Normal file
View File

@@ -0,0 +1,240 @@
# WPILib CMake Support
WPILib is normally built with Gradle, however for some systems, such as Linux based coprocessors, Gradle doesn't work correctly, especially if cscore is needed, which requires OpenCV. Furthermore, the CMake build can be used for C++ development because it provides better build caching compared to Gradle. We provide the CMake build for these cases. Although macOS is supported, these docs will only go over Linux and Windows builds, but should mostly work for macOS as well. If you are stuck, you can look at the GitHub workflows for any OS to see how it works.
## Libraries that get built
* apriltag
* cameraserver
* cscore
* fieldImages
* hal (simulation HAL only)
* ntcore
* romiVendordep
* simulation extensions
* wpigui
* wpilib (wpilibc, wpilibj, and myRobot)
* wpilibNewCommands
* wpimath
* wpinet
* wpiunits
* wpiutil
* xrpVendordep
## GUI apps that get built
* datalogtool
* glass
* outlineviewer
* roborioteamnumbersetter
* sysid
* halsim_gui (if simulation extensions are enabled)
By default, all libraries get built with a default CMake setup. The libraries are built as shared libraries, and include the JNI libraries as well as building the Java JARs. Data Log Tool and the roboRIO Team Number Setter are only built if libssh is available.
## Prerequisites
The protobuf library and compiler are needed for protobuf generation.
OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
If you want JNI and Java, you will need a JDK of at least version 17 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
If you are building with unit tests or simulation modules, you will also need an Internet connection for the initial setup process, as CMake will clone google-test and imgui from GitHub.
## Build Options
The following build options are available:
* `BUILD_SHARED_LIBS` (ON Default)
* This option will cause CMake to build static libraries instead of shared libraries. If this is off, `WITH_JAVA` must be off. Otherwise CMake will error.
* `WITH_CSCORE` (ON Default)
* This option will cause cscore to be built. Turning this off will implicitly disable cameraserver. If this is off, the OpenCV build requirement is removed.
* `WITH_EXAMPLES` (OFF Default)
* This option will build C++ examples.
* `WITH_GUI` (ON Default)
* This option will build GUI items. If this is off, and `WITH_SIMULATION_MODULES` is on, the simulation GUI will not be built.
* `WITH_JAVA` (OFF Default)
* This option will enable Java and JNI builds. If this is on, `BUILD_SHARED_LIBS` must be on. Otherwise CMake will error.
* `WITH_JAVA_SOURCE` (`WITH_JAVA` Default)
* This option will build Java source JARs for each enabled Java library. This does not require `WITH_JAVA` to be on, allowing source JARs to be built without the compiled JARs if desired.
* `WITH_NTCORE` (ON Default)
* This option will cause ntcore to be built. Turning this off will implicitly disable wpinet, and will cause an error if `WITH_WPILIB` is enabled.
* `WITH_SIMULATION_MODULES` (ON Default)
* This option will build simulation modules.
* `WITH_TESTS` (ON Default)
* This option will build C++ unit tests. These can be run via `ctest -C <config>`, where `<config>` is the build configuration, e.g. `Debug` or `Release`.
* `WITH_WPILIB` (ON Default)
* This option will build the HAL and wpilibc/j during the build. The HAL is the simulation HAL, unless the external HAL options are used. The CMake build has no capability to build for the roboRIO.
* `WITH_WPIMATH` (ON Default)
* This option will build the wpimath library. This option must be on to build wpilib.
* `WITH_PROTOBUF` (ON Default)
* This option will build with the protobuf library.
* `WITH_WPIUNITS` (`WITH_JAVA` Default)
* This option will build the wpiunits library. This option must be on to build the Java wpimath library and requires `WITH_JAVA` to also be on.
* `OPENCV_JAVA_INSTALL_DIR`
* Set this option to the location of the archive of the OpenCV Java bindings (it should be called opencv-xxx.jar, with the x'es being version numbers). NOTE: set it to the LOCATION of the file, not the file itself!
* `NO_WERROR` (OFF Default)
* This option will disable the `-Werror` compilation flag for non-MSVC builds.
* `WPILIB_TARGET_WARNINGS`
* Add compiler flags to this option to customize compiler options like warnings.
## Build Setup
The WPILib CMake build does not allow in source builds. Because the `build` directory is used by Gradle, we recommend a `build-cmake` directory in the root. This folder is included in the gitignore. We support building with Ninja; other options like Makefiles may be broken.
Once you have a build folder, run CMake configuration in the root directory with the following command.
```
cmake --preset default
```
If you want to change any of the options, add `-DOPTIONHERE=VALUE` to the `cmake` command. This will check for any dependencies. If everything works properly this will succeed. If not, please check out the troubleshooting section for help.
If you want, you can also use `ccmake` in order to visually set these properties as well. [Here](https://cmake.org/cmake/help/v3.0/manual/ccmake.1.html) is the link to the documentation for that program. On Windows, you can use `cmake-gui` instead.
Note that if you are cross-compiling, you will need to override the protobuf options manually to point to the libraries for the target platform. Leave the protoc binary location as the path to the binary for the host platform, since protoc needs to execute on the host platform.
## Presets
The WPILib CMake setup has a variety of presets for common configurations and options used. The default sets the generator to Ninja and build directory to `build-cmake`. The other presets are `with-java` (sets `WITH_JAVA=ON`), `sccache` (sets the C/C++ compiler launcher to sccache), and `with-java-sccache` (a comibination of `with-java` and `sccache`.
## Building
Once you have CMake setup. run `cmake --build .` from the directory you configured CMake in. This will build all libraries possible. We recommend running `cmake --build .` with multiple jobs. For allwpilib, a good rule of thumb is one worker for every 2 GB of available RAM. To run a multiple job build, run the following command with x being the number of jobs you want.
```
cmake --build . --parallel x
```
Note: wpimath takes gigabytes of RAM to compile. Because of this, the compilers may crash while building due to a lack of memory and your computer may slow down. If you have less than 16 GB of RAM available, you may want to consider building it separately first by adding `--target wpimath` and running it with ~3 jobs to prevent crashes from running out of memory.
To build with a certain configuration, like `Debug` or `Release`, add `--config <config>`, where `<config>` is the name of the configuration you want to build with.
## Installing
After build, the easiest way to use the libraries is to install them. Run the following command to install the libraries. This will install them so that they can be used from external CMake projects.
```
sudo cmake --build . --target install
```
## Preparing to use the installed libraries
On Windows, make sure the directories for the libraries you built are on PATH. For wpilib, the default install location is `C:\Program Files (x86)\allwpilib`. If you built other libraries like OpenCV and protobuf from source, install them, and add the install directories to PATH. This ensures CMake can locate the libraries.
You will also want to add the directories where the DLLs are located (usually the `bin` subdirectory of the install directory) to PATH so they can be loaded by your program. If you are using OpenCV and Java, the `opencv_java` DLL is located in either the `lib` subdirectory if you built but didn't install OpenCV, or the `java` subdirectory if you did install OpenCV.
## Using the installed libraries for C++.
Using the libraries from C++ is the easiest way to use the built libraries.
To do so, create a new folder to contain your project. Add the following code below to a `CMakeLists.txt` file in that directory.
```cmake
cmake_minimum_required(VERSION 3.11)
project(vision_app) # Project Name Here
find_package(wpilib REQUIRED)
add_executable(my_vision_app main.cpp) # executable name as first parameter
target_link_libraries(my_vision_app cameraserver ntcore cscore wpiutil)
```
If you want to use other libraries or are building a robot program, `wpilibc` and `hal` should be added in the `target_link_libraries` function, along with any other libraries you plan on using, e.g. `wpimath`.
Add a `main.cpp` file to contain your code, and create a build folder. Move into the build folder, and run
```
cmake /path/to/folder/containing/CMakeLists
```
After that, run `cmake --build .`. That will create your executable. Then you should be able to run `./my_vision_app` to run your application.
## Using the installed libraries for Java
Using the built JARs is more involved than using the C++ libraries, but the additional work involves providing the paths to various libraries and JARs when needed.
Create a new folder to contain your project. Add the following code below to a `CMakeLists.txt` file in that directory.
```cmake
cmake_minimum_required(VERSION 3.11)
project(robot)
find_package(Java REQUIRED COMPONENTS Development)
include(UseJava)
find_package(wpilib REQUIRED)
find_jar(opencvJar opencv-xxx PATHS ENV PATH) # Change to OpenCV version
file(GLOB_RECURSE JAVA_SOURCES *.java)
# If you want Gradle compatibility or you are using one of the templates/examples, comment out the above line and uncomment this line instead:
# file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
add_jar(robot ${JAVA_SOURCES}
INCLUDE_JARS apriltag_jar cscore_jar hal_jar ntcore_jar wpilibNewCommands_jar wpimath_jar wpinet_jar wpiutil_jar wpiunits_jar wpilibj_jar ${opencvJar})
export_jars(TARGETS robot FILE robot.jar)
```
This includes all the built JARs except for the vendordeps. If you are not using a JAR/library, you may remove it.
Add a `Main.java` file to contain your code, and create a build folder. Move into the build folder, and run
```
cmake /path/to/folder/containing/CMakeLists
```
After that, run `cmake --build .` to create your JAR file. To execute the JAR file, you need to include the wpilib JARs and your JAR in the classpath, and execute your Java program's entry point. If you are using cscore or cameraserver, you also need to include the path to the OpenCV JAR. If you built it from source, it will be in your OpenCV build directory. If it's installed on the system, CMake may find it from PATH, but you will likely need to locate the JAR and manually give CMake the JAR directory. If you are on Linux, you will also need to add the path of the libraries to `LD_LIBRARY_PATH`. This can be done by prepending `LD_LIBRARY_PATH=/path/to/libraries` to the Java command. If you need to add more paths, separate them with colons. The final command should look like `java -cp "robot.jar:/path/to/library_jars/*" main.package.Main`, using a semicolon to separate paths instead of a colon if you are on Windows. If you are on Linux, the final command should look more like `LD_LIBRARY_PATH=/path/to/libraries java -cp robot.jar:/path/to/library_jars/* main.package.Main`.
## Using vendordeps
Vendordeps are not included as part of the `wpilib` CMake package. However, if you want to use a vendordep, you need to use `find_package(VENDORDEP)`, where `VENDORDEP` is the name of the vendordep (case-sensitive), like `xrpVendordep` or `romiVendordep`. Note that wpilibNewCommands, while a vendordep in normal robot projects, is not built as a vendordep in CMake, and is instead included as part of the `wpilib` CMake package. After you used `find_package`, you can reference the vendordep library like normal, either by using `target_link_libraries` for C++ or `add_jar` for Java.
## Troubleshooting
Below are some common issues that are run into when building.
#### Missing OpenCV
If you are missing OpenCV, you will get an error message similar to this.
```
CMake Error at cscore/CMakeLists.txt:3 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
```
If you get that, you need make sure OpenCV was installed, and then reattempt to configure. If that doesn't work, set the `OpenCV_DIR` variable to the directory where you built OpenCV.
#### Missing Java
If you are missing Java, you will get a message like the following.
```
CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find Java (missing: Java_JAVA_EXECUTABLE Java_JAR_EXECUTABLE
Java_JAVAC_EXECUTABLE Java_JAVAH_EXECUTABLE Java_JAVADOC_EXECUTABLE)
```
If this happens, make sure you have a JDK of at least version 8 installed, and that your JAVA_HOME variable is set properly to point to the JDK.
In addition, if you do not need Java, you can disable it with `-DWITH_JAVA=OFF`.
#### Java: Can't find dependent libraries
If one of the libraries can't be found, you will get an error similar to this one:
```
java.io.IOException: wpiHaljni could not be loaded from path or an embedded resource.
attempted to load for platform /windows/x86-64/
Last Load Error:
C:\Program Files (x86)\allwpilib\bin\wpiHaljni.dll: Can't find dependent libraries
```
If you get this error, that's usually an indication that not all your libraries are in your PATH. The two libraries that should be in your PATH are OpenCV and protobuf. If the error is coming from cscore, it's likely you're missing OpenCV. Otherwise, it's likely you're missing protobuf.
Note that Linux will not have this specific type of error, as it will usually tell you the dependent library you are missing. In that case, you most likely need to add the library to `LD_LIBRARY_PATH`.

View File

@@ -17,13 +17,15 @@ Welcome to the WPILib project. This repository contains the HAL, WPILibJ, and WP
- [Custom toolchain location](#custom-toolchain-location)
- [Formatting/Linting](#formattinglinting)
- [CMake](#cmake)
- [Bazel](#bazel)
- [Running examples in simulation](#running-examples-in-simulation)
- [Publishing](#publishing)
- [Structure and Organization](#structure-and-organization)
- [Contributing to WPILib](#contributing-to-wpilib)
- [Contributing to WPILib](./CONTRIBUTING.md)
## WPILib Mission
The WPILib Mission is to enable FIRST Robotics teams to focus on writing game-specific software rather than focusing on hardware details - "raise the floor, don't lower the ceiling". We work to enable teams with limited programming knowledge and/or mentor experience to be as successful as possible, while not hampering the abilities of teams with more advanced programming capabilities. We support Kit of Parts control system components directly in the library. We also strive to keep parity between major features of each language (Java, C++, and NI's LabVIEW), so that teams aren't at a disadvantage for choosing a specific programming language. WPILib is an open source project, licensed under the BSD 3-clause license. You can find a copy of the license [here](LICENSE.md).
The WPILib Mission is to enable FIRST Robotics teams to focus on writing game-specific software rather than focusing on hardware details - "raise the floor, don't lower the ceiling". We work to enable teams with limited programming knowledge and/or mentor experience to be as successful as possible, while not hampering the abilities of teams with more advanced programming capabilities. We support Kit of Parts control system components directly in the library. We also strive to keep parity between major features of each language (Java, C++, Python, and NI's LabVIEW), so that teams aren't at a disadvantage for choosing a specific programming language. WPILib is an open source project, licensed under the BSD 3-clause license. You can find a copy of the license [here](LICENSE.md).
# Quick Start
@@ -40,11 +42,11 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
## Requirements
- [JDK 11](https://adoptium.net/temurin/releases/?version=11)
- [JDK 17](https://adoptium.net/temurin/releases/?version=17)
- Note that the JRE is insufficient; the full JDK is required
- On Ubuntu, run `sudo apt install openjdk-11-jdk`
- On Windows, install the JDK 11 .msi from the link above
- On macOS, install the JDK 11 .pkg from the link above
- On Ubuntu, run `sudo apt install openjdk-17-jdk`
- On Windows, install the JDK 17 .msi from the link above
- On macOS, install the JDK 17 .pkg from the link above
- C++ compiler
- On Linux, install GCC 11 or greater
- On Windows, install [Visual Studio Community 2022](https://visualstudio.microsoft.com/vs/community/) and select the C++ programming language during installation (Gradle can't use the build tools for Visual Studio)
@@ -57,11 +59,13 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
On macOS ARM, run `softwareupdate --install-rosetta`. This is necessary to be able to use the macOS x86 roboRIO toolchain on ARM.
On linux, run `sudo apt install gfortran`. This is necessary to be able to build WPIcal on linux platforms.
## Setup
Clone the WPILib repository and follow the instructions above for installing any required tooling.
Clone the WPILib repository and follow the instructions above for installing any required tooling. The build process uses versioning information from git. Downloading the source is not sufficient to run the build.
See the [styleguide README](https://github.com/wpilibsuite/styleguide/blob/main/README.md) for wpiformat setup instructions. We use clang-format 14.
See the [styleguide README](https://github.com/wpilibsuite/styleguide/blob/main/README.md) for wpiformat setup instructions.
## Building
@@ -87,9 +91,24 @@ If opening from a fresh clone, generated java dependencies will not exist. Most
`./gradlew build` builds _everything_, which includes debug and release builds for desktop and all installed cross compilers. Many developers don't need or want to build all of this. Therefore, common tasks have shortcuts to only build necessary components for common development and testing tasks.
`./gradlew testDesktopCpp` and `./gradlew testDesktopJava` will build and run the tests for `wpilibc` and `wpilibj` respectively. They will only build the minimum components required to run the tests.
`./gradlew testDesktopCpp` and `./gradlew testDesktopJava` will build and run the tests for `wpilibc` and `wpilibj` respectively. They will only build the minimum components required to run the tests. `./gradlew testDesktop` will run both `testDesktopJava` and `testDesktopCpp`.
`testDesktopCpp` and `testDesktopJava` tasks also exist for the projects `wpiutil`, `ntcore`, `cscore`, `hal` `wpilibNewCommands` and `cameraserver`. These can be ran with `./gradlew :projectName:task`.
`testDesktopCpp`, `testDesktopJava`, and `testDesktop` tasks also exist for the following projects:
- `apriltag`
- `cameraserver`
- `cscore`
- `hal`
- `ntcore`
- `wpilibNewCommands`
- `wpimath`
- `wpinet`
- `wpiunits`
- `wpiutil`
- `romiVendordep`
- `xrpVendordep`
These can be ran with `./gradlew :projectName:task`.
`./gradlew buildDesktopCpp` and `./gradlew buildDesktopJava` will compile `wpilibcExamples` and `wpilibjExamples` respectively. The results can't be ran, but they can compile.
@@ -117,9 +136,12 @@ If you have installed the FRC Toolchain to a directory other than the default, o
Once a PR has been submitted, formatting can be run in CI by commenting `/format` on the PR. A new commit will be pushed with the formatting changes.
> [!NOTE]
> The `/format` action has been temporarily disabled. The individual formatting commands can be run locally as shown below. Alternately, the Lint and Format action for a PR will upload a patch file that can be downloaded and applied manually.
#### wpiformat
wpiformat can be executed anywhere in the repository via `py -3 -m wpiformat -clang 14` on Windows or `python3 -m wpiformat -clang 14` on other platforms.
wpiformat can be executed anywhere in the repository via `py -3 -m wpiformat` on Windows or `python3 -m wpiformat` on other platforms.
#### Java Code Quality Tools
@@ -127,9 +149,27 @@ The Java code quality tools Checkstyle, PMD, and Spotless can be run via `./grad
If you only want to run the Java autoformatter, run `./gradlew spotlessApply`.
### Generated files
Several files within WPILib are generated using Jinja. If a PR is opened that modifies these templates then the files can be generated through CI by commenting `/pregen` on the PR. A new commit will be pushed with the regenerated files. See [GeneratedFiles.md](GeneratedFiles.md) for more information.
### CMake
CMake is also supported for building. See [README-CMAKE.md](README-CMAKE.md).
CMake is also supported for building. See [README-CMake.md](README-CMake.md).
### Bazel
Bazel is also supported for building. See [README-Bazel.md](README-Bazel.md).
## Running examples in simulation
Examples can be run in simulation with the following command:
```bash
./gradlew wpilibcExamples:runExample
./gradlew wpilibjExamples:runExample
```
where `Example` is the example's folder name.
## Publishing
@@ -153,7 +193,3 @@ The hal directory contains more C++ code meant to run on the roboRIO. HAL is an
The upstream_utils directory contains scripts for updating copies of thirdparty code in the repository.
The [styleguide repository](https://github.com/wpilibsuite/styleguide) contains our style guides for C++ and Java code. Anything submitted to the WPILib project needs to follow the code style guides outlined in there. For details about the style, please see the contributors document [here](CONTRIBUTING.md#coding-guidelines).
# Contributing to WPILib
See [CONTRIBUTING.md](CONTRIBUTING.md).

View File

@@ -15,8 +15,8 @@ licenses, and/or restrictions:
Program Locations
------- ---------
RoboRIO Libraries ni-libraries
Google Test gtest
Google Test thirdparty/googletest/include
thirdparty/googletest/src
LLVM wpiutil/src/main/native/thirdparty/llvm
wpiutil/src/test/native/cpp/llvm/
JSON for Modern C++ wpiutil/src/main/native/thirdparty/json
@@ -33,19 +33,29 @@ jQuery wpinet/src/main/native/resources/jquery-*
popper.js wpinet/src/main/native/resources/popper-*
units wpimath/src/main/native/include/units/
Eigen wpimath/src/main/native/thirdparty/eigen/include/
StackWalker wpiutil/src/main/native/windows/StackWalker.*
GHC filesystem wpiutil/src/main/native/thirdparty/include/wpi/ghc/
Team 254 Library wpilibj/src/main/java/edu/wpi/first/wpilibj/spline/SplineParameterizer.java
wpilibj/src/main/java/edu/wpi/first/wpilibj/trajectory/TrajectoryParameterizer.java
wpilibc/src/main/native/include/spline/SplineParameterizer.h
wpilibc/src/main/native/include/trajectory/TrajectoryParameterizer.h
wpilibc/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp
Team 254 Library wpimath/src/main/java/edu/wpi/first/math/spline/SplineParameterizer.java
wpimath/src/main/java/edu/wpi/first/math/trajectory/TrajectoryParameterizer.java
wpimath/src/main/native/include/frc/spline/SplineParameterizer.h
wpimath/src/main/native/include/frc/trajectory/TrajectoryParameterizer.h
wpimath/src/main/native/cpp/trajectory/TrajectoryParameterizer.cpp
Portable File Dialogs wpigui/src/main/native/include/portable-file-dialogs.h
Drake wpimath/src/main/native/thirdparty/drake/
wpimath/src/test/native/cpp/drake/
wpimath/src/test/native/include/drake/
V8 export-template wpiutil/src/main/native/include/wpi/SymbolExports.h
GCEM wpimath/src/main/native/thirdparty/gcem/include/
Sleipnir wpimath/src/main/native/thirdparty/sleipnir
Debugging wpiutil/src/main/native/thirdparty/debugging
argparse wpiutil/src/main/native/thirdparty/argparse/include/wpi/argparse.h
apriltag apriltag/src/main/native/thirdparty/apriltag
glfw thirdparty/imgui_suite/glfw
Dear ImGui thirdparty/imgui_suite/imgui
implot thirdparty/imgui_suite/implot
memory wpiutil/src/main/native/thirdparty/memory
nanopb wpiutil/src/main/native/thirdparty/nanopb
protobuf wpiutil/src/main/native/thirdparty/protobuf
mrcal wpical/src/main/native/thirdparty/mrcal
libdogleg wpical/src/main/native/thirdparty/libdogleg
Simd hal/src/main/native/athena/simd
Additionally, glfw, memory, and nanopb were all modified for use in WPILib.
==============================================================================
Google Test License
@@ -464,7 +474,7 @@ limitations under the License.
==============================================================================
MPacks License
MPack License
==============================================================================
The MIT License (MIT)
@@ -1015,35 +1025,6 @@ Exhibit B - "Incompatible With Secondary Licenses" Notice
defined by the Mozilla Public License, v. 2.0.
===================
StackWalker License
===================
Copyright (c) 2005-2013, Jochen Kalmbach
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
Neither the name of Jochen Kalmbach nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
================
Team 254 Library
================
@@ -1069,41 +1050,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
=============
Drake Library
=============
All components of Drake are licensed under the BSD 3-Clause License
shown below. Where noted in the source code, some portions may
be subject to other permissive, non-viral licenses.
Copyright 2012-2016 Robot Locomotion Group @ CSAIL
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. Redistributions
in binary form must reproduce the above copyright notice, this list of
conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution. Neither the name of
the Massachusetts Institute of Technology nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=====================
Portable File Dialogs
=====================
@@ -1115,33 +1061,6 @@ and/or modify it under the terms of the Do What the **** You Want
to Public License, Version 2, as published by the WTFPL Task Force.
See http://www.wtfpl.net/ for more details.
======================
Boost Software License
======================
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
======
fmtlib
======
@@ -1173,29 +1092,6 @@ of this Software are embedded into a machine-executable object form of such
source code, you may redistribute such embedded portions in such object form
without including the above copyright and permission notices.
==============
GHC filesystem
==============
Copyright (c) 2018, Steffen Schümann <s.schuemann@pobox.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==================
V8 export-template
==================
@@ -1242,3 +1138,564 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================
2024 Field Image
================
2024 Field Image from MikLast: https://www.chiefdelphi.com/t/2024-crescendo-top-down-field-renders/447764
================
Sleipnir License
================
Copyright (c) Sleipnir contributors
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
=================
Debugging License
=================
MIT License
Copyright (c) 2021-2022 René Ferdinand Rivera Morell
Copyright (c) 2018 Isabella Muerte
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================
argparse License
================
Copyright (c) 2018 Pranav Srinivas Kumar <pranav.srinivas.kumar@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================
apriltag License
================
BSD 2-Clause License
Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
============
gl3w License
============
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
============
glfw License
============
Copyright (c) 2002-2006 Marcus Geelnard
Copyright (c) 2006-2019 Camilla Löwy
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would
be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not
be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
==================
Dear ImGui License
==================
The MIT License (MIT)
Copyright (c) 2014-2024 Omar Cornut
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============
implot License
==============
MIT License
Copyright (c) 2020 Evan Pezent
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============
memory License
==============
Copyright (C) 2015-2023 Jonathan Müller and foonathan/memory contributors
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but
is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
==============
nanopb License
==============
Copyright (c) 2011 Petteri Aimonen <jpa at nanopb.mail.kapsi.fi>
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held liable
for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you use
this software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
================
protobuf License
================
Copyright 2008 Google Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Code generated by the Protocol Buffer compiler is owned by the owner
of the input file used when generating it. This code is not
standalone and requires a support library to be linked with it. This
support library is itself covered by the above license.
===========
stb License
===========
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
=============
mrcal License
=============
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright (c) 2017-2023 California Institute of Technology ("Caltech"). U.S.
Government sponsorship acknowledged. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
=================
libdogleg License
=================
Copyright 2011 Oblong Industries 2017 Dima Kogan <dima@secretsauce.net>
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
The full text of the license is available at http://www.gnu.org/licenses
============
Simd License
============
MIT License
Copyright (c) 2011-2017 Ihar Yermalayeu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

125
WORKSPACE Normal file
View File

@@ -0,0 +1,125 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Download Extra java rules
http_archive(
name = "rules_jvm_external",
sha256 = "08ea921df02ffe9924123b0686dc04fd0ff875710bfadb7ad42badb931b0fd50",
strip_prefix = "rules_jvm_external-6.1",
url = "https://github.com/bazelbuild/rules_jvm_external/releases/download/6.1/rules_jvm_external-6.1.tar.gz",
)
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
rules_jvm_external_deps()
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_artifacts = [
"org.ejml:ejml-simple:0.43.1",
"com.fasterxml.jackson.core:jackson-annotations:2.15.2",
"com.fasterxml.jackson.core:jackson-core:2.15.2",
"com.fasterxml.jackson.core:jackson-databind:2.15.2",
"us.hebi.quickbuf:quickbuf-runtime:1.3.3",
"com.google.code.gson:gson:2.10.1",
]
maven_install(
name = "maven",
artifacts = maven_artifacts,
repositories = [
"https://repo1.maven.org/maven2",
"https://frcmaven.wpi.edu/artifactory/release/",
],
)
# Download toolchains
http_archive(
name = "rules_bzlmodrio_toolchains",
sha256 = "ff25b5f9445cbd43759be4c6582b987d1065cf817c593eedc7ada1a699298c84",
url = "https://github.com/wpilibsuite/rules_bzlmodRio_toolchains/releases/download/2025-1.bcr2/rules_bzlmodRio_toolchains-2025-1.bcr2.tar.gz",
)
load("@rules_bzlmodrio_toolchains//:maven_deps.bzl", "setup_legacy_setup_toolchains_dependencies")
setup_legacy_setup_toolchains_dependencies()
load("@rules_bzlmodrio_toolchains//toolchains:load_toolchains.bzl", "load_toolchains")
load_toolchains()
#
http_archive(
name = "rules_bzlmodrio_jdk",
sha256 = "81869fe9860e39b17e4a9bc1d33c1ca2faede7e31d9538ed0712406f753a2163",
url = "https://github.com/wpilibsuite/rules_bzlmodRio_jdk/releases/download/17.0.12-7/rules_bzlmodRio_jdk-17.0.12-7.tar.gz",
)
load("@rules_bzlmodrio_jdk//:maven_deps.bzl", "setup_legacy_setup_jdk_dependencies")
setup_legacy_setup_jdk_dependencies()
register_toolchains(
"@local_roborio//:macos",
"@local_roborio//:linux",
"@local_roborio//:windows",
"@local_systemcore//:macos",
"@local_systemcore//:linux",
"@local_systemcore//:windows",
"@local_raspi_bullseye_32//:macos",
"@local_raspi_bullseye_32//:linux",
"@local_raspi_bullseye_32//:windows",
"@local_raspi_bookworm_32//:macos",
"@local_raspi_bookworm_32//:linux",
"@local_raspi_bookworm_32//:windows",
"@local_bullseye_32//:macos",
"@local_bullseye_32//:linux",
"@local_bullseye_32//:windows",
"@local_bullseye_64//:macos",
"@local_bullseye_64//:linux",
"@local_bullseye_64//:windows",
"@local_bookworm_32//:macos",
"@local_bookworm_32//:linux",
"@local_bookworm_32//:windows",
"@local_bookworm_64//:macos",
"@local_bookworm_64//:linux",
"@local_bookworm_64//:windows",
)
setup_legacy_setup_jdk_dependencies()
http_archive(
name = "bzlmodrio-ni",
sha256 = "fff62c3cb3e83f9a0d0a01f1739477c9ca5e9a6fac05be1ad59dafcd385801f7",
url = "https://github.com/wpilibsuite/bzlmodRio-ni/releases/download/2025.2.0/bzlmodRio-ni-2025.2.0.tar.gz",
)
load("@bzlmodrio-ni//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_ni_cpp_dependencies")
setup_legacy_bzlmodrio_ni_cpp_dependencies()
http_archive(
name = "bzlmodrio-opencv",
sha256 = "ba3f4910ce9cc0e08abff732aeb5835b1bcfd864ca5296edeadcf2935f7e81b9",
url = "https://github.com/wpilibsuite/bzlmodRio-opencv/releases/download/2025.4.10.0-3.bcr1/bzlmodRio-opencv-2025.4.10.0-3.bcr1.tar.gz",
)
load("@bzlmodrio-opencv//:maven_cpp_deps.bzl", "setup_legacy_bzlmodrio_opencv_cpp_dependencies")
setup_legacy_bzlmodrio_opencv_cpp_dependencies()
load("@bzlmodrio-opencv//:maven_java_deps.bzl", "setup_legacy_bzlmodrio_opencv_java_dependencies")
setup_legacy_bzlmodrio_opencv_java_dependencies()
http_archive(
name = "build_bazel_apple_support",
sha256 = "c4bb2b7367c484382300aee75be598b92f847896fb31bbd22f3a2346adf66a80",
url = "https://github.com/bazelbuild/apple_support/releases/download/1.15.1/apple_support.1.15.1.tar.gz",
)
load(
"@build_bazel_apple_support//lib:repositories.bzl",
"apple_support_dependencies",
)
apple_support_dependencies()

112
apriltag/BUILD.bazel Normal file
View File

@@ -0,0 +1,112 @@
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
load("@rules_java//java:defs.bzl", "java_binary", "java_library")
load("@rules_python//python:defs.bzl", "py_binary")
load("//shared/bazel/rules/gen:gen-resources.bzl", "generate_resources")
cc_library(
name = "thirdparty-apriltag",
srcs = glob(["src/main/native/thirdparty/apriltag/src/**"]),
hdrs = glob(["src/main/native/thirdparty/apriltag/include/**"]),
copts = select({
"@bazel_tools//src/conditions:darwin": [
"-Wno-format-nonliteral",
"-Wno-gnu-zero-variadic-macro-arguments",
"-Wno-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
"@bazel_tools//src/conditions:windows": [
"/wd4005",
"/wd4018",
"/wd4244",
"/wd4267",
"/wd4996",
],
"@rules_bzlmodrio_toolchains//constraints/combined:is_linux": [
"-Wno-format-nonliteral",
"-Wno-maybe-uninitialized",
"-Wno-sign-compare",
"-Wno-type-limits",
],
}),
includes = ["src/main/native/thirdparty/apriltag/include/common"],
strip_include_prefix = "src/main/native/thirdparty/apriltag/include",
visibility = ["//visibility:public"],
)
generate_resources(
name = "generate-resources",
namespace = "frc",
prefix = "APRILTAG",
resource_files = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
)
cc_library(
name = "apriltag.static",
srcs = [":generate-resources"] + glob(
["src/main/native/cpp/**"],
exclude = ["src/main/native/cpp/jni/**"],
),
hdrs = glob(["src/main/native/include/**/*"]),
defines = ["WPILIB_EXPORTS"],
strip_include_prefix = "src/main/native/include",
visibility = ["//visibility:public"],
deps = [
":thirdparty-apriltag",
"//wpimath:wpimath.static",
"//wpiutil:wpiutil.static",
],
)
java_library(
name = "apriltag-java",
srcs = glob(["src/main/java/**/*.java"]),
resource_strip_prefix = "apriltag/src/main/native/resources",
resources = glob(["src/main/native/resources/**"]),
visibility = ["//visibility:public"],
deps = [
"//wpimath:wpimath-java",
"//wpiutil:wpiutil-java",
"@bzlmodrio-opencv//libraries/java/opencv",
"@maven//:com_fasterxml_jackson_core_jackson_annotations",
"@maven//:com_fasterxml_jackson_core_jackson_core",
"@maven//:com_fasterxml_jackson_core_jackson_databind",
],
)
cc_test(
name = "apriltag-cpp-test",
size = "small",
srcs = glob(["src/test/native/cpp/**"]),
tags = [
"no-asan",
],
deps = [
":apriltag.static",
"//thirdparty/googletest:googletest.static",
],
)
cc_binary(
name = "DevMain-Cpp",
srcs = ["src/dev/native/cpp/main.cpp"],
deps = [
":apriltag.static",
],
)
java_binary(
name = "DevMain-Java",
srcs = ["src/dev/java/edu/wpi/first/apriltag/DevMain.java"],
main_class = "edu.wpi.first.apriltag.DevMain",
deps = [
":apriltag-java",
],
)
py_binary(
name = "convert_apriltag_layouts",
srcs = ["convert_apriltag_layouts.py"],
tags = ["manual"],
)

View File

@@ -2,117 +2,157 @@ project(apriltag)
include(CompileWarnings)
include(GenResources)
include(FetchContent)
FetchContent_Declare(
apriltaglib
GIT_REPOSITORY https://github.com/wpilibsuite/apriltag.git
GIT_TAG ad31e33d20f9782b7239cb15cde57c56c91383ad
file(
GLOB_RECURSE apriltaglib_src
src/main/native/thirdparty/apriltag/src/*.c
src/main/native/thirdparty/apriltag/src/*.cpp
)
# Don't use apriltag's CMakeLists.txt due to conflicting naming and JNI
FetchContent_GetProperties(apriltaglib)
if(NOT apriltaglib_POPULATED)
FetchContent_Populate(apriltaglib)
# Disable apriltag C library warnings
if(MSVC)
set_source_files_properties(
${apriltaglib_src}
PROPERTIES COMPILE_FLAGS "/wd4005 /wd4018 /wd4244 /wd4267 /wd4996"
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set_source_files_properties(
${apriltaglib_src}
PROPERTIES
COMPILE_FLAGS
"-Wno-format-nonliteral -Wno-gnu-zero-variadic-macro-arguments -Wno-uninitialized -Wno-sign-compare -Wno-type-limits"
)
else()
set_source_files_properties(
${apriltaglib_src}
PROPERTIES
COMPILE_FLAGS
"-Wno-format-nonliteral -Wno-gnu-zero-variadic-macro-arguments -Wno-maybe-uninitialized -Wno-sign-compare -Wno-type-limits"
)
endif()
aux_source_directory(${apriltaglib_SOURCE_DIR}/common APRILTAGLIB_COMMON_SRC)
file(GLOB TAG_FILES ${apriltaglib_SOURCE_DIR}/tag*.c)
set(APRILTAGLIB_SRCS ${apriltaglib_SOURCE_DIR}/apriltag.c ${apriltaglib_SOURCE_DIR}/apriltag_pose.c ${apriltaglib_SOURCE_DIR}/apriltag_quad_thresh.c)
file(GLOB apriltag_jni_src src/main/native/cpp/jni/AprilTagJNI.cpp)
if (WITH_JAVA)
find_package(Java REQUIRED)
find_package(JNI REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-encoding" "UTF8" "-Xlint:unchecked")
if(WITH_JAVA)
include(UseJava)
set(CMAKE_JNI_TARGET true)
set(CMAKE_JNI_TARGET true)
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
file(GLOB JACKSON_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/jackson/*.jar")
find_file(OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS ${OPENCV_JAVA_INSTALL_DIR} ${OpenCV_INSTALL_PATH}/bin ${OpenCV_INSTALL_PATH}/share/java
NO_DEFAULT_PATH)
file(GLOB EJML_JARS "${WPILIB_BINARY_DIR}/wpimath/thirdparty/ejml/*.jar")
file(GLOB JACKSON_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/jackson/*.jar")
find_file(
OPENCV_JAR_FILE
NAMES opencv-${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}.jar
PATHS
${OPENCV_JAVA_INSTALL_DIR}
${OpenCV_INSTALL_PATH}/bin
${OpenCV_INSTALL_PATH}/share/java
${OpenCV_INSTALL_PATH}/share/java/opencv4
${OpenCV_INSTALL_PATH}/share/OpenCV/java
NO_DEFAULT_PATH
)
set(CMAKE_JAVA_INCLUDE_PATH apriltag.jar ${EJML_JARS} ${JACKSON_JARS})
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(
GLOB_RECURSE JAVA_RESOURCES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
src/main/native/resources/*.json
)
add_jar(
apriltag_jar
SOURCES ${JAVA_SOURCES}
RESOURCES
NAMESPACE "edu/wpi/first/apriltag" ${JAVA_RESOURCES}
INCLUDE_JARS
wpimath_jar
wpiunits_jar
wpiutil_jar
${EJML_JARS}
${OPENCV_JAR_FILE}
${JACKSON_JARS}
OUTPUT_NAME apriltag
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
GENERATE_NATIVE_HEADERS apriltag_jni_headers
)
set_property(TARGET apriltag_jar PROPERTY FOLDER "java")
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(GLOB_RECURSE JAVA_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} src/main/native/resources/*.json)
add_jar(apriltag_jar
SOURCES ${JAVA_SOURCES}
RESOURCES NAMESPACE "edu/wpi/first/apriltag" ${JAVA_RESOURCES}
INCLUDE_JARS wpimath_jar ${EJML_JARS} wpiutil_jar ${OPENCV_JAR_FILE}
OUTPUT_NAME apriltag
GENERATE_NATIVE_HEADERS apriltag_jni_headers)
install_jar(apriltag_jar DESTINATION ${java_lib_dest})
install_jar_exports(TARGETS apriltag_jar FILE apriltag_jar.cmake DESTINATION share/apriltag)
get_property(APRILTAG_JAR_FILE TARGET apriltag_jar PROPERTY JAR_FILE)
install(FILES ${APRILTAG_JAR_FILE} DESTINATION "${java_lib_dest}")
add_library(apriltagjni ${apriltag_jni_src} ${apriltaglib_src})
wpilib_target_warnings(apriltagjni)
target_link_libraries(apriltagjni PUBLIC apriltag)
set_property(TARGET apriltag_jar PROPERTY FOLDER "java")
set_property(TARGET apriltagjni PROPERTY FOLDER "libraries")
add_library(apriltagjni ${apriltag_jni_src})
wpilib_target_warnings(apriltagjni)
target_link_libraries(apriltagjni PUBLIC apriltag)
set_property(TARGET apriltagjni PROPERTY FOLDER "libraries")
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
add_dependencies(apriltagjni apriltag_jar)
if (MSVC)
install(TARGETS apriltagjni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
install(TARGETS apriltagjni EXPORT apriltagjni DESTINATION "${main_lib_dest}")
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
add_dependencies(apriltagjni apriltag_jar)
install(TARGETS apriltagjni EXPORT apriltagjni)
export(TARGETS apriltagjni FILE apriltagjni.cmake NAMESPACE apriltagjni::)
endif()
GENERATE_RESOURCES(src/main/native/resources/edu/wpi/first/apriltag generated/main/cpp APRILTAG frc apriltag_resources_src)
if(WITH_JAVA_SOURCE)
include(UseJava)
include(CreateSourceJar)
add_source_jar(
apriltag_src_jar
BASE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/src/main/java
OUTPUT_NAME apriltag-sources
OUTPUT_DIR ${WPILIB_BINARY_DIR}/${java_lib_dest}
)
set_property(TARGET apriltag_src_jar PROPERTY FOLDER "java")
install_jar(apriltag_src_jar DESTINATION ${java_lib_dest})
endif()
generate_resources(
src/main/native/resources/edu/wpi/first/apriltag
generated/main/cpp
APRILTAG
frc
apriltag_resources_src
)
file(GLOB apriltag_native_src src/main/native/cpp/*.cpp)
add_library(apriltag ${apriltag_native_src} ${apriltag_resources_src} ${APRILTAGLIB_SRCS} ${APRILTAGLIB_COMMON_SRC} ${TAG_FILES})
add_library(apriltag ${apriltag_native_src} ${apriltag_resources_src} ${apriltaglib_src})
set_target_properties(apriltag PROPERTIES DEBUG_POSTFIX "d")
set_property(TARGET apriltag PROPERTY FOLDER "libraries")
target_compile_features(apriltag PUBLIC cxx_std_20)
wpilib_target_warnings(apriltag)
# disable warnings that apriltaglib can't handle
if (MSVC)
target_compile_options(apriltag PRIVATE /wd4018)
else()
target_compile_options(apriltag PRIVATE -Wno-sign-compare -Wno-gnu-zero-variadic-macro-arguments)
endif()
target_link_libraries(apriltag wpimath)
target_include_directories(apriltag PUBLIC
$<BUILD_INTERFACE:${apriltaglib_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/apriltag>)
target_include_directories(
apriltag
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/apriltag>
)
install(TARGETS apriltag EXPORT apriltag DESTINATION "${main_lib_dest}")
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/apriltag")
install(
DIRECTORY src/main/native/include/ src/main/native/thirdparty/apriltag/include/
DESTINATION "${include_dest}/apriltag"
)
target_include_directories(
apriltag
SYSTEM
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/apriltag/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/thirdparty/apriltag/include/common>
)
if (WITH_JAVA AND MSVC)
install(TARGETS apriltag RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
install(TARGETS apriltag EXPORT apriltag)
export(TARGETS apriltag FILE apriltag.cmake NAMESPACE apriltag::)
if (WITH_FLAT_INSTALL)
set (apriltag_config_dir ${wpilib_dest})
else()
set (apriltag_config_dir share/apriltag)
endif()
configure_file(apriltag-config.cmake.in ${WPILIB_BINARY_DIR}/apriltag-config.cmake)
install(FILES ${WPILIB_BINARY_DIR}/apriltag-config.cmake DESTINATION share/apriltag)
install(EXPORT apriltag DESTINATION share/apriltag)
configure_file(apriltag-config.cmake.in ${WPILIB_BINARY_DIR}/apriltag-config.cmake )
install(FILES ${WPILIB_BINARY_DIR}/apriltag-config.cmake DESTINATION ${apriltag_config_dir})
install(EXPORT apriltag DESTINATION ${apriltag_config_dir})
if (WITH_TESTS)
if(WITH_TESTS)
wpilib_add_test(apriltag src/test/native/cpp)
target_include_directories(apriltag_test PRIVATE src/test/native/include)
target_link_libraries(apriltag_test apriltag gmock_main)
target_link_libraries(apriltag_test apriltag googletest)
endif()

28
apriltag/README.md Normal file
View File

@@ -0,0 +1,28 @@
# AprilTag
## Adding new field to AprilTagFields
### Adding field JSON
1. Add a field layout CSV file to `src/main/native/resources/edu/wpi/first/apriltag`
1. See docstring in `convert_apriltag_layouts.py` for more
2. Run `convert_apriltag_layouts.py` in the same directory as this readme to generate the JSON
3. That script overwrites all generated JSONs, so undo undesired changes if necessary
4. Update the field dimensions at the bottom of the JSON
1. Length should be in meters from alliance wall to alliance wall
2. Width should be in meters from inside guardrail plastic to plastic
### Java updates
1. Update `src/main/java/edu/wpi/first/apriltag/AprilTagFields.java`
1. Add enum value for new field to `AprilTagFields`
2. Update `AprilTagFields.kDefaultField` if necessary
### C++ updates
1. Update `src/main/native/include/frc/apriltag/AprilTagFields.h`
1. Add enum value for new field to `AprilTagFields`
2. Update `AprilTagFields::kDefaultField` if necessary
2. Update `src/main/native/cpp/AprilTagFields.cpp`
1. Add resource getter prototype like `std::string_view GetResource_2024_crescendo_json()`
2. Add case for new field to switch in `LoadAprilTagLayoutField()`

View File

@@ -5,3 +5,6 @@ include(CMakeFindDependencyMacro)
@FILENAME_DEP_REPLACE@
include(${SELF_DIR}/apriltag.cmake)
if(@WITH_JAVA@)
include(${SELF_DIR}/apriltag_jar.cmake)
endif()

View File

@@ -1,5 +1,7 @@
apply from: "${rootDir}/shared/resources.gradle"
apply plugin: 'c'
ext {
nativeName = 'apriltag'
devMain = 'edu.wpi.first.apriltag.DevMain'
@@ -23,6 +25,16 @@ ext {
include '*.cpp'
}
}
apriltagC(CSourceSet) {
source {
srcDirs 'src/main/native/thirdparty/apriltag/src'
include '**/*.c', '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/thirdparty/apriltag/include',
'src/main/native/thirdparty/apriltag/include/common'
}
}
}
}
}
@@ -30,12 +42,10 @@ ext {
evaluationDependsOn(':wpimath')
apply from: "${rootDir}/shared/jni/setupBuild.gradle"
apply from: "${rootDir}/shared/apriltaglib.gradle"
apply from: "${rootDir}/shared/opencv.gradle"
dependencies {
implementation project(':wpimath')
devImplementation project(':wpimath')
}
sourceSets {
@@ -46,8 +56,47 @@ sourceSets {
}
}
cppHeadersZip {
from('src/main/native/thirdparty/apriltag/include') {
into '/'
}
}
// Suppress sign-compare warnings
nativeUtils.platformConfigs.each {
if (it.name.contains('windows')) {
it.cCompiler.args.add("/wd4005")
it.cCompiler.args.add("/wd4018")
it.cCompiler.args.add("/wd4244")
it.cCompiler.args.add("/wd4267")
it.cCompiler.args.add("/wd4996")
} else if (it.name.contains('osx')) {
it.cCompiler.args.add("-Wno-format-nonliteral")
it.cCompiler.args.add("-Wno-gnu-zero-variadic-macro-arguments")
it.cCompiler.args.add("-Wno-uninitialized")
it.cCompiler.args.add("-Wno-sign-compare")
it.cCompiler.args.add("-Wno-type-limits")
} else {
it.cCompiler.args.add("-Wno-format-nonliteral")
it.cCompiler.args.add("-Wno-gnu-zero-variadic-macro-arguments")
it.cCompiler.args.add("-Wno-maybe-uninitialized")
it.cCompiler.args.add("-Wno-sign-compare")
it.cCompiler.args.add("-Wno-type-limits")
}
}
model {
components {}
components {
all {
it.sources.each {
it.exportedHeaders {
srcDirs 'src/main/native/include',
'src/main/native/thirdparty/apriltag/include',
'src/main/native/thirdparty/apriltag/include/common'
}
}
}
}
binaries {
all {
if (!it.buildable || !(it instanceof NativeBinarySpec)) {
@@ -62,8 +111,6 @@ model {
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
}
nativeUtils.useRequiredLibrary(it, 'apriltaglib')
}
}
tasks {

View File

@@ -0,0 +1,90 @@
#!/usr/bin/env python3
"""
This script converts all AprilTag field layout CSV files in
src/main/native/resources/edu/wpi/first/apriltag to the JSON format
AprilTagFields expects.
The input CSV has the following format:
* Columns: ID, X, Y, Z, Z Rotation, Y Rotation
* ID is a positive integer
* X, Y, and Z are decimal inches
* Z Rotation is yaw in degrees
* Y Rotation is pitch in degrees
The values come from a table in the layout marking diagram (e.g.,
https://firstfrc.blob.core.windows.net/frc2024/FieldAssets/2024LayoutMarkingDiagram.pdf).
"""
import csv
import json
import os
from wpimath import geometry, units
def main():
# Find AprilTag field layout CSVs
filenames = [
os.path.join(dp, f)
for dp, dn, fn in os.walk("src/main/native/resources/edu/wpi/first/apriltag")
for f in fn
if f.endswith(".csv")
]
for filename in filenames:
json_data = {"tags": [], "field": {"length": 0.0, "width": 0.0}}
# Read CSV and fill in JSON data
with open(filename, newline="") as csvfile:
reader = csv.reader(csvfile, delimiter=",")
# Skip header
next(reader)
for row in reader:
# Unpack row elements
id = int(row[0])
x = float(row[1])
y = float(row[2])
z = float(row[3])
zRotation = float(row[4])
yRotation = float(row[5])
# Turn yaw into quaternion
q = geometry.Rotation3d(
units.radians(0),
units.degreesToRadians(yRotation),
units.degreesToRadians(zRotation),
).getQuaternion()
json_data["tags"].append(
{
"ID": id,
"pose": {
"translation": {
"x": units.inchesToMeters(x),
"y": units.inchesToMeters(y),
"z": units.inchesToMeters(z),
},
"rotation": {
"quaternion": {
"W": q.W(),
"X": q.X(),
"Y": q.Y(),
"Z": q.Z(),
}
},
},
}
)
# Write JSON
with open(filename.replace(".csv", ".json"), "w") as f:
json.dump(json_data, f, indent=2)
f.write("\n")
if __name__ == "__main__":
main()

View File

@@ -6,17 +6,28 @@ package edu.wpi.first.apriltag;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.wpi.first.apriltag.jni.AprilTagJNI;
import edu.wpi.first.math.geometry.Pose3d;
import edu.wpi.first.util.RawFrame;
import java.util.Objects;
/** Represents an AprilTag's metadata. */
@SuppressWarnings("MemberName")
public class AprilTag {
/** The tag's ID. */
@JsonProperty(value = "ID")
public int ID;
/** The tag's pose. */
@JsonProperty(value = "pose")
public Pose3d pose;
/**
* Constructs an AprilTag.
*
* @param ID The tag's ID.
* @param pose The tag's pose.
*/
@SuppressWarnings("ParameterName")
@JsonCreator
public AprilTag(
@@ -28,11 +39,7 @@ public class AprilTag {
@Override
public boolean equals(Object obj) {
if (obj instanceof AprilTag) {
var other = (AprilTag) obj;
return ID == other.ID && pose.equals(other.pose);
}
return false;
return obj instanceof AprilTag tag && ID == tag.ID && pose.equals(tag.pose);
}
@Override
@@ -44,4 +51,28 @@ public class AprilTag {
public String toString() {
return "AprilTag(ID: " + ID + ", pose: " + pose + ")";
}
/**
* Generates a RawFrame containing the apriltag with the id with family 16h5 passed in.
*
* @param id id
* @return A RawFrame containing the AprilTag image
*/
public static RawFrame generate16h5AprilTagImage(int id) {
RawFrame frame = new RawFrame();
AprilTagJNI.generate16h5AprilTagImage(frame, frame.getNativeObj(), id);
return frame;
}
/**
* Generates a RawFrame containing the apriltag with the id with family 36h11 passed in.
*
* @param id id
* @return A RawFrame containing the AprilTag image
*/
public static RawFrame generate36h11AprilTagImage(int id) {
RawFrame frame = new RawFrame();
AprilTagJNI.generate36h11AprilTagImage(frame, frame.getNativeObj(), id);
return frame;
}
}

View File

@@ -72,7 +72,7 @@ public class AprilTagDetection {
* @return Homography matrix
*/
public Matrix<N3, N3> getHomographyMatrix() {
return new MatBuilder<>(Nat.N3(), Nat.N3()).fill(m_homography);
return MatBuilder.fill(Nat.N3(), Nat.N3(), m_homography);
}
/**
@@ -95,7 +95,7 @@ public class AprilTagDetection {
/**
* Gets a corner of the tag in image pixel coordinates. These always wrap counter-clock wise
* around the tag.
* around the tag. Index 0 is the bottom left corner.
*
* @param ndx Corner index (range is 0-3, inclusive)
* @return Corner point X coordinate
@@ -106,7 +106,7 @@ public class AprilTagDetection {
/**
* Gets a corner of the tag in image pixel coordinates. These always wrap counter-clock wise
* around the tag.
* around the tag. Index 0 is the bottom left corner.
*
* @param ndx Corner index (range is 0-3, inclusive)
* @return Corner point Y coordinate
@@ -117,7 +117,8 @@ public class AprilTagDetection {
/**
* Gets the corners of the tag in image pixel coordinates. These always wrap counter-clock wise
* around the tag.
* around the tag. The first set of corner coordinates are the coordinates for the bottom left
* corner.
*
* @return Corner point array (X and Y for each corner in order)
*/

View File

@@ -57,8 +57,21 @@ public class AprilTagDetector implements AutoCloseable {
*/
public boolean debug;
/** Default constructor. */
public Config() {}
/**
* Constructs a detector configuration.
*
* @param numThreads How many threads should be used for computation.
* @param quadDecimate Quad decimation.
* @param quadSigma What Gaussian blur should be applied to the segmented image (used for quad
* detection).
* @param refineEdges When true, the edges of the each quad are adjusted to "snap to" strong
* gradients nearby.
* @param decodeSharpening How much sharpening should be done to decoded images.
* @param debug Debug mode.
*/
Config(
int numThreads,
float quadDecimate,
@@ -86,12 +99,8 @@ public class AprilTagDetector implements AutoCloseable {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Config)) {
return false;
}
Config other = (Config) obj;
return numThreads == other.numThreads
return obj instanceof Config other
&& numThreads == other.numThreads
&& quadDecimate == other.quadDecimate
&& quadSigma == other.quadSigma
&& refineEdges == other.refineEdges
@@ -103,8 +112,8 @@ public class AprilTagDetector implements AutoCloseable {
/** Quad threshold parameters. */
@SuppressWarnings("MemberName")
public static class QuadThresholdParameters {
/** Threshold used to reject quads containing too few pixels. Default is 5 pixels. */
public int minClusterPixels = 5;
/** Threshold used to reject quads containing too few pixels. Default is 300 pixels. */
public int minClusterPixels = 300;
/**
* How many corner candidates to consider when segmenting a group of pixels into a quad. Default
@@ -115,9 +124,9 @@ public class AprilTagDetector implements AutoCloseable {
/**
* Critical angle, in radians. The detector will reject quads where pairs of edges have angles
* that are close to straight or close to 180 degrees. Zero means that no quads are rejected.
* Default is 10 degrees.
* Default is 45 degrees.
*/
public double criticalAngle = 10 * Math.PI / 180.0;
public double criticalAngle = 45 * Math.PI / 180.0;
/**
* When fitting lines to the contours, the maximum mean squared error allowed. This is useful in
@@ -139,8 +148,21 @@ public class AprilTagDetector implements AutoCloseable {
*/
public boolean deglitch;
/** Default constructor. */
public QuadThresholdParameters() {}
/**
* Constructs quad threshold parameters.
*
* @param minClusterPixels Threshold used to reject quads containing too few pixels.
* @param maxNumMaxima How many corner candidates to consider when segmenting a group of pixels
* into a quad.
* @param criticalAngle Critical angle, in radians.
* @param maxLineFitMSE When fitting lines to the contours, the maximum mean squared error
* allowed.
* @param minWhiteBlackDiff Minimum brightness offset.
* @param deglitch Whether the thresholded image be should be deglitched.
*/
QuadThresholdParameters(
int minClusterPixels,
int maxNumMaxima,
@@ -168,12 +190,8 @@ public class AprilTagDetector implements AutoCloseable {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof QuadThresholdParameters)) {
return false;
}
QuadThresholdParameters other = (QuadThresholdParameters) obj;
return minClusterPixels == other.minClusterPixels
return obj instanceof QuadThresholdParameters other
&& minClusterPixels == other.minClusterPixels
&& maxNumMaxima == other.maxNumMaxima
&& criticalAngle == other.criticalAngle
&& maxLineFitMSE == other.maxLineFitMSE
@@ -182,8 +200,11 @@ public class AprilTagDetector implements AutoCloseable {
}
}
/** Constructs an AprilTagDetector. */
@SuppressWarnings("this-escape")
public AprilTagDetector() {
m_native = AprilTagJNI.createDetector();
setQuadThresholdParameters(new QuadThresholdParameters());
}
@Override
@@ -244,7 +265,7 @@ public class AprilTagDetector implements AutoCloseable {
* Adds a family of tags to be detected.
*
* @param fam Family name, e.g. "tag16h5"
* @param bitsCorrected maximum number of bits to correct
* @param bitsCorrected Maximum number of bits to correct
* @throws IllegalArgumentException if family name not recognized
*/
public void addFamily(String fam, int bitsCorrected) {
@@ -270,11 +291,13 @@ public class AprilTagDetector implements AutoCloseable {
/**
* Detect tags from an 8-bit image.
*
* <p>The image must be grayscale.
*
* @param img 8-bit OpenCV Mat image
* @return Results (array of AprilTagDetection)
*/
public AprilTagDetection[] detect(Mat img) {
return AprilTagJNI.detect(m_native, img.cols(), img.rows(), img.cols(), img.dataAddr());
return AprilTagJNI.detect(m_native, img.cols(), img.rows(), (int) img.step1(), img.dataAddr());
}
private long m_native;

View File

@@ -16,6 +16,8 @@ import edu.wpi.first.math.geometry.Translation3d;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
@@ -44,8 +46,11 @@ import java.util.Optional;
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonAutoDetect(getterVisibility = JsonAutoDetect.Visibility.NONE)
public class AprilTagFieldLayout {
/** Common origin positions for the AprilTag coordinate system. */
public enum OriginPosition {
/** Blue alliance wall, right side. */
kBlueAllianceWallRightSide,
/** Red alliance wall, right side. */
kRedAllianceWallRightSide,
}
@@ -113,6 +118,26 @@ public class AprilTagFieldLayout {
return new ArrayList<>(m_apriltags.values());
}
/**
* Returns the length of the field the layout is representing in meters.
*
* @return length, in meters
*/
@JsonIgnore
public double getFieldLength() {
return m_fieldDimensions.fieldLength;
}
/**
* Returns the length of the field the layout is representing in meters.
*
* @return width, in meters
*/
@JsonIgnore
public double getFieldWidth() {
return m_fieldDimensions.fieldWidth;
}
/**
* Sets the origin based on a predefined enumeration of coordinate frame origins. The origins are
* calculated from the field dimensions.
@@ -123,20 +148,15 @@ public class AprilTagFieldLayout {
* @param origin The predefined origin
*/
@JsonIgnore
public void setOrigin(OriginPosition origin) {
switch (origin) {
case kBlueAllianceWallRightSide:
setOrigin(new Pose3d());
break;
case kRedAllianceWallRightSide:
setOrigin(
new Pose3d(
new Translation3d(m_fieldDimensions.fieldLength, m_fieldDimensions.fieldWidth, 0),
new Rotation3d(0, 0, Math.PI)));
break;
default:
throw new IllegalArgumentException("Unsupported enum value");
}
public final void setOrigin(OriginPosition origin) {
var pose =
switch (origin) {
case kBlueAllianceWallRightSide -> Pose3d.kZero;
case kRedAllianceWallRightSide -> new Pose3d(
new Translation3d(m_fieldDimensions.fieldLength, m_fieldDimensions.fieldWidth, 0),
new Rotation3d(0, 0, Math.PI));
};
setOrigin(pose);
}
/**
@@ -148,10 +168,20 @@ public class AprilTagFieldLayout {
* @param origin The new origin for tag transformations
*/
@JsonIgnore
public void setOrigin(Pose3d origin) {
public final void setOrigin(Pose3d origin) {
m_origin = origin;
}
/**
* Returns the origin used for tag pose transformation.
*
* @return the origin
*/
@JsonIgnore
public Pose3d getOrigin() {
return m_origin;
}
/**
* Gets an AprilTag pose by its ID.
*
@@ -188,6 +218,29 @@ public class AprilTagFieldLayout {
new ObjectMapper().writeValue(path.toFile(), this);
}
/**
* Get an official {@link AprilTagFieldLayout}.
*
* @param field The loadable AprilTag field layout.
* @return AprilTagFieldLayout of the field.
* @throws UncheckedIOException If the layout does not exist.
*/
public static AprilTagFieldLayout loadField(AprilTagFields field) {
if (field.m_fieldLayout == null) {
try {
field.m_fieldLayout = loadFromResource(field.m_resourceFile);
} catch (IOException e) {
throw new UncheckedIOException(
"Could not load AprilTagFieldLayout from " + field.m_resourceFile, e);
}
}
// Copy layout because the layout's origin is mutable
return new AprilTagFieldLayout(
field.m_fieldLayout.getTags(),
field.m_fieldLayout.getFieldLength(),
field.m_fieldLayout.getFieldWidth());
}
/**
* Deserializes a field layout from a resource within a internal jar file.
*
@@ -199,19 +252,24 @@ public class AprilTagFieldLayout {
* @throws IOException If the resource could not be loaded
*/
public static AprilTagFieldLayout loadFromResource(String resourcePath) throws IOException {
try (InputStream stream = AprilTagFieldLayout.class.getResourceAsStream(resourcePath);
InputStreamReader reader = new InputStreamReader(stream)) {
InputStream stream = AprilTagFieldLayout.class.getResourceAsStream(resourcePath);
if (stream == null) {
// Class.getResourceAsStream() returns null if the resource does not exist.
throw new IOException("Could not locate resource: " + resourcePath);
}
InputStreamReader reader = new InputStreamReader(stream, StandardCharsets.UTF_8);
try {
return new ObjectMapper().readerFor(AprilTagFieldLayout.class).readValue(reader);
} catch (IOException e) {
throw new IOException("Failed to load AprilTagFieldLayout: " + resourcePath);
}
}
@Override
public boolean equals(Object obj) {
if (obj instanceof AprilTagFieldLayout) {
var other = (AprilTagFieldLayout) obj;
return m_apriltags.equals(other.m_apriltags) && m_origin.equals(other.m_origin);
}
return false;
return obj instanceof AprilTagFieldLayout layout
&& m_apriltags.equals(layout.m_apriltags)
&& m_origin.equals(layout.m_origin);
}
@Override
@@ -224,11 +282,11 @@ public class AprilTagFieldLayout {
private static class FieldDimensions {
@SuppressWarnings("MemberName")
@JsonProperty(value = "length")
public double fieldLength;
public final double fieldLength;
@SuppressWarnings("MemberName")
@JsonProperty(value = "width")
public double fieldWidth;
public final double fieldWidth;
@JsonCreator()
FieldDimensions(

View File

@@ -4,19 +4,32 @@
package edu.wpi.first.apriltag;
import java.io.IOException;
import java.io.UncheckedIOException;
/** Loadable AprilTag field layouts. */
public enum AprilTagFields {
/** 2022 Rapid React. */
k2022RapidReact("2022-rapidreact.json"),
k2023ChargedUp("2023-chargedup.json");
/** 2023 Charged Up. */
k2023ChargedUp("2023-chargedup.json"),
/** 2024 Crescendo. */
k2024Crescendo("2024-crescendo.json"),
/** 2025 Reefscape Welded (see TU 12). */
k2025ReefscapeWelded("2025-reefscape-welded.json"),
/** 2025 Reefscape AndyMark (see TU 12). */
k2025ReefscapeAndyMark("2025-reefscape-andymark.json");
/** Base resource directory. */
public static final String kBaseResourceDir = "/edu/wpi/first/apriltag/";
/** Alias to the current game. */
public static final AprilTagFields kDefaultField = k2023ChargedUp;
public static final AprilTagFields kDefaultField = k2025ReefscapeWelded;
/** Resource filename. */
public final String m_resourceFile;
AprilTagFieldLayout m_fieldLayout;
AprilTagFields(String resourceFile) {
m_resourceFile = kBaseResourceDir + resourceFile;
}
@@ -25,9 +38,11 @@ public enum AprilTagFields {
* Get a {@link AprilTagFieldLayout} from the resource JSON.
*
* @return AprilTagFieldLayout of the field
* @throws IOException If the layout does not exist
* @throws UncheckedIOException If the layout does not exist
* @deprecated Use {@link AprilTagFieldLayout#loadField(AprilTagFields)} instead.
*/
public AprilTagFieldLayout loadAprilTagLayoutField() throws IOException {
return AprilTagFieldLayout.loadFromResource(m_resourceFile);
@Deprecated(forRemoval = true, since = "2025")
public AprilTagFieldLayout loadAprilTagLayoutField() {
return AprilTagFieldLayout.loadField(this);
}
}

View File

@@ -29,10 +29,19 @@ public class AprilTagPoseEstimator {
this.cy = cy;
}
/** Tag size, in meters. */
public double tagSize;
/** Camera horizontal focal length, in pixels. */
public double fx;
/** Camera vertical focal length, in pixels. */
public double fy;
/** Camera horizontal focal center, in pixels. */
public double cx;
/** Camera vertical focal center, in pixels. */
public double cy;
@Override
@@ -46,12 +55,8 @@ public class AprilTagPoseEstimator {
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Config)) {
return false;
}
Config other = (Config) obj;
return tagSize == other.tagSize
return obj instanceof Config other
&& tagSize == other.tagSize
&& fx == other.fx
&& fy == other.fy
&& cx == other.cx

View File

@@ -8,34 +8,45 @@ import edu.wpi.first.apriltag.AprilTagDetection;
import edu.wpi.first.apriltag.AprilTagDetector;
import edu.wpi.first.apriltag.AprilTagPoseEstimate;
import edu.wpi.first.math.geometry.Transform3d;
import edu.wpi.first.util.RawFrame;
import edu.wpi.first.util.RuntimeLoader;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicBoolean;
/** AprilTag JNI. */
public class AprilTagJNI {
static boolean libraryLoaded = false;
static RuntimeLoader<AprilTagJNI> loader = null;
/** Sets whether JNI should be loaded in the static block. */
public static class Helper {
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
/**
* Returns true if the JNI should be loaded in the static block.
*
* @return True if the JNI should be loaded in the static block.
*/
public static boolean getExtractOnStaticLoad() {
return extractOnStaticLoad.get();
}
/**
* Sets whether the JNI should be loaded in the static block.
*
* @param load Whether the JNI should be loaded in the static block.
*/
public static void setExtractOnStaticLoad(boolean load) {
extractOnStaticLoad.set(load);
}
/** Utility class. */
private Helper() {}
}
static {
if (Helper.getExtractOnStaticLoad()) {
try {
loader =
new RuntimeLoader<>(
"apriltagjni", RuntimeLoader.getDefaultExtractionRoot(), AprilTagJNI.class);
loader.loadLibrary();
RuntimeLoader.loadLibrary("apriltagjni");
} catch (IOException ex) {
ex.printStackTrace();
System.exit(1);
@@ -44,31 +55,119 @@ public class AprilTagJNI {
}
}
/**
* Constructs an AprilTag detector engine.
*
* @return The detector engine handle
*/
public static native long createDetector();
/**
* Destroys an AprilTag detector engine.
*
* @param det The detector engine handle
*/
public static native void destroyDetector(long det);
/**
* Sets the detector engine configuration.
*
* @param det The detector engine handle
* @param config A configuration
*/
public static native void setDetectorConfig(long det, AprilTagDetector.Config config);
/**
* Gets the detector engine configuration.
*
* @param det The detector engine handle
* @return The configuration
*/
public static native AprilTagDetector.Config getDetectorConfig(long det);
/**
* Sets the detector engine quad threshold parameters.
*
* @param det The detector engine handle
* @param params Quad threshold parameters
*/
public static native void setDetectorQTP(
long det, AprilTagDetector.QuadThresholdParameters params);
/**
* Gets the detector engine quad threshold parameters.
*
* @param det The detector engine handle
* @return Quad threshold parameters
*/
public static native AprilTagDetector.QuadThresholdParameters getDetectorQTP(long det);
/**
* Adds a family of tags to be detected by the detector engine.
*
* @param det The detector engine handle
* @param fam Family name, e.g. "tag16h5"
* @param bitsCorrected Maximum number of bits to correct
* @return False if family can't be found
*/
public static native boolean addFamily(long det, String fam, int bitsCorrected);
/**
* Removes a family of tags from the detector.
*
* @param det The detector engine handle
* @param fam Family name, e.g. "tag16h5"
*/
public static native void removeFamily(long det, String fam);
/**
* Unregister all families.
*
* @param det The detector engine handle
*/
public static native void clearFamilies(long det);
/**
* Detect tags from an 8-bit image.
*
* @param det The detector engine handle
* @param width The width of the image
* @param height The height of the image
* @param stride The number of bytes between image rows (often the same as width)
* @param bufAddr The address of the image buffer
* @return The results (array of AprilTagDetection)
*/
public static native AprilTagDetection[] detect(
long det, int width, int height, int stride, long bufAddr);
/**
* Estimates the pose of the tag using the homography method described in [1].
*
* @param homography Homography 3x3 matrix data
* @param tagSize The tag size, in meters
* @param fx The camera horizontal focal length, in pixels
* @param fy The camera vertical focal length, in pixels
* @param cx The camera horizontal focal center, in pixels
* @param cy The camera vertical focal center, in pixels
* @return Pose estimate
*/
public static native Transform3d estimatePoseHomography(
double[] homography, double tagSize, double fx, double fy, double cx, double cy);
/**
* Estimates the pose of the tag. This returns one or two possible poses for the tag, along with
* the object-space error of each.
*
* @param homography Homography 3x3 matrix data
* @param corners Corner point array (X and Y for each corner in order)
* @param tagSize The tag size, in meters
* @param fx The camera horizontal focal length, in pixels
* @param fy The camera vertical focal length, in pixels
* @param cx The camera horizontal focal center, in pixels
* @param cy The camera vertical focal center, in pixels
* @param nIters Number of iterations
* @return Initial and (possibly) second pose estimates
*/
public static native AprilTagPoseEstimate estimatePoseOrthogonalIteration(
double[] homography,
double[] corners,
@@ -79,6 +178,20 @@ public class AprilTagJNI {
double cy,
int nIters);
/**
* Estimates tag pose. This method is an easier to use interface to
* EstimatePoseOrthogonalIteration(), running 50 iterations and returning the pose with the lower
* object-space error.
*
* @param homography Homography 3x3 matrix data
* @param corners Corner point array (X and Y for each corner in order)
* @param tagSize The tag size, in meters
* @param fx The camera horizontal focal length, in pixels
* @param fy The camera vertical focal length, in pixels
* @param cx The camera horizontal focal center, in pixels
* @param cy The camera vertical focal center, in pixels
* @return Pose estimate
*/
public static native Transform3d estimatePose(
double[] homography,
double[] corners,
@@ -87,4 +200,25 @@ public class AprilTagJNI {
double fy,
double cx,
double cy);
/**
* Generates a RawFrame containing the apriltag with the id with family 16h5 passed in.
*
* @param frameObj generated frame (output parameter).
* @param frame raw frame handle
* @param id id
*/
public static native void generate16h5AprilTagImage(RawFrame frameObj, long frame, int id);
/**
* Generates a RawFrame containing the apriltag with the id with family 36h11 passed in.
*
* @param frameObj generated frame (output parameter).
* @param frame raw frame handle
* @param id id
*/
public static native void generate36h11AprilTagImage(RawFrame frameObj, long frame, int id);
/** Utility class. */
private AprilTagJNI() {}
}

View File

@@ -4,10 +4,53 @@
#include "frc/apriltag/AprilTag.h"
#include <cstring>
#include <wpi/json.h>
#ifdef _WIN32
#pragma warning(disable : 4200)
#elif defined(__clang__)
#pragma clang diagnostic ignored "-Wc99-extensions"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wpedantic"
#endif
#include "apriltag.h"
#include "tag16h5.h"
#include "tag36h11.h"
using namespace frc;
static bool FamilyToImage(wpi::RawFrame* frame, apriltag_family_t* family,
int id) {
image_u8_t* image = apriltag_to_image(family, id);
size_t totalDataSize = image->height * image->stride;
bool rv = frame->Reserve(totalDataSize);
std::memcpy(frame->data, image->buf, totalDataSize);
frame->size = totalDataSize;
frame->width = image->width;
frame->height = image->height;
frame->stride = image->stride;
frame->pixelFormat = WPI_PIXFMT_GRAY;
image_u8_destroy(image);
return rv;
}
bool AprilTag::Generate36h11AprilTagImage(wpi::RawFrame* frame, int id) {
apriltag_family_t* tagFamily = tag36h11_create();
bool rv = FamilyToImage(frame, tagFamily, id);
tag36h11_destroy(tagFamily);
return rv;
}
bool AprilTag::Generate16h5AprilTagImage(wpi::RawFrame* frame, int id) {
apriltag_family_t* tagFamily = tag16h5_create();
bool rv = FamilyToImage(frame, tagFamily, id);
tag16h5_destroy(tagFamily);
return rv;
}
void frc::to_json(wpi::json& json, const AprilTag& apriltag) {
json = wpi::json{{"ID", apriltag.ID}, {"pose", apriltag.pose}};
}

View File

@@ -5,7 +5,7 @@
#include "frc/apriltag/AprilTagDetector.h"
#include <cmath>
#include <numbers>
#include <utility>
#ifdef _WIN32
#pragma warning(disable : 4200)
@@ -17,13 +17,7 @@
#include "apriltag.h"
#include "tag16h5.h"
#include "tag25h9.h"
#include "tag36h11.h"
#include "tagCircle21h7.h"
#include "tagCircle49h12.h"
#include "tagCustom48h12.h"
#include "tagStandard41h12.h"
#include "tagStandard52h13.h"
using namespace frc;
@@ -46,7 +40,9 @@ void AprilTagDetector::Results::Destroy() {
}
}
AprilTagDetector::AprilTagDetector() : m_impl{apriltag_detector_create()} {}
AprilTagDetector::AprilTagDetector() : m_impl{apriltag_detector_create()} {
SetQuadThresholdParameters({});
}
AprilTagDetector& AprilTagDetector::operator=(AprilTagDetector&& rhs) {
Destroy();
@@ -115,20 +111,8 @@ bool AprilTagDetector::AddFamily(std::string_view fam, int bitsCorrected) {
// create the family
if (fam == "tag16h5") {
data = tag16h5_create();
} else if (fam == "tag25h9") {
data = tag25h9_create();
} else if (fam == "tag36h11") {
data = tag36h11_create();
} else if (fam == "tagCircle21h7") {
data = tagCircle21h7_create();
} else if (fam == "tagCircle49h12") {
data = tagCircle49h12_create();
} else if (fam == "tagStandard41h12") {
data = tagStandard41h12_create();
} else if (fam == "tagStandard52h13") {
data = tagStandard52h13_create();
} else if (fam == "tagCustom48h12") {
data = tagCustom48h12_create();
}
if (!data) {
m_families.erase(fam); // don't keep null value
@@ -146,7 +130,7 @@ void AprilTagDetector::RemoveFamily(std::string_view fam) {
apriltag_detector_remove_family(
static_cast<apriltag_detector_t*>(m_impl),
static_cast<apriltag_family_t*>(it->second));
DestroyFamily(it->getKey(), it->second);
DestroyFamily(it->first, it->second);
m_families.erase(it);
}
}
@@ -174,7 +158,7 @@ void AprilTagDetector::Destroy() {
void AprilTagDetector::DestroyFamilies() {
for (auto&& entry : m_families) {
DestroyFamily(entry.getKey(), entry.second);
DestroyFamily(entry.first, entry.second);
}
}
@@ -182,19 +166,7 @@ void AprilTagDetector::DestroyFamily(std::string_view name, void* data) {
auto fam = static_cast<apriltag_family_t*>(data);
if (name == "tag16h5") {
tag16h5_destroy(fam);
} else if (name == "tag25h9") {
tag25h9_destroy(fam);
} else if (name == "tag36h11") {
tag36h11_destroy(fam);
} else if (name == "tagCircle21h7") {
tagCircle21h7_destroy(fam);
} else if (name == "tagCircle49h12") {
tagCircle49h12_destroy(fam);
} else if (name == "tagStandard41h12") {
tagStandard41h12_destroy(fam);
} else if (name == "tagStandard52h13") {
tagStandard52h13_destroy(fam);
} else if (name == "tagCustom48h12") {
tagCustom48h12_destroy(fam);
}
}

View File

@@ -5,25 +5,24 @@
#include "frc/apriltag/AprilTagFieldLayout.h"
#include <system_error>
#include <utility>
#include <vector>
#include <units/angle.h>
#include <units/length.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/json.h>
#include <wpi/raw_istream.h>
#include <wpi/raw_ostream.h>
using namespace frc;
AprilTagFieldLayout::AprilTagFieldLayout(std::string_view path) {
std::error_code error_code;
wpi::raw_fd_istream input{path, error_code};
if (error_code) {
auto fileBuffer = wpi::MemoryBuffer::GetFile(path);
if (!fileBuffer) {
throw std::runtime_error(fmt::format("Cannot open file: {}", path));
}
wpi::json json;
input >> json;
wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer());
for (const auto& tag : json.at("tags").get<std::vector<AprilTag>>()) {
m_apriltags[tag.ID] = tag;
@@ -42,6 +41,23 @@ AprilTagFieldLayout::AprilTagFieldLayout(std::vector<AprilTag> apriltags,
}
}
units::meter_t AprilTagFieldLayout::GetFieldLength() const {
return m_fieldLength;
}
units::meter_t AprilTagFieldLayout::GetFieldWidth() const {
return m_fieldWidth;
}
std::vector<AprilTag> AprilTagFieldLayout::GetTags() const {
std::vector<AprilTag> tags;
tags.reserve(m_apriltags.size());
for (const auto& tag : m_apriltags) {
tags.emplace_back(tag.second);
}
return tags;
}
void AprilTagFieldLayout::SetOrigin(OriginPosition origin) {
switch (origin) {
case OriginPosition::kBlueAllianceWallRightSide:
@@ -60,6 +76,10 @@ void AprilTagFieldLayout::SetOrigin(const Pose3d& origin) {
m_origin = origin;
}
Pose3d AprilTagFieldLayout::GetOrigin() const {
return m_origin;
}
std::optional<frc::Pose3d> AprilTagFieldLayout::GetTagPose(int ID) const {
const auto& it = m_apriltags.find(ID);
if (it == m_apriltags.end()) {
@@ -105,3 +125,45 @@ void frc::from_json(const wpi::json& json, AprilTagFieldLayout& layout) {
layout.m_fieldWidth =
units::meter_t{json.at("field").at("width").get<double>()};
}
// Use namespace declaration for forward declaration
namespace frc {
// C++ generated from resource files
std::string_view GetResource_2022_rapidreact_json();
std::string_view GetResource_2023_chargedup_json();
std::string_view GetResource_2024_crescendo_json();
std::string_view GetResource_2025_reefscape_welded_json();
std::string_view GetResource_2025_reefscape_andymark_json();
} // namespace frc
AprilTagFieldLayout AprilTagFieldLayout::LoadField(AprilTagField field) {
std::string_view fieldString;
switch (field) {
case AprilTagField::k2022RapidReact:
fieldString = GetResource_2022_rapidreact_json();
break;
case AprilTagField::k2023ChargedUp:
fieldString = GetResource_2023_chargedup_json();
break;
case AprilTagField::k2024Crescendo:
fieldString = GetResource_2024_crescendo_json();
break;
case AprilTagField::k2025ReefscapeWelded:
fieldString = GetResource_2025_reefscape_welded_json();
break;
case AprilTagField::k2025ReefscapeAndyMark:
fieldString = GetResource_2025_reefscape_andymark_json();
break;
case AprilTagField::kNumFields:
throw std::invalid_argument("Invalid Field");
}
wpi::json json = wpi::json::parse(fieldString);
return json.get<AprilTagFieldLayout>();
}
AprilTagFieldLayout frc::LoadAprilTagLayoutField(AprilTagField field) {
return AprilTagFieldLayout::LoadField(field);
}

View File

@@ -1,32 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc/apriltag/AprilTagFields.h"
#include <wpi/json.h>
namespace frc {
// C++ generated from resource files
std::string_view GetResource_2022_rapidreact_json();
std::string_view GetResource_2023_chargedup_json();
AprilTagFieldLayout LoadAprilTagLayoutField(AprilTagField field) {
std::string_view fieldString;
switch (field) {
case AprilTagField::k2022RapidReact:
fieldString = GetResource_2022_rapidreact_json();
break;
case AprilTagField::k2023ChargedUp:
fieldString = GetResource_2023_chargedup_json();
break;
case AprilTagField::kNumFields:
throw std::invalid_argument("Invalid Field");
}
wpi::json json = wpi::json::parse(fieldString);
return json.get<AprilTagFieldLayout>();
}
} // namespace frc

View File

@@ -110,7 +110,7 @@ static AprilTagPoseEstimate DoEstimateOrthogonalIteration(
apriltag_pose_t pose1, pose2;
double err1, err2;
estimate_tag_pose_orthogonal_iteration(&info, &err1, &pose1, &err2, &pose2,
nIters);
nIters, 1e-7);
return {MakePose(pose1), MakePose(pose2), err1, err2};
}

View File

@@ -2,12 +2,17 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <jni.h>
#include <cstdio>
#include <cstring>
#define WPI_RAWFRAME_JNI
#include <wpi/RawFrame.h>
#include <wpi/jni_util.h>
#include "edu_wpi_first_apriltag_jni_AprilTagJNI.h"
#include "frc/apriltag/AprilTag.h"
#include "frc/apriltag/AprilTagDetector.h"
#include "frc/apriltag/AprilTagPoseEstimator.h"
@@ -24,6 +29,7 @@ static JClass quaternionCls;
static JClass rotation3dCls;
static JClass transform3dCls;
static JClass translation3dCls;
static JClass rawFrameCls;
static JException illegalArgEx;
static JException nullPointerEx;
@@ -36,7 +42,8 @@ static const JClassInit classes[] = {
{"edu/wpi/first/math/geometry/Quaternion", &quaternionCls},
{"edu/wpi/first/math/geometry/Rotation3d", &rotation3dCls},
{"edu/wpi/first/math/geometry/Transform3d", &transform3dCls},
{"edu/wpi/first/math/geometry/Translation3d", &translation3dCls}};
{"edu/wpi/first/math/geometry/Translation3d", &translation3dCls},
{"edu/wpi/first/util/RawFrame", &rawFrameCls}};
static const JExceptionInit exceptions[] = {
{"java/lang/IllegalArgumentException", &illegalArgEx},
@@ -504,15 +511,14 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseHomography
nullPointerEx.Throw(env, "homography cannot be null");
return nullptr;
}
JDoubleArrayRef harr{env, homography};
JSpan<const jdouble, 9> harr{env, homography};
if (harr.size() != 9) {
illegalArgEx.Throw(env, "homography array must be size 9");
return nullptr;
}
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
return MakeJObject(env, estimator.EstimateHomography(
std::span<const double, 9>{harr.array()}));
return MakeJObject(env, estimator.EstimateHomography(harr));
}
/*
@@ -530,7 +536,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
nullPointerEx.Throw(env, "homography cannot be null");
return nullptr;
}
JDoubleArrayRef harr{env, homography};
JSpan<const jdouble, 9> harr{env, homography};
if (harr.size() != 9) {
illegalArgEx.Throw(env, "homography array must be size 9");
return nullptr;
@@ -541,7 +547,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
nullPointerEx.Throw(env, "corners cannot be null");
return nullptr;
}
JDoubleArrayRef carr{env, corners};
JSpan<const jdouble, 8> carr{env, corners};
if (carr.size() != 8) {
illegalArgEx.Throw(env, "corners array must be size 8");
return nullptr;
@@ -549,9 +555,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
return MakeJObject(env,
estimator.EstimateOrthogonalIteration(
std::span<const double, 9>{harr.array()},
std::span<const double, 8>{carr.array()}, nIters));
estimator.EstimateOrthogonalIteration(harr, carr, nIters));
}
/*
@@ -569,7 +573,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePose
nullPointerEx.Throw(env, "homography cannot be null");
return nullptr;
}
JDoubleArrayRef harr{env, homography};
JSpan<const jdouble, 9> harr{env, homography};
if (harr.size() != 9) {
illegalArgEx.Throw(env, "homography array must be size 9");
return nullptr;
@@ -580,16 +584,51 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePose
nullPointerEx.Throw(env, "corners cannot be null");
return nullptr;
}
JDoubleArrayRef carr{env, corners};
JSpan<const jdouble, 8> carr{env, corners};
if (carr.size() != 8) {
illegalArgEx.Throw(env, "corners array must be size 8");
return nullptr;
}
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
return MakeJObject(
env, estimator.Estimate(std::span<const double, 9>{harr.array()},
std::span<const double, 8>{carr.array()}));
return MakeJObject(env, estimator.Estimate(harr, carr));
}
/*
* Class: edu_wpi_first_apriltag_jni_AprilTagJNI
* Method: generate16h5AprilTagImage
* Signature: (Ljava/lang/Object;JI)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_apriltag_jni_AprilTagJNI_generate16h5AprilTagImage
(JNIEnv* env, jclass, jobject frameObj, jlong framePtr, jint id)
{
auto* frame = reinterpret_cast<wpi::RawFrame*>(framePtr);
if (!frame) {
nullPointerEx.Throw(env, "frame is null");
return;
}
bool newData = AprilTag::Generate16h5AprilTagImage(frame, id);
wpi::SetFrameData(env, rawFrameCls, frameObj, *frame, newData);
}
/*
* Class: edu_wpi_first_apriltag_jni_AprilTagJNI
* Method: generate36h11AprilTagImage
* Signature: (Ljava/lang/Object;JI)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_apriltag_jni_AprilTagJNI_generate36h11AprilTagImage
(JNIEnv* env, jclass, jobject frameObj, jlong framePtr, jint id)
{
auto* frame = reinterpret_cast<wpi::RawFrame*>(framePtr);
if (!frame) {
nullPointerEx.Throw(env, "frame is null");
return;
}
// function might reallocate
bool newData = AprilTag::Generate36h11AprilTagImage(frame, id);
wpi::SetFrameData(env, rawFrameCls, frameObj, *frame, newData);
}
} // extern "C"

View File

@@ -4,25 +4,28 @@
#pragma once
#include <wpi/RawFrame.h>
#include <wpi/SymbolExports.h>
#include <wpi/json_fwd.h>
#include "frc/geometry/Pose3d.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
/**
* Represents an AprilTag's metadata.
*/
struct WPILIB_DLLEXPORT AprilTag {
/// The tag's ID.
int ID;
/// The tag's pose.
Pose3d pose;
/**
* Checks equality between this AprilTag and another object.
*/
bool operator==(const AprilTag&) const = default;
static bool Generate36h11AprilTagImage(wpi::RawFrame* frame, int id);
static bool Generate16h5AprilTagImage(wpi::RawFrame* frame, int id);
};
WPILIB_DLLEXPORT

View File

@@ -9,10 +9,9 @@
#include <span>
#include <string_view>
#include <Eigen/Core>
#include <wpi/SymbolExports.h>
#include "frc/EigenCore.h"
namespace frc {
/**
@@ -94,7 +93,7 @@ class WPILIB_DLLEXPORT AprilTagDetection final {
/**
* Gets a corner of the tag in image pixel coordinates. These always
* wrap counter-clock wise around the tag.
* wrap counter-clock wise around the tag. Index 0 is the bottom left corner.
*
* @param ndx Corner index (range is 0-3, inclusive)
* @return Corner point
@@ -105,7 +104,8 @@ class WPILIB_DLLEXPORT AprilTagDetection final {
/**
* Gets the corners of the tag in image pixel coordinates. These always
* wrap counter-clock wise around the tag.
* wrap counter-clock wise around the tag. The first set of corner coordinates
* are the coordinates for the bottom left corner.
*
* @param cornersBuf Corner point array (X and Y for each corner in order)
* @return Corner point array (copy of cornersBuf span)

View File

@@ -83,10 +83,10 @@ class WPILIB_DLLEXPORT AprilTagDetector {
bool operator==(const QuadThresholdParameters&) const = default;
/**
* Threshold used to reject quads containing too few pixels. Default is 5
* Threshold used to reject quads containing too few pixels. Default is 300
* pixels.
*/
int minClusterPixels = 5;
int minClusterPixels = 300;
/**
* How many corner candidates to consider when segmenting a group of pixels
@@ -97,9 +97,9 @@ class WPILIB_DLLEXPORT AprilTagDetector {
/**
* Critical angle. The detector will reject quads where pairs of edges have
* angles that are close to straight or close to 180 degrees. Zero means
* that no quads are rejected. Default is 10 degrees.
* that no quads are rejected. Default is 45 degrees.
*/
units::radian_t criticalAngle = 10_deg;
units::radian_t criticalAngle = 45_deg;
/**
* When fitting lines to the contours, the maximum mean squared error
@@ -205,7 +205,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
* Adds a family of tags to be detected.
*
* @param fam Family name, e.g. "tag16h5"
* @param bitsCorrected
* @param bitsCorrected Maximum number of bits to correct
* @return False if family can't be found
*/
bool AddFamily(std::string_view fam, int bitsCorrected = 2);
@@ -226,6 +226,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
/**
* Detect tags from an 8-bit image.
* The image must be grayscale.
*
* @param width width of the image
* @param height height of the image
@@ -237,6 +238,7 @@ class WPILIB_DLLEXPORT AprilTagDetector {
/**
* Detect tags from an 8-bit image.
* The image must be grayscale.
*
* @param width width of the image
* @param height height of the image

View File

@@ -11,14 +11,12 @@
#include <units/length.h>
#include <wpi/SymbolExports.h>
#include <wpi/json_fwd.h>
#include "frc/apriltag/AprilTag.h"
#include "frc/apriltag/AprilTagFields.h"
#include "frc/geometry/Pose3d.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
/**
* Class for representing a layout of AprilTags on a field and reading them from
@@ -41,11 +39,24 @@ namespace frc {
* towards the opposing alliance). */
class WPILIB_DLLEXPORT AprilTagFieldLayout {
public:
/**
* Common origin positions for the AprilTag coordinate system.
*/
enum class OriginPosition {
/// Blue alliance wall, right side.
kBlueAllianceWallRightSide,
/// Red alliance wall, right side.
kRedAllianceWallRightSide,
};
/**
* Loads an AprilTagFieldLayout from a predefined field
*
* @param field The predefined field
* @return AprilTagFieldLayout of the field
*/
static AprilTagFieldLayout LoadField(AprilTagField field);
AprilTagFieldLayout() = default;
/**
@@ -65,6 +76,24 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
AprilTagFieldLayout(std::vector<AprilTag> apriltags,
units::meter_t fieldLength, units::meter_t fieldWidth);
/**
* Returns the length of the field the layout is representing.
* @return length
*/
units::meter_t GetFieldLength() const;
/**
* Returns the length of the field the layout is representing.
* @return width
*/
units::meter_t GetFieldWidth() const;
/**
* Returns a vector of all the april tags used in this layout.
* @return list of tags
*/
std::vector<AprilTag> GetTags() const;
/**
* Sets the origin based on a predefined enumeration of coordinate frame
* origins. The origins are calculated from the field dimensions.
@@ -79,13 +108,19 @@ class WPILIB_DLLEXPORT AprilTagFieldLayout {
/**
* Sets the origin for tag pose transformation.
*
* This tranforms the Pose3ds returned by GetTagPose(int) to return the
* This transforms the Pose3ds returned by GetTagPose(int) to return the
* correct pose relative to the provided origin.
*
* @param origin The new origin for tag transformations
*/
void SetOrigin(const Pose3d& origin);
/**
* Returns the origin used for tag pose transformation.
* @return the origin
*/
Pose3d GetOrigin() const;
/**
* Gets an AprilTag pose by its ID.
*
@@ -126,4 +161,15 @@ void to_json(wpi::json& json, const AprilTagFieldLayout& layout);
WPILIB_DLLEXPORT
void from_json(const wpi::json& json, AprilTagFieldLayout& layout);
/**
* Loads an AprilTagFieldLayout from a predefined field
*
* @param field The predefined field
* @return AprilTagFieldLayout of the field
* @deprecated Use AprilTagFieldLayout::LoadField() instead
*/
[[deprecated("Use AprilTagFieldLayout::LoadField() instead")]]
WPILIB_DLLEXPORT AprilTagFieldLayout
LoadAprilTagLayoutField(AprilTagField field);
} // namespace frc

View File

@@ -8,25 +8,28 @@
#include <wpi/SymbolExports.h>
#include "frc/apriltag/AprilTagFieldLayout.h"
namespace frc {
/**
* Loadable AprilTag field layouts.
*/
enum class AprilTagField {
/// 2022 Rapid React.
k2022RapidReact,
/// 2023 Charged Up.
k2023ChargedUp,
/// 2024 Crescendo.
k2024Crescendo,
/// 2025 Reefscape AndyMark (see TU12).
k2025ReefscapeAndyMark,
/// 2025 Reefscape Welded (see TU12).
k2025ReefscapeWelded,
/// Alias to the current game.
kDefaultField = k2025ReefscapeWelded,
// This is a placeholder for denoting the last supported field. This should
// always be the last entry in the enum and should not be used by users
kNumFields,
};
/**
* Loads an AprilTagFieldLayout from a predefined field
*
* @param field The predefined field
*/
WPILIB_DLLEXPORT AprilTagFieldLayout
LoadAprilTagLayoutField(AprilTagField field);
} // namespace frc

View File

@@ -0,0 +1,296 @@
{
"tags": [
{
"ID": 1,
"pose": {
"translation": {
"x": 15.079471999999997,
"y": 0.24587199999999998,
"z": 1.355852
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 2,
"pose": {
"translation": {
"x": 16.185134,
"y": 0.883666,
"z": 1.355852
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 3,
"pose": {
"translation": {
"x": 16.579342,
"y": 4.982717999999999,
"z": 1.4511020000000001
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 4,
"pose": {
"translation": {
"x": 16.579342,
"y": 5.547867999999999,
"z": 1.4511020000000001
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 5,
"pose": {
"translation": {
"x": 14.700757999999999,
"y": 8.2042,
"z": 1.355852
},
"rotation": {
"quaternion": {
"W": -0.7071067811865475,
"X": -0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 6,
"pose": {
"translation": {
"x": 1.8415,
"y": 8.2042,
"z": 1.355852
},
"rotation": {
"quaternion": {
"W": -0.7071067811865475,
"X": -0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 7,
"pose": {
"translation": {
"x": -0.038099999999999995,
"y": 5.547867999999999,
"z": 1.4511020000000001
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 8,
"pose": {
"translation": {
"x": -0.038099999999999995,
"y": 4.982717999999999,
"z": 1.4511020000000001
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 9,
"pose": {
"translation": {
"x": 0.356108,
"y": 0.883666,
"z": 1.355852
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 10,
"pose": {
"translation": {
"x": 1.4615159999999998,
"y": 0.24587199999999998,
"z": 1.355852
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 11,
"pose": {
"translation": {
"x": 11.904726,
"y": 3.7132259999999997,
"z": 1.3208
},
"rotation": {
"quaternion": {
"W": -0.8660254037844387,
"X": -0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 12,
"pose": {
"translation": {
"x": 11.904726,
"y": 4.49834,
"z": 1.3208
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 13,
"pose": {
"translation": {
"x": 11.220196,
"y": 4.105148,
"z": 1.3208
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 14,
"pose": {
"translation": {
"x": 5.320792,
"y": 4.105148,
"z": 1.3208
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 15,
"pose": {
"translation": {
"x": 4.641342,
"y": 4.49834,
"z": 1.3208
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 16,
"pose": {
"translation": {
"x": 4.641342,
"y": 3.7132259999999997,
"z": 1.3208
},
"rotation": {
"quaternion": {
"W": -0.4999999999999998,
"X": -0.0,
"Y": 0.0,
"Z": 0.8660254037844387
}
}
}
}
],
"field": {
"length": 16.541,
"width": 8.211
}
}

View File

@@ -0,0 +1,23 @@
ID,X,Y,Z,Z-Rotation,X-Rotation
1,656.98,24.73,58.5,126,0
2,656.98,291.9,58.5,234,0
3,452.4,316.21,51.25,270,0
4,365.2,241.44,73.54,0,30
5,365.2,75.19,73.54,0,30
6,530.49,129.97,12.13,300,0
7,546.87,158.3,12.13,0,0
8,530.49,186.63,12.13,60,0
9,497.77,186.63,12.13,120,0
10,481.39,158.3,12.13,180,0
11,497.77,129.97,12.13,240,0
12,33.91,24.73,58.5,54,0
13,33.91,291.9,58.5,306,0
14,325.68,241.44,73.54,180,30
15,325.68,75.19,73.54,180,30
16,238.49,0.42,51.25,90,0
17,160.39,129.97,12.13,240,0
18,144,158.3,12.13,180,0
19,160.39,186.63,12.13,120,0
20,193.1,186.63,12.13,60,0
21,209.49,158.3,12.13,0,0
22,193.1,129.97,12.13,300,0
1 ID X Y Z Z-Rotation X-Rotation
2 1 656.98 24.73 58.5 126 0
3 2 656.98 291.9 58.5 234 0
4 3 452.4 316.21 51.25 270 0
5 4 365.2 241.44 73.54 0 30
6 5 365.2 75.19 73.54 0 30
7 6 530.49 129.97 12.13 300 0
8 7 546.87 158.3 12.13 0 0
9 8 530.49 186.63 12.13 60 0
10 9 497.77 186.63 12.13 120 0
11 10 481.39 158.3 12.13 180 0
12 11 497.77 129.97 12.13 240 0
13 12 33.91 24.73 58.5 54 0
14 13 33.91 291.9 58.5 306 0
15 14 325.68 241.44 73.54 180 30
16 15 325.68 75.19 73.54 180 30
17 16 238.49 0.42 51.25 90 0
18 17 160.39 129.97 12.13 240 0
19 18 144 158.3 12.13 180 0
20 19 160.39 186.63 12.13 120 0
21 20 193.1 186.63 12.13 60 0
22 21 209.49 158.3 12.13 0 0
23 22 193.1 129.97 12.13 300 0

View File

@@ -0,0 +1,404 @@
{
"tags": [
{
"ID": 1,
"pose": {
"translation": {
"x": 16.687292,
"y": 0.628142,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": 0.4539904997395468,
"X": 0.0,
"Y": 0.0,
"Z": 0.8910065241883678
}
}
}
},
{
"ID": 2,
"pose": {
"translation": {
"x": 16.687292,
"y": 7.414259999999999,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": -0.45399049973954675,
"X": -0.0,
"Y": 0.0,
"Z": 0.8910065241883679
}
}
}
},
{
"ID": 3,
"pose": {
"translation": {
"x": 11.49096,
"y": 8.031733999999998,
"z": 1.30175
},
"rotation": {
"quaternion": {
"W": -0.7071067811865475,
"X": -0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 4,
"pose": {
"translation": {
"x": 9.276079999999999,
"y": 6.132575999999999,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 0.9659258262890683,
"X": 0.0,
"Y": 0.25881904510252074,
"Z": 0.0
}
}
}
},
{
"ID": 5,
"pose": {
"translation": {
"x": 9.276079999999999,
"y": 1.9098259999999998,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 0.9659258262890683,
"X": 0.0,
"Y": 0.25881904510252074,
"Z": 0.0
}
}
}
},
{
"ID": 6,
"pose": {
"translation": {
"x": 13.474446,
"y": 3.3012379999999997,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.8660254037844387,
"X": -0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 7,
"pose": {
"translation": {
"x": 13.890498,
"y": 4.0208200000000005,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 8,
"pose": {
"translation": {
"x": 13.474446,
"y": 4.740402,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 9,
"pose": {
"translation": {
"x": 12.643358,
"y": 4.740402,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 10,
"pose": {
"translation": {
"x": 12.227305999999999,
"y": 4.0208200000000005,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 11,
"pose": {
"translation": {
"x": 12.643358,
"y": 3.3012379999999997,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.4999999999999998,
"X": -0.0,
"Y": 0.0,
"Z": 0.8660254037844387
}
}
}
},
{
"ID": 12,
"pose": {
"translation": {
"x": 0.8613139999999999,
"y": 0.628142,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": 0.8910065241883679,
"X": 0.0,
"Y": 0.0,
"Z": 0.45399049973954675
}
}
}
},
{
"ID": 13,
"pose": {
"translation": {
"x": 0.8613139999999999,
"y": 7.414259999999999,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": -0.8910065241883678,
"X": -0.0,
"Y": 0.0,
"Z": 0.45399049973954686
}
}
}
},
{
"ID": 14,
"pose": {
"translation": {
"x": 8.272272,
"y": 6.132575999999999,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 5.914589856893349e-17,
"X": -0.25881904510252074,
"Y": 1.5848095757158825e-17,
"Z": 0.9659258262890683
}
}
}
},
{
"ID": 15,
"pose": {
"translation": {
"x": 8.272272,
"y": 1.9098259999999998,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 5.914589856893349e-17,
"X": -0.25881904510252074,
"Y": 1.5848095757158825e-17,
"Z": 0.9659258262890683
}
}
}
},
{
"ID": 16,
"pose": {
"translation": {
"x": 6.057646,
"y": 0.010667999999999999,
"z": 1.30175
},
"rotation": {
"quaternion": {
"W": 0.7071067811865476,
"X": 0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 17,
"pose": {
"translation": {
"x": 4.073905999999999,
"y": 3.3012379999999997,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.4999999999999998,
"X": -0.0,
"Y": 0.0,
"Z": 0.8660254037844387
}
}
}
},
{
"ID": 18,
"pose": {
"translation": {
"x": 3.6576,
"y": 4.0208200000000005,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 19,
"pose": {
"translation": {
"x": 4.073905999999999,
"y": 4.740402,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 20,
"pose": {
"translation": {
"x": 4.904739999999999,
"y": 4.740402,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 21,
"pose": {
"translation": {
"x": 5.321046,
"y": 4.0208200000000005,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 22,
"pose": {
"translation": {
"x": 4.904739999999999,
"y": 3.3012379999999997,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.8660254037844387,
"X": -0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
}
],
"field": {
"length": 17.548,
"width": 8.042
}
}

View File

@@ -0,0 +1,23 @@
ID,X,Y,Z,Z-Rotation,X-Rotation
1,657.37,25.8,58.5,126,0
2,657.37,291.2,58.5,234,0
3,455.15,317.15,51.25,270,0
4,365.2,241.64,73.54,0,30
5,365.2,75.39,73.54,0,30
6,530.49,130.17,12.13,300,0
7,546.87,158.5,12.13,0,0
8,530.49,186.83,12.13,60,0
9,497.77,186.83,12.13,120,0
10,481.39,158.5,12.13,180,0
11,497.77,130.17,12.13,240,0
12,33.51,25.8,58.5,54,0
13,33.51,291.2,58.5,306,0
14,325.68,241.64,73.54,180,30
15,325.68,75.39,73.54,180,30
16,235.73,-0.15,51.25,90,0
17,160.39,130.17,12.13,240,0
18,144,158.5,12.13,180,0
19,160.39,186.83,12.13,120,0
20,193.1,186.83,12.13,60,0
21,209.49,158.5,12.13,0,0
22,193.1,130.17,12.13,300,0
1 ID X Y Z Z-Rotation X-Rotation
2 1 657.37 25.8 58.5 126 0
3 2 657.37 291.2 58.5 234 0
4 3 455.15 317.15 51.25 270 0
5 4 365.2 241.64 73.54 0 30
6 5 365.2 75.39 73.54 0 30
7 6 530.49 130.17 12.13 300 0
8 7 546.87 158.5 12.13 0 0
9 8 530.49 186.83 12.13 60 0
10 9 497.77 186.83 12.13 120 0
11 10 481.39 158.5 12.13 180 0
12 11 497.77 130.17 12.13 240 0
13 12 33.51 25.8 58.5 54 0
14 13 33.51 291.2 58.5 306 0
15 14 325.68 241.64 73.54 180 30
16 15 325.68 75.39 73.54 180 30
17 16 235.73 -0.15 51.25 90 0
18 17 160.39 130.17 12.13 240 0
19 18 144 158.5 12.13 180 0
20 19 160.39 186.83 12.13 120 0
21 20 193.1 186.83 12.13 60 0
22 21 209.49 158.5 12.13 0 0
23 22 193.1 130.17 12.13 300 0

View File

@@ -0,0 +1,404 @@
{
"tags": [
{
"ID": 1,
"pose": {
"translation": {
"x": 16.697198,
"y": 0.65532,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": 0.4539904997395468,
"X": 0.0,
"Y": 0.0,
"Z": 0.8910065241883678
}
}
}
},
{
"ID": 2,
"pose": {
"translation": {
"x": 16.697198,
"y": 7.3964799999999995,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": -0.45399049973954675,
"X": -0.0,
"Y": 0.0,
"Z": 0.8910065241883679
}
}
}
},
{
"ID": 3,
"pose": {
"translation": {
"x": 11.560809999999998,
"y": 8.05561,
"z": 1.30175
},
"rotation": {
"quaternion": {
"W": -0.7071067811865475,
"X": -0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 4,
"pose": {
"translation": {
"x": 9.276079999999999,
"y": 6.137656,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 0.9659258262890683,
"X": 0.0,
"Y": 0.25881904510252074,
"Z": 0.0
}
}
}
},
{
"ID": 5,
"pose": {
"translation": {
"x": 9.276079999999999,
"y": 1.914906,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 0.9659258262890683,
"X": 0.0,
"Y": 0.25881904510252074,
"Z": 0.0
}
}
}
},
{
"ID": 6,
"pose": {
"translation": {
"x": 13.474446,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.8660254037844387,
"X": -0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 7,
"pose": {
"translation": {
"x": 13.890498,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 8,
"pose": {
"translation": {
"x": 13.474446,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 9,
"pose": {
"translation": {
"x": 12.643358,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 10,
"pose": {
"translation": {
"x": 12.227305999999999,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 11,
"pose": {
"translation": {
"x": 12.643358,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.4999999999999998,
"X": -0.0,
"Y": 0.0,
"Z": 0.8660254037844387
}
}
}
},
{
"ID": 12,
"pose": {
"translation": {
"x": 0.851154,
"y": 0.65532,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": 0.8910065241883679,
"X": 0.0,
"Y": 0.0,
"Z": 0.45399049973954675
}
}
}
},
{
"ID": 13,
"pose": {
"translation": {
"x": 0.851154,
"y": 7.3964799999999995,
"z": 1.4859
},
"rotation": {
"quaternion": {
"W": -0.8910065241883678,
"X": -0.0,
"Y": 0.0,
"Z": 0.45399049973954686
}
}
}
},
{
"ID": 14,
"pose": {
"translation": {
"x": 8.272272,
"y": 6.137656,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 5.914589856893349e-17,
"X": -0.25881904510252074,
"Y": 1.5848095757158825e-17,
"Z": 0.9659258262890683
}
}
}
},
{
"ID": 15,
"pose": {
"translation": {
"x": 8.272272,
"y": 1.914906,
"z": 1.8679160000000001
},
"rotation": {
"quaternion": {
"W": 5.914589856893349e-17,
"X": -0.25881904510252074,
"Y": 1.5848095757158825e-17,
"Z": 0.9659258262890683
}
}
}
},
{
"ID": 16,
"pose": {
"translation": {
"x": 5.9875419999999995,
"y": -0.0038099999999999996,
"z": 1.30175
},
"rotation": {
"quaternion": {
"W": 0.7071067811865476,
"X": 0.0,
"Y": 0.0,
"Z": 0.7071067811865476
}
}
}
},
{
"ID": 17,
"pose": {
"translation": {
"x": 4.073905999999999,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.4999999999999998,
"X": -0.0,
"Y": 0.0,
"Z": 0.8660254037844387
}
}
}
},
{
"ID": 18,
"pose": {
"translation": {
"x": 3.6576,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 6.123233995736766e-17,
"X": 0.0,
"Y": 0.0,
"Z": 1.0
}
}
}
},
{
"ID": 19,
"pose": {
"translation": {
"x": 4.073905999999999,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.5000000000000001,
"X": 0.0,
"Y": 0.0,
"Z": 0.8660254037844386
}
}
}
},
{
"ID": 20,
"pose": {
"translation": {
"x": 4.904739999999999,
"y": 4.745482,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 0.8660254037844387,
"X": 0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
},
{
"ID": 21,
"pose": {
"translation": {
"x": 5.321046,
"y": 4.0259,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": 1.0,
"X": 0.0,
"Y": 0.0,
"Z": 0.0
}
}
}
},
{
"ID": 22,
"pose": {
"translation": {
"x": 4.904739999999999,
"y": 3.3063179999999996,
"z": 0.308102
},
"rotation": {
"quaternion": {
"W": -0.8660254037844387,
"X": -0.0,
"Y": 0.0,
"Z": 0.49999999999999994
}
}
}
}
],
"field": {
"length": 17.548,
"width": 8.052
}
}

View File

@@ -0,0 +1,276 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include "common/matd.h"
#include "common/image_u8.h"
#include "common/zarray.h"
#include "common/workerpool.h"
#include "common/timeprofile.h"
#include "common/pthreads_cross.h"
#define APRILTAG_TASKS_PER_THREAD_TARGET 10
struct quad
{
float p[4][2]; // corners
bool reversed_border;
// H: tag coordinates ([-1,1] at the black corners) to pixels
// Hinv: pixels to tag
matd_t *H, *Hinv;
};
// Represents a tag family. Every tag belongs to a tag family. Tag
// families are generated by the Java tool
// april.tag.TagFamilyGenerator and can be converted to C using
// april.tag.TagToC.
typedef struct apriltag_family apriltag_family_t;
struct apriltag_family
{
// How many codes are there in this tag family?
uint32_t ncodes;
// The codes in the family.
uint64_t *codes;
int width_at_border;
int total_width;
bool reversed_border;
// The bit locations.
uint32_t nbits;
uint32_t *bit_x;
uint32_t *bit_y;
// minimum hamming distance between any two codes. (e.g. 36h11 => 11)
uint32_t h;
// a human-readable name, e.g., "tag36h11"
char *name;
// some detector implementations may preprocess codes in order to
// accelerate decoding. They put their data here. (Do not use the
// same apriltag_family instance in more than one implementation)
void *impl;
};
struct apriltag_quad_thresh_params
{
// reject quads containing too few pixels
int min_cluster_pixels;
// how many corner candidates to consider when segmenting a group
// of pixels into a quad.
int max_nmaxima;
// Reject quads where pairs of edges have angles that are close to
// straight or close to 180 degrees. Zero means that no quads are
// rejected. (In radians).
float critical_rad;
float cos_critical_rad;
// When fitting lines to the contours, what is the maximum mean
// squared error allowed? This is useful in rejecting contours
// that are far from being quad shaped; rejecting these quads "early"
// saves expensive decoding processing.
float max_line_fit_mse;
// When we build our model of black & white pixels, we add an
// extra check that the white model must be (overall) brighter
// than the black model. How much brighter? (in pixel values,
// [0,255]). .
int min_white_black_diff;
// should the thresholded image be deglitched? Only useful for
// very noisy images
int deglitch;
};
// Represents a detector object. Upon creating a detector, all fields
// are set to reasonable values, but can be overridden by accessing
// these fields.
typedef struct apriltag_detector apriltag_detector_t;
struct apriltag_detector
{
///////////////////////////////////////////////////////////////
// User-configurable parameters.
// How many threads should be used?
int nthreads;
// detection of quads can be done on a lower-resolution image,
// improving speed at a cost of pose accuracy and a slight
// decrease in detection rate. Decoding the binary payload is
// still done at full resolution. .
float quad_decimate;
// What Gaussian blur should be applied to the segmented image
// (used for quad detection?) Parameter is the standard deviation
// in pixels. Very noisy images benefit from non-zero values
// (e.g. 0.8).
float quad_sigma;
// When true, the edges of the each quad are adjusted to "snap
// to" strong gradients nearby. This is useful when decimation is
// employed, as it can increase the quality of the initial quad
// estimate substantially. Generally recommended to be on (true).
//
// Very computationally inexpensive. Option is ignored if
// quad_decimate = 1.
bool refine_edges;
// How much sharpening should be done to decoded images? This
// can help decode small tags but may or may not help in odd
// lighting conditions or low light conditions.
//
// The default value is 0.25.
double decode_sharpening;
// When true, write a variety of debugging images to the
// current working directory at various stages through the
// detection process. (Somewhat slow).
bool debug;
struct apriltag_quad_thresh_params qtp;
///////////////////////////////////////////////////////////////
// Statistics relating to last processed frame
timeprofile_t *tp;
uint32_t nedges;
uint32_t nsegments;
uint32_t nquads;
///////////////////////////////////////////////////////////////
// Internal variables below
// Not freed on apriltag_destroy; a tag family can be shared
// between multiple users. The user should ultimately destroy the
// tag family passed into the constructor.
zarray_t *tag_families;
// Used to manage multi-threading.
workerpool_t *wp;
// Used for thread safety.
pthread_mutex_t mutex;
};
// Represents the detection of a tag. These are returned to the user
// and must be individually destroyed by the user.
typedef struct apriltag_detection apriltag_detection_t;
struct apriltag_detection
{
// a pointer for convenience. not freed by apriltag_detection_destroy.
apriltag_family_t *family;
// The decoded ID of the tag
int id;
// How many error bits were corrected? Note: accepting large numbers of
// corrected errors leads to greatly increased false positive rates.
// NOTE: As of this implementation, the detector cannot detect tags with
// a hamming distance greater than 2.
int hamming;
// A measure of the quality of the binary decoding process: the
// average difference between the intensity of a data bit versus
// the decision threshold. Higher numbers roughly indicate better
// decodes. This is a reasonable measure of detection accuracy
// only for very small tags-- not effective for larger tags (where
// we could have sampled anywhere within a bit cell and still
// gotten a good detection.)
float decision_margin;
// The 3x3 homography matrix describing the projection from an
// "ideal" tag (with corners at (-1,1), (1,1), (1,-1), and (-1,
// -1)) to pixels in the image. This matrix will be freed by
// apriltag_detection_destroy.
matd_t *H;
// The center of the detection in image pixel coordinates.
double c[2];
// The corners of the tag in image pixel coordinates. These always
// wrap counter-clock wise around the tag.
double p[4][2];
};
// don't forget to add a family!
apriltag_detector_t *apriltag_detector_create(void);
// add a family to the apriltag detector. caller still "owns" the family.
// a single instance should only be provided to one apriltag detector instance.
void apriltag_detector_add_family_bits(apriltag_detector_t *td, apriltag_family_t *fam, int bits_corrected);
// Tunable, but really, 2 is a good choice. Values of >=3
// consume prohibitively large amounts of memory, and otherwise
// you want the largest value possible.
static inline void apriltag_detector_add_family(apriltag_detector_t *td, apriltag_family_t *fam)
{
apriltag_detector_add_family_bits(td, fam, 2);
}
// does not deallocate the family.
void apriltag_detector_remove_family(apriltag_detector_t *td, apriltag_family_t *fam);
// unregister all families, but does not deallocate the underlying tag family objects.
void apriltag_detector_clear_families(apriltag_detector_t *td);
// Destroy the april tag detector (but not the underlying
// apriltag_family_t used to initialize it.)
void apriltag_detector_destroy(apriltag_detector_t *td);
// Detect tags from an image and return an array of
// apriltag_detection_t*. You can use apriltag_detections_destroy to
// free the array and the detections it contains, or call
// _detection_destroy and zarray_destroy yourself.
zarray_t *apriltag_detector_detect(apriltag_detector_t *td, image_u8_t *im_orig);
// Call this method on each of the tags returned by apriltag_detector_detect
void apriltag_detection_destroy(apriltag_detection_t *det);
// destroys the array AND the detections within it.
void apriltag_detections_destroy(zarray_t *detections);
// Renders the apriltag.
// Caller is responsible for calling image_u8_destroy on the image
image_u8_t *apriltag_to_image(apriltag_family_t *fam, uint32_t idx);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,101 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <math.h>
// Computes the cholesky factorization of A, putting the lower
// triangular matrix into R.
static inline void mat33_chol(const double *A,
double *R)
{
// A[0] = R[0]*R[0]
R[0] = sqrt(A[0]);
// A[1] = R[0]*R[3];
R[3] = A[1] / R[0];
// A[2] = R[0]*R[6];
R[6] = A[2] / R[0];
// A[4] = R[3]*R[3] + R[4]*R[4]
R[4] = sqrt(A[4] - R[3]*R[3]);
// A[5] = R[3]*R[6] + R[4]*R[7]
R[7] = (A[5] - R[3]*R[6]) / R[4];
// A[8] = R[6]*R[6] + R[7]*R[7] + R[8]*R[8]
R[8] = sqrt(A[8] - R[6]*R[6] - R[7]*R[7]);
R[1] = 0;
R[2] = 0;
R[5] = 0;
}
static inline void mat33_lower_tri_inv(const double *A,
double *R)
{
// A[0]*R[0] = 1
R[0] = 1 / A[0];
// A[3]*R[0] + A[4]*R[3] = 0
R[3] = -A[3]*R[0] / A[4];
// A[4]*R[4] = 1
R[4] = 1 / A[4];
// A[6]*R[0] + A[7]*R[3] + A[8]*R[6] = 0
R[6] = (-A[6]*R[0] - A[7]*R[3]) / A[8];
// A[7]*R[4] + A[8]*R[7] = 0
R[7] = -A[7]*R[4] / A[8];
// A[8]*R[8] = 1
R[8] = 1 / A[8];
}
static inline void mat33_sym_solve(const double *A,
const double *B,
double *R)
{
double L[9];
mat33_chol(A, L);
double M[9];
mat33_lower_tri_inv(L, M);
double tmp[3];
tmp[0] = M[0]*B[0];
tmp[1] = M[3]*B[0] + M[4]*B[1];
tmp[2] = M[6]*B[0] + M[7]*B[1] + M[8]*B[2];
R[0] = M[0]*tmp[0] + M[3]*tmp[1] + M[6]*tmp[2];
R[1] = M[4]*tmp[1] + M[7]*tmp[2];
R[2] = M[8]*tmp[2];
}

View File

@@ -0,0 +1,81 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "apriltag.h"
#include "common/matd.h"
typedef struct {
apriltag_detection_t* det;
double tagsize; // In meters.
double fx; // In pixels.
double fy; // In pixels.
double cx; // In pixels.
double cy; // In pixels.
} apriltag_detection_info_t;
/**
* This struct holds the transformation from the camera optical frame to
* the April tag frame. The pose refers to the position of the tag within
* the camera frame.
*/
typedef struct {
matd_t* R; // Rotation matrix 3x3 of doubles.
matd_t* t; // Translation matrix 3x1 of doubles.
} apriltag_pose_t;
/**
* Estimate pose of the tag using the homography method described in [1].
* @outparam pose
*/
void estimate_pose_for_tag_homography(
apriltag_detection_info_t* info,
apriltag_pose_t* pose);
/**
* Estimate pose of the tag. This returns one or two possible poses for the
* tag, along with the object-space error of each.
*
* This uses the homography method described in [1] for the initial estimate.
* Then Orthogonal Iteration [2] is used to refine this estimate. Then [3] is
* used to find a potential second local minima and Orthogonal Iteration is
* used to refine this second estimate.
*
* [1]: E. Olson, “Apriltag: A robust and flexible visual fiducial system,” in
* 2011 IEEE International Conference on Robotics and Automation,
* May 2011, pp. 34003407.
* [2]: Lu, G. D. Hager and E. Mjolsness, "Fast and globally convergent pose
* estimation from video images," in IEEE Transactions on Pattern Analysis
* and Machine Intelligence, vol. 22, no. 6, pp. 610-622, June 2000.
* doi: 10.1109/34.862199
* [3]: Schweighofer and A. Pinz, "Robust Pose Estimation from a Planar Target,"
* in IEEE Transactions on Pattern Analysis and Machine Intelligence,
* vol. 28, no. 12, pp. 2024-2030, Dec. 2006. doi: 10.1109/TPAMI.2006.252
*
* @outparam err1, pose1, err2, pose2
*/
void estimate_tag_pose_orthogonal_iteration(
apriltag_detection_info_t* info,
double* err1,
apriltag_pose_t* pose1,
double* err2,
apriltag_pose_t* pose2,
int nIters,
double min_improvement_per_iteration);
/**
* Estimate tag pose.
* This method is an easier to use interface to estimate_tag_pose_orthogonal_iteration.
*
* @outparam pose
* @return Object-space error of returned pose.
*/
double estimate_tag_pose(apriltag_detection_info_t* info, apriltag_pose_t* pose);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,41 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#if !defined(NDEBUG) || defined(_DEBUG)
#include <string.h>
#include <stdio.h>
#define DEBUG 1
#else
#define DEBUG 0
#endif
#define debug_print(fmt, ...) \
do { if (DEBUG) fprintf(stderr, "%s:%d:%s(): " fmt, strrchr("/"__FILE__,'/')+1, \
__LINE__, __func__, ##__VA_ARGS__); fflush(stderr);} while (0)

View File

@@ -0,0 +1,32 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#define TNAME double
#include "doubles_floats_impl.h"
#undef TNAME

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,32 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#define TNAME float
#include "doubles_floats_impl.h"
#undef TNAME

View File

@@ -0,0 +1,124 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "zarray.h"
// This library tries to avoid needless proliferation of types.
//
// A point is a double[2]. (Note that when passing a double[2] as an
// argument, it is passed by pointer, not by value.)
//
// A polygon is a zarray_t of double[2]. (Note that in this case, the
// zarray contains the actual vertex data, and not merely a pointer to
// some other data. IMPORTANT: A polygon must be specified in CCW
// order. It is implicitly closed (do not list the same point at the
// beginning at the end.
//
// Where sensible, it is assumed that objects should be allocated
// sparingly; consequently "init" style methods, rather than "create"
// methods are used.
////////////////////////////////////////////////////////////////////
// Lines
typedef struct
{
// Internal representation: a point that the line goes through (p) and
// the direction of the line (u).
double p[2];
double u[2]; // always a unit vector
} g2d_line_t;
// initialize a line object.
void g2d_line_init_from_points(g2d_line_t *line, const double p0[2], const double p1[2]);
// The line defines a one-dimensional coordinate system whose origin
// is p. Where is q? (If q is not on the line, the point nearest q is
// returned.
double g2d_line_get_coordinate(const g2d_line_t *line, const double q[2]);
// Intersect two lines. The intersection, if it exists, is written to
// p (if not NULL), and 1 is returned. Else, zero is returned.
int g2d_line_intersect_line(const g2d_line_t *linea, const g2d_line_t *lineb, double *p);
////////////////////////////////////////////////////////////////////
// Line Segments. line.p is always one endpoint; p1 is the other
// endpoint.
typedef struct
{
g2d_line_t line;
double p1[2];
} g2d_line_segment_t;
void g2d_line_segment_init_from_points(g2d_line_segment_t *seg, const double p0[2], const double p1[2]);
// Intersect two segments. The intersection, if it exists, is written
// to p (if not NULL), and 1 is returned. Else, zero is returned.
int g2d_line_segment_intersect_segment(const g2d_line_segment_t *sega, const g2d_line_segment_t *segb, double *p);
void g2d_line_segment_closest_point(const g2d_line_segment_t *seg, const double *q, double *p);
double g2d_line_segment_closest_point_distance(const g2d_line_segment_t *seg, const double *q);
////////////////////////////////////////////////////////////////////
// Polygons
zarray_t *g2d_polygon_create_data(double v[][2], int sz);
zarray_t *g2d_polygon_create_zeros(int sz);
zarray_t *g2d_polygon_create_empty(void);
void g2d_polygon_add(zarray_t *poly, double v[2]);
// Takes a polygon in either CW or CCW and modifies it (if necessary)
// to be CCW.
void g2d_polygon_make_ccw(zarray_t *poly);
// Return 1 if point q lies within poly.
int g2d_polygon_contains_point(const zarray_t *poly, double q[2]);
// Do the edges of the polygons cross? (Does not test for containment).
int g2d_polygon_intersects_polygon(const zarray_t *polya, const zarray_t *polyb);
// Does polya completely contain polyb?
int g2d_polygon_contains_polygon(const zarray_t *polya, const zarray_t *polyb);
// Is there some point which is in both polya and polyb?
int g2d_polygon_overlaps_polygon(const zarray_t *polya, const zarray_t *polyb);
// returns the number of points written to x. see comments.
int g2d_polygon_rasterize(const zarray_t *poly, double y, double *x);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,183 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include "matd.h"
#include "zarray.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Given a 3x3 homography matrix and the focal lengths of the
* camera, compute the pose of the tag. The focal lengths should
* be given in pixels. For example, if the camera's focal length
* is twice the width of the sensor, and the sensor is 600 pixels
* across, the focal length in pixels is 2*600. Note that the
* focal lengths in the fx and fy direction will be approximately
* equal for most lenses, and is not a function of aspect ratio.
*
* Theory: The homography matrix is the product of the camera
* projection matrix and the tag's pose matrix (the matrix that
* projects points from the tag's local coordinate system to the
* camera's coordinate frame).
*
* [ h00 h01 h02 h03] = [ fx 0 cx 0 ] [ R00 R01 R02 TX ]
* [ h10 h11 h12 h13] = [ 0 fy cy 0 ] [ R10 R11 R12 TY ]
* [ h20 h21 h22 h23] = [ 0 0 s 0 ] [ R20 R21 R22 TZ ]
* [ 0 0 0 1 ]
*
* fx is the focal length in the x direction of the camera
* (typically measured in pixels), fy is the focal length. cx and
* cy give the focal center (usually the middle of the image), and
* s is either +1 or -1, depending on the conventions you use. (We
* use 1.)
* When observing a tag, the points we project in world space all
* have z=0, so we can form a 3x3 matrix by eliminating the 3rd
* column of the pose matrix.
*
* [ h00 h01 h02 ] = [ fx 0 cx 0 ] [ R00 R01 TX ]
* [ h10 h11 h12 ] = [ 0 fy cy 0 ] [ R10 R11 TY ]
* [ h20 h21 h22 ] = [ 0 0 s 0 ] [ R20 R21 TZ ]
* [ 0 0 1 ]
*
* (note that these h's are different from the ones above.)
*
* We can multiply the right-hand side to yield a set of equations
* relating the values of h to the values of the pose matrix.
*
* There are two wrinkles. The first is that the homography matrix
* is known only up to scale. We recover the unknown scale by
* constraining the magnitude of the first two columns of the pose
* matrix to be 1. We use the geometric average scale. The sign of
* the scale factor is recovered by constraining the observed tag
* to be in front of the camera. Once scaled, we recover the first
* two colmuns of the rotation matrix. The third column is the
* cross product of these.
*
* The second wrinkle is that the computed rotation matrix might
* not be exactly orthogonal, so we perform a polar decomposition
* to find a good pure rotation approximation.
*
* Tagsize is the size of the tag in your desired units. I.e., if
* your tag measures 0.25m along the side, your tag size is
* 0.25. (The homography is computed in terms of *half* the tag
* size, i.e., that a tag is 2 units wide as it spans from -1 to
* +1, but this code makes the appropriate adjustment.)
*
* A note on signs:
*
* The code below incorporates no additional negative signs, but
* respects the sign of any parameters that you pass in. Flipping
* the signs allows you to modify the projection to suit a wide
* variety of conditions.
*
* In the "pure geometry" projection matrix, the image appears
* upside down; i.e., the x and y coordinates on the left hand
* side are the opposite of those on the right of the camera
* projection matrix. This would happen for all parameters
* positive: recall that points in front of the camera have
* negative Z values, which will cause the sign of all points to
* flip.
*
* However, most cameras flip things so that the image appears
* "right side up" as though you were looking through the lens
* directly. This means that the projected points should have the
* same sign as the points on the right of the camera projection
* matrix. To achieve this, flip fx and fy.
*
* One further complication: cameras typically put y=0 at the top
* of the image, instead of the bottom. Thus you generally want to
* flip y yet again (so it's now positive again).
*
* General advice: you probably want fx negative, fy positive, cx
* and cy positive, and s=1.
**/
// correspondences is a list of float[4]s, consisting of the points x
// and y concatenated. We will compute a homography such that y = Hx
// Specifically, float [] { a, b, c, d } where x = [a b], y = [c d].
#define HOMOGRAPHY_COMPUTE_FLAG_INVERSE 1
#define HOMOGRAPHY_COMPUTE_FLAG_SVD 0
matd_t *homography_compute(zarray_t *correspondences, int flags);
//void homography_project(const matd_t *H, double x, double y, double *ox, double *oy);
static inline void homography_project(const matd_t *H, double x, double y, double *ox, double *oy)
{
double xx = MATD_EL(H, 0, 0)*x + MATD_EL(H, 0, 1)*y + MATD_EL(H, 0, 2);
double yy = MATD_EL(H, 1, 0)*x + MATD_EL(H, 1, 1)*y + MATD_EL(H, 1, 2);
double zz = MATD_EL(H, 2, 0)*x + MATD_EL(H, 2, 1)*y + MATD_EL(H, 2, 2);
*ox = xx / zz;
*oy = yy / zz;
}
// assuming that the projection matrix is:
// [ fx 0 cx 0 ]
// [ 0 fy cy 0 ]
// [ 0 0 1 0 ]
//
// And that the homography is equal to the projection matrix times the model matrix,
// recover the model matrix (which is returned). Note that the third column of the model
// matrix is missing in the expression below, reflecting the fact that the homography assumes
// all points are at z=0 (i.e., planar) and that the element of z is thus omitted.
// (3x1 instead of 4x1).
//
// [ fx 0 cx 0 ] [ R00 R01 TX ] [ H00 H01 H02 ]
// [ 0 fy cy 0 ] [ R10 R11 TY ] = [ H10 H11 H12 ]
// [ 0 0 1 0 ] [ R20 R21 TZ ] = [ H20 H21 H22 ]
// [ 0 0 1 ]
//
// fx*R00 + cx*R20 = H00 (note, H only known up to scale; some additional adjustments required; see code.)
// fx*R01 + cx*R21 = H01
// fx*TX + cx*TZ = H02
// fy*R10 + cy*R20 = H10
// fy*R11 + cy*R21 = H11
// fy*TY + cy*TZ = H12
// R20 = H20
// R21 = H21
// TZ = H22
matd_t *homography_to_pose(const matd_t *H, double fx, double fy, double cx, double cy);
// Similar to above
// Recover the model view matrix assuming that the projection matrix is:
//
// [ F 0 A 0 ] (see glFrustrum)
// [ 0 G B 0 ]
// [ 0 0 C D ]
// [ 0 0 -1 0 ]
matd_t *homography_to_model_view(const matd_t *H, double F, double G, double A, double B);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,84 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <stdint.h>
// to support conversions between different types, we define all image
// types at once. Type-specific implementations can then #include this
// file, assured that the basic types of each image are known.
typedef struct image_u8 image_u8_t;
struct image_u8
{
const int32_t width;
const int32_t height;
const int32_t stride;
uint8_t *buf;
};
typedef struct image_u8x3 image_u8x3_t;
struct image_u8x3
{
const int32_t width;
const int32_t height;
const int32_t stride; // bytes per line
uint8_t *buf;
};
typedef struct image_u8x4 image_u8x4_t;
struct image_u8x4
{
const int32_t width;
const int32_t height;
const int32_t stride; // bytes per line
uint8_t *buf;
};
typedef struct image_f32 image_f32_t;
struct image_f32
{
const int32_t width;
const int32_t height;
const int32_t stride; // floats per line
float *buf; // indexed as buf[y*stride + x]
};
typedef struct image_u32 image_u32_t;
struct image_u32
{
const int32_t width;
const int32_t height;
const int32_t stride; // int32_ts per line
uint32_t *buf; // indexed as buf[y*stride + x]
};

View File

@@ -0,0 +1,90 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <stdint.h>
#include "image_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct image_u8_lut image_u8_lut_t;
struct image_u8_lut
{
// When drawing, we compute the squared distance between a given pixel and a filled region.
// int idx = squared_distance * scale;
// We then index into values[idx] to obtain the color. (If we must index beyond nvalues,
// no drawing is performed.)
float scale;
int nvalues;
uint8_t *values;
};
// Create or load an image. returns NULL on failure. Uses default
// stride alignment.
image_u8_t *image_u8_create_stride(unsigned int width, unsigned int height, unsigned int stride);
image_u8_t *image_u8_create(unsigned int width, unsigned int height);
image_u8_t *image_u8_create_alignment(unsigned int width, unsigned int height, unsigned int alignment);
image_u8_t *image_u8_create_from_f32(image_f32_t *fim);
image_u8_t *image_u8_create_from_pnm(const char *path);
image_u8_t *image_u8_create_from_pnm_alignment(const char *path, int alignment);
image_u8_t *image_u8_copy(const image_u8_t *in);
void image_u8_draw_line(image_u8_t *im, float x0, float y0, float x1, float y1, int v, int width);
void image_u8_draw_circle(image_u8_t *im, float x0, float y0, float r, int v);
void image_u8_draw_annulus(image_u8_t *im, float x0, float y0, float r0, float r1, int v);
void image_u8_fill_line_max(image_u8_t *im, const image_u8_lut_t *lut, const float *xy0, const float *xy1);
void image_u8_clear(image_u8_t *im);
void image_u8_darken(image_u8_t *im);
void image_u8_convolve_2D(image_u8_t *im, const uint8_t *k, int ksz);
void image_u8_gaussian_blur(image_u8_t *im, double sigma, int k);
// 1.5, 2, 3, 4, ... supported
image_u8_t *image_u8_decimate(image_u8_t *im, float factor);
void image_u8_destroy(image_u8_t *im);
// Write a pnm. Returns 0 on success
// Currently only supports GRAY and RGBA. Does not write out alpha for RGBA
int image_u8_write_pnm(const image_u8_t *im, const char *path);
// rotate the image by 'rad' radians. (Rotated in the "intuitive
// sense", i.e., if Y were up. When input values are unavailable, the
// value 'pad' is inserted instead. The geometric center of the output
// image corresponds to the geometric center of the input image.
image_u8_t *image_u8_rotate(const image_u8_t *in, double rad, uint8_t pad);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,64 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <stdint.h>
#include "image_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/////////////////////////////////////
// IMPORTANT NOTE ON BYTE ORDER
//
// Format conversion routines will (unless otherwise specified) assume
// R, G, B, ordering of bytes. This is consistent with GTK, PNM, etc.
//
/////////////////////////////////////
// Create or load an image. returns NULL on failure
image_u8x3_t *image_u8x3_create(unsigned int width, unsigned int height);
image_u8x3_t *image_u8x3_create_alignment(unsigned int width, unsigned int height, unsigned int alignment);
image_u8x3_t *image_u8x3_create_from_pnm(const char *path);
image_u8x3_t *image_u8x3_copy(const image_u8x3_t *in);
void image_u8x3_gaussian_blur(image_u8x3_t *im, double sigma, int ksz);
void image_u8x3_destroy(image_u8x3_t *im);
int image_u8x3_write_pnm(const image_u8x3_t *im, const char *path);
// only width 1 supported
void image_u8x3_draw_line(image_u8x3_t *im, float x0, float y0, float x1, float y1, uint8_t rgb[3]);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,65 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <stdint.h>
#include "image_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/////////////////////////////////////
// IMPORTANT NOTE ON BYTE ORDER
//
// Format conversion routines will (unless otherwise specified) assume
// R, G, B, A ordering of bytes.
//
/////////////////////////////////////
// Create or load an image. returns NULL on failure
image_u8x4_t *image_u8x4_create(unsigned int width, unsigned int height);
image_u8x4_t *image_u8x4_create_alignment(unsigned int width, unsigned int height, unsigned int alignment);
image_u8x4_t *image_u8x4_create_from_pnm(const char *path);
image_u8x4_t *image_u8x4_copy(const image_u8x4_t *in);
void image_u8x4_destroy(image_u8x4_t *im);
// Write a pnm. Return 0 on success.
// Currently supports GRAY and RGB
int image_u8x4_write_pnm(const image_u8x4_t *im, const char *path);
image_u8x4_t *image_u8x4_create_from_pam(const char *path);
void image_u8x4_write_pam(const image_u8x4_t *im, const char *path);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,446 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <assert.h>
#include <stddef.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* Defines a matrix structure for holding double-precision values with
* data in row-major order (i.e. index = row*ncols + col).
*
* nrows and ncols are 1-based counts with the exception that a scalar (non-matrix)
* is represented with nrows=0 and/or ncols=0.
*/
typedef struct
{
unsigned int nrows, ncols;
double data[];
// double *data;
} matd_t;
#define MATD_ALLOC(name, nrows, ncols) double name ## _storage [nrows*ncols]; matd_t name = { .nrows = nrows, .ncols = ncols, .data = &name ## _storage };
/**
* Defines a small value which can be used in place of zero for approximating
* calculations which are singular at zero values (i.e. inverting a matrix with
* a zero or near-zero determinant).
*/
#define MATD_EPS 1e-8
/**
* A macro to reference a specific matd_t data element given it's zero-based
* row and column indexes. Suitable for both retrieval and assignment.
*/
#define MATD_EL(m, row, col) (m)->data[((row)*(m)->ncols + (col))]
/**
* Creates a double matrix with the given number of rows and columns (or a scalar
* in the case where rows=0 and/or cols=0). All data elements will be initialized
* to zero. It is the caller's responsibility to call matd_destroy() on the
* returned matrix.
*/
matd_t *matd_create(int rows, int cols);
/**
* Creates a double matrix with the given number of rows and columns (or a scalar
* in the case where rows=0 and/or cols=0). All data elements will be initialized
* using the supplied array of data, which must contain at least rows*cols elements,
* arranged in row-major order (i.e. index = row*ncols + col). It is the caller's
* responsibility to call matd_destroy() on the returned matrix.
*/
matd_t *matd_create_data(int rows, int cols, const double *data);
/**
* Creates a double matrix with the given number of rows and columns (or a scalar
* in the case where rows=0 and/or cols=0). All data elements will be initialized
* using the supplied array of float data, which must contain at least rows*cols elements,
* arranged in row-major order (i.e. index = row*ncols + col). It is the caller's
* responsibility to call matd_destroy() on the returned matrix.
*/
matd_t *matd_create_dataf(int rows, int cols, const float *data);
/**
* Creates a square identity matrix with the given number of rows (and
* therefore columns), or a scalar with value 1 in the case where dim=0.
* It is the caller's responsibility to call matd_destroy() on the
* returned matrix.
*/
matd_t *matd_identity(int dim);
/**
* Creates a scalar with the supplied value 'v'. It is the caller's responsibility
* to call matd_destroy() on the returned matrix.
*
* NOTE: Scalars are different than 1x1 matrices (implementation note:
* they are encoded as 0x0 matrices). For example: for matrices A*B, A
* and B must both have specific dimensions. However, if A is a
* scalar, there are no restrictions on the size of B.
*/
matd_t *matd_create_scalar(double v);
/**
* Retrieves the cell value for matrix 'm' at the given zero-based row and column index.
* Performs more thorough validation checking than MATD_EL().
*/
double matd_get(const matd_t *m, unsigned int row, unsigned int col);
/**
* Assigns the given value to the matrix cell at the given zero-based row and
* column index. Performs more thorough validation checking than MATD_EL().
*/
void matd_put(matd_t *m, unsigned int row, unsigned int col, double value);
/**
* Retrieves the scalar value of the given element ('m' must be a scalar).
* Performs more thorough validation checking than MATD_EL().
*/
double matd_get_scalar(const matd_t *m);
/**
* Assigns the given value to the supplied scalar element ('m' must be a scalar).
* Performs more thorough validation checking than MATD_EL().
*/
void matd_put_scalar(matd_t *m, double value);
/**
* Creates an exact copy of the supplied matrix 'm'. It is the caller's
* responsibility to call matd_destroy() on the returned matrix.
*/
matd_t *matd_copy(const matd_t *m);
/**
* Creates a copy of a subset of the supplied matrix 'a'. The subset will include
* rows 'r0' through 'r1', inclusive ('r1' >= 'r0'), and columns 'c0' through 'c1',
* inclusive ('c1' >= 'c0'). All parameters are zero-based (i.e. matd_select(a, 0, 0, 0, 0)
* will return only the first cell). Cannot be used on scalars or to extend
* beyond the number of rows/columns of 'a'. It is the caller's responsibility to
* call matd_destroy() on the returned matrix.
*/
matd_t *matd_select(const matd_t *a, unsigned int r0, int r1, unsigned int c0, int c1);
/**
* Prints the supplied matrix 'm' to standard output by applying the supplied
* printf format specifier 'fmt' for each individual element. Each row will
* be printed on a separate newline.
*/
void matd_print(const matd_t *m, const char *fmt);
/**
* Prints the transpose of the supplied matrix 'm' to standard output by applying
* the supplied printf format specifier 'fmt' for each individual element. Each
* row will be printed on a separate newline.
*/
void matd_print_transpose(const matd_t *m, const char *fmt);
/**
* Adds the two supplied matrices together, cell-by-cell, and returns the results
* as a new matrix of the same dimensions. The supplied matrices must have
* identical dimensions. It is the caller's responsibility to call matd_destroy()
* on the returned matrix.
*/
matd_t *matd_add(const matd_t *a, const matd_t *b);
/**
* Adds the values of 'b' to matrix 'a', cell-by-cell, and overwrites the
* contents of 'a' with the results. The supplied matrices must have
* identical dimensions.
*/
void matd_add_inplace(matd_t *a, const matd_t *b);
/**
* Subtracts matrix 'b' from matrix 'a', cell-by-cell, and returns the results
* as a new matrix of the same dimensions. The supplied matrices must have
* identical dimensions. It is the caller's responsibility to call matd_destroy()
* on the returned matrix.
*/
matd_t *matd_subtract(const matd_t *a, const matd_t *b);
/**
* Subtracts the values of 'b' from matrix 'a', cell-by-cell, and overwrites the
* contents of 'a' with the results. The supplied matrices must have
* identical dimensions.
*/
void matd_subtract_inplace(matd_t *a, const matd_t *b);
/**
* Scales all cell values of matrix 'a' by the given scale factor 's' and
* returns the result as a new matrix of the same dimensions. It is the caller's
* responsibility to call matd_destroy() on the returned matrix.
*/
matd_t *matd_scale(const matd_t *a, double s);
/**
* Scales all cell values of matrix 'a' by the given scale factor 's' and
* overwrites the contents of 'a' with the results.
*/
void matd_scale_inplace(matd_t *a, double s);
/**
* Multiplies the two supplied matrices together (matrix product), and returns the
* results as a new matrix. The supplied matrices must have dimensions such that
* columns(a) = rows(b). The returned matrix will have a row count of rows(a)
* and a column count of columns(b). It is the caller's responsibility to call
* matd_destroy() on the returned matrix.
*/
matd_t *matd_multiply(const matd_t *a, const matd_t *b);
/**
* Creates a matrix which is the transpose of the supplied matrix 'a'. It is the
* caller's responsibility to call matd_destroy() on the returned matrix.
*/
matd_t *matd_transpose(const matd_t *a);
/**
* Calculates the determinant of the supplied matrix 'a'.
*/
double matd_det(const matd_t *a);
/**
* Attempts to compute an inverse of the supplied matrix 'a' and return it as
* a new matrix. This is strictly only possible if the determinant of 'a' is
* non-zero (matd_det(a) != 0).
*
* If the determinant is zero, NULL is returned. It is otherwise the
* caller's responsibility to cope with the results caused by poorly
* conditioned matrices. (E.g.., if such a situation is likely to arise, compute
* the pseudo-inverse from the SVD.)
**/
matd_t *matd_inverse(const matd_t *a);
static inline void matd_set_data(matd_t *m, const double *data)
{
memcpy(m->data, data, m->nrows * m->ncols * sizeof(double));
}
/**
* Determines whether the supplied matrix 'a' is a scalar (positive return) or
* not (zero return, indicating a matrix of dimensions at least 1x1).
*/
static inline int matd_is_scalar(const matd_t *a)
{
assert(a != NULL);
return a->ncols <= 1 && a->nrows <= 1;
}
/**
* Determines whether the supplied matrix 'a' is a row or column vector
* (positive return) or not (zero return, indicating either 'a' is a scalar or a
* matrix with at least one dimension > 1).
*/
static inline int matd_is_vector(const matd_t *a)
{
assert(a != NULL);
return a->ncols == 1 || a->nrows == 1;
}
/**
* Determines whether the supplied matrix 'a' is a row or column vector
* with a dimension of 'len' (positive return) or not (zero return).
*/
static inline int matd_is_vector_len(const matd_t *a, int len)
{
assert(a != NULL);
return (a->ncols == 1 && a->nrows == (unsigned int)len) || (a->ncols == (unsigned int)len && a->nrows == 1);
}
/**
* Calculates the magnitude of the supplied matrix 'a'.
*/
double matd_vec_mag(const matd_t *a);
/**
* Calculates the magnitude of the distance between the points represented by
* matrices 'a' and 'b'. Both 'a' and 'b' must be vectors and have the same
* dimension (although one may be a row vector and one may be a column vector).
*/
double matd_vec_dist(const matd_t *a, const matd_t *b);
/**
* Same as matd_vec_dist, but only uses the first 'n' terms to compute distance
*/
double matd_vec_dist_n(const matd_t *a, const matd_t *b, int n);
/**
* Calculates the dot product of two vectors. Both 'a' and 'b' must be vectors
* and have the same dimension (although one may be a row vector and one may be
* a column vector).
*/
double matd_vec_dot_product(const matd_t *a, const matd_t *b);
/**
* Calculates the normalization of the supplied vector 'a' (i.e. a unit vector
* of the same dimension and orientation as 'a' with a magnitude of 1) and returns
* it as a new vector. 'a' must be a vector of any dimension and must have a
* non-zero magnitude. It is the caller's responsibility to call matd_destroy()
* on the returned matrix.
*/
matd_t *matd_vec_normalize(const matd_t *a);
/**
* Calculates the cross product of supplied matrices 'a' and 'b' (i.e. a x b)
* and returns it as a new matrix. Both 'a' and 'b' must be vectors of dimension
* 3, but can be either row or column vectors. It is the caller's responsibility
* to call matd_destroy() on the returned matrix.
*/
matd_t *matd_crossproduct(const matd_t *a, const matd_t *b);
double matd_err_inf(const matd_t *a, const matd_t *b);
/**
* Creates a new matrix by applying a series of matrix operations, as expressed
* in 'expr', to the supplied list of matrices. Each matrix to be operated upon
* must be represented in the expression by a separate matrix placeholder, 'M',
* and there must be one matrix supplied as an argument for each matrix
* placeholder in the expression. All rules and caveats of the corresponding
* matrix operations apply to the operated-on matrices. It is the caller's
* responsibility to call matd_destroy() on the returned matrix.
*
* Available operators (in order of increasing precedence):
* M+M add two matrices together
* M-M subtract one matrix from another
* M*M multiply two matrices together (matrix product)
* MM multiply two matrices together (matrix product)
* -M negate a matrix
* M^-1 take the inverse of a matrix
* M' take the transpose of a matrix
*
* Expressions can be combined together and grouped by enclosing them in
* parenthesis, i.e.:
* -M(M+M+M)-(M*M)^-1
*
* Scalar values can be generated on-the-fly, i.e.:
* M*2.2 scales M by 2.2
* -2+M adds -2 to all elements of M
*
* All whitespace in the expression is ignored.
*/
matd_t *matd_op(const char *expr, ...);
/**
* Frees the memory associated with matrix 'm', being the result of an earlier
* call to a matd_*() function, after which 'm' will no longer be usable.
*/
void matd_destroy(matd_t *m);
typedef struct
{
matd_t *U;
matd_t *S;
matd_t *V;
} matd_svd_t;
/** Compute a complete SVD of a matrix. The SVD exists for all
* matrices. For a matrix MxN, we will have:
*
* A = U*S*V'
*
* where A is MxN, U is MxM (and is an orthonormal basis), S is MxN
* (and is diagonal up to machine precision), and V is NxN (and is an
* orthonormal basis).
*
* The caller is responsible for destroying U, S, and V.
**/
matd_svd_t matd_svd(matd_t *A);
#define MATD_SVD_NO_WARNINGS 1
matd_svd_t matd_svd_flags(matd_t *A, int flags);
////////////////////////////////
// PLU Decomposition
// All square matrices (even singular ones) have a partially-pivoted
// LU decomposition such that A = PLU, where P is a permutation
// matrix, L is a lower triangular matrix, and U is an upper
// triangular matrix.
//
typedef struct
{
// was the input matrix singular? When a zero pivot is found, this
// flag is set to indicate that this has happened.
int singular;
unsigned int *piv; // permutation indices
int pivsign; // either +1 or -1
// The matd_plu_t object returned "owns" the enclosed LU matrix. It
// is not expected that the returned object is itself useful to
// users: it contains the L and U information all smushed
// together.
matd_t *lu; // combined L and U matrices, permuted so they can be triangular.
} matd_plu_t;
matd_plu_t *matd_plu(const matd_t *a);
void matd_plu_destroy(matd_plu_t *mlu);
double matd_plu_det(const matd_plu_t *lu);
matd_t *matd_plu_p(const matd_plu_t *lu);
matd_t *matd_plu_l(const matd_plu_t *lu);
matd_t *matd_plu_u(const matd_plu_t *lu);
matd_t *matd_plu_solve(const matd_plu_t *mlu, const matd_t *b);
// uses LU decomposition internally.
matd_t *matd_solve(matd_t *A, matd_t *b);
////////////////////////////////
// Cholesky Factorization
/**
* Creates a double matrix with the Cholesky lower triangular matrix
* of A. A must be symmetric, positive definite. It is the caller's
* responsibility to call matd_destroy() on the returned matrix.
*/
//matd_t *matd_cholesky(const matd_t *A);
typedef struct
{
int is_spd;
matd_t *u;
} matd_chol_t;
matd_chol_t *matd_chol(matd_t *A);
matd_t *matd_chol_solve(const matd_chol_t *chol, const matd_t *b);
void matd_chol_destroy(matd_chol_t *chol);
// only sensible on PSD matrices
matd_t *matd_chol_inverse(matd_t *a);
void matd_ltransposetriangle_solve(matd_t *u, const double *b, double *x);
void matd_ltriangle_solve(matd_t *u, const double *b, double *x);
void matd_utriangle_solve(matd_t *u, const double *b, double *x);
double matd_max(matd_t *m);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,204 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#define _USE_MATH_DEFINES
#include <math.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
#ifdef __cplusplus
extern "C" {
#endif
#define to_radians(x) ( (x) * (M_PI / 180.0 ))
#define to_degrees(x) ( (x) * (180.0 / M_PI ))
/* DEPRECATE, threshold meaningless without context.
static inline int dequals(double a, double b)
{
double thresh = 1e-9;
return (fabs(a-b) < thresh);
}
*/
static inline int dequals_mag(double a, double b, double thresh)
{
return (fabs(a-b) < thresh);
}
static inline int isq(int v)
{
return v*v;
}
static inline float fsq(float v)
{
return v*v;
}
static inline double sq(double v)
{
return v*v;
}
static inline double sgn(double v)
{
return (v>=0) ? 1 : -1;
}
// random number between [0, 1)
static inline float randf(void)
{
return (float)(rand() / (RAND_MAX + 1.0));
}
static inline float signed_randf(void)
{
return randf()*2 - 1;
}
// return a random integer between [0, bound)
static inline int irand(int bound)
{
int v = (int) (randf()*bound);
if (v == bound)
return (bound-1);
//assert(v >= 0);
//assert(v < bound);
return v;
}
/** Map vin to [0, 2*PI) **/
static inline double mod2pi_positive(double vin)
{
return vin - M_2_PI * floor(vin / M_2_PI);
}
/** Map vin to [-PI, PI) **/
static inline double mod2pi(double vin)
{
return mod2pi_positive(vin + M_PI) - M_PI;
}
/** Return vin such that it is within PI degrees of ref **/
static inline double mod2pi_ref(double ref, double vin)
{
return ref + mod2pi(vin - ref);
}
/** Map vin to [0, 360) **/
static inline double mod360_positive(double vin)
{
return vin - 360 * floor(vin / 360);
}
/** Map vin to [-180, 180) **/
static inline double mod360(double vin)
{
return mod360_positive(vin + 180) - 180;
}
static inline int mod_positive(int vin, int mod) {
return (vin % mod + mod) % mod;
}
static inline int theta_to_int(double theta, int max)
{
theta = mod2pi_ref(M_PI, theta);
int v = (int) (theta / M_2_PI * max);
if (v == max)
v = 0;
assert (v >= 0 && v < max);
return v;
}
static inline int imin(int a, int b)
{
return (a < b) ? a : b;
}
static inline int imax(int a, int b)
{
return (a > b) ? a : b;
}
static inline int64_t imin64(int64_t a, int64_t b)
{
return (a < b) ? a : b;
}
static inline int64_t imax64(int64_t a, int64_t b)
{
return (a > b) ? a : b;
}
static inline int iclamp(int v, int minv, int maxv)
{
return imax(minv, imin(v, maxv));
}
static inline double dclamp(double a, double min, double max)
{
if (a < min)
return min;
if (a > max)
return max;
return a;
}
static inline int fltcmp (float f1, float f2)
{
float epsilon = f1-f2;
if (epsilon < 0.0)
return -1;
else if (epsilon > 0.0)
return 1;
else
return 0;
}
static inline int dblcmp (double d1, double d2)
{
double epsilon = d1-d2;
if (epsilon < 0.0)
return -1;
else if (epsilon > 0.0)
return 1;
else
return 0;
}
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,54 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <stdint.h>
enum { PAM_GRAYSCALE_ALPHA = 5000, PAM_RGB_ALPHA, PAM_RGB, PAM_GRAYSCALE };
typedef struct pam pam_t;
struct pam
{
int type; // one of PAM_*
int width, height; // note, stride always width.
int depth; // bytes per pixel
int maxval; // maximum value per channel, e.g. 255 for 8bpp
size_t datalen; // in bytes
uint8_t *data;
};
pam_t *pam_create_from_file(const char *inpath);
int pam_write_file(pam_t *pam, const char *outpath);
void pam_destroy(pam_t *pam);
pam_t *pam_copy(pam_t *pam);
// NB doesn't handle many conversions yet.
pam_t *pam_convert(pam_t *in, int type);

View File

@@ -0,0 +1,103 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include "image_u8.h"
#include "image_u8x3.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct pjpeg_component pjpeg_component_t;
struct pjpeg_component
{
// resolution of this component (which is smaller than the
// dimensions of the image if the channel has been sub-sampled.)
uint32_t width, height;
// number of bytes per row. May be larger than width for alignment
// reasons.
uint32_t stride;
// data[y*stride + x]
uint8_t *data;
////////////////////////////////////////////////////////////////
// These items probably not of great interest to most
// applications.
uint8_t id; // the identifier associated with this component
uint8_t hv; // horiz scale (high 4 bits) / vert scale (low 4 bits)
uint8_t scalex, scaley; // derived from hv above
uint8_t tq; // quantization table index
// this filled in at the last moment by SOS
uint8_t tda; // which huff tables will we use for DC (high 4 bits) and AC (low 4 bits)
};
typedef struct pjpeg pjpeg_t;
struct pjpeg
{
// status of the decode is put here. Non-zero means error.
int error;
uint32_t width, height; // pixel dimensions
int ncomponents;
pjpeg_component_t *components;
};
enum PJPEG_FLAGS {
PJPEG_STRICT = 1, // Don't try to recover from errors.
PJPEG_MJPEG = 2, // Support JPGs with missing DHT segments.
};
enum PJPEG_ERROR {
PJPEG_OKAY = 0,
PJPEG_ERR_FILE, // something wrong reading file
PJPEG_ERR_DQT, // something wrong with DQT marker
PJPEG_ERR_SOF, // something wrong with SOF marker
PJPEG_ERR_DHT, // something wrong with DHT marker
PJPEG_ERR_SOS, // something wrong with SOS marker
PJPEG_ERR_MISSING_DHT, // missing a necessary huffman table
PJPEG_ERR_DRI, // something wrong with DRI marker
PJPEG_ERR_RESET, // didn't get a reset marker where we expected. Corruption?
PJPEG_ERR_EOF, // ran out of bytes while decoding
PJEPG_ERR_UNSUPPORTED, // an unsupported format
};
pjpeg_t *pjpeg_create_from_file(const char *path, uint32_t flags, int *error);
pjpeg_t *pjpeg_create_from_buffer(uint8_t *buf, int buflen, uint32_t flags, int *error);
void pjpeg_destroy(pjpeg_t *pj);
image_u8_t *pjpeg_to_u8_baseline(pjpeg_t *pj);
image_u8x3_t *pjpeg_to_u8x3_baseline(pjpeg_t *pj);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,58 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#define PNM_FORMAT_BINARY 4
#define PNM_FORMAT_GRAY 5
#define PNM_FORMAT_RGB 6
// supports ppm, pnm, pgm
typedef struct pnm pnm_t;
struct pnm
{
int width, height;
int format;
int max; // 1 = binary, 255 = one byte, 65535 = two bytes
uint32_t buflen;
uint8_t *buf; // if max=65535, in big endian
};
pnm_t *pnm_create_from_file(const char *path);
void pnm_destroy(pnm_t *pnm);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,82 @@
/**
Copyright John Schember <john@nachtimwald.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef __CPTHREAD_H__
#define __CPTHREAD_H__
#ifdef _WIN32
#include <stdbool.h>
#include <windows.h>
#else
#include <pthread.h>
#include <sched.h>
#endif
#include <time.h>
#ifdef _WIN32
typedef CRITICAL_SECTION pthread_mutex_t;
typedef void pthread_mutexattr_t;
typedef void pthread_attr_t;
typedef void pthread_condattr_t;
typedef void pthread_rwlockattr_t;
typedef HANDLE pthread_t;
typedef CONDITION_VARIABLE pthread_cond_t;
#ifdef __cplusplus
extern "C" {
#endif
int pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg);
int pthread_join(pthread_t thread, void **value_ptr);
int pthread_detach(pthread_t);
int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutexattr_t *attr);
int pthread_mutex_destroy(pthread_mutex_t *mutex);
int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
int pthread_cond_init(pthread_cond_t *cond, pthread_condattr_t *attr);
int pthread_cond_destroy(pthread_cond_t *cond);
int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime);
int pthread_cond_signal(pthread_cond_t *cond);
int pthread_cond_broadcast(pthread_cond_t *cond);
int sched_yield(void);
#ifdef __cplusplus
}
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
unsigned int pcthread_get_num_procs(void);
void ms_to_timespec(struct timespec *ts, unsigned int ms);
unsigned int timespec_to_ms(const struct timespec *abstime);
#ifdef __cplusplus
}
#endif
#endif /* __CPTHREAD_H__ */

View File

@@ -0,0 +1,465 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
#include <stdio.h>
#include <stdarg.h>
#include <stdbool.h>
#include <ctype.h>
#include "zarray.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct string_buffer string_buffer_t;
typedef struct string_feeder string_feeder_t;
struct string_feeder
{
char *s;
size_t len;
size_t pos;
int line, col;
};
/**
* Similar to sprintf(), except that it will malloc() enough space for the
* formatted string which it returns. It is the caller's responsibility to call
* free() on the returned string when it is no longer needed.
*/
char *sprintf_alloc(const char *fmt, ...)
#ifndef _MSC_VER
__attribute__ ((format (printf, 1, 2)))
#endif
;
/**
* Similar to vsprintf(), except that it will malloc() enough space for the
* formatted string which it returns. It is the caller's responsibility to call
* free() on the returned string when it is no longer needed.
*/
char *vsprintf_alloc(const char *fmt, va_list args);
/**
* Concatenates 1 or more strings together and returns the result, which will be a
* newly allocated string which it is the caller's responsibility to free.
*/
#define str_concat(...) _str_concat_private(__VA_ARGS__, NULL)
char *_str_concat_private(const char *first, ...);
// Returns the index of the first character that differs:
int str_diff_idx(const char * a, const char * b);
/**
* Splits the supplied string into an array of strings by subdividing it at
* each occurrence of the supplied delimiter string. The split strings will not
* contain the delimiter. The original string will remain unchanged.
* If str is composed of all delimiters, an empty array will be returned.
*
* It is the caller's responsibility to free the returned zarray, as well as
* the strings contained within it, e.g.:
*
* zarray_t *za = str_split("this is a haystack", " ");
* => ["this", "is", "a", "haystack"]
* zarray_vmap(za, free);
* zarray_destroy(za);
*/
zarray_t *str_split(const char *str, const char *delim);
zarray_t *str_split_spaces(const char *str);
void str_split_destroy(zarray_t *s);
/*
* Determines if str1 exactly matches str2 (more efficient than strcmp(...) == 0)
*/
static inline bool streq(const char *str1, const char* str2)
{
int i;
for (i = 0 ; str1[i] != '\0' ; i++) {
if (str1[i] != str2[i])
return false;
}
return str2[i] == '\0';
}
/**
* Determines if str1 exactly matches str2, ignoring case (more efficient than
* strcasecmp(...) == 0)
*/
static inline bool strcaseeq(const char *str1, const char* str2)
{
int i;
for (i = 0 ; str1[i] != '\0' ; i++) {
if (str1[i] == str2[i])
continue;
else if (islower(str1[i]) && (str1[i] - 32) == str2[i])
continue;
else if (isupper(str1[i]) && (str1[i] + 32) == str2[i])
continue;
return false;
}
return str2[i] == '\0';
}
/**
* Trims whitespace characters (i.e. matching isspace()) from the beginning and/or
* end of the supplied string. This change affects the supplied string in-place.
* The supplied/edited string is returned to enable chained reference.
*
* Note: do not pass a string literal to this function
*/
char *str_trim(char *str);
/**
* Trims whitespace characters (i.e. matching isspace()) from the beginning
* of the supplied string. This change affects the supplied string in-place.
* The supplied/edited string is returned to enable chained reference.
*
* Note: do not pass a string literal to this function
*/
char *str_lstrip(char *str);
/**
* Trims whitespace characters (i.e. matching isspace()) from the end of the
* supplied string. This change affects the supplied string in-place.
* The supplied/edited string is returned to enable chained reference.
*
* Note: do not pass a string literal to this function
*/
char *str_rstrip(char *str);
/**
* Returns true if the end of string 'haystack' matches 'needle', else false.
*
* Note: An empty needle ("") will match any source.
*/
bool str_ends_with(const char *haystack, const char *needle);
/**
* Returns true if the start of string 'haystack' matches 'needle', else false.
*
* Note: An empty needle ("") will match any source.
*/
bool str_starts_with(const char *haystack, const char *needle);
/**
* Returns true if the start of string 'haystack' matches any needle, else false.
*
* Note: An empty needle ("") will match any source.
*/
bool str_starts_with_any(const char *haystack, const char **needles, int num_needles);
/**
* Returns true if the string 'haystack' matches any needle, else false.
*/
bool str_matches_any(const char *haystack, const char **needles, int num_needles);
/**
* Retrieves a (newly-allocated) substring of the given string, 'str', starting
* from character index 'startidx' through index 'endidx' - 1 (inclusive).
* An 'endidx' value -1 is equivalent to strlen(str).
*
* It is the caller's responsibility to free the returned string.
*
* Examples:
* str_substring("string", 1, 3) = "tr"
* str_substring("string", 2, -1) = "ring"
* str_substring("string", 3, 3) = ""
*
* Note: startidx must be >= endidx
*/
char *str_substring(const char *str, size_t startidx, size_t endidx);
/**
* Retrieves the zero-based index of the beginning of the supplied substring
* (needle) within the search string (haystack) if it exists.
*
* Returns -1 if the supplied needle is not found within the haystack.
*/
int str_indexof(const char *haystack, const char *needle);
static inline int str_contains(const char *haystack, const char *needle) {
return str_indexof(haystack, needle) >= 0;
}
// same as above, but returns last match
int str_last_indexof(const char *haystack, const char *needle);
/**
* Replaces all upper-case characters within the supplied string with their
* lower-case counterparts, modifying the original string's contents.
*
* Returns the supplied / modified string.
*/
char *str_tolowercase(char *s);
/**
* Replaces all lower-case characters within the supplied string with their
* upper-case counterparts, modifying the original string's contents.
*
* Returns the supplied / modified string.
*/
char *str_touppercase(char *s);
/**
* Replaces all occurrences of 'needle' in the string 'haystack', substituting
* for them the value of 'replacement', and returns the result as a newly-allocated
* string. The original strings remain unchanged.
*
* It is the caller's responsibility to free the returned string.
*
* Examples:
* str_replace("string", "ri", "u") = "stung"
* str_replace("singing", "ing", "") = "s"
* str_replace("string", "foo", "bar") = "string"
*
* Note: An empty needle will match only an empty haystack
*/
char *str_replace(const char *haystack, const char *needle, const char *replacement);
char *str_replace_many(const char *_haystack, ...);
//////////////////////////////////////////////////////
// String Buffer
/**
* Creates and initializes a string buffer object which can be used with any of
* the string_buffer_*() functions.
*
* It is the caller's responsibility to free the string buffer resources with
* a call to string_buffer_destroy() when it is no longer needed.
*/
string_buffer_t *string_buffer_create(void);
/**
* Frees the resources associated with a string buffer object, including space
* allocated for any appended characters / strings.
*/
void string_buffer_destroy(string_buffer_t *sb);
/**
* Appends a single character to the end of the supplied string buffer.
*/
void string_buffer_append(string_buffer_t *sb, char c);
/**
* Removes a single character from the end of the string and
* returns it. Does nothing if string is empty and returns NULL
*/
char string_buffer_pop_back(string_buffer_t *sb);
/**
* Appends the supplied string to the end of the supplied string buffer.
*/
void string_buffer_append_string(string_buffer_t *sb, const char *str);
/**
* Formats the supplied string and arguments in a manner akin to printf(), and
* appends the resulting string to the end of the supplied string buffer.
*/
void string_buffer_appendf(string_buffer_t *sb, const char *fmt, ...)
#ifndef _MSC_VER
__attribute__ ((format (printf, 2, 3)))
#endif
;
/**
* Determines whether the character contents held by the supplied string buffer
* ends with the supplied string.
*
* Returns true if the string buffer's contents ends with 'str', else false.
*/
bool string_buffer_ends_with(string_buffer_t *sb, const char *str);
/**
* Returns the string-length of the contents of the string buffer (not counting \0).
* Equivalent to calling strlen() on the string returned by string_buffer_to_string(sb).
*/
size_t string_buffer_size(string_buffer_t *sb);
/**
* Returns the contents of the string buffer in a newly-allocated string, which
* it is the caller's responsibility to free once it is no longer needed.
*/
char *string_buffer_to_string(string_buffer_t *sb);
/**
* Clears the contents of the string buffer, setting its length to zero.
*/
void string_buffer_reset(string_buffer_t *sb);
//////////////////////////////////////////////////////
// String Feeder
/**
* Creates a string feeder object which can be used to traverse the supplied
* string using the string_feeder_*() functions. A local copy of the string's
* contents will be stored so that future changes to 'str' will not be
* reflected by the string feeder object.
*
* It is the caller's responsibility to call string_feeder_destroy() on the
* returned object when it is no longer needed.
*/
string_feeder_t *string_feeder_create(const char *str);
/**
* Frees resources associated with the supplied string feeder object, after
* which it will no longer be valid for use.
*/
void string_feeder_destroy(string_feeder_t *sf);
/**
* Determines whether any characters remain to be retrieved from the string
* feeder's string (not including the terminating '\0').
*
* Returns true if at least one more character can be retrieved with calls to
* string_feeder_next(), string_feeder_peek(), string_feeder_peek(), or
* string_feeder_consume(), else false.
*/
bool string_feeder_has_next(string_feeder_t *sf);
/**
* Retrieves the next available character from the supplied string feeder
* (which may be the terminating '\0' character) and advances the feeder's
* position to the next character in the string.
*
* Note: Attempts to read past the end of the string will throw an assertion.
*/
char string_feeder_next(string_feeder_t *sf);
/**
* Retrieves a series of characters from the supplied string feeder. The number
* of characters returned will be 'length' or the number of characters
* remaining in the string, whichever is shorter. The string feeder's position
* will be advanced by the number of characters returned.
*
* It is the caller's responsibility to free the returned string when it is no
* longer needed.
*
* Note: Calling once the end of the string has already been read will throw an assertion.
*/
char *string_feeder_next_length(string_feeder_t *sf, size_t length);
/**
* Retrieves the next available character from the supplied string feeder
* (which may be the terminating '\0' character), but does not advance
* the feeder's position so that subsequent calls to _next() or _peek() will
* retrieve the same character.
*
* Note: Attempts to peek past the end of the string will throw an assertion.
*/
char string_feeder_peek(string_feeder_t *sf);
/**
* Retrieves a series of characters from the supplied string feeder. The number
* of characters returned will be 'length' or the number of characters
* remaining in the string, whichever is shorter. The string feeder's position
* will not be advanced.
*
* It is the caller's responsibility to free the returned string when it is no
* longer needed.
*
* Note: Calling once the end of the string has already been read will throw an assertion.
*/
char *string_feeder_peek_length(string_feeder_t *sf, size_t length);
/**
* Retrieves the line number of the current position in the supplied
* string feeder, which will be incremented whenever a newline is consumed.
*
* Examples:
* prior to reading 1st character: line = 1, column = 0
* after reading 1st non-newline character: line = 1, column = 1
* after reading 2nd non-newline character: line = 1, column = 2
* after reading 1st newline character: line = 2, column = 0
* after reading 1st character after 1st newline: line = 2, column = 1
* after reading 2nd newline character: line = 3, column = 0
*/
int string_feeder_get_line(string_feeder_t *sf);
/**
* Retrieves the column index in the current line for the current position
* in the supplied string feeder, which will be incremented with each
* non-newline character consumed, and reset to 0 whenever a newline (\n) is
* consumed.
*
* Examples:
* prior to reading 1st character: line = 1, column = 0
* after reading 1st non-newline character: line = 1, column = 1
* after reading 2nd non-newline character: line = 1, column = 2
* after reading 1st newline character: line = 2, column = 0
* after reading 1st character after 1st newline: line = 2, column = 1
* after reading 2nd newline character: line = 3, column = 0
*/
int string_feeder_get_column(string_feeder_t *sf);
/**
* Determines whether the supplied string feeder's remaining contents starts
* with the given string.
*
* Returns true if the beginning of the string feeder's remaining contents matches
* the supplied string exactly, else false.
*/
bool string_feeder_starts_with(string_feeder_t *sf, const char *str);
/**
* Consumes from the string feeder the number of characters contained in the
* given string (not including the terminating '\0').
*
* Throws an assertion if the consumed characters do not exactly match the
* contents of the supplied string.
*/
void string_feeder_require(string_feeder_t *sf, const char *str);
/*#ifndef strdup
static inline char *strdup(const char *s) {
int len = strlen(s);
char *out = malloc(len+1);
memcpy(out, s, len + 1);
return out;
}
#endif
*/
// find everything that looks like an env variable and expand it
// using getenv. Caller should free the result.
// e.g. "$HOME/abc" ==> "/home/ebolson/abc"
char *str_expand_envs(const char *in);
#ifdef __cplusplus
}
#endif

View File

@@ -0,0 +1,34 @@
/* Copyright (C) 2013-2016, The Regents of The University of Michigan.
All rights reserved.
This software was developed in the APRIL Robotics Lab under the
direction of Edwin Olson, ebolson@umich.edu. This software may be
available under alternative licensing terms; contact the address above.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the Regents of The University of Michigan.
*/
#pragma once
void svd22(const double A[4], double U[4], double S[2], double V[4]);
// for the matrix [a b; b d]
void svd_sym_singular_values(double A00, double A01, double A11,
double *Lmin, double *Lmax);

Some files were not shown because too many files have changed in this diff Show More