Compare commits

...

137 Commits

Author SHA1 Message Date
Peter Johnson
90cfa00115 [build] cmake: Fix libssh include directory order (#4459)
This broke the build if the directory where libssh was installed also
contained a system libuv install.
2022-10-07 22:53:22 -07:00
Starlight220
5cf961edb9 [commands] Refactor lambda-based commands to inherit FunctionalCommand (#4451) 2022-10-06 17:49:27 -05:00
Starlight220
b2276e47de [wpimath] Enable continuous angle input for HolonomicDriveController (#4453) 2022-10-06 17:46:22 -05:00
PJ Reiniger
893b46139a [fieldImages] Add utilities to simplify loading of fields (#4456) 2022-10-06 17:45:07 -05:00
Starlight220
60e29627c0 [commands] C++ unique_ptr migration (#4319)
Add a CommandPtr with an internal unique_ptr to enable not needing to move the underlying classes, which is error-prone due to the potential for lambda captures.
2022-10-05 17:19:28 -05:00
Starlight220
3b81cf6c35 [wpilib] Improve Color.toString (#4450) 2022-10-04 14:36:51 -05:00
Peter Johnson
5c067d30a0 [wpinet] WebSocket: Add SendFrames() (#4445) 2022-10-03 08:04:08 -05:00
Peter Johnson
ceaf493811 [wpiutil] MakeJByteArray: Use span<uint8> instead of string_view (#4446) 2022-10-02 08:28:50 -05:00
Starlight220
10e04e2b13 [examples] FrisbeeBot: Fix reference capture (#4449)
The parameter should be passed by value.
2022-10-02 08:18:43 -05:00
Peter Johnson
726f67c64b [build] Add exeSplitSetup (#4444) 2022-10-02 08:13:08 -05:00
Peter Johnson
c7b7624c1c [wpiutil] Add MessagePack utility functions (#4448)
Also add mpack to srcDirs.
2022-10-02 08:11:42 -05:00
Peter Johnson
d600529ec0 [wpinet] uv::Async: Add UnsafeSend() (#4447)
This version assumes the loop still exists, avoiding some overhead.
2022-10-02 08:10:54 -05:00
Tyler Veness
b53b3526a2 [wpimath] Add CoordinateSystem conversion for Transform3d (#4443)
I also refactored Pose3d's conversion implementation to use the
Translation3d and Rotation3d conversions, thereby giving Translation3d
and Rotation3d test coverage. No changes were made to the expected
values of the Pose3d conversion tests.

The expected values of the Transform3d conversion tests were copied from
the Pose3d conversion tests without modification.
2022-10-01 21:09:04 -07:00
Tyler Veness
38bb23eb18 [wpimath] Add scalar multiply and divide operators to all geometry classes (#4438)
Closes #4435.
2022-09-28 21:34:29 -07:00
Tyler Veness
3937ff8221 [wpilib] Remove deprecated Controller class (#4440)
Now that old command-based has been removed, this base class can be
removed too.
2022-09-28 21:33:55 -07:00
Oliver W
abbfe244b5 [wpilib] Improve Color FromHSV (#4439) 2022-09-28 21:33:33 -07:00
Dustin Spicuzza
4ddb8aa0dd [sim] Provide function that resets all simulation data (#4016)
Fixes #3867
2022-09-26 14:38:38 -07:00
Tyler Veness
a791470de7 Clean up Java warning suppressions (#4433)
Checkstyle naming conventions were changed to allow most of what's in
wpimath. Naming rules were disabled completely in wpimath since almost
all suppressions are for math notation.
2022-09-24 00:13:55 -07:00
Thad House
17f504f548 [hal,wpilib] Fix SPI Mode Setting (#4434)
SPI Mode setting was very broken. MSB and LSB sets did not work (MSB is the only one supported)
and if LSB was set (which was the default) the ioct to set clock phase would fail. This
deprecates all the individual functions, the LSB/MSB functions, and adds an SPI mode selection
function. This is usually more understandable, and shows up in a lot more documentation
2022-09-24 00:11:37 -07:00
Tyler Veness
773198537c [wpiutil] Add wpi::scope_exit (#4432)
This is based on std::scope_exit in the C++ library fundamentals TS v3.
2022-09-23 14:48:59 -07:00
Peter Johnson
5ac658c8f0 [wpiutil] Logger: Conditionalize around WPI_LOG (#4431)
The FMT_STRING() call used in the macro does formatter initialization,
overhead that's not required if Log() is not going to be called.
2022-09-22 23:14:46 -07:00
Peter Johnson
8767e4a941 [wpiutil] DataLog: Fix SetMetadata output (#4430) 2022-09-22 21:54:55 -07:00
Peter Johnson
8c4af073f4 [wpiutil] Synchronization: shutdown race protection (#4429) 2022-09-22 21:53:51 -07:00
Thad House
c79f38584a [build] Fix Java integration tests (#4428)
The new jni libraries for the libraries were never added, so they never get deployed.
2022-09-21 23:15:35 -07:00
Starlight220
36c08dd97c [build] Fix cmake install of fmtlib (#4426) 2022-09-20 09:48:44 -07:00
Peter Johnson
69b7b3dd7d [ci] Remove the Windows cmake job (#4425)
This currently is running into space issues due to vcpkg that are
difficult to fix.
2022-09-18 18:24:55 -07:00
Ryan Blue
738c75fed8 [readme] Fix formatting/linting link (#4423) 2022-09-18 15:12:28 -07:00
Tyler Veness
4eb1d03fb3 [wpimath] Document C++ LinearFilter exception (#4417) 2022-09-17 00:24:35 -07:00
Tyler Veness
ba4ec6c967 [build] Fix clang-tidy false positive on Linux (#4406)
* Fix clang-tidy false positive on Linux

```
== clang-tidy /home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp ==
/home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp:12:33: error: expected class name [clang-diagnostic-error]
class StackTraceWalker : public StackWalker {
                                ^
/home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp:16:17: error: unknown type name 'LPCTSTR' [clang-diagnostic-error]
  void OnOutput(LPCTSTR szText) override;
                ^
/home/tav/frc/wpilib/allwpilib/wpiutil/src/main/native/windows/StackTrace.cpp:23:33: error: unknown type name 'LPCTSTR' [clang-diagnostic-error]
void StackTraceWalker::OnOutput(LPCTSTR szText) {
                                ^
```

* Fix false positives for macOS code
2022-09-17 00:23:59 -07:00
Ryan Blue
97836f0e55 [commands] Fix ProfiledPIDSubsystem setGoal behavior (#4414)
Remove m_goal from ProfiledPIDSubsystem

Delegate setGoal to backing controller
2022-09-17 00:22:45 -07:00
Tyler Veness
fdfb85f695 [wpimath] Remove Java LQR constructor that takes a controller gain matrix (#4419)
The controller gain matrix K should be computed from the solution to the
DARE, but this constructor does not do that. It effectively violates a
postcondition enforced by the other constructors by letting the user
throw in a controller gain matrix that didn't come from an LQR.

Removing this constructor is a breaking change, but it never should have
been included in the class in the first place. There's also no valid
reason to use it. I assume it was originally added for debugging the
class internals.

This constructor does not exist in C++.
2022-09-17 00:18:08 -07:00
Tyler Veness
ab1baf4832 [wpimath] Add rotation matrix constructor to Rotation3d (#4413) 2022-09-17 00:17:30 -07:00
Tyler Veness
9730032866 [wpimath] Document LQR and KalmanFilter exceptions (#4418) 2022-09-17 00:16:40 -07:00
Brandon Parsons
5b656eecf6 [wpimath] Fix HTML5 entity (#4420)
Replace &top; with \u22a4, since Unicode references are supported
but HTML5 entities are not. Should be fixed if JDK is ever
moved forward.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2022-09-17 00:15:40 -07:00
Starlight220
9ae38eaa7c [commands] Add owning overload to ProxyScheduleCommand (#4405) 2022-09-13 18:33:19 -07:00
Starlight220
cb33bd71df [commands] deprecate withInterrupt decorator (#4407)
until() was recently added as a more intuitive alias for this. At this point, keeping this decorator will just cause confusion, given the functionally-equivalent until() alias and the similarly-named getInterruptionBehavior/withInterruptBehavior
2022-09-11 10:37:55 -07:00
Starlight220
d9b4e7b8bf [commands] Revert "Change grouping decorator impl to flatten nested group structures (#3335)" (#4402)
This reverts commit ef4ea84cb5.
2022-09-07 09:04:21 -07:00
T Grinch
0389bf5214 [hal] REVPH: Improve handling of disconnected CAN Bus (#4169)
Force the status to be 0 (no error) upon initialization of the REV PneumaticHub.
This prevents a program crash in the case of a robot code restart with no CAN Bus present.
2022-09-07 09:01:55 -07:00
T Grinch
4267fa08d1 [wpilibc] ADIS IMUs: Fix memory leak (#4170) 2022-09-06 13:10:33 -07:00
Peter Johnson
65c8fbd452 [wpilib] MotorControllerGroup: Override setVoltage (#4403)
This causes setVoltage to be called on the lower level motor contollers,
which is benefical in cases when they are smart motor controllers.
Previously, the default implementation (using the bus voltage and
calling set()) was used in this case.

This does slightly pessimize the case when the lower level motor
controllers use the default setVoltage implementation, but given the
prevalence of smart motor controllers, this seems like an overall win.
2022-09-06 08:18:33 -07:00
Tyler Veness
f36162fddc [wpimath] Improve Discretization internal docs (#4400) 2022-09-04 17:24:38 -07:00
Tyler Veness
5149f7d894 [wpimath] Add two-vector Rotation3d constructor (#4398)
This is useful for turning a 3D vector into an orientation relative a
coordinate system vector.
2022-09-04 13:16:29 -07:00
Tyler Veness
20b5bed1cb [wpimath] Clean up Java Quaternion class (#4399)
Vector.norm() and Vector.dot() were added to make the implementation
simpler and match the C++ version more closely.
2022-09-04 09:45:02 -07:00
Peter Johnson
f18dd1905d [build] Include all thirdparty sources in distribution (#4397)
Was missing several.
2022-09-03 09:23:51 -07:00
Peter Johnson
aa9d7f1cdc [wpiutil] Import foonathan memory (#4306) 2022-09-02 20:32:21 -07:00
Peter Johnson
2742662254 [ci] Remove a couple of obsolete clang-tidy checks (#4396)
We no longer use LLVM StringRef or Twine.
2022-09-02 20:31:27 -07:00
Thad House
a5df391166 [hal, wpilib] Fix up DIO pulse API (#4387)
The FPGA API takes microseconds directly, instead of a scaled value. Also add a new HAL level API to trigger multiple DIOs with the same pulse at once.
2022-09-02 16:49:42 -07:00
Peter Johnson
59e6706b75 [glass] Turn on docking by default
This uses a full-viewport dockspace and shift to enable docking.
2022-09-02 15:43:54 -07:00
Peter Johnson
8461bb1e03 [glass] Add support for saving docking info 2022-09-02 15:43:54 -07:00
Peter Johnson
b873e208b4 [wpigui] Add support for imgui config flags 2022-09-02 15:43:54 -07:00
Peter Johnson
873e72df8c [build] Update imgui to 1.88 docking branch 2022-09-02 15:43:54 -07:00
Peter Johnson
c8bd6fc5b4 [ci] Fix comment-command (take 2) (#4395) 2022-09-02 08:51:07 -07:00
Peter Johnson
fed68b83b4 [ci] Fix comment-command action not running runners (#4393)
Triggering runners from a push from a runner requires use of a PAT.
https://stackoverflow.com/questions/67550727/push-event-doesnt-trigger-workflow-on-push-paths-github-actions
2022-09-02 08:16:31 -07:00
Tyler Veness
0ef8a4e1df [wpimath] Support formatting more Eigen types (#4391)
Added an Eigen::SparseMatrix formatter.

Also modified the Eigen::Matrix formatter to support Eigen::MatrixXd.
Eigen::MatrixXd sets both dimension template arguments to -1, so they
can't be used for iteration. rows() and cols() are now used instead.

rows() and cols() are constexpr for statically sized matrices, so
there's no performance loss there.
2022-09-02 01:00:05 -07:00
Thad House
c393b3b367 [build] Update to native utils 2023.1.0 and Gradle 7.5.1 (#4392) 2022-09-02 00:59:47 -07:00
ohowe
b5a17f762c [wpimath] Add direction to slew rate limiter (#4377) 2022-09-01 14:46:46 -07:00
Tyler Veness
fafc81ed1a [wpiutil] Upgrade to fmt 9.1.0 (#4389) 2022-09-01 14:45:18 -07:00
Peter Johnson
cc56bdc787 [wpiutil] SafeThread: Add Synchronization object variant (#4382)
This enables use of SafeThread with Synchronization's WaitForObjects() blocking.
2022-08-31 11:29:57 -07:00
Starlight220
4254438d8d [commands] Mark command group lifecycle methods as final (#4385)
This prevents accidental footguns due to overriding of command group lifecycle methods.
2022-08-31 09:15:28 -07:00
CarloWoolsey
97c15af238 [wpimath] LinearSystemId: Fix docs, move C++ impls out of header (#4388)
- Fix inaccuracies and inconsistencies in Java & C++ LinearSystemId documentation.
- Move LinearSystemId function definitions to LinearSystemId.cpp
2022-08-31 09:12:48 -07:00
Peter Johnson
d22ff8a158 [wpiutil] Add JNI access to C++ stderr (#4381)
This is useful in some debugging scenarios.  System.err is separately buffered, so when e.g. debugging test cases it doesn't interleave correctly with the C++ stdout/stderr logging. Even using flush() doesn't seem to help, I think because Gradle does its own buffering.
2022-08-30 20:40:16 -07:00
Peter Johnson
fdb5a2791f [wpiutil] jni_util: Add Mac-friendly MakeJLongArray/JArrayRef (#4383)
Mac has jlong == long long and int64_t = long, so the types are
incompatible despite being the same size.
2022-08-30 20:39:42 -07:00
Starlight220
c3a93fb995 [commands] Revamp Interruptible (#4192) 2022-08-29 21:53:47 -07:00
OmegaMetor
f2a8d38d2a [commands] Rename Command.repeat to repeatedly (#4379) 2022-08-29 15:20:17 -07:00
Peter Johnson
9e24c6eac0 [wpiutil] Logger: paren-protect instance usage in macro (#4384) 2022-08-29 13:25:53 -07:00
Tyler Veness
fe4d12ce22 [wpimath] Add LTV controller derivations and make enums private (#4380)
The LTV differential drive controller derivation wasn't included inline
because it's too long.
2022-08-28 23:04:52 -07:00
Brandon Parsons
eb08486039 [build] Fix MacOS binary rpath generation (#4376)
For RPATH on MacOS use '@loader_path' instead of '$ORIGIN' to reference the directory where the executable is located. The latter is the mechanism used on Linux.

I think this was exposed due to newer OS X ignoring $DYLD_LIBRARY_PATH for security reasons.
2022-08-25 18:17:16 -07:00
Tyler Veness
ccf83c634a [build] Use native-utils platform names instead of raw strings (#4375) 2022-08-25 12:54:11 -07:00
Peter Johnson
3fd69749e7 [docs] Upgrade to doxygen 1.9.4 (#4370)
Doxygen 1.9.2 requires libclang-9, which is no longer available on
Ubuntu 22.04.
2022-08-21 18:49:04 -07:00
Peter Johnson
594df5fc08 [wpinet] uv/util.h: Pull in ws2_32.lib on Windows for ntohs (#4371) 2022-08-21 18:48:49 -07:00
Tyler Veness
539070820d [ci] Enable asan for wpinet and wpiutil (#4369) 2022-08-21 14:59:07 -07:00
Peter Johnson
564a56d99b [wpinet] Fix memory leak in WorkerThreadTest (#4368) 2022-08-21 10:29:31 -07:00
Tyler Veness
5adf50d93c [upstream_utils] Refactor upstream_utils scripts (#4367)
* Root folder variable names are now more descriptive
* clone_repo() now restores the current working directory
* Removed setup_upstream_repo() since it's now identical to clone_repo()
* Moved am_patches()'s for loop into user scripts so the filename prefix
  doesn't need to be included in every patch filename
* Renamed am_patches() to git_am() since its only job now is to run "git am"
* Removed unused apply_patches() function
* Fixed typo in git_am()'s ignore_whitespace arg name
2022-08-20 07:26:34 -07:00
Tyler Veness
d80e8039d7 [wpiutil] Suppress fmtlib clang-tidy warning in C++20 consteval contexts (#4364) 2022-08-19 23:52:19 -07:00
Tyler Veness
0e6d67b23b [upstream_utils] Remove yapf format disable comment (#4366) 2022-08-19 23:51:57 -07:00
Tyler Veness
be5270697a [build] Suppress enum-enum deprecation warning in OpenCV (#4365) 2022-08-19 23:51:43 -07:00
Tyler Veness
8d28851263 Add Rosetta install command to build requirements (#4363) 2022-08-18 19:58:43 -07:00
Tyler Veness
3d2115c93e [wpinet] include-what-you-use in MulticastTest (#4360)
This fixes an MSVC compilation error with C++20.
2022-08-18 14:03:55 -07:00
Tyler Veness
91002ae3cc [wpimath] Upgrade to Drake 1.6.0 (#4361) 2022-08-18 14:03:28 -07:00
Tyler Veness
148c18e658 [wpinet] Upgrade to libuv 1.44.2 (#4362) 2022-08-18 13:57:49 -07:00
Tyler Veness
a2a5c926b6 Fix clang-tidy warnings (#4359)
The warnings included recommendations of braces for if statement
readability, a recommendation for default initialization of an int
array, and include-what-you-use (indirectly through clang-tidy reporting
undefined symbols).
2022-08-17 19:53:56 -07:00
Tyler Veness
ea6b1d8449 [wpiutil] Remove unused ManagedStatic class (#4358)
We migrated to magic statics for lazy construction like the following:
```cpp
class Singleton {
  static Singleton& GetSingleton() {
    static Singleton instance;
    return instance;
  }
};
```
2022-08-17 18:04:42 -07:00
Tyler Veness
ac9be78e27 Use stricter C++ type conversions (#4357)
Now, implicit narrowing conversions are only used with wpi::Now(). This
also fixes clang-tidy warnings about C-style casts. For example:
```
== clang-tidy /__w/allwpilib/allwpilib/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc ==
/__w/allwpilib/allwpilib/wpilibNewCommands/src/main/native/include/frc2/command/SwerveControllerCommand.inc:95:18: warning: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [google-readability-casting]
  auto curTime = units::second_t(m_timer.Get());
                 ^
```
In that case at least, the cast was removed entirely since Get() already
returns a units::second_t.
2022-08-17 13:42:36 -07:00
Tyler Veness
151dabb2af [wpiutil] Upgrade to fmt 9.0.0 (#4337)
fmt removed fmt::make_args_checked since it's no longer needed for
constexpr format string checks.

fmt deprecated implicit conversions from enums to integers in format
arguments, so I added explicit static casts.
2022-08-16 15:35:26 -07:00
Tyler Veness
340465c929 [ci] Upgrade to clang-format and clang-tidy 14 (NFC) (#4347) 2022-08-16 15:25:04 -07:00
Michael Leong
d45bcddd15 [examples] Add comments to StateSpaceDifferentialDrive (#4341) 2022-08-15 06:26:20 -07:00
Tyler Veness
0e0786331a Update LLVM libraries to 14.0.6 (#4350)
The main noticeable change is the SmallString conversion operator to std::string is now explicit instead of implicit.
2022-08-15 05:38:15 -07:00
Tyler Veness
c5db23f296 [wpimath] Add Eigen sparse matrix and iterative solver support (#4349)
These are useful for efficiently solving huge, but sparse systems of
equations that occur often in optimization problems.
2022-08-13 18:32:02 -07:00
Tyler Veness
44abc8dfa6 [upstream_utils] Remove git version from upstream patches (#4351)
This reduces commit noise when other git versions are used. The version
was removed by passing `--no-signature` to `git format-patch` which is
now documented in the readme.
2022-08-13 18:31:26 -07:00
Tyler Veness
3fdb2f767d [wpimath] Add comments with Ramsete equations (#4348) 2022-08-11 07:09:16 -07:00
Tyler Veness
0485f05da9 [wpilibjExamples] Upgrade jacoco to match allwpilib (#4346) 2022-08-05 10:21:40 -07:00
Thad House
0a5eb65231 [wpinet] Handle empty txt block for mdns announcer (#4072) 2022-08-03 11:15:56 -07:00
sciencewhiz
19ffebaf3e [wpilib] Add reference to I2C Lockup to API Docs (NFC) (#4340) 2022-07-29 21:01:21 -07:00
Tyler Veness
ce1a90d639 [hal] Replace SerialHelper "goto done" with continue (#4342)
The logic is already correct for closing all the objects. So we should just be continuing on error.
2022-07-27 14:37:32 -07:00
Tyler Veness
d25af48797 [ci] Make upstream_utils CI fail on untracked files (#4339)
This catches issues like update scripts putting new files in a different
directory from the old ones.
2022-07-24 19:34:16 -07:00
Jeffrey Morris
ebb836dacb [examples] Fix negations in event loop examples (#4334) 2022-07-24 19:33:52 -07:00
Tyler Veness
d83e202f00 [upstream_utils] Update paths in update_fmt.py (#4338) 2022-07-22 18:08:36 -07:00
Tyler Veness
3ccf806064 [wpimath] Remove redundant LinearFilter.finiteDifference() argument (#4335)
The number of samples is already determined by the length of the stencil
list.
2022-07-22 12:50:30 -05:00
Tyler Veness
6f1e01f8bd [wpimath] Document example of online filtering for LinearFilter.finiteDifference() (#4336) 2022-07-22 12:46:33 -05:00
sciencewhiz
1023c34b1c [readme] Update location of ni-libraries (#4333)
Fixes #4321
2022-07-09 17:44:03 -05:00
Tyler Veness
faa29d596c [wpilib] Improve Notifier docs (NFC) (#4326) 2022-07-01 06:45:00 -07:00
Tyler Veness
add00a96ed [wpimath] Improve DifferentialDriveAccelerationLimiter docs (NFC) (#4323)
Defined trackwidth, added skipped steps to the algorithm's internal
proof, and grouped the algorithm steps more logically with blank lines.
2022-07-01 06:43:57 -07:00
Tyler Veness
82fac41244 [wpimath] Better document trackwidth parameters (NFC) (#4324) 2022-07-01 06:42:49 -07:00
Tyler Veness
5eb44e22a9 Format Python scripts with black (NFC) (#4325) 2022-07-01 06:41:44 -07:00
Peter Johnson
2e09fa7325 [build] Fix mpack cmake (#4322) 2022-06-24 19:35:13 -07:00
Starlight220
fe3c24b1ee [command] Add ignoringDisable decorator (#4305) 2022-06-24 10:52:53 -07:00
Thad House
aa221597bc [build] Add M1 builds, change arm name, update to 2023 deps (#4315) 2022-06-20 12:28:46 -06:00
Tyler Veness
579a8ee229 [ci] Use one worker for Windows release Gradle build (#4318)
It was running out of heap space.
2022-06-18 22:45:12 -07:00
Justus
5105c5eab6 [wpilibj] Change "final" to "exit" in the IterativeRobotBase JavaDoc (NFC) (#4317)
"exit" is used in every other instance.
2022-06-18 15:02:36 -07:00
PJ Reiniger
787fe6e7a5 [wpiutil] Separate third party libraries (#4190) 2022-06-18 08:08:31 -07:00
ohowe
6671f8d099 [wpigui] Update portable file dialogs (#4316)
All commits from March 16, 2022 to June 1, 2022
This fixes the save button in sysid on macOS.
2022-06-17 22:47:22 -07:00
Starlight220
9ac9b69aa2 [command] Reorder Scheduler operations (#4261)
Fixes several cases where calling scheduler operations from a command callback could result in NPEs or other issues.

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2022-06-15 23:32:16 -07:00
Tyler Veness
e61028cb18 [build] halsim_gui: Add wpinet dependency (#4313) 2022-06-15 23:14:31 -07:00
ohowe
661d23eaf5 [glass] Add precision setting for NetworkTable view (#4311) 2022-06-15 21:21:52 -07:00
Tyler Veness
666040e3e5 [hal] Throw exceptions for invalid sizes in I2C and SPI JNI (#4312)
GCC's static analyzer is correctly reporting that resize() requires an
unsigned integer, but the argument provided in the JNI function could be
negative since it's a signed byte. Throwing an exception if the argument
is negative fixes the warning.
2022-06-15 21:20:52 -07:00
Tyler Veness
aebc272449 [build] Upgrade to spotbugs Gradle plugin 5.0.8 (#4310)
This fixes a SecurityManager deprecation warning generated by spotbugs.
2022-06-14 20:26:53 -07:00
Starlight220
fd884581e4 [wpilib] Add BooleanEvent/Trigger factories on HID classes (#4247) 2022-06-13 22:48:16 -07:00
Tyler Veness
9b1bf5c7f1 [wpimath] Move Drake and Eigen to thirdparty folders (#4307) 2022-06-11 21:07:15 -07:00
Starlight220
c9e620a920 [wpilibc] Change EventLoop data structure to vector (#4304) 2022-06-10 05:38:54 -07:00
Peter Johnson
41d40dd62f [wpinet] Fix libuv unused variable warning on Mac (#4299) 2022-06-09 23:30:16 -07:00
PJ Reiniger
30f5b68264 [wpinet] Fix JNI loading error (#4295) 2022-06-08 22:21:22 -07:00
DeltaDizzy
f7b3f4b90e [examples] Getting Started: Change Joystick to XboxController (#4194) 2022-06-08 22:20:33 -07:00
Connor Worley
a99c11c14c [wpimath] Replace UKF implementation with square root form (#4168)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2022-06-08 22:19:01 -07:00
Starlight220
45b7fc445b [wpilib] Add EventLoop (#4104)
This is a generic expansion of the command-based Trigger framework.
2022-06-08 22:16:51 -07:00
Peter Johnson
16a4888c52 [wpilib] Default off LiveWindow telemetry (#4301)
The original idea of LiveWindow telemetry was to automatically make
telemetry data visible to users.  This has proved increasingly
problematic in recent years due to the "spooky action at a distance"
of telemetry happening for objects that are only constructed but not
used, and blocking or slow object reads resulting in hard-to-debug
loop overrun conditions.
2022-06-08 22:13:00 -07:00
Thad House
17752f1337 [ci] Split debug and release Windows builds (#4277)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2022-06-06 17:25:02 -07:00
Starlight220
abb45a68db [commands] Remove custom test wrappers (#4296)
Use AtomicBoolean and AtomicInteger instead of
custom ConditionHolder and Counter classes.
2022-06-06 17:13:11 -07:00
Peter Johnson
1280a54ef3 [upstream_utils]: Make work with Python 3.8 (#4298)
str.removesuffix() is only available in Python 3.9, which is not in many
Linux installations.
2022-06-06 17:07:16 -07:00
Starlight220
f2d243fa68 [build] Change defaults for Java lints (#4300)
Removes the need to individually suppress the "serial" warning.
2022-06-06 17:06:43 -07:00
sciencewhiz
a4787130f4 Update using development build to work with 2023 gradlerio (#4294) 2022-06-04 13:58:51 -07:00
Prateek Machiraju
af7985e46c [wpiutil] Use invoke_result_t instead of result_of in future.h (#4293)
std::result_of is deprecated in C++17.
2022-06-02 23:04:20 -07:00
Tyler Veness
e9d1b5c2d0 [hal] Remove deprecated SimDevice functions (#4209) 2022-06-02 22:53:02 -07:00
Prateek Machiraju
45b598d236 [wpilibj] Add toString() methods to Color and Color8Bit (#4286) 2022-06-02 21:23:11 -07:00
Prateek Machiraju
fc37265da5 [wpimath] Add angle measurement convention to ArmFeedforward docs (NFC) (#4285) 2022-06-02 21:22:47 -07:00
Prateek Machiraju
a4ec13eb0e [wpilibjexamples] Remove unnecessary voltage desaturation 2022-06-02 21:22:19 -07:00
Prateek Machiraju
2fa52007af [wpilibc] Use GetBatteryVoltage() in MotorController::SetVoltage
This avoids having to cast to units::voltage_t
2022-06-02 21:22:19 -07:00
Prateek Machiraju
d9f9cd1140 [wpimath] Reset prev_time on pose estimator reset (#4283) 2022-06-02 21:21:42 -07:00
1276 changed files with 51693 additions and 12174 deletions

View File

@@ -53,7 +53,6 @@ Checks:
google-readability-avoid-underscore-in-googletest-name,
google-readability-casting,
google-runtime-operator,
llvm-twine-local,
misc-definitions-in-headers,
misc-misplaced-const,
misc-new-delete-overloads,
@@ -70,6 +69,3 @@ Checks:
modernize-use-using,
readability-braces-around-statements'
FormatStyle: file
CheckOptions:
- key: bugprone-dangling-handle
value: 'wpi::StringRef;wpi::Twine'

View File

@@ -49,35 +49,3 @@ jobs:
- name: test
working-directory: build
run: ctest --output-on-failure
build-windows:
env:
VCPKG_DEFAULT_TRIPLET: x64-windows
name: "Build - Windows"
runs-on: windows-2019
steps:
- uses: actions/checkout@v3
- name: Install CMake
uses: lukka/get-cmake@v3.23.0
- name: Run vcpkg
uses: lukka/run-vcpkg@v10.2
with:
vcpkgDirectory: ${{ runner.workspace }}/vcpkg
vcpkgGitCommitId: f6af75acc923c833a5620943e3fc7d5e4930f0df # HEAD on 2022-04-10
runVcpkgInstall: true
- name: Install jinja
run: python -m pip install jinja2
- name: configure
run: mkdir build && cd build && cmake -DWITH_JAVA=OFF -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake ..
- name: build
working-directory: build
run: cmake --build . --parallel $(nproc)
- name: test
working-directory: build
run: ctest -C "Debug" --output-on-failure

View File

@@ -20,6 +20,8 @@ jobs:
content: "rocket",
});
- uses: actions/checkout@v3
with:
token: ${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}
- name: Fetch all history and metadata
run: |
git fetch --prune --unshallow
@@ -29,7 +31,7 @@ jobs:
run: |
gh pr checkout $NUMBER
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
GITHUB_TOKEN: "${{ secrets.COMMENT_COMMAND_PAT_TOKEN }}"
NUMBER: ${{ github.event.issue.number }}
- name: Set up Python 3.8
uses: actions/setup-python@v2
@@ -37,13 +39,14 @@ jobs:
python-version: 3.8
- name: Install clang-format
run: |
sudo sh -c "echo 'deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-proposed restricted main multiverse universe' >> /etc/apt/sources.list.d/proposed-repositories.list"
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-format-12
sudo apt-get install -y clang-format-14
- name: Install wpiformat
run: pip3 install wpiformat
- name: Run wpiformat
run: wpiformat -clang 12
run: wpiformat -clang 14
- name: Commit
run: |
# Set credentials

View File

@@ -16,11 +16,11 @@ jobs:
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:10-20.04
artifact-name: Raspbian
build-options: "-Ponlylinuxraspbian"
artifact-name: Arm32
build-options: "-Ponlylinuxarm32"
- container: wpilib/aarch64-cross-ubuntu:bionic-20.04
artifact-name: Aarch64
build-options: "-Ponlylinuxaarch64bionic"
artifact-name: Arm64
build-options: "-Ponlylinuxarm64"
- container: wpilib/ubuntu-base:20.04
artifact-name: Linux
build-options: "-Ponlylinuxx86-64"
@@ -52,11 +52,20 @@ jobs:
matrix:
include:
- os: windows-2019
artifact-name: Win64
artifact-name: Win64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly --max-workers 1"
- os: windows-2019
artifact-name: Win64Release
architecture: x64
build-options: "-PciReleaseOnly --max-workers 1"
task: "copyAllOutputs"
- os: macOS-11
artifact-name: macOS
architecture: x64
build-options: "-Pbuildalldesktop"
task: "build"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
steps:
@@ -86,12 +95,12 @@ jobs:
shell: bash
if: startsWith(github.ref, 'refs/tags/v')
- name: Build with Gradle
run: ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ env.EXTRA_GRADLE_ARGS }}
run: ./gradlew ${{ matrix.task }} --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
env:
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: Sign Libraries with Developer ID
run: ./gradlew build -PbuildServer -PskipJavaFormat -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} ${{ env.EXTRA_GRADLE_ARGS }}
run: ./gradlew build -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')))

View File

@@ -28,13 +28,14 @@ jobs:
python-version: 3.8
- name: Install clang-format
run: |
sudo sh -c "echo 'deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-proposed restricted main multiverse universe' >> /etc/apt/sources.list.d/proposed-repositories.list"
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-format-12
sudo apt-get install -y clang-format-14
- name: Install wpiformat
run: pip3 install wpiformat
- name: Run
run: wpiformat -clang 12
run: wpiformat -clang 14
- name: Check output
run: git --no-pager diff --exit-code HEAD
- name: Generate diff
@@ -63,9 +64,10 @@ jobs:
python-version: 3.8
- name: Install clang-tidy
run: |
sudo sh -c "echo 'deb http://archive.ubuntu.com/ubuntu/ $(lsb_release -cs)-proposed restricted main multiverse universe' >> /etc/apt/sources.list.d/proposed-repositories.list"
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo sh -c "echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' >> /etc/apt/sources.list.d/proposed-repositories.list"
sudo apt-get update -q
sudo apt-get install -y clang-tidy-12 clang-format-12
sudo apt-get install -y clang-tidy-14 clang-format-14
- name: Install wpiformat
run: pip3 install wpiformat
- name: Create compile_commands.json
@@ -73,7 +75,7 @@ jobs:
- name: List changed files
run: wpiformat -list-changed-files
- name: Run clang-tidy
run: wpiformat -clang 12 -no-format -tidy-changed -compile-commands=build/compile_commands/linuxx86-64 -vv
run: wpiformat -clang 14 -no-format -tidy-changed -compile-commands=build/compile_commands/linuxx86-64 -vv
javaformat:
name: "Java format"
runs-on: ubuntu-latest

View File

@@ -15,7 +15,7 @@ jobs:
- name: asan
cmake-flags: "-DCMAKE_BUILD_TYPE=Asan"
ctest-env: ""
ctest-flags: "-E 'wpinet|wpiutil|ntcore|wpilibc'"
ctest-flags: "-E 'ntcore|wpilibc'"
- name: tsan
cmake-flags: "-DCMAKE_BUILD_TYPE=Tsan"
ctest-env: "TSAN_OPTIONS=second_deadlock_stack=1"

View File

@@ -37,6 +37,10 @@ jobs:
run: |
cd upstream_utils
./update_eigen.py
- name: Run update_fmt.py
run: |
cd upstream_utils
./update_fmt.py
- name: Run update_libuv.py
run: |
cd upstream_utils
@@ -49,5 +53,11 @@ jobs:
run: |
cd upstream_utils
./update_stack_walker.py
- name: Run update_memory.py
run: |
cd upstream_utils
./update_memory.py
- 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

View File

@@ -37,7 +37,7 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont
## Coding Guidelines
WPILib uses modified Google style guides for both C++ and Java, which can be found in the [styleguide repository](https://github.com/wpilibsuite/styleguide). Autoformatters are available for many popular editors at https://github.com/google/styleguide. Running wpiformat is required for all contributions and is enforced by our continuous integration system. We currently use clang-format 12.0 with wpiformat.
WPILib uses modified Google style guides for both C++ and Java, which can be found in the [styleguide repository](https://github.com/wpilibsuite/styleguide). Autoformatters are available for many popular editors at https://github.com/google/styleguide. Running wpiformat is required for all contributions and is enforced by our continuous integration system. We currently use clang-format 14.0 with wpiformat.
While the library should be fully formatted according to the styles, additional elements of the style guide were not followed when the library was initially created. All new code should follow the guidelines. If you are looking for some easy ramp-up tasks, finding areas that don't follow the style guide and fixing them is very welcome.

View File

@@ -6,9 +6,9 @@ This article contains instructions on building projects using a development buil
## Development Build
Development builds are the per-commit build hosted everytime 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).
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).
In order 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.
In order 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`
```groovy
wpi.maven.useLocal = false
@@ -23,13 +23,13 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = '2022.+'
wpi.versions.wpimathVersion = '2022.+'
wpi.versions.wpilibVersion = '2023.+'
wpi.versions.wpimathVersion = '2023.+'
```
C++
@@ -37,13 +37,13 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = '2022.+'
wpi.versions.wpimathVersion = '2022.+'
wpi.versions.wpilibVersion = '2023.+'
wpi.versions.wpimathVersion = '2023.+'
```
## Local Build
@@ -54,7 +54,7 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
}
wpi.maven.useLocal = false
@@ -68,7 +68,7 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
}
wpi.maven.useLocal = false

View File

@@ -16,7 +16,7 @@ Welcome to the WPILib project. This repository contains the HAL, WPILibJ, and WP
- [Using Development Builds](#using-development-builds)
- [Custom toolchain location](#custom-toolchain-location)
- [Gazebo simulation](#gazebo-simulation)
- [Formatting/linting with wpiformat](#formattinglinting-with-wpiformat)
- [Formatting/Linting](#formattinglinting)
- [CMake](#cmake)
- [Publishing](#publishing)
- [Structure and Organization](#structure-and-organization)
@@ -54,7 +54,9 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen
- Run `./gradlew installRoboRioToolchain` after cloning this repository
- If the WPILib installer was used, this toolchain is already installed
- Raspberry Pi toolchain (optional)
- Run `./gradlew installRaspbianToolchain` after cloning this repository
- Run `./gradlew installArm32Toolchain` after cloning this repository
On macOS ARM, run `softwareupdate --install-rosetta`. This is necessary to be able to use the macOS x86 roboRIO toolchain on ARM.
## Setup
@@ -166,7 +168,7 @@ The Simulation directory contains extra simulation tools and libraries, such as
The integration test directories for C++ and Java contain test code that runs on our test-system. When you submit code for review, it is tested by those programs. If you add new functionality you should make sure to write tests for it so we don't break it in the future.
The hal directory contains more C++ code meant to run on the roboRIO. HAL is an acronym for "Hardware Abstraction Layer", and it interfaces with the NI Libraries. The NI Libraries contain the low-level code for controlling devices on your robot. The NI Libraries are found in the ni-libraries folder.
The hal directory contains more C++ code meant to run on the roboRIO. HAL is an acronym for "Hardware Abstraction Layer", and it interfaces with the NI Libraries. The NI Libraries contain the low-level code for controlling devices on your robot. The NI Libraries are found in the [ni-libraries](https://github.com/wpilibsuite/ni-libraries) project.
The upstream_utils directory contains scripts for updating copies of thirdparty code in the repository.

View File

@@ -17,41 +17,35 @@ Program Locations
------- ---------
RoboRIO Libraries ni-libraries
Google Test gtest
LLVM wpiutil/src/main/native/include/wpi/{various files}
wpiutil/src/main/native/cpp/llvm/
wpiutil/src/main/native/cpp/leb128.cpp
wpiutil/src/test/native/cpp/leb128Test.cpp
JSON for Modern C++ wpiutil/src/main/native/include/wpi/json.h
wpiutil/src/main/native/cpp/json_*.cpp
LLVM wpiutil/src/main/native/thirdparty/llvm
wpiutil/src/test/native/cpp/llvm/
JSON for Modern C++ wpiutil/src/main/native/thirdparty/json
wpiutil/src/test/native/cpp/json/
libuv wpinet/src/main/native/thirdparty/libuv/
fmtlib wpiutil/src/main/native/fmtlib/
sigslot wpiutil/src/main/native/include/wpi/Signal.h
wpiutil/src/test/native/cpp/sigslot/
tcpsockets wpiutil/src/main/native/cpp/TCP{Stream,Connector,Acceptor}.cpp
wpiutil/src/main/native/include/wpi/TCP*.h
MPack wpiutil/src/main/native/include/mpack.h
wpiutil/src/main/native/cpp/mpack.cpp
fmtlib wpiutil/src/main/native/thirdparty/fmtlib/
sigslot wpiutil/src/main/native/thirdparty/sigslot
tcpsockets wpinet/src/main/native/thirdparty/tcpsockets
MPack wpiutil/src/main/native/thirdparty/mpack
Bootstrap wpinet/src/main/native/resources/bootstrap-*
CoreUI wpinet/src/main/native/resources/coreui-*
Feather Icons wpinet/src/main/native/resources/feather-*
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/eigeninclude/
wpimath/src/main/native/include/unsupported/
Eigen wpimath/src/main/native/thirdparty/eigen/include/
StackWalker wpiutil/src/main/native/windows/StackWalker.*
TCB span wpiutil/src/main/native/include/wpi/span.h
TCB span wpiutil/src/main/native/thirdparty/include/wpi/span.h
wpiutil/src/test/native/cpp/span/
GHC filesystem wpiutil/src/main/native/include/wpi/ghc/
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
Portable File Dialogs wpigui/src/main/native/include/portable-file-dialogs.h
Drake wpimath/src/main/native/cpp/drake/common/drake_assert_and_throw.cpp
wpimath/src/main/native/cpp/drake/math/discrete_algebraic_riccati_equation.cpp
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
==============================================================================

View File

@@ -23,7 +23,7 @@ plugins {
id 'net.ltgt.errorprone' version '2.0.2' apply false
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
id 'com.diffplug.spotless' version '6.4.2' apply false
id 'com.github.spotbugs' version '5.0.6' apply false
id 'com.github.spotbugs' version '5.0.8' apply false
}
wpilibVersioning.buildServerMode = project.hasProperty('buildServer')
@@ -87,7 +87,12 @@ task copyAllOutputs(type: Copy) {
build.dependsOn copyAllOutputs
copyAllOutputs.dependsOn outputVersions
def copyReleaseOnly = project.hasProperty('ciReleaseOnly')
ext.addTaskToCopyAllOutputs = { task ->
if (copyReleaseOnly && task.name.contains('debug')) {
return
}
copyAllOutputs.dependsOn task
copyAllOutputs.inputs.file task.archivePath
copyAllOutputs.from task.archivePath
@@ -151,5 +156,5 @@ ext.getCurrentArch = {
}
wrapper {
gradleVersion = '7.3.3'
gradleVersion = '7.5.1'
}

View File

@@ -5,5 +5,5 @@ repositories {
}
}
dependencies {
implementation "edu.wpi.first:native-utils:2023.0.1"
implementation "edu.wpi.first:native-utils:2023.1.0"
}

View File

@@ -41,7 +41,6 @@ dependencies {
model {
components {
multiCameraServerCpp(NativeExecutableSpec) {
targetBuildTypes 'release'
sources {
cpp {
source {

View File

@@ -33,12 +33,10 @@ import java.util.concurrent.atomic.AtomicInteger;
* Singleton class for creating and keeping camera servers. Also publishes camera information to
* NetworkTables.
*/
@SuppressWarnings("PMD.UnusedPrivateField")
public final class CameraServer {
public static final int kBasePort = 1181;
private static final String kPublishName = "/CameraPublisher";
private static CameraServer server;
private static final AtomicInteger m_defaultUsbDevice = new AtomicInteger();
private static String m_primarySourceName;
@@ -63,6 +61,7 @@ public final class CameraServer {
// - "PropertyInfo/{Property}" - Property supporting information
// Listener for video events
@SuppressWarnings("PMD.UnusedPrivateField")
private static final VideoListener m_videoListener =
new VideoListener(
event -> {
@@ -185,6 +184,7 @@ public final class CameraServer {
0x4fff,
true);
@SuppressWarnings("PMD.UnusedPrivateField")
private static final int m_tableListener =
NetworkTableInstance.getDefault()
.addEntryListener(
@@ -243,10 +243,15 @@ public final class CameraServer {
}
},
EntryListenerFlags.kImmediate | EntryListenerFlags.kUpdate);
private static int m_nextPort = kBasePort;
private static String[] m_addresses = new String[0];
@SuppressWarnings("MissingJavadocMethod")
/**
* Return URI of source with the given index.
*
* @param source Source index.
*/
private static String makeSourceValue(int source) {
switch (VideoSource.getKindFromInt(CameraServerJNI.getSourceKind(source))) {
case kUsb:
@@ -267,12 +272,21 @@ public final class CameraServer {
}
}
@SuppressWarnings("MissingJavadocMethod")
/**
* Return URI of stream with the given address and port.
*
* @param address Stream IP address.
* @param port Stream remote port.
*/
private static String makeStreamValue(String address, int port) {
return "mjpg:http://" + address + ":" + port + "/?action=stream";
}
@SuppressWarnings("MissingJavadocMethod")
/**
* Return URI of sink stream with the given index.
*
* @param sink Sink index.
*/
private static synchronized String[] getSinkStreamValues(int sink) {
// Ignore all but MjpegServer
if (VideoSink.getKindFromInt(CameraServerJNI.getSinkKind(sink)) != VideoSink.Kind.kMjpeg) {
@@ -302,7 +316,11 @@ public final class CameraServer {
return values.toArray(new String[0]);
}
@SuppressWarnings("MissingJavadocMethod")
/**
* Return list of stream source URIs for the given source index.
*
* @param source Source index.
*/
private static synchronized String[] getSourceStreamValues(int source) {
// Ignore all but HttpCamera
if (VideoSource.getKindFromInt(CameraServerJNI.getSourceKind(source))
@@ -337,7 +355,7 @@ public final class CameraServer {
return values;
}
@SuppressWarnings("MissingJavadocMethod")
/** Update list of stream URIs. */
private static synchronized void updateStreamValues() {
// Over all the sinks...
for (VideoSink i : m_sinks.values()) {
@@ -383,7 +401,7 @@ public final class CameraServer {
}
}
@SuppressWarnings("MissingJavadocMethod")
/** Provide string description of pixel format. */
private static String pixelFormatToString(PixelFormat pixelFormat) {
switch (pixelFormat) {
case kMJPEG:
@@ -401,9 +419,11 @@ public final class CameraServer {
}
}
/// Provide string description of video mode.
/// The returned string is "{width}x{height} {format} {fps} fps".
@SuppressWarnings("MissingJavadocMethod")
/**
* Provide string description of video mode.
*
* <p>The returned string is "{width}x{height} {format} {fps} fps".
*/
private static String videoModeToString(VideoMode mode) {
return mode.width
+ "x"
@@ -415,7 +435,11 @@ public final class CameraServer {
+ " fps";
}
@SuppressWarnings("MissingJavadocMethod")
/**
* Get list of video modes for the given source handle.
*
* @param sourceHandle Source handle.
*/
private static String[] getSourceModeValues(int sourceHandle) {
VideoMode[] modes = CameraServerJNI.enumerateSourceVideoModes(sourceHandle);
String[] modeStrings = new String[modes.length];
@@ -425,7 +449,13 @@ public final class CameraServer {
return modeStrings;
}
@SuppressWarnings("MissingJavadocMethod")
/**
* Publish a source property value to NetworkTables.
*
* @param table NetworkTable to which to push value.
* @param event Video event.
* @param isNew Whether the property value hasn't been pushed to NetworkTables before.
*/
private static void putSourcePropertyValue(NetworkTable table, VideoEvent event, boolean isNew) {
String name;
String infoName;

View File

@@ -609,7 +609,7 @@ cs::CvSink CameraServer::GetVideo(const cs::VideoSource& camera) {
if (kind != cs::VideoSink::kCv) {
auto csShared = GetCameraServerShared();
csShared->SetCameraServerError("expected OpenCV sink, but got {}",
kind);
static_cast<int>(kind));
return cs::CvSink{};
}
return *static_cast<cs::CvSink*>(&it->second);

View File

@@ -27,20 +27,17 @@ class CameraServerShared {
template <typename S, typename... Args>
inline void SetCameraServerError(const S& format, Args&&... args) {
SetCameraServerErrorV(format,
fmt::make_args_checked<Args...>(format, args...));
SetCameraServerErrorV(format, fmt::make_format_args(args...));
}
template <typename S, typename... Args>
inline void SetVisionRunnerError(const S& format, Args&&... args) {
SetVisionRunnerErrorV(format,
fmt::make_args_checked<Args...>(format, args...));
SetVisionRunnerErrorV(format, fmt::make_format_args(args...));
}
template <typename S, typename... Args>
inline void ReportDriverStationError(const S& format, Args&&... args) {
ReportDriverStationErrorV(format,
fmt::make_args_checked<Args...>(format, args...));
ReportDriverStationErrorV(format, fmt::make_format_args(args...));
}
};

View File

@@ -4,4 +4,12 @@ macro(wpilib_target_warnings target)
else()
target_compile_options(${target} PRIVATE /wd4146 /wd4244 /wd4251 /wd4267 /WX /D_CRT_SECURE_NO_WARNINGS ${WPILIB_TARGET_WARNINGS})
endif()
# Suppress C++-specific OpenCV warning; C compiler rejects it with an error
# https://github.com/opencv/opencv/issues/20269
if(UNIX AND NOT APPLE)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>)
elseif(UNIX AND APPLE)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-anon-enum-enum-conversion>)
endif()
endmacro()

View File

@@ -100,8 +100,9 @@ void TestTimingDMA(int squelch, std::pair<int, int> param) {
auto value = HAL_GetDMASampleDigitalSource(&dmaSamples[startIndex],
dioHandle, &status);
ASSERT_EQ(0, status);
if (value)
if (value) {
break;
}
startIndex++;
}
ASSERT_LT(startIndex, 6);

View File

@@ -23,8 +23,8 @@ model {
enableCheckTask true
javaCompileTasks << compileJava
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.roborio)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.raspbian)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.aarch64bionic)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm32)
jniCrossCompileOptions << JniCrossCompileOptions(nativeUtils.wpi.platforms.linuxarm64)
sources {
cpp {
@@ -180,7 +180,7 @@ model {
components {
examplesMap.each { key, value ->
if (key == "usbviewer") {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxarm32') && !project.hasProperty('onlylinuxarm64')) {
"${key}"(NativeExecutableSpec) {
targetBuildTypes 'debug'
binaries.all {
@@ -189,7 +189,7 @@ model {
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib library: 'cscore', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui_static')
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm32 || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm64) {
it.buildable = false
return
}

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.cscore;
/** USB camera information. */
@SuppressWarnings("MemberName")
public class UsbCameraInfo {
/**
* Create a new set of UsbCameraInfo.
@@ -28,26 +29,20 @@ public class UsbCameraInfo {
}
/** Device number (e.g. N in '/dev/videoN' on Linux). */
@SuppressWarnings("MemberName")
public int dev;
/** Path to device if available (e.g. '/dev/video0' on Linux). */
@SuppressWarnings("MemberName")
public String path;
/** Vendor/model name of the camera as provided by the USB driver. */
@SuppressWarnings("MemberName")
public String name;
/** Other path aliases to device (e.g. '/dev/v4l/by-id/...' etc on Linux). */
@SuppressWarnings("MemberName")
public String[] otherPaths;
/** USB vendor id. */
@SuppressWarnings("MemberName")
public int vendorId;
/** USB product id. */
@SuppressWarnings("MemberName")
public int productId;
}

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.cscore;
/** Video event. */
@SuppressWarnings("MemberName")
public class VideoEvent {
public enum Kind {
kUnknown(0x0000),
@@ -117,39 +118,29 @@ public class VideoEvent {
this.listener = listener;
}
@SuppressWarnings("MemberName")
public Kind kind;
// Valid for kSource* and kSink* respectively
@SuppressWarnings("MemberName")
public int sourceHandle;
@SuppressWarnings("MemberName")
public int sinkHandle;
// Source/sink/property name
@SuppressWarnings("MemberName")
public String name;
// Fields for kSourceVideoModeChanged event
@SuppressWarnings("MemberName")
public VideoMode mode;
// Fields for kSourceProperty* events
@SuppressWarnings("MemberName")
public int propertyHandle;
@SuppressWarnings("MemberName")
public VideoProperty.Kind propertyKind;
@SuppressWarnings("MemberName")
public int value;
@SuppressWarnings("MemberName")
public String valueStr;
// Listener that was triggered
@SuppressWarnings("MemberName")
public int listener;
public VideoSource getSource() {

View File

@@ -64,7 +64,6 @@ public class VideoListener implements AutoCloseable {
private static boolean s_waitQueue;
private static final Condition s_waitQueueCond = s_lock.newCondition();
@SuppressWarnings("PMD.AvoidCatchingThrowable")
private static void startThread() {
s_thread =
new Thread(

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.cscore;
/** Video mode. */
@SuppressWarnings("MemberName")
public class VideoMode {
public enum PixelFormat {
kUnknown(0),
@@ -62,18 +63,14 @@ public class VideoMode {
}
/** Pixel format. */
@SuppressWarnings("MemberName")
public PixelFormat pixelFormat;
/** Width in pixels. */
@SuppressWarnings("MemberName")
public int width;
/** Height in pixels. */
@SuppressWarnings("MemberName")
public int height;
/** Frames per second. */
@SuppressWarnings("MemberName")
public int fps;
}

View File

@@ -523,7 +523,8 @@ Image* Frame::GetImageImpl(int width, int height,
WPI_DEBUG4(Instance::GetInstance().logger,
"converting image from {}x{} type {} to {}x{} type {}", cur->width,
cur->height, cur->pixelFormat, width, height, pixelFormat);
cur->height, static_cast<int>(cur->pixelFormat), width, height,
static_cast<int>(pixelFormat));
// If the source image is a JPEG, we need to decode it before we can do
// anything else with it. Note that if the destination format is JPEG, we

View File

@@ -22,7 +22,9 @@ class Image {
public:
#ifndef __linux__
explicit Image(size_t capacity) { m_data.reserve(capacity); }
explicit Image(size_t capacity) {
m_data.reserve(capacity);
}
#else
explicit Image(size_t capacity)
: m_data{capacity, default_init_allocator<uchar>{}} {
@@ -34,20 +36,38 @@ class Image {
Image& operator=(const Image&) = delete;
// Getters
operator std::string_view() const { return str(); } // NOLINT
std::string_view str() const { return {data(), size()}; }
size_t capacity() const { return m_data.capacity(); }
operator std::string_view() const { // NOLINT
return str();
}
std::string_view str() const {
return {data(), size()};
}
size_t capacity() const {
return m_data.capacity();
}
const char* data() const {
return reinterpret_cast<const char*>(m_data.data());
}
char* data() { return reinterpret_cast<char*>(m_data.data()); }
size_t size() const { return m_data.size(); }
char* data() {
return reinterpret_cast<char*>(m_data.data());
}
size_t size() const {
return m_data.size();
}
const std::vector<uchar>& vec() const { return m_data; }
std::vector<uchar>& vec() { return m_data; }
const std::vector<uchar>& vec() const {
return m_data;
}
std::vector<uchar>& vec() {
return m_data;
}
void resize(size_t size) { m_data.resize(size); }
void SetSize(size_t size) { m_data.resize(size); }
void resize(size_t size) {
m_data.resize(size);
}
void SetSize(size_t size) {
m_data.resize(size);
}
cv::Mat AsMat() {
int type;
@@ -68,7 +88,9 @@ class Image {
return cv::Mat{height, width, type, m_data.data()};
}
cv::_InputArray AsInputArray() { return cv::_InputArray{m_data}; }
cv::_InputArray AsInputArray() {
return cv::_InputArray{m_data};
}
bool Is(int width_, int height_) {
return width == width_ && height == height_;
@@ -90,8 +112,12 @@ class Image {
bool IsLarger(const Image& oth) {
return width >= oth.width && height >= oth.height;
}
bool IsSmaller(int width_, int height_) { return !IsLarger(width_, height_); }
bool IsSmaller(const Image& oth) { return !IsLarger(oth); }
bool IsSmaller(int width_, int height_) {
return !IsLarger(width_, height_);
}
bool IsSmaller(const Image& oth) {
return !IsLarger(oth);
}
private:
std::vector<uchar> m_data;

View File

@@ -21,7 +21,7 @@ inline void NamedLog(wpi::Logger& logger, unsigned int level, const char* file,
Args&&... args) {
if (logger.HasLogger() && level >= logger.min_level()) {
NamedLogV(logger, level, file, line, name, format,
fmt::make_args_checked<Args...>(format, args...));
fmt::make_format_args(args...));
}
}

View File

@@ -495,7 +495,7 @@ void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os,
auto kind = source.GetPropertyKind(prop);
fmt::print(os, "\n\"name\": \"{}\"", name);
fmt::print(os, ",\n\"id\": \"{}\"", prop);
fmt::print(os, ",\n\"type\": \"{}\"", kind);
fmt::print(os, ",\n\"type\": \"{}\"", static_cast<int>(kind));
fmt::print(os, ",\n\"min\": \"{}\"", source.GetPropertyMin(prop, &status));
fmt::print(os, ",\n\"max\": \"{}\"", source.GetPropertyMax(prop, &status));
fmt::print(os, ",\n\"step\": \"{}\"",

View File

@@ -58,13 +58,13 @@ static std::string GetUsbNameFromFile(int vendor, int product) {
// next vendor, but didn't match product?
if (line[0] != '\t') {
buf += "Unknown";
return buf;
return std::string{buf};
}
// look for product
if (wpi::starts_with(wpi::substr(line, 1), productStr)) {
buf += wpi::trim(wpi::substr(line, 6));
return buf;
return std::string{buf};
}
}
}

View File

@@ -279,19 +279,23 @@ static bool IsPercentageProperty(std::string_view name) {
void UsbCameraImpl::ProcessFrame(IMFSample* videoSample,
const VideoMode& mode) {
if (!videoSample)
if (!videoSample) {
return;
}
ComPtr<IMFMediaBuffer> buf;
if (!SUCCEEDED(videoSample->ConvertToContiguousBuffer(buf.GetAddressOf()))) {
DWORD bcnt = 0;
if (!SUCCEEDED(videoSample->GetBufferCount(&bcnt)))
if (!SUCCEEDED(videoSample->GetBufferCount(&bcnt))) {
return;
if (bcnt == 0)
}
if (bcnt == 0) {
return;
if (!SUCCEEDED(videoSample->GetBufferByIndex(0, buf.GetAddressOf())))
}
if (!SUCCEEDED(videoSample->GetBufferByIndex(0, buf.GetAddressOf()))) {
return;
}
}
BYTE* ptr = NULL;
@@ -474,11 +478,13 @@ static cs::VideoMode::PixelFormat GetFromGUID(const GUID& guid) {
}
bool UsbCameraImpl::DeviceConnect() {
if (m_mediaSource && m_sourceReader)
if (m_mediaSource && m_sourceReader) {
return true;
}
if (m_connectVerbose)
if (m_connectVerbose) {
SINFO("Connecting to USB camera on {}", m_path);
}
SDEBUG3("{}", "opening device");
@@ -580,8 +586,9 @@ template void UsbCameraImpl::DeviceAddProperty(std::string_view name_,
DeviceAddProperty(#val, CameraControl_##val, pCamControl);
void UsbCameraImpl::DeviceCacheProperties() {
if (!m_sourceReader)
if (!m_sourceReader) {
return;
}
IAMVideoProcAmp* pProcAmp = NULL;
@@ -778,22 +785,25 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetProperty(
// Look up
auto prop = static_cast<UsbCameraProperty*>(GetProperty(property));
if (!prop)
if (!prop) {
return CS_INVALID_PROPERTY;
}
// If setting before we get, guess initial type based on set
if (prop->propKind == CS_PROP_NONE) {
if (setString)
if (setString) {
prop->propKind = CS_PROP_STRING;
else
} else {
prop->propKind = CS_PROP_INTEGER;
}
}
// Check kind match
if ((setString && prop->propKind != CS_PROP_STRING) ||
(!setString && (prop->propKind &
(CS_PROP_BOOLEAN | CS_PROP_INTEGER | CS_PROP_ENUM)) == 0))
(!setString && (prop->propKind & (CS_PROP_BOOLEAN | CS_PROP_INTEGER |
CS_PROP_ENUM)) == 0)) {
return CS_WRONG_PROPERTY_TYPE;
}
// Handle percentage property
int percentageProperty = prop->propPair;
@@ -810,8 +820,9 @@ CS_StatusValue UsbCameraImpl::DeviceCmdSetProperty(
// Actually set the new value on the device (if possible)
if (!prop->device) {
if (prop->id == kPropConnectVerboseId)
if (prop->id == kPropConnectVerboseId) {
m_connectVerbose = value;
}
} else {
if (!prop->DeviceSet(lock, m_sourceReader.Get())) {
return CS_PROPERTY_WRITE_FAILED;
@@ -913,11 +924,13 @@ bool UsbCameraImpl::DeviceStreamOff() {
}
void UsbCameraImpl::DeviceCacheMode() {
if (!m_sourceReader)
if (!m_sourceReader) {
return;
}
if (m_windowsVideoModes.size() == 0)
if (m_windowsVideoModes.size() == 0) {
return;
}
if (!m_currentMode) {
// First, see if our set mode is valid
@@ -982,8 +995,9 @@ CS_StatusValue UsbCameraImpl::DeviceSetMode() {
}
void UsbCameraImpl::DeviceCacheVideoModes() {
if (!m_sourceReader)
if (!m_sourceReader) {
return;
}
std::vector<VideoMode> modes;
m_windowsVideoModes.clear();
@@ -1098,13 +1112,13 @@ std::vector<UsbCameraInfo> EnumerateUsbCameras(CS_Status* status) {
sizeof(buf) / sizeof(WCHAR), &characters);
storage.clear();
wpi::sys::windows::UTF16ToUTF8(buf, characters, storage);
info.name = storage.string();
info.name = std::string{storage};
ppDevices[i]->GetString(
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK, buf,
sizeof(buf) / sizeof(WCHAR), &characters);
storage.clear();
wpi::sys::windows::UTF16ToUTF8(buf, characters, storage);
info.path = storage.string();
info.path = std::string{storage};
// Try to parse path from symbolic link
ParseVidAndPid(info.path, &info.productId, &info.vendorId);

View File

@@ -96,10 +96,10 @@ class UsbCameraImpl : public SourceImpl,
};
explicit Message(Kind kind_)
: kind(kind_), data{0}, from(std::this_thread::get_id()) {}
: kind(kind_), from(std::this_thread::get_id()) {}
Kind kind;
int data[4];
int data[4]{0};
std::string dataStr;
std::thread::id from;
};

View File

@@ -40,8 +40,9 @@ UsbCameraProperty::UsbCameraProperty(std::string_view name_,
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
IAMVideoProcAmp* pProcAmp) {
if (!pProcAmp)
if (!pProcAmp) {
return true;
}
lock.unlock();
long newValue = 0, paramFlag = 0; // NOLINT(runtime/int)
@@ -60,8 +61,9 @@ bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
IAMVideoProcAmp* pProcAmp,
int newValue) const {
if (!pProcAmp)
if (!pProcAmp) {
return true;
}
lock.unlock();
if (SUCCEEDED(
@@ -104,8 +106,9 @@ UsbCameraProperty::UsbCameraProperty(std::string_view name_,
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
IAMCameraControl* pProcAmp) {
if (!pProcAmp)
if (!pProcAmp) {
return true;
}
lock.unlock();
long newValue = 0, paramFlag = 0; // NOLINT(runtime/int)
@@ -124,8 +127,9 @@ bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
IAMCameraControl* pProcAmp,
int newValue) const {
if (!pProcAmp)
if (!pProcAmp) {
return true;
}
lock.unlock();
if (SUCCEEDED(pProcAmp->Set(tagCameraControl, newValue,
@@ -139,8 +143,9 @@ bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
bool UsbCameraProperty::DeviceGet(std::unique_lock<wpi::mutex>& lock,
IMFSourceReader* sourceReader) {
if (!sourceReader)
if (!sourceReader) {
return true;
}
if (isControlProperty) {
ComPtr<IAMCameraControl> pProcAmp;
@@ -169,8 +174,9 @@ bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
bool UsbCameraProperty::DeviceSet(std::unique_lock<wpi::mutex>& lock,
IMFSourceReader* sourceReader,
int newValue) const {
if (!sourceReader)
if (!sourceReader) {
return true;
}
if (isControlProperty) {
ComPtr<IAMCameraControl> pProcAmp;

View File

@@ -20,7 +20,7 @@ endif()
add_executable(datalogtool ${datalogtool_src} ${datalogtool_resources_src} ${datalogtool_rc} ${APP_ICON_MACOSX})
wpilib_link_macos_gui(datalogtool)
target_link_libraries(datalogtool libglass ${LIBSSH_LIBRARIES})
target_include_directories(datalogtool PRIVATE ${LIBSSH_INCLUDE_DIRS})
target_include_directories(datalogtool SYSTEM PRIVATE ${LIBSSH_INCLUDE_DIRS})
if (WIN32)
set_target_properties(datalogtool PROPERTIES WIN32_EXECUTABLE YES)

View File

@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxarm32') && !project.hasProperty('onlylinuxarm64')) {
description = "roboRIO Team Number Setter"
@@ -27,12 +27,12 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
nativeUtils {
nativeDependencyContainer {
libssh(getNativeDependencyTypeClass('WPIStaticMavenDependency')) {
groupId = "edu.wpi.first.thirdparty.frc2022"
groupId = "edu.wpi.first.thirdparty.frc2023"
artifactId = "libssh"
headerClassifier = "headers"
sourceClassifier = "sources"
ext = "zip"
version = '0.95-1'
version = '0.95-3'
targetPlatforms.addAll(nativeUtils.wpi.platforms.desktopPlatforms)
}
}
@@ -107,7 +107,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm32 || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm64) {
it.buildable = false
return
}

View File

@@ -10,7 +10,7 @@ model {
tasks {
// Create the run task.
$.components.datalogtool.binaries.each { bin ->
if (bin.buildable && bin.name.toLowerCase().contains("debug")) {
if (bin.buildable && bin.name.toLowerCase().contains("debug") && nativeUtils.isNativeDesktopPlatform(bin.targetPlatform)) {
Task run = project.tasks.create("run", Exec) {
commandLine bin.tasks.install.runScriptFile.get().asFile.toString()
}
@@ -30,10 +30,10 @@ model {
def icon = file("$project.projectDir/src/main/native/mac/datalogtool.icns")
// Create the macOS bundle.
def bundleTask = project.tasks.create("bundleDataLogToolOsxApp", Copy) {
def bundleTask = project.tasks.create("bundleDataLogToolOsxApp" + binary.targetPlatform.architecture.name, Copy) {
description("Creates a macOS application bundle for DataLogTool")
from(file("$project.projectDir/Info.plist"))
into(file("$project.buildDir/outputs/bundles/DataLogTool.app/Contents"))
into(file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/DataLogTool.app/Contents"))
into("MacOS") { with copySpec { from binary.executable.file } }
into("Resources") { with copySpec { from icon } }
@@ -48,7 +48,7 @@ model {
"codesign --force --strict --deep " +
"--timestamp --options=runtime " +
"--verbose -s ${project.findProperty("developerID")} " +
"$project.buildDir/outputs/bundles/DataLogTool.app/"
"$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/DataLogTool.app/"
]
commandLine args
}
@@ -58,12 +58,12 @@ model {
// Reset the application path if we are creating a bundle.
if (binary.targetPlatform.operatingSystem.isMacOsX()) {
applicationPath = file("$project.buildDir/outputs/bundles")
applicationPath = file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name")
project.build.dependsOn bundleTask
}
// Create the ZIP.
def task = project.tasks.create("copyDataLogToolExecutable", Zip) {
def task = project.tasks.create("copyDataLogToolExecutable" + binary.targetPlatform.architecture.name, Zip) {
description("Copies the DataLogTool executable to the outputs directory.")
destinationDirectory = outputsFolder

View File

@@ -37,7 +37,7 @@ cppProjectZips.add(project(':wpilibNewCommands').cppHeadersZip)
doxygen {
executables {
doxygen version : '1.9.2',
doxygen version : '1.9.4',
baseURI : 'https://frcmaven.wpi.edu/artifactory/generic-release-mirror/doxygen'
}
}
@@ -115,6 +115,9 @@ doxygen {
// json
exclude 'wpi/json.h'
// memory
exclude 'wpi/memory/**'
// mpack
exclude 'wpi/mpack.h'

View File

@@ -7,6 +7,9 @@ if (WITH_JAVA)
find_package(Java REQUIRED)
include(UseJava)
file(GLOB JACKSON_JARS "${WPILIB_BINARY_DIR}/wpiutil/thirdparty/jackson/*.jar")
set(CMAKE_JAVA_INCLUDE_PATH fieldImages.jar ${JACKSON_JARS})
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(GLOB_RECURSE JAVA_RESOURCES src/main/native/resources/*.json src/main/native/resources/*.png src/main/native/resources/*.jpg)
add_jar(field_images_jar SOURCES ${JAVA_SOURCES} RESOURCES NAMESPACE "edu/wpi/first/fields" ${JAVA_RESOURCES} OUTPUT_NAME fieldImages)

View File

@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxarm32') && !project.hasProperty('onlylinuxarm64')) {
apply plugin: 'cpp'
apply plugin: 'c'
@@ -13,6 +13,12 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
apply plugin: 'windows-resources'
}
dependencies {
implementation "com.fasterxml.jackson.core:jackson-annotations:2.12.4"
implementation "com.fasterxml.jackson.core:jackson-core:2.12.4"
implementation "com.fasterxml.jackson.core:jackson-databind:2.12.4"
}
ext {
nativeName = 'fieldImages'
baseId = nativeName

View File

@@ -0,0 +1,90 @@
// 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.
package edu.wpi.fields;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
public class FieldConfig {
public static class Corners {
@JsonProperty("top-left")
public double[] m_topLeft;
@JsonProperty("bottom-right")
public double[] m_bottomRight;
}
@JsonProperty("game")
public String m_game;
@JsonProperty("field-image")
public String m_fieldImage;
@JsonProperty("field-corners")
public Corners m_fieldCorners;
@JsonProperty("field-size")
public double[] m_fieldSize;
@JsonProperty("field-unit")
public String m_fieldUnit;
public FieldConfig() {}
@SuppressWarnings("deprecation")
public URL getImageUrl() {
return getClass().getResource(Fields.kBaseResourceDir + m_fieldImage);
}
@SuppressWarnings("deprecation")
public InputStream getImageAsStream() {
return getClass().getResourceAsStream(Fields.kBaseResourceDir + m_fieldImage);
}
/**
* Loads a predefined field configuration from a resource file.
*
* @param field The predefined field
* @return The field configuration
* @throws IOException Throws if the file could not be loaded
*/
public static FieldConfig loadField(Fields field) throws IOException {
return loadFromResource(field.m_resourceFile);
}
/**
* Loads a field configuration from a file on disk.
*
* @param file The json file to load
* @return The field configuration
* @throws IOException Throws if the file could not be loaded
*/
public static FieldConfig loadFromFile(Path file) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(file)) {
return new ObjectMapper().readerFor(FieldConfig.class).readValue(reader);
}
}
/**
* Loads a field configuration from a resource file located inside the programs jar file.
*
* @param resourcePath The path to the resource file
* @return The field configuration
* @throws IOException Throws if the resoure could not be loaded
*/
public static FieldConfig loadFromResource(String resourcePath) throws IOException {
try (InputStream stream = FieldConfig.class.getResourceAsStream(resourcePath);
InputStreamReader reader = new InputStreamReader(stream)) {
return new ObjectMapper().readerFor(FieldConfig.class).readValue(reader);
}
}
}

View File

@@ -1,25 +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.
package edu.wpi.fields;
public class FieldImages {
public static final String k2018PowerUpFieldConfig = "/edu/wpi/first/fields/2018-powerup.json";
public static final String k2019DeepSpaceFieldConfig =
"/edu/wpi/first/fields/2019-deepspace.json";
public static final String k2020InfiniteRechargeFieldConfig =
"/edu/wpi/first/fields/2020-infiniterecharge.json";
public static final String k2021InfiniteRechargeFieldConfig =
"/edu/wpi/first/fields/2021-infiniterecharge.json";
public static final String k2021BarrelFieldConfig =
"/edu/wpi/first/fields/2021-barrelracingpath.json";
public static final String k2021BounceFieldConfig = "/edu/wpi/first/fields/2021-bouncepath.json";
public static final String k2021GalacticSearchAFieldConfig =
"/edu/wpi/first/fields/2021-galacticsearcha.json";
public static final String k2021GalacticSearchBFieldConfig =
"/edu/wpi/first/fields/2021-galacticsearchb.json";
public static final String k2021SlalomFieldConfig = "/edu/wpi/first/fields/2021-slalompath.json";
public static final String k2022RapidReactFieldConfig =
"/edu/wpi/first/fields/2022-rapidreact.json";
}

View File

@@ -0,0 +1,29 @@
// 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.
package edu.wpi.fields;
public enum Fields {
k2018PowerUp("2018-powerup.json"),
k2019DeepSpace("2019-deepspace.json"),
k2020InfiniteRecharge("2020-infiniterecharge.json"),
k2021InfiniteRecharge("2021-infiniterecharge.json"),
k2021Barrel("2021-barrelracingpath.json"),
k2021Bounce("2021-bouncepath.json"),
k2021GalacticSearchA("2021-galacticsearcha.json"),
k2021GalacticSearchB("2021-galacticsearchb.json"),
k2021Slalom("2021-slalompath.json"),
k2022RapidReact("2022-rapidreact.json");
public static final String kBaseResourceDir = "/edu/wpi/first/fields/";
/** Alias to the current game. */
public static final Fields kDefaultField = k2022RapidReact;
public final String m_resourceFile;
Fields(String resourceFile) {
m_resourceFile = kBaseResourceDir + resourceFile;
}
}

View File

@@ -0,0 +1,19 @@
// 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.
package edu.wpi.fields;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
class LoadConfigTest {
@ParameterizedTest
@EnumSource(Fields.class)
void testLoad(Fields field) {
FieldConfig config = Assertions.assertDoesNotThrow(() -> FieldConfig.loadField(field));
Assertions.assertNotNull(config.getImageUrl());
}
}

View File

@@ -1,6 +1,6 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxarm32') && !project.hasProperty('onlylinuxarm64')) {
description = "A different kind of dashboard"
@@ -100,7 +100,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm32 || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm64) {
it.buildable = false
return
}
@@ -128,7 +128,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm32 || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm64) {
it.buildable = false
return
}
@@ -169,7 +169,7 @@ if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxra
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.raspbian || it.targetPlatform.name == nativeUtils.wpi.platforms.aarch64bionic) {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm32 || it.targetPlatform.name == nativeUtils.wpi.platforms.linuxarm64) {
it.buildable = false
return
}

View File

@@ -64,7 +64,8 @@ model {
tasks {
// Create the run task.
$.components.glassApp.binaries.each { bin ->
if (bin.buildable && bin.name.toLowerCase().contains("debug")) {
if (bin.buildable && bin.name.toLowerCase().contains("debug") && nativeUtils.isNativeDesktopPlatform(bin.targetPlatform)) {
Task run = project.tasks.create("run", Exec) {
commandLine bin.tasks.install.runScriptFile.get().asFile.toString()
}
@@ -84,10 +85,10 @@ model {
def icon = file("$project.projectDir/src/app/native/mac/glass.icns")
// Create the macOS bundle.
def bundleTask = project.tasks.create("bundleGlassOsxApp", Copy) {
def bundleTask = project.tasks.create("bundleGlassOsxApp" + binary.targetPlatform.architecture.name, Copy) {
description("Creates a macOS application bundle for Glass")
from(file("$project.projectDir/Info.plist"))
into(file("$project.buildDir/outputs/bundles/Glass.app/Contents"))
into(file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/Glass.app/Contents"))
into("MacOS") { with copySpec { from binary.executable.file } }
into("Resources") { with copySpec { from icon } }
@@ -102,7 +103,7 @@ model {
"codesign --force --strict --deep " +
"--timestamp --options=runtime " +
"--verbose -s ${project.findProperty("developerID")} " +
"$project.buildDir/outputs/bundles/Glass.app/"
"$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/Glass.app/"
]
commandLine args
}
@@ -112,12 +113,12 @@ model {
// Reset the application path if we are creating a bundle.
if (binary.targetPlatform.operatingSystem.isMacOsX()) {
applicationPath = file("$project.buildDir/outputs/bundles")
applicationPath = file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name")
project.build.dependsOn bundleTask
}
// Create the ZIP.
def task = project.tasks.create("copyGlassExecutable", Zip) {
def task = project.tasks.create("copyGlassExecutable" + binary.targetPlatform.architecture.name, Zip) {
description("Copies the Glass executable to the outputs directory.")
destinationDirectory = outputsFolder

View File

@@ -179,6 +179,11 @@ int main(int argc, char** argv) {
gui::AddIcon(glass::GetResource_glass_256_png());
gui::AddIcon(glass::GetResource_glass_512_png());
gui::AddEarlyExecute(
[] { ImGui::DockSpaceOverViewport(ImGui::GetMainViewport()); });
gui::AddInit([] { ImGui::GetIO().ConfigDockingWithShift = true; });
gPlotProvider = std::make_unique<glass::PlotProvider>(
glass::GetStorageRoot().GetChild("Plots"));
gNtProvider = std::make_unique<glass::NetworkTablesProvider>(
@@ -291,7 +296,8 @@ int main(int argc, char** argv) {
}
});
gui::Initialize("Glass - DISCONNECTED", 1024, 768);
gui::Initialize("Glass - DISCONNECTED", 1024, 768,
ImGuiConfigFlags_DockingEnable);
gEnterKey = &glass::GetStorageRoot().GetInt("enterKey", GLFW_KEY_ENTER);
if (auto win = gui::GetSystemWindow()) {
gPrevKeyCallback = glfwSetKeyCallback(win, RemapEnterKeyCallback);

View File

@@ -69,6 +69,9 @@ static bool JsonToWindow(const wpi::json& jfile, const char* filename) {
wpi::raw_string_ostream ini{iniStr};
for (auto&& jsection : jfile.items()) {
if (jsection.key() == "Docking") {
continue;
}
if (!jsection.value().is_object()) {
ImGui::LogText("%s section %s is not object", filename,
jsection.key().c_str());
@@ -95,6 +98,31 @@ static bool JsonToWindow(const wpi::json& jfile, const char* filename) {
ini << '\n';
}
}
// emit Docking section last
auto docking = jfile.find("Docking");
if (docking != jfile.end()) {
for (auto&& jsubsection : docking->items()) {
if (!jsubsection.value().is_array()) {
ImGui::LogText("%s section %s subsection %s is not array", filename,
"Docking", jsubsection.key().c_str());
return false;
}
ini << "[Docking][" << jsubsection.key() << "]\n";
for (auto&& jv : jsubsection.value()) {
try {
auto& value = jv.get_ref<const std::string&>();
ini << value << "\n";
} catch (wpi::json::exception&) {
ImGui::LogText("%s section %s subsection %s value is not string",
filename, "Docking", jsubsection.key().c_str());
return false;
}
}
ini << '\n';
}
}
ini.flush();
ImGui::LoadIniSettingsFromMemory(iniStr.data(), iniStr.size());
@@ -204,7 +232,11 @@ static wpi::json WindowToJson() {
}
curSection = &jsection[subsection];
if (curSection->is_null()) {
*curSection = wpi::json::object();
if (section == "Docking") {
*curSection = wpi::json::array();
} else {
*curSection = wpi::json::object();
}
}
} else {
// value
@@ -212,7 +244,11 @@ static wpi::json WindowToJson() {
continue; // shouldn't happen, but just in case
}
auto [name, value] = wpi::split(line, '=');
(*curSection)[name] = value;
if (curSection->is_object()) {
(*curSection)[name] = value;
} else if (curSection->is_array()) {
curSection->emplace_back(line);
}
}
}

View File

@@ -149,7 +149,6 @@ class Plot {
bool& m_legendHorizontal;
int& m_legendLocation;
bool& m_crosshairs;
bool& m_antialiased;
bool& m_mousePosition;
bool& m_yAxis2;
bool& m_yAxis3;
@@ -327,7 +326,7 @@ PlotSeries::Action PlotSeries::EmitPlot(PlotView& view, double now, size_t i,
int offset;
};
GetterData getterData = {now, GetZeroTime() * 1.0e-6, m_data, size, offset};
auto getter = [](void* data, int idx) {
auto getter = [](int idx, void* data) {
auto d = static_cast<GetterData*>(data);
if (idx == d->size) {
return ImPlotPoint{
@@ -487,7 +486,6 @@ Plot::Plot(Storage& storage)
m_legendLocation{
storage.GetInt("legendLocation", ImPlotLocation_NorthWest)},
m_crosshairs{storage.GetBool("crosshairs", false)},
m_antialiased{storage.GetBool("antialiased", false)},
m_mousePosition{storage.GetBool("mousePosition", true)},
m_yAxis2{storage.GetBool("yaxis2", false)},
m_yAxis3{storage.GetBool("yaxis3", false)},
@@ -573,7 +571,6 @@ void Plot::EmitPlot(PlotView& view, double now, bool paused, size_t i) {
static_cast<int>(i));
ImPlotFlags plotFlags = (m_legend ? 0 : ImPlotFlags_NoLegend) |
(m_crosshairs ? ImPlotFlags_Crosshairs : 0) |
(m_antialiased ? ImPlotFlags_AntiAliased : 0) |
(m_mousePosition ? 0 : ImPlotFlags_NoMouseText);
if (ImPlot::BeginPlot(label, ImVec2(-1, m_height), plotFlags)) {
@@ -608,7 +605,6 @@ void Plot::EmitPlot(PlotView& view, double now, bool paused, size_t i) {
(m_axis[i].lockMin ? ImPlotAxisFlags_LockMin : 0) |
(m_axis[i].lockMax ? ImPlotAxisFlags_LockMax : 0) |
(m_axis[i].autoFit ? ImPlotAxisFlags_AutoFit : 0) |
(m_axis[i].logScale ? ImPlotAxisFlags_AutoFit : 0) |
(m_axis[i].invert ? ImPlotAxisFlags_Invert : 0) |
(m_axis[i].opposite ? ImPlotAxisFlags_Opposite : 0) |
(m_axis[i].gridLines ? 0 : ImPlotAxisFlags_NoGridLines) |
@@ -620,6 +616,9 @@ void Plot::EmitPlot(PlotView& view, double now, bool paused, size_t i) {
ImPlot::SetupAxisLimits(
ImAxis_Y1 + i, m_axis[i].min, m_axis[i].max,
m_axis[i].apply ? ImGuiCond_Always : ImGuiCond_Once);
ImPlot::SetupAxisScale(ImAxis_Y1 + i, m_axis[i].logScale
? ImPlotScale_Log10
: ImPlotScale_Linear);
m_axis[i].apply = false;
}
@@ -656,7 +655,6 @@ void Plot::EmitPlot(PlotView& view, double now, bool paused, size_t i) {
// copy plot settings back to storage
m_legend = (plot->Flags & ImPlotFlags_NoLegend) == 0;
m_crosshairs = (plot->Flags & ImPlotFlags_Crosshairs) != 0;
m_antialiased = (plot->Flags & ImPlotFlags_AntiAliased) != 0;
m_legendOutside =
(plot->Items.Legend.Flags & ImPlotLegendFlags_Outside) != 0;
m_legendHorizontal =
@@ -671,12 +669,12 @@ void Plot::EmitPlot(PlotView& view, double now, bool paused, size_t i) {
m_axis[i].lockMin = (flags & ImPlotAxisFlags_LockMin) != 0;
m_axis[i].lockMax = (flags & ImPlotAxisFlags_LockMax) != 0;
m_axis[i].autoFit = (flags & ImPlotAxisFlags_AutoFit) != 0;
m_axis[i].logScale = (flags & ImPlotAxisFlags_LogScale) != 0;
m_axis[i].invert = (flags & ImPlotAxisFlags_Invert) != 0;
m_axis[i].opposite = (flags & ImPlotAxisFlags_Opposite) != 0;
m_axis[i].gridLines = (flags & ImPlotAxisFlags_NoGridLines) == 0;
m_axis[i].tickMarks = (flags & ImPlotAxisFlags_NoTickMarks) == 0;
m_axis[i].tickLabels = (flags & ImPlotAxisFlags_NoTickLabels) == 0;
m_axis[i].logScale = plot->Axes[ImAxis_Y1 + i].Scale == ImPlotScale_Log10;
}
}
}

View File

@@ -368,7 +368,8 @@ static std::shared_ptr<nt::Value> StringToStringArray(std::string_view in) {
return nt::NetworkTableValue::MakeStringArray(std::move(out));
}
static void EmitEntryValueReadonly(NetworkTablesModel::Entry& entry) {
static void EmitEntryValueReadonly(NetworkTablesModel::Entry& entry,
NetworkTablesFlags flags) {
auto& val = entry.value;
if (!val) {
return;
@@ -378,9 +379,20 @@ static void EmitEntryValueReadonly(NetworkTablesModel::Entry& entry) {
case NT_BOOLEAN:
ImGui::LabelText("boolean", "%s", val->GetBoolean() ? "true" : "false");
break;
case NT_DOUBLE:
ImGui::LabelText("double", "%.6f", val->GetDouble());
case NT_DOUBLE: {
unsigned char precision = (flags & NetworkTablesFlags_Precision) >>
kNetworkTablesFlags_PrecisionBitShift;
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
ImGui::LabelText("double", fmt::format("%.{}f", precision).c_str(),
val->GetDouble());
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
break;
}
case NT_STRING: {
// GetString() comes from a std::string, so it's null terminated
ImGui::LabelText("string", "%s", val->GetString().data());
@@ -417,7 +429,8 @@ static char* GetTextBuffer(std::string_view in) {
return textBuffer;
}
static void EmitEntryValueEditable(NetworkTablesModel::Entry& entry) {
static void EmitEntryValueEditable(NetworkTablesModel::Entry& entry,
NetworkTablesFlags flags) {
auto& val = entry.value;
if (!val) {
return;
@@ -435,10 +448,20 @@ static void EmitEntryValueEditable(NetworkTablesModel::Entry& entry) {
}
case NT_DOUBLE: {
double v = val->GetDouble();
if (ImGui::InputDouble("double", &v, 0, 0, "%.6f",
unsigned char precision = (flags & NetworkTablesFlags_Precision) >>
kNetworkTablesFlags_PrecisionBitShift;
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
if (ImGui::InputDouble("double", &v, 0, 0,
fmt::format("%.{}f", precision).c_str(),
ImGuiInputTextFlags_EnterReturnsTrue)) {
nt::SetEntryValue(entry.entry, nt::NetworkTableValue::MakeDouble(v));
}
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif
break;
}
case NT_STRING: {
@@ -600,9 +623,9 @@ static void EmitEntry(NetworkTablesModel::Entry& entry, const char* name,
ImGui::NextColumn();
if (flags & NetworkTablesFlags_ReadOnly) {
EmitEntryValueReadonly(entry);
EmitEntryValueReadonly(entry, flags);
} else {
EmitEntryValueEditable(entry);
EmitEntryValueEditable(entry, flags);
}
ImGui::NextColumn();
@@ -743,19 +766,23 @@ void NetworkTablesFlagsSettings::Update() {
m_pCreateNoncanonicalKeys = &storage.GetBool(
"createNonCanonical",
m_defaultFlags & NetworkTablesFlags_CreateNoncanonicalKeys);
m_pPrecision = &storage.GetInt(
"precision", (m_defaultFlags & NetworkTablesFlags_Precision) >>
kNetworkTablesFlags_PrecisionBitShift);
}
m_flags &=
~(NetworkTablesFlags_TreeView | NetworkTablesFlags_ShowConnections |
NetworkTablesFlags_ShowFlags | NetworkTablesFlags_ShowTimestamp |
NetworkTablesFlags_CreateNoncanonicalKeys);
m_flags &= ~(
NetworkTablesFlags_TreeView | NetworkTablesFlags_ShowConnections |
NetworkTablesFlags_ShowFlags | NetworkTablesFlags_ShowTimestamp |
NetworkTablesFlags_CreateNoncanonicalKeys | NetworkTablesFlags_Precision);
m_flags |=
(*m_pTreeView ? NetworkTablesFlags_TreeView : 0) |
(*m_pShowConnections ? NetworkTablesFlags_ShowConnections : 0) |
(*m_pShowFlags ? NetworkTablesFlags_ShowFlags : 0) |
(*m_pShowTimestamp ? NetworkTablesFlags_ShowTimestamp : 0) |
(*m_pCreateNoncanonicalKeys ? NetworkTablesFlags_CreateNoncanonicalKeys
: 0);
: 0) |
(*m_pPrecision << kNetworkTablesFlags_PrecisionBitShift);
}
void NetworkTablesFlagsSettings::DisplayMenu() {
@@ -766,6 +793,17 @@ void NetworkTablesFlagsSettings::DisplayMenu() {
ImGui::MenuItem("Show Connections", "", m_pShowConnections);
ImGui::MenuItem("Show Flags", "", m_pShowFlags);
ImGui::MenuItem("Show Timestamp", "", m_pShowTimestamp);
if (ImGui::BeginMenu("Decimal Precision")) {
static const char* precisionOptions[] = {"1", "2", "3", "4", "5",
"6", "7", "8", "9", "10"};
for (int i = 1; i <= 10; i++) {
if (ImGui::MenuItem(precisionOptions[i - 1], nullptr,
i == *m_pPrecision)) {
*m_pPrecision = i;
}
}
ImGui::EndMenu();
}
ImGui::Separator();
ImGui::MenuItem("Allow creation of non-canonical keys", "",
m_pCreateNoncanonicalKeys);

View File

@@ -88,6 +88,8 @@ class NetworkTablesModel : public Model {
using NetworkTablesFlags = int;
static constexpr const int kNetworkTablesFlags_PrecisionBitShift = 6;
enum NetworkTablesFlags_ {
NetworkTablesFlags_TreeView = 1 << 0,
NetworkTablesFlags_ReadOnly = 1 << 1,
@@ -95,8 +97,10 @@ enum NetworkTablesFlags_ {
NetworkTablesFlags_ShowFlags = 1 << 3,
NetworkTablesFlags_ShowTimestamp = 1 << 4,
NetworkTablesFlags_CreateNoncanonicalKeys = 1 << 5,
NetworkTablesFlags_Default = 1 & ~NetworkTablesFlags_ReadOnly &
~NetworkTablesFlags_CreateNoncanonicalKeys
NetworkTablesFlags_Precision = 0xff << kNetworkTablesFlags_PrecisionBitShift,
NetworkTablesFlags_Default = (1 & ~NetworkTablesFlags_ReadOnly &
~NetworkTablesFlags_CreateNoncanonicalKeys) |
(6 << kNetworkTablesFlags_PrecisionBitShift),
};
void DisplayNetworkTables(
@@ -120,6 +124,7 @@ class NetworkTablesFlagsSettings {
bool* m_pShowFlags = nullptr;
bool* m_pShowTimestamp = nullptr;
bool* m_pCreateNoncanonicalKeys = nullptr;
int* m_pPrecision = nullptr;
NetworkTablesFlags m_defaultFlags; // NOLINT
NetworkTablesFlags m_flags; // NOLINT
};

Binary file not shown.

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

6
gradlew vendored
View File

@@ -205,6 +205,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

14
gradlew.bat vendored
View File

@@ -14,7 +14,7 @@
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@@ -25,7 +25,7 @@
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal

View File

@@ -100,6 +100,11 @@ ext {
}
}
}
exeSplitSetup = {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
}
apply from: "${rootDir}/shared/jni/setupBuild.gradle"

View File

@@ -7,7 +7,6 @@ package edu.wpi.first.hal;
/**
* JNI wrapper for library <b>FRC_NetworkCommunication</b><br>.
*/
@SuppressWarnings({"MethodName", "LineLength"})
public class FRCNetComm {
/**
* Resource type from UsageReporting.

View File

@@ -5,12 +5,11 @@
package edu.wpi.first.hal;
/** Structure for holding the values stored in an accumulator. */
@SuppressWarnings("MemberName")
public class AccumulatorResult {
/** The total value accumulated. */
@SuppressWarnings("MemberName")
public long value;
/** The number of sample value was accumulated over. */
@SuppressWarnings("MemberName")
public long count;
/**

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class AddressableLEDJNI extends JNIWrapper {
public static native int initialize(int pwmHandle);

View File

@@ -111,6 +111,5 @@ public class AnalogJNI extends JNIWrapper {
public static native boolean getAnalogTriggerOutput(int analogTriggerHandle, int type);
@SuppressWarnings("AbbreviationAsWordInName")
public static native int getAnalogTriggerFPGAIndex(int analogTriggerHandle);
}

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class CANAPIJNI extends JNIWrapper {
public static native int initializeCAN(int manufacturer, int deviceId, int deviceType);

View File

@@ -4,14 +4,10 @@
package edu.wpi.first.hal;
@SuppressWarnings("MemberName")
public class CANData {
@SuppressWarnings("MemberName")
public final byte[] data = new byte[8];
@SuppressWarnings("MemberName")
public int length;
@SuppressWarnings("MemberName")
public long timestamp;
/**

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class CTREPCMJNI extends JNIWrapper {
public static native int initialize(int module);

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class DIOJNI extends JNIWrapper {
public static native int initializeDIOPort(int halPortHandle, boolean input);
@@ -22,7 +21,9 @@ public class DIOJNI extends JNIWrapper {
public static native boolean getDIODirection(int dioPortHandle);
public static native void pulse(int dioPortHandle, double pulseLength);
public static native void pulse(int dioPortHandle, double pulseLengthSeconds);
public static native void pulseMultiple(long channelMask, double pulseLengthSeconds);
public static native boolean isPulsing(int dioPortHandle);

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class DMAJNI extends JNIWrapper {
public static native int initialize();

View File

@@ -7,7 +7,6 @@ package edu.wpi.first.hal;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("AbbreviationAsWordInName")
public class DMAJNISample {
private static final int kEnable_Accumulator0 = 8;
private static final int kEnable_Accumulator1 = 9;

View File

@@ -17,6 +17,5 @@ public class DutyCycleJNI extends JNIWrapper {
public static native int getOutputScaleFactor(int handle);
@SuppressWarnings("AbbreviationAsWordInName")
public static native int getFPGAIndex(int handle);
}

View File

@@ -50,7 +50,6 @@ public class EncoderJNI extends JNIWrapper {
public static native void setEncoderIndexSource(
int encoderHandle, int digitalSourceHandle, int analogTriggerType, int indexingType);
@SuppressWarnings("AbbreviationAsWordInName")
public static native int getEncoderFPGAIndex(int encoderHandle);
public static native int getEncoderEncodingScale(int encoderHandle);

View File

@@ -12,7 +12,6 @@ import java.util.List;
* JNI Wrapper for HAL<br>
* .
*/
@SuppressWarnings({"AbbreviationAsWordInName", "MethodName"})
public final class HAL extends JNIWrapper {
public static native void waitForDSData();
@@ -153,7 +152,11 @@ public final class HAL extends JNIWrapper {
public static native int nativeGetControlWord();
@SuppressWarnings("MissingJavadocMethod")
/**
* Get the current DriverStation control word.
*
* @param controlWord Storage for control word.
*/
public static void getControlWord(ControlWord controlWord) {
int word = nativeGetControlWord();
controlWord.update(
@@ -167,7 +170,11 @@ public final class HAL extends JNIWrapper {
private static native int nativeGetAllianceStation();
@SuppressWarnings("MissingJavadocMethod")
/**
* Get the alliance station.
*
* @return The alliance station.
*/
public static AllianceStationID getAllianceStation() {
switch (nativeGetAllianceStation()) {
case 0:
@@ -187,13 +194,10 @@ public final class HAL extends JNIWrapper {
}
}
@SuppressWarnings("MissingJavadocMethod")
public static native boolean isNewControlData();
@SuppressWarnings("MissingJavadocMethod")
public static native void releaseDSMutex();
@SuppressWarnings("MissingJavadocMethod")
public static native boolean waitForDSDataTimeout(double timeout);
public static final int kMaxJoystickAxes = 12;

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public final class HALUtil extends JNIWrapper {
public static final int NULL_PARAMETER = -1005;
public static final int SAMPLE_RATE_TOO_HIGH = 1001;

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public final class HALValue {
public static final int kUnassigned = 0;
public static final int kBoolean = 0x01;

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.hal;
import java.nio.ByteBuffer;
@SuppressWarnings("AbbreviationAsWordInName")
public class I2CJNI extends JNIWrapper {
public static native void i2CInitialize(int port);

View File

@@ -5,25 +5,21 @@
package edu.wpi.first.hal;
/** Structure for holding the match info data request. */
@SuppressWarnings("MemberName")
public class MatchInfoData {
/** Stores the event name. */
@SuppressWarnings("MemberName")
public String eventName = "";
/** Stores the game specific message. */
@SuppressWarnings("MemberName")
public String gameSpecificMessage = "";
/** Stores the match number. */
@SuppressWarnings("MemberName")
public int matchNumber;
/** Stores the replay number. */
@SuppressWarnings("MemberName")
public int replayNumber;
/** Stores the match type. */
@SuppressWarnings("MemberName")
public int matchType;
/**
@@ -35,7 +31,6 @@ public class MatchInfoData {
* @param replayNumber Replay number.
* @param matchType Match type.
*/
@SuppressWarnings("MissingJavadocMethod")
public void setData(
String eventName,
String gameSpecificMessage,

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.hal;
/** Structure for holding the config data result for PWM. */
@SuppressWarnings("MemberName")
public class PWMConfigDataResult {
PWMConfigDataResult(int max, int deadbandMax, int center, int deadbandMin, int min) {
this.max = max;
@@ -15,22 +16,17 @@ public class PWMConfigDataResult {
}
/** The maximum PWM value. */
@SuppressWarnings("MemberName")
public int max;
/** The deadband maximum PWM value. */
@SuppressWarnings("MemberName")
public int deadbandMax;
/** The center PWM value. */
@SuppressWarnings("MemberName")
public int center;
/** The deadband minimum PWM value. */
@SuppressWarnings("MemberName")
public int deadbandMin;
/** The minimum PWM value. */
@SuppressWarnings("MemberName")
public int min;
}

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class PWMJNI extends DIOJNI {
public static native int initializePWMPort(int halPortHandle);

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class PortsJNI extends JNIWrapper {
public static native int getNumAccumulators();

View File

@@ -4,86 +4,60 @@
package edu.wpi.first.hal;
@SuppressWarnings("MemberName")
public class PowerDistributionFaults {
@SuppressWarnings("MemberName")
public final boolean Channel0BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel1BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel2BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel3BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel4BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel5BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel6BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel7BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel8BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel9BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel10BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel11BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel12BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel13BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel14BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel15BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel16BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel17BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel18BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel19BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel20BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel21BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel22BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel23BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Brownout;
@SuppressWarnings("MemberName")
public final boolean CanWarning;
@SuppressWarnings("MemberName")
public final boolean HardwareFault;
/**

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class PowerDistributionJNI extends JNIWrapper {
public static final int AUTOMATIC_TYPE = 0;
public static final int CTRE_TYPE = 1;

View File

@@ -4,89 +4,62 @@
package edu.wpi.first.hal;
@SuppressWarnings("MemberName")
public class PowerDistributionStickyFaults {
@SuppressWarnings("MemberName")
public final boolean Channel0BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel1BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel2BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel3BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel4BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel5BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel6BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel7BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel8BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel9BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel10BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel11BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel12BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel13BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel14BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel15BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel16BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel17BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel18BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel19BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel20BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel21BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel22BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Channel23BreakerFault;
@SuppressWarnings("MemberName")
public final boolean Brownout;
@SuppressWarnings("MemberName")
public final boolean CanWarning;
@SuppressWarnings("MemberName")
public final boolean CanBusOff;
@SuppressWarnings("MemberName")
public final boolean HasReset;
/**

View File

@@ -4,23 +4,18 @@
package edu.wpi.first.hal;
@SuppressWarnings("MemberName")
public class PowerDistributionVersion {
@SuppressWarnings("MemberName")
public final int firmwareMajor;
@SuppressWarnings("MemberName")
public final int firmwareMinor;
@SuppressWarnings("MemberName")
public final int firmwareFix;
@SuppressWarnings("MemberName")
public final int hardwareMinor;
@SuppressWarnings("MemberName")
public final int hardwareMajor;
@SuppressWarnings("MemberName")
public final int uniqueId;
/**

View File

@@ -4,72 +4,50 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
@SuppressWarnings("MemberName")
public class REVPHFaults {
@SuppressWarnings("MemberName")
public final boolean Channel0Fault;
@SuppressWarnings("MemberName")
public final boolean Channel1Fault;
@SuppressWarnings("MemberName")
public final boolean Channel2Fault;
@SuppressWarnings("MemberName")
public final boolean Channel3Fault;
@SuppressWarnings("MemberName")
public final boolean Channel4Fault;
@SuppressWarnings("MemberName")
public final boolean Channel5Fault;
@SuppressWarnings("MemberName")
public final boolean Channel6Fault;
@SuppressWarnings("MemberName")
public final boolean Channel7Fault;
@SuppressWarnings("MemberName")
public final boolean Channel8Fault;
@SuppressWarnings("MemberName")
public final boolean Channel9Fault;
@SuppressWarnings("MemberName")
public final boolean Channel10Fault;
@SuppressWarnings("MemberName")
public final boolean Channel11Fault;
@SuppressWarnings("MemberName")
public final boolean Channel12Fault;
@SuppressWarnings("MemberName")
public final boolean Channel13Fault;
@SuppressWarnings("MemberName")
public final boolean Channel14Fault;
@SuppressWarnings("MemberName")
public final boolean Channel15Fault;
@SuppressWarnings("MemberName")
public final boolean CompressorOverCurrent;
@SuppressWarnings("MemberName")
public final boolean CompressorOpen;
@SuppressWarnings("MemberName")
public final boolean SolenoidOverCurrent;
@SuppressWarnings("MemberName")
public final boolean Brownout;
@SuppressWarnings("MemberName")
public final boolean CanWarning;
@SuppressWarnings("MemberName")
public final boolean HardwareFault;
/**

View File

@@ -4,7 +4,6 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class REVPHJNI extends JNIWrapper {
public static final int COMPRESSOR_CONFIG_TYPE_DISABLED = 0;
public static final int COMPRESSOR_CONFIG_TYPE_DIGITAL = 1;

View File

@@ -4,27 +4,20 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
@SuppressWarnings("MemberName")
public class REVPHStickyFaults {
@SuppressWarnings("MemberName")
public final boolean CompressorOverCurrent;
@SuppressWarnings("MemberName")
public final boolean CompressorOpen;
@SuppressWarnings("MemberName")
public final boolean SolenoidOverCurrent;
@SuppressWarnings("MemberName")
public final boolean Brownout;
@SuppressWarnings("MemberName")
public final boolean CanWarning;
@SuppressWarnings("MemberName")
public final boolean CanBusOff;
@SuppressWarnings("MemberName")
public final boolean HasReset;
/**

View File

@@ -4,24 +4,18 @@
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
@SuppressWarnings("MemberName")
public class REVPHVersion {
@SuppressWarnings("MemberName")
public final int firmwareMajor;
@SuppressWarnings("MemberName")
public final int firmwareMinor;
@SuppressWarnings("MemberName")
public final int firmwareFix;
@SuppressWarnings("MemberName")
public final int hardwareMinor;
@SuppressWarnings("MemberName")
public final int hardwareMajor;
@SuppressWarnings("MemberName")
public final int uniqueId;
/**

View File

@@ -6,8 +6,19 @@ package edu.wpi.first.hal;
import java.nio.ByteBuffer;
@SuppressWarnings("AbbreviationAsWordInName")
public class SPIJNI extends JNIWrapper {
public static final int INVALID_PORT = -1;
public static final int ONBOARD_CS0_PORT = 0;
public static final int ONBOARD_CS1_PORT = 1;
public static final int ONBOARD_CS2_PORT = 2;
public static final int ONBOARD_CS3_PORT = 3;
public static final int MXP_PORT = 4;
public static final int SPI_MODE0 = 0;
public static final int SPI_MODE1 = 1;
public static final int SPI_MODE2 = 2;
public static final int SPI_MODE3 = 3;
public static native void spiInitialize(int port);
public static native int spiTransaction(
@@ -28,8 +39,9 @@ public class SPIJNI extends JNIWrapper {
public static native void spiSetSpeed(int port, int speed);
public static native void spiSetOpts(
int port, int msbFirst, int sampleOnTrailing, int clkIdleHigh);
public static native void spiSetMode(int port, int mode);
public static native int spiGetMode(int port);
public static native void spiSetChipSelectActiveHigh(int port);

View File

@@ -106,22 +106,6 @@ public class SimDevice implements AutoCloseable {
return m_handle;
}
/**
* Creates a value on the simulated device.
*
* <p>Returns null if not in simulation.
*
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param initialValue initial value
* @return simulated value object
* @deprecated Use direction function instead
*/
@Deprecated
public SimValue createValue(String name, boolean readonly, HALValue initialValue) {
return createValue(name, readonly ? Direction.kOutput : Direction.kInput, initialValue);
}
/**
* Creates a value on the simulated device.
*
@@ -176,22 +160,6 @@ public class SimDevice implements AutoCloseable {
return new SimLong(handle);
}
/**
* Creates a double value on the simulated device.
*
* <p>Returns null if not in simulation.
*
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param initialValue initial value
* @return simulated double value object
* @deprecated Use direction function instead
*/
@Deprecated
public SimDouble createDouble(String name, boolean readonly, double initialValue) {
return createDouble(name, readonly ? Direction.kOutput : Direction.kInput, initialValue);
}
/**
* Creates a double value on the simulated device.
*
@@ -210,25 +178,6 @@ public class SimDevice implements AutoCloseable {
return new SimDouble(handle);
}
/**
* Creates an enumerated value on the simulated device.
*
* <p>Enumerated values are always in the range 0 to numOptions-1.
*
* <p>Returns null if not in simulation.
*
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param options array of option descriptions
* @param initialValue initial value (selection)
* @return simulated enum value object
* @deprecated Use direction function instead
*/
@Deprecated
public SimEnum createEnum(String name, boolean readonly, String[] options, int initialValue) {
return createEnum(name, readonly ? Direction.kOutput : Direction.kInput, options, initialValue);
}
/**
* Creates an enumerated value on the simulated device.
*
@@ -276,22 +225,6 @@ public class SimDevice implements AutoCloseable {
return new SimEnum(handle);
}
/**
* Creates a boolean value on the simulated device.
*
* <p>Returns null if not in simulation.
*
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param initialValue initial value
* @return simulated boolean value object
* @deprecated Use direction function instead
*/
@Deprecated
public SimBoolean createBoolean(String name, boolean readonly, boolean initialValue) {
return createBoolean(name, readonly ? Direction.kOutput : Direction.kInput, initialValue);
}
/**
* Creates a boolean value on the simulated device.
*

View File

@@ -36,30 +36,6 @@ public class SimDeviceJNI extends JNIWrapper {
private static native int createSimValueNative(
int device, String name, int direction, int type, long value1, double value2);
/**
* Creates a value on a simulated device.
*
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
*
* @param device simulated device handle
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param initialValue initial value
* @return simulated value handle
* @deprecated Use direction-taking function instead
*/
@Deprecated
public static int createSimValue(
int device, String name, boolean readonly, HALValue initialValue) {
return createSimValueNative(
device,
name,
readonly ? kOutput : kInput,
initialValue.getType(),
initialValue.getNativeLong(),
initialValue.getNativeDouble());
}
/**
* Creates a value on a simulated device.
*
@@ -111,25 +87,6 @@ public class SimDeviceJNI extends JNIWrapper {
return createSimValueNative(device, name, direction, HALValue.kLong, initialValue, 0.0);
}
/**
* Creates a double value on a simulated device.
*
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
*
* @param device simulated device handle
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param initialValue initial value
* @return simulated value handle
* @deprecated Use direction-taking function instead
*/
@Deprecated
public static int createSimValueDouble(
int device, String name, boolean readonly, double initialValue) {
return createSimValueNative(
device, name, readonly ? kOutput : kInput, HALValue.kDouble, 0, initialValue);
}
/**
* Creates a double value on a simulated device.
*
@@ -146,27 +103,6 @@ public class SimDeviceJNI extends JNIWrapper {
return createSimValueNative(device, name, direction, HALValue.kDouble, 0, initialValue);
}
/**
* Creates an enumerated value on a simulated device.
*
* <p>Enumerated values are always in the range 0 to numOptions-1.
*
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
*
* @param device simulated device handle
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param options array of option descriptions
* @param initialValue initial value (selection)
* @return simulated value handle
* @deprecated Use direction-taking function instead
*/
@Deprecated
public static int createSimValueEnum(
int device, String name, boolean readonly, String[] options, int initialValue) {
return createSimValueEnum(device, name, readonly ? kOutput : kInput, options, initialValue);
}
/**
* Creates an enumerated value on a simulated device.
*
@@ -207,25 +143,6 @@ public class SimDeviceJNI extends JNIWrapper {
double[] optionValues,
int initialValue);
/**
* Creates a boolean value on a simulated device.
*
* <p>Returns 0 if not in simulation; this can be used to avoid calls to Set/Get functions.
*
* @param device simulated device handle
* @param name value name
* @param readonly if the value should not be written from simulation side
* @param initialValue initial value
* @return simulated value handle
* @deprecated Use direction-taking function instead
*/
@Deprecated
public static int createSimValueBoolean(
int device, String name, boolean readonly, boolean initialValue) {
return createSimValueNative(
device, name, readonly ? kOutput : kInput, HALValue.kBoolean, initialValue ? 1 : 0, 0.0);
}
/**
* Creates a boolean value on a simulated device.
*

View File

@@ -8,7 +8,7 @@ import edu.wpi.first.hal.JNIWrapper;
import java.nio.ByteBuffer;
import java.nio.IntBuffer;
@SuppressWarnings("AbbreviationAsWordInName")
@SuppressWarnings("MethodName")
public class CANJNI extends JNIWrapper {
public static final int CAN_SEND_PERIOD_NO_REPEAT = 0;
public static final int CAN_SEND_PERIOD_STOP_REPEATING = -1;
@@ -17,14 +17,11 @@ public class CANJNI extends JNIWrapper {
public static final int CAN_IS_FRAME_REMOTE = 0x80000000;
public static final int CAN_IS_FRAME_11BIT = 0x40000000;
@SuppressWarnings("MethodName")
public static native void FRCNetCommCANSessionMuxSendMessage(
int messageID, byte[] data, int periodMs);
@SuppressWarnings("MethodName")
public static native byte[] FRCNetCommCANSessionMuxReceiveMessage(
IntBuffer messageID, int messageIDMask, ByteBuffer timeStamp);
@SuppressWarnings("MethodName")
public static native void getCANStatus(CANStatus status);
}

View File

@@ -5,28 +5,32 @@
package edu.wpi.first.hal.can;
/** Structure for holding the result of a CAN Status request. */
@SuppressWarnings("MemberName")
public class CANStatus {
/** The utilization of the CAN Bus. */
@SuppressWarnings("MemberName")
public double percentBusUtilization;
/** The CAN Bus off count. */
@SuppressWarnings("MemberName")
public int busOffCount;
/** The CAN Bus TX full count. */
@SuppressWarnings("MemberName")
public int txFullCount;
/** The CAN Bus receive error count. */
@SuppressWarnings("MemberName")
public int receiveErrorCount;
/** The CAN Bus transmit error count. */
@SuppressWarnings("MemberName")
public int transmitErrorCount;
@SuppressWarnings("MissingJavadocMethod")
/**
* Set CAN bus status.
*
* @param percentBusUtilization CAN bus utilization as a percent.
* @param busOffCount Bus off event count.
* @param txFullCount TX buffer full event count.
* @param receiveErrorCount Receive error event count.
* @param transmitErrorCount Transmit error event count.
*/
public void setStatus(
double percentBusUtilization,
int busOffCount,

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.hal.simulation;
import edu.wpi.first.hal.JNIWrapper;
@SuppressWarnings("AbbreviationAsWordInName")
public class CTREPCMDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(
int index, NotifyCallback callback, boolean initialNotify);

View File

@@ -6,7 +6,6 @@ package edu.wpi.first.hal.simulation;
import edu.wpi.first.hal.JNIWrapper;
@SuppressWarnings("AbbreviationAsWordInName")
public class REVPHDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(
int index, NotifyCallback callback, boolean initialNotify);

View File

@@ -7,17 +7,13 @@ package edu.wpi.first.hal.simulation;
import edu.wpi.first.hal.JNIWrapper;
public class RoboRioDataJNI extends JNIWrapper {
@SuppressWarnings("AbbreviationAsWordInName")
public static native int registerFPGAButtonCallback(
NotifyCallback callback, boolean initialNotify);
@SuppressWarnings("AbbreviationAsWordInName")
public static native void cancelFPGAButtonCallback(int uid);
@SuppressWarnings("AbbreviationAsWordInName")
public static native boolean getFPGAButton();
@SuppressWarnings("AbbreviationAsWordInName")
public static native void setFPGAButton(boolean fPGAButton);
public static native int registerVInVoltageCallback(

View File

@@ -28,18 +28,21 @@ public class SimDeviceDataJNI extends JNIWrapper {
public static native int getSimValueDeviceHandle(int handle);
@SuppressWarnings("MemberName")
public static class SimDeviceInfo {
@SuppressWarnings("JavadocMethod")
public String name;
public int handle;
/**
* SimDeviceInfo constructor.
*
* @param name SimDevice name.
* @param handle SimDevice handle.
*/
public SimDeviceInfo(String name, int handle) {
this.name = name;
this.handle = handle;
}
@SuppressWarnings("MemberName")
public String name;
@SuppressWarnings("MemberName")
public int handle;
}
public static native SimDeviceInfo[] enumerateSimDevices(String prefix);
@@ -70,32 +73,30 @@ public class SimDeviceDataJNI extends JNIWrapper {
public static native int getSimValueHandle(int device, String name);
@SuppressWarnings("MemberName")
public static class SimValueInfo {
@SuppressWarnings("JavadocMethod")
public String name;
public int handle;
public int direction;
public HALValue value;
/**
* SimValueInfo constructor.
*
* @param name SimValue name.
* @param handle SimValue handle.
* @param direction SimValue direction.
* @param type SimValue type.
* @param value1 Value 1.
* @param value2 Value 2.
*/
public SimValueInfo(
String name, int handle, int direction, int type, long value1, double value2) {
this.name = name;
this.handle = handle;
this.readonly = direction == 1;
this.direction = direction;
this.value = HALValue.fromNative(type, value1, value2);
}
@SuppressWarnings("MemberName")
public String name;
@SuppressWarnings("MemberName")
public int handle;
@SuppressWarnings("MemberName")
@Deprecated
public boolean readonly;
@SuppressWarnings("MemberName")
public int direction;
@SuppressWarnings("MemberName")
public HALValue value;
}
public static native SimValueInfo[] enumerateSimValues(int device);

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.hal.util;
/** Exception indicating that the resource is already allocated. */
@SuppressWarnings("serial")
public class AllocationException extends RuntimeException {
/**
* Create a new AllocationException.

View File

@@ -7,7 +7,6 @@ package edu.wpi.first.hal.util;
/**
* This exception represents an error in which a lower limit was set as higher than an upper limit.
*/
@SuppressWarnings("serial")
public class BoundaryException extends RuntimeException {
/**
* Create a new exception with the given message.

View File

@@ -8,7 +8,6 @@ package edu.wpi.first.hal.util;
* Exception indicating that the resource is already allocated This is meant to be thrown by the
* resource class.
*/
@SuppressWarnings("serial")
public class CheckedAllocationException extends Exception {
/**
* Create a new CheckedAllocationException.

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.hal.util;
/** Exception indicating that an error has occurred with a HAL Handle. */
@SuppressWarnings("serial")
public class HalHandleException extends RuntimeException {
/**
* Create a new HalHandleException.

View File

@@ -5,7 +5,6 @@
package edu.wpi.first.hal.util;
/** Exception for bad status codes from the chip object. */
@SuppressWarnings("serial")
public final class UncleanStatusException extends IllegalStateException {
private final int m_statusCode;

View File

@@ -121,8 +121,9 @@ static void writeRegister(Register reg, uint8_t data) {
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000)
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
// Send a stop transmit/receive message with the data
@@ -133,8 +134,9 @@ static void writeRegister(Register reg, uint8_t data) {
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000)
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
}
@@ -151,8 +153,9 @@ static uint8_t readRegister(Register reg) {
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000)
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
// Receive a message with the data and stop
@@ -163,8 +166,9 @@ static uint8_t readRegister(Register reg) {
// Execute and wait until it's done (up to a millisecond)
initialTime = HAL_GetFPGATime(&status);
while (accel->readSTAT(&status) & 1) {
if (HAL_GetFPGATime(&status) > initialTime + 1000)
if (HAL_GetFPGATime(&status) > initialTime + 1000) {
break;
}
}
return accel->readDATI(&status);

View File

@@ -23,8 +23,9 @@ HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle,
return false;
}
for (int32_t i = 0; i < kNumAccumulators; i++) {
if (port->channel == kAccumulatorChannels[i])
if (port->channel == kAccumulatorChannels[i]) {
return true;
}
}
return false;
}

View File

@@ -233,9 +233,11 @@ void HAL_SetCTREPCMClosedLoopControl(HAL_CTREPCMHandle handle, HAL_Bool enabled,
return;
}
int32_t can_status = 0;
std::scoped_lock lock{pcm->lock};
pcm->control.bits.closedLoopEnable = enabled ? 1 : 0;
SendControl(pcm.get(), status);
SendControl(pcm.get(), &can_status);
}
HAL_Bool HAL_GetCTREPCMClosedLoopControl(HAL_CTREPCMHandle handle,
@@ -394,9 +396,8 @@ void HAL_SetCTREPCMOneShotDuration(HAL_CTREPCMHandle handle, int32_t index,
}
std::scoped_lock lock{pcm->lock};
pcm->oneShot.sol10MsPerUnit[index] =
(std::min)(static_cast<uint32_t>(durMs) / 10,
static_cast<uint32_t>(0xFF));
pcm->oneShot.sol10MsPerUnit[index] = (std::min)(
static_cast<uint32_t>(durMs) / 10, static_cast<uint32_t>(0xFF));
HAL_WriteCANPacketRepeating(pcm->canHandle, pcm->oneShot.sol10MsPerUnit, 8,
Control3, SendPeriod, status);
}

View File

@@ -133,8 +133,9 @@ HAL_Bool HAL_CheckDIOChannel(int32_t channel) {
void HAL_FreeDIOPort(HAL_DigitalHandle dioPortHandle) {
auto port = digitalChannelHandles->Get(dioPortHandle, HAL_HandleEnum::DIO);
// no status, so no need to check for a proper free.
if (port == nullptr)
if (port == nullptr) {
return;
}
digitalChannelHandles->Free(dioPortHandle, HAL_HandleEnum::DIO);
// Wait for no other object to hold this handle.
@@ -407,13 +408,24 @@ HAL_Bool HAL_GetDIODirection(HAL_DigitalHandle dioPortHandle, int32_t* status) {
}
}
void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLength,
void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLengthSeconds,
int32_t* status) {
auto port = digitalChannelHandles->Get(dioPortHandle, HAL_HandleEnum::DIO);
if (port == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
uint32_t pulseLengthMicroseconds =
static_cast<uint32_t>(pulseLengthSeconds * 1e6);
if (pulseLengthMicroseconds <= 0 || pulseLengthMicroseconds > 0xFFFF) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(status,
"Length must be between 1 and 65535 microseconds");
return;
}
tDIO::tPulse pulse;
if (port->channel >= kNumDigitalHeaders + kNumDigitalMXPChannels) {
@@ -425,9 +437,29 @@ void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLength,
}
digitalSystem->writePulseLength(
static_cast<uint16_t>(1.0e9 * pulseLength /
(pwmSystem->readLoopTiming(status) * 25)),
status);
static_cast<uint16_t>(pulseLengthMicroseconds), status);
digitalSystem->writePulse(pulse, status);
}
void HAL_PulseMultiple(uint32_t channelMask, double pulseLengthSeconds,
int32_t* status) {
uint32_t pulseLengthMicroseconds =
static_cast<uint32_t>(pulseLengthSeconds * 1e6);
if (pulseLengthMicroseconds <= 0 || pulseLengthMicroseconds > 0xFFFF) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(status,
"Length must be between 1 and 65535 microseconds");
return;
}
tDIO::tPulse pulse;
pulse.Headers = channelMask & 0x2FF;
pulse.MXP = (channelMask & 0xFFFF) >> 10;
pulse.SPIPort = (channelMask & 0x1F) >> 26;
digitalSystem->writePulseLength(
static_cast<uint16_t>(pulseLengthMicroseconds), status);
digitalSystem->writePulse(pulse, status);
}

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