Compare commits

...

190 Commits

Author SHA1 Message Date
Ryan Blue
abb2857e03 [wpilib] Counter: Fix default distance per pulse, add distance and rate to C++ (#5796)
- Default distance per pulse in java was 0; 1 is a more reasonable default
- C++ was missing this functionality
2023-10-19 23:42:53 -07:00
Peter Johnson
b14a61e1c0 [readme] Add link to QuickBuffers release page (#5795) 2023-10-19 22:07:40 -07:00
Peter Johnson
cf54d9ccb7 [wpiutil, ntcore] Add structured data support (#5391)
This adds support for two serialization formats for complex data types:

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

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

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

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

Properly handle error return values from Send functions.

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

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

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

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

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

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

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

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

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

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

Fixed this warning:
```
CMake Warning (dev) at /usr/share/cmake/Modules/FetchContent.cmake:1316 (message):
  The DOWNLOAD_EXTRACT_TIMESTAMP option was not given and policy CMP0135 is
  not set.  The policy's OLD behavior will be used.  When using a URL
  download, the timestamps of extracted files should preferably be that of
  the time of extraction, otherwise code that depends on the extracted
  contents might not be rebuilt if the URL changes.  The OLD behavior
  preserves the timestamps from the archive instead, but this is usually not
  what you want.  Update your project to the NEW behavior or specify the
  DOWNLOAD_EXTRACT_TIMESTAMP option with a value of true to avoid this
  robustness issue.
Call Stack (most recent call first):
  imgui/CMakeLists.txt:23 (FetchContent_Declare)
```
2023-08-28 15:06:51 -07:00
Tyler Veness
969979d6c7 [wpiutil] Update to foonathan memory 0.7-3 (#5573) 2023-08-28 15:03:36 -07:00
Tyler Veness
0d2d989e84 [wpimath] Update to gcem 1.17.0 (#5575) 2023-08-28 15:03:06 -07:00
Tyler Veness
cf86af7166 [wpiutil] Update to mpack 1.1.1 (#5574) 2023-08-28 15:02:36 -07:00
Ryan Blue
a0c029a35b [commands] Fix dangling SelectCommand documentation (NFC) (#5567) 2023-08-25 09:41:25 -07:00
Tyler Veness
349141b91b [upstream_utils] Document adding a patch (NFC) (#5432)
Co-authored-by: autoantwort <41973254+autoantwort@users.noreply.github.com>
2023-08-24 15:00:07 -07:00
Tyler Veness
7889b35b67 [wpimath] Add RamseteController comparison to LTV controller docs (NFC) (#5559) 2023-08-24 00:04:54 -07:00
Ryan Blue
b3ef536677 [build] Ignore nt/sim json files in spotless (#5565) 2023-08-24 00:04:28 -07:00
Tyler Veness
ed895815b5 [build] Compile Java with UTF-8 encoding (#5564) 2023-08-24 00:03:38 -07:00
Joseph Eng
2e4ad35e36 [wpiutil] jni_util: Add JSpan and CriticalJSpan (#5554)
These replace JArrayRef et al and support statically sized arrays similar to std::span.
2023-08-24 00:02:56 -07:00
Tyler Veness
8f3d6a1d4b [wpimath] Remove discretizeAQTaylor() (#5562)
It gives incorrect results. Any replacement should just be an
implementation detail of discretizeAQ().

Closes #5339.
2023-08-23 10:47:32 -07:00
Tyler Veness
7c20fa1b18 [wpimath] Refactor DARE tests to reduce RAM usage at compile time (#5557) 2023-08-23 10:46:50 -07:00
Peter Johnson
89e738262c [ntcore] Limit buffer pool size to 64KB per connection (#5485)
Previously this was unlimited, which could result in holding on to a
large amount of memory if the connection got backlogged or a burst of
data transmission occurred.
2023-08-20 13:53:52 -07:00
1671 changed files with 210861 additions and 41529 deletions

View File

@@ -14,25 +14,28 @@ jobs:
include:
- os: ubuntu-22.04
name: Linux
container: wpilib/roborio-cross-ubuntu:2023-22.04
flags: ""
container: wpilib/roborio-cross-ubuntu:2024-22.04
flags: "-DCMAKE_BUILD_TYPE=Release -DWITH_EXAMPLES=ON"
- os: macOS-12
name: macOS
container: ""
flags: "-DWITH_JAVA=OFF"
env: "PATH=\"/usr/local/opt/protobuf@3/bin:$PATH\""
flags: "-DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DCMAKE_LIBRARY_PATH=/usr/local/opt/protobuf@3/lib -DProtobuf_INCLUDE_DIR=/usr/local/opt/protobuf@3/include -DProtobuf_PROTOC_EXECUTABLE=/usr/local/opt/protobuf@3/bin/protoc"
name: "Build - ${{ matrix.name }}"
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@v3
- name: Install dependencies (Linux)
if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3 libprotobuf-dev protobuf-compiler ninja-build
- name: Install QuickBuffers (Linux)
if: runner.os == 'Linux'
run: wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.2/protoc-gen-quickbuf_1.3.2_amd64.deb && sudo apt install ./protoc-gen-quickbuf_1.3.2_amd64.deb
- name: Install opencv (macOS)
run: brew install opencv
run: brew install opencv protobuf@3 ninja
if: runner.os == 'macOS'
- name: Set up Python 3.8 (macOS)
@@ -41,16 +44,79 @@ jobs:
with:
python-version: 3.8
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Install jinja
run: python -m pip install jinja2
- uses: actions/checkout@v3
- name: configure
run: mkdir build && cd build && cmake ${{ matrix.flags }} ..
run: cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache ${{ matrix.flags }}
env:
SCCACHE_GHA_ENABLED: "true"
- name: build
working-directory: build
run: cmake --build . --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"
- name: test
working-directory: build
run: ctest --output-on-failure
build-windows:
name: "Build - Windows"
runs-on: windows-2022
steps:
- uses: ilammy/msvc-dev-cmd@v1
- name: Install CMake
uses: lukka/get-cmake@v3.27.6
- name: Run vcpkg
uses: lukka/run-vcpkg@v11.1
with:
vcpkgDirectory: ${{ runner.workspace }}/vcpkg
vcpkgGitCommitId: 78b61582c9e093fda56a01ebb654be15a0033897 # HEAD on 2023-08-6
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Install jinja
run: python -m pip install jinja2
- uses: actions/checkout@v3
- name: configure
run: cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_BUILD_TYPE=Release -DWITH_JAVA=OFF -DWITH_EXAMPLES=ON -DUSE_SYSTEM_FMTLIB=ON -DUSE_SYSTEM_LIBUV=ON -DUSE_SYSTEM_EIGEN=ON -DCMAKE_TOOLCHAIN_FILE=${{ runner.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_INSTALL_OPTIONS=--clean-after-build -DVCPKG_TARGET_TRIPLET=x64-windows-release -DVCPKG_HOST_TRIPLET=x64-windows-release
env:
SCCACHE_GHA_ENABLED: "true"
# Build wpiutil at full speed, wpimath depends on wpiutil
- name: build wpiutil
working-directory: build
run: cmake --build . --parallel $(nproc) --target wpiutil/all
env:
SCCACHE_GHA_ENABLED: "true"
# Build wpimath slow to prevent OOM
- name: build wpimath
working-directory: build
run: cmake --build . --parallel 1 --target wpimath/all
env:
SCCACHE_GHA_ENABLED: "true"
# Build everything else fast
- name: build
working-directory: build
run: cmake --build . --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"
- name: test
working-directory: build
# UnitTest_test segfaults on exit occasionally
run: ctest --output-on-failure -E 'UnitTest'

View File

@@ -12,7 +12,7 @@ jobs:
fail-fast: false
matrix:
include:
- container: wpilib/roborio-cross-ubuntu:2023-22.04
- container: wpilib/roborio-cross-ubuntu:2024-22.04
artifact-name: Athena
build-options: "-Ponlylinuxathena"
- container: wpilib/raspbian-cross-ubuntu:bullseye-22.04
@@ -26,8 +26,17 @@ jobs:
build-options: "-Ponlylinuxx86-64"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ubuntu-22.04
container: ${{ matrix.container }}
steps:
- name: Free Disk Space
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: false
docker-images: false
swap-storage: false
- uses: actions/checkout@v3
with:
fetch-depth: 0
@@ -35,10 +44,16 @@ jobs:
run: echo "EXTRA_GRADLE_ARGS=-PreleaseMode" >> $GITHUB_ENV
if: startsWith(github.ref, 'refs/tags/v')
- name: Build with Gradle
run: ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.container }}
options: -v ${{ github.workspace }}:/work -w /work -e ARTIFACTORY_PUBLISH_USERNAME -e ARTIFACTORY_PUBLISH_PASSWORD -e GITHUB_REF -e CI
run: df . && rm -f semicolon_delimited_script && echo $GITHUB_REF && ./gradlew build --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
env:
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: Check free disk space
run: df .
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
@@ -57,34 +72,40 @@ jobs:
task: "build"
build-options: "-PciDebugOnly --max-workers 1"
outputs: "build/allOutputs"
build-dir: "c:\\work"
- os: windows-2022
artifact-name: Win64Release
architecture: x64
build-options: "-PciReleaseOnly --max-workers 1"
task: "copyAllOutputs"
outputs: "build/allOutputs"
# - os: windows-2022
# artifact-name: WinArm64Debug
# architecture: x64
# task: "build"
# build-options: "-PciDebugOnly -Pbuildwinarm64 -Ponlywindowsarm64 --max-workers 1"
# outputs: "build/allOutputs"
# - os: windows-2022
# artifact-name: WinArm64Release
# architecture: x64
# build-options: "-PciReleaseOnly -Pbuildwinarm64 -Ponlywindowsarm64 --max-workers 1"
# task: "copyAllOutputs"
# outputs: "build/allOutputs"
build-dir: "c:\\work"
- os: windows-2022
artifact-name: WinArm64Debug
architecture: x64
task: "build"
build-options: "-PciDebugOnly -Pbuildwinarm64 -Ponlywindowsarm64 --max-workers 1"
outputs: "build/allOutputs"
build-dir: "c:\\work"
- os: windows-2022
artifact-name: WinArm64Release
architecture: x64
build-options: "-PciReleaseOnly -Pbuildwinarm64 -Ponlywindowsarm64 --max-workers 1"
task: "copyAllOutputs"
outputs: "build/allOutputs"
build-dir: "c:\\work"
- os: macOS-12
artifact-name: macOS
architecture: x64
task: "build"
outputs: "build/allOutputs"
build-dir: "."
- os: windows-2022
artifact-name: Win32
architecture: x86
task: ":ntcoreffi:build"
outputs: "ntcoreffi/build/outputs"
build-dir: "c:\\work"
name: "Build - ${{ matrix.artifact-name }}"
runs-on: ${{ matrix.os }}
steps:
@@ -117,20 +138,31 @@ jobs:
- name: Set Java Heap Size
run: sed -i 's/-Xmx2g/-Xmx1g/g' gradle.properties
if: matrix.artifact-name == 'Win32'
- name: Configure build directory (Windows)
run: xcopy . ${{ matrix.build-dir }} /i /s /e /h /q
if: matrix.os == 'windows-2022'
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- name: Build with Gradle
run: ./gradlew ${{ matrix.task }} --build-cache -PbuildServer -PskipJavaFormat ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
working-directory: ${{ matrix.build-dir }}
env:
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- name: Sign Libraries with Developer ID
run: ./gradlew copyAllOutputs --build-cache -PbuildServer -PskipJavaFormat -PdeveloperID=${{ secrets.APPLE_DEVELOPER_ID }} ${{ matrix.build-options }} ${{ env.EXTRA_GRADLE_ARGS }}
working-directory: ${{ matrix.build-dir }}
if: |
matrix.artifact-name == 'macOS' && (github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')))
- name: Check disk free space (Windows)
run: wmic logicaldisk get caption, freespace
if: matrix.os == 'windows-2022'
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.artifact-name }}
path: ${{ matrix.outputs }}
path: ${{ matrix.build-dir }}/${{ matrix.outputs }}
build-documentation:
name: "Build - Documentation"
@@ -162,27 +194,37 @@ jobs:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
with:
repository: wpilibsuite/build-tools
- uses: actions/download-artifact@v3
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
with:
path: combiner/products/build/allOutputs
- name: Flatten Artifacts
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
run: rsync -a --delete combiner/products/build/allOutputs/*/* combiner/products/build/allOutputs/
- name: Check version number exists
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
run: |
cat combiner/products/build/allOutputs/version.txt
test -s combiner/products/build/allOutputs/version.txt
- uses: actions/setup-java@v3
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
with:
distribution: 'zulu'
java-version: 11
- name: Combine
if: |
!startsWith(github.ref, 'refs/tags/v') &&
github.ref != 'refs/heads/main'
run: cd combiner && ./gradlew publish -Pallwpilib
- name: Combine (Master)
- name: Combine (Main)
if: |
github.repository_owner == 'wpilibsuite' &&
github.ref == 'refs/heads/main'
@@ -201,6 +243,9 @@ jobs:
ARTIFACTORY_PUBLISH_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PUBLISH_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
- uses: actions/upload-artifact@v3
if: |
github.repository_owner == 'wpilibsuite' &&
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
with:
name: Maven
path: ~/releases

View File

@@ -26,22 +26,33 @@ jobs:
ctest-flags: ""
name: "${{ matrix.name }}"
runs-on: ubuntu-22.04
container: wpilib/roborio-cross-ubuntu:2023-22.04
container: wpilib/roborio-cross-ubuntu:2024-22.04
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3 clang-14
run: sudo apt-get update && sudo apt-get install -y libopencv-dev libopencv4.5-java python-is-python3 clang-14 libprotobuf-dev protobuf-compiler ninja-build
- name: Install QuickBuffers
if: runner.os == 'Linux'
run: wget https://github.com/HebiRobotics/QuickBuffers/releases/download/1.3.2/protoc-gen-quickbuf_1.3.2_amd64.deb && sudo apt install ./protoc-gen-quickbuf_1.3.2_amd64.deb
- name: Run sccache-cache
uses: mozilla-actions/sccache-action@v0.0.3
- name: Install jinja
run: python -m pip install jinja2
- uses: actions/checkout@v3
- name: configure
run: mkdir build && cd build && cmake -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 ${{ matrix.cmake-flags }} ..
run: mkdir build && cd build && cmake -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_C_COMPILER:FILEPATH=/usr/bin/clang-14 -DCMAKE_CXX_COMPILER:FILEPATH=/usr/bin/clang++-14 ${{ matrix.cmake-flags }} ..
env:
SCCACHE_GHA_ENABLED: "true"
- name: build
working-directory: build
run: cmake --build . --parallel $(nproc)
env:
SCCACHE_GHA_ENABLED: "true"
- name: test
working-directory: build

View File

@@ -41,6 +41,10 @@ jobs:
run: |
cd upstream_utils
./update_gcem.py
- name: Run update_json.py
run: |
cd upstream_utils
./update_json.py
- name: Run update_libuv.py
run: |
cd upstream_utils
@@ -61,6 +65,10 @@ jobs:
run: |
cd upstream_utils
./update_memory.py
- name: Run update_protobuf.py
run: |
cd upstream_utils
./update_protobuf.py
- name: Add untracked files to index so they count as changes
run: git add -A
- name: Check output

1
.gitignore vendored
View File

@@ -205,6 +205,7 @@ NO
*.user
*.userosscache
*.sln.docstates
CMakeSettings.json
# Visual C++ cache files
ipch/

View File

@@ -29,8 +29,9 @@ includeOtherLibs {
^Eigen/
^cameraserver/
^cscore
^drake/
^fmt/
^gtest/
^google/
^hal/
^imgui
^implot

View File

@@ -11,10 +11,15 @@ if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION 10.0.18362.0 CACHE STRING INTERNAL FORCE)
endif()
cmake_minimum_required(VERSION 3.3.0)
cmake_minimum_required(VERSION 3.11)
project(allwpilib)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
# Make timestamps of extracted files from FetchContent the time of extraction
if (POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
message(STATUS "Platform version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
set(WPILIB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
@@ -150,7 +155,6 @@ endif()
set( wpilib_dest "")
set( include_dest include )
set( main_lib_dest lib )
set( java_lib_dest java )
set( jni_lib_dest jni )
@@ -172,6 +176,12 @@ endif()
find_package(LIBSSH 0.7.1)
find_package(Protobuf REQUIRED)
find_program(Quickbuf_EXECUTABLE
NAMES protoc-gen-quickbuf
DOC "The Quickbuf protoc plugin"
)
if (WITH_FLAT_INSTALL)
set(WPIUTIL_DEP_REPLACE "include($\{SELF_DIR\}/wpiutil-config.cmake)")
set(WPINET_DEP_REPLACE "include($\{SELF_DIR\}/wpinet-config.cmake)")
@@ -289,6 +299,7 @@ if (WITH_GUI)
add_subdirectory(wpigui)
add_subdirectory(glass)
add_subdirectory(outlineviewer)
add_subdirectory(sysid)
if (LIBSSH_FOUND)
add_subdirectory(roborioteamnumbersetter)
add_subdirectory(datalogtool)
@@ -313,6 +324,8 @@ if (WITH_WPILIB)
add_subdirectory(wpilibj)
add_subdirectory(wpilibc)
add_subdirectory(wpilibNewCommands)
add_subdirectory(romiVendordep)
add_subdirectory(xrpVendordep)
if (WITH_EXAMPLES)
add_subdirectory(wpilibcExamples)
endif()

View File

@@ -4,11 +4,16 @@ This article contains instructions on building projects using a development buil
**Note:** This only applies to Java/C++ teams.
> [!WARNING]
> **There are no stability or compatibility guarantees for builds outside of [tagged releases](https://github.com/wpilibsuite/allwpilib/releases). Changes may not be fully documented. Use them at your own risk!**
>
> Development builds may be non-functional between the end of the season and the start of beta testing. Development builds are also likely to be incompatible with vendor libraries during this time.
## Development Build
Development builds are the per-commit build hosted every time a commit is pushed to the [allwpilib](https://github.com/wpilibsuite/allwpilib/) repository. These builds are then hosted on [artifactory](https://frcmaven.wpi.edu/artifactory/webapp/#/home).
To build a project using a development build, find the build.gradle file and open it. Then, add the following code below the plugin section and replace YEAR with the year of the development version. It is also necessary to use a 2023 GradleRIO version, ie `2023.0.0-alpha-1`
To build a project using a development build, find the build.gradle file and open it. Then, add the following code below the plugin section and replace YEAR with the year of the development version. It is also necessary to use a 2024 GradleRIO version, ie `2024.0.0-alpha-1`
```groovy
wpi.maven.useLocal = false
@@ -23,13 +28,13 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2024.0.0-alpha-1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = '2023.+'
wpi.versions.wpimathVersion = '2023.+'
wpi.versions.wpilibVersion = '2024.+'
wpi.versions.wpimathVersion = '2024.+'
```
C++
@@ -37,13 +42,13 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2024.0.0-alpha-1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.versions.wpilibVersion = '2023.+'
wpi.versions.wpimathVersion = '2023.+'
wpi.versions.wpilibVersion = '2024.+'
wpi.versions.wpimathVersion = '2024.+'
```
### Development Build Documentation
@@ -59,7 +64,7 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2024.0.0-alpha-1"
}
wpi.maven.useLocal = false
@@ -73,7 +78,7 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2023.0.0-alpha-1"
id "edu.wpi.first.GradleRIO" version "2024.0.0-alpha-1"
}
wpi.maven.useLocal = false

View File

@@ -12,14 +12,19 @@ WPILib is normally built with Gradle, however for some systems, such as Linux ba
* halsim
* wpigui
* wpimath
* wpilibNewCommands
By default, all libraries except for the HAL and WPILib get built with a default CMake setup. The libraries are built as shared libraries, and include the JNI libraries as well as building the Java JARs.
## Prerequisites
The most common prerequisite is going to be OpenCV. OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
The jinja2 pip package is needed to generate classes for NT4's pubsub.
In addition, if you want JNI and Java, you will need a JDK of at least version 11 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
The protobuf library and compiler are needed for protobuf generation. The QuickBuffers protoc-gen package is also required when Java is being built; this can be obtained from https://github.com/HebiRobotics/QuickBuffers/releases/.
OpenCV needs to be findable by CMake. On systems like the Jetson, this is installed by default. Otherwise, you will need to build OpenCV from source and install it.
If you want JNI and Java, you will need a JDK of at least version 11 installed. In addition, you need a `JAVA_HOME` environment variable set properly and set to the JDK directory.
If you are building with unit tests or simulation modules, you will also need an Internet connection for the initial setup process, as CMake will clone google-test and imgui from GitHub.
@@ -93,7 +98,7 @@ Using the libraries from C++ is the easiest way to use the built libraries.
To do so, create a new folder to contain your project. Add the following code below to a `CMakeLists.txt` file in that directory.
```
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.11)
project(vision_app) # Project Name Here
find_package(wpilib REQUIRED)

View File

@@ -7,7 +7,7 @@ include(FetchContent)
FetchContent_Declare(
apriltaglib
GIT_REPOSITORY https://github.com/wpilibsuite/apriltag.git
GIT_TAG e55b751f2465bd40a880d9acb87d24289e2af89e
GIT_TAG 64be6ab26abf5e995321997fd0752c609a7e30f4
)
# Don't use apriltag's CMakeLists.txt due to conflicting naming and JNI
@@ -62,15 +62,11 @@ if (WITH_JAVA)
target_link_libraries(apriltagjni PRIVATE apriltag_jni_headers)
add_dependencies(apriltagjni apriltag_jar)
if (MSVC)
install(TARGETS apriltagjni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
install(TARGETS apriltagjni EXPORT apriltagjni DESTINATION "${main_lib_dest}")
install(TARGETS apriltagjni EXPORT apriltagjni)
endif()
GENERATE_RESOURCES(src/main/native/resources/edu/wpi/first/apriltag generated/main/cpp APRILTAG frc apriltag_resources_src)
generate_resources(src/main/native/resources/edu/wpi/first/apriltag generated/main/cpp APRILTAG frc apriltag_resources_src)
file(GLOB apriltag_native_src src/main/native/cpp/*.cpp)
@@ -82,9 +78,9 @@ target_compile_features(apriltag PUBLIC cxx_std_20)
wpilib_target_warnings(apriltag)
# disable warnings that apriltaglib can't handle
if (MSVC)
target_compile_options(apriltag PRIVATE /wd4018)
target_compile_options(apriltag PRIVATE /wd4018 /wd4005 /wd4996)
else()
target_compile_options(apriltag PRIVATE -Wno-sign-compare -Wno-gnu-zero-variadic-macro-arguments)
target_compile_options(apriltag PRIVATE -Wno-sign-compare -Wno-gnu-zero-variadic-macro-arguments -Wno-type-limits)
endif()
target_link_libraries(apriltag wpimath)
@@ -94,13 +90,9 @@ target_include_directories(apriltag PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/apriltag>)
install(TARGETS apriltag EXPORT apriltag DESTINATION "${main_lib_dest}")
install(TARGETS apriltag EXPORT apriltag)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/apriltag")
if (WITH_JAVA AND MSVC)
install(TARGETS apriltag RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
if (WITH_FLAT_INSTALL)
set (apriltag_config_dir ${wpilib_dest})
else()

View File

@@ -199,9 +199,16 @@ public class AprilTagFieldLayout {
* @throws IOException If the resource could not be loaded
*/
public static AprilTagFieldLayout loadFromResource(String resourcePath) throws IOException {
try (InputStream stream = AprilTagFieldLayout.class.getResourceAsStream(resourcePath);
InputStreamReader reader = new InputStreamReader(stream)) {
InputStream stream = AprilTagFieldLayout.class.getResourceAsStream(resourcePath);
if (stream == null) {
// Class.getResourceAsStream() returns null if the resource does not exist.
throw new IOException("Could not locate resource: " + resourcePath);
}
InputStreamReader reader = new InputStreamReader(stream);
try {
return new ObjectMapper().readerFor(AprilTagFieldLayout.class).readValue(reader);
} catch (IOException e) {
throw new IOException("Failed to load AprilTagFieldLayout: " + resourcePath);
}
}

View File

@@ -5,6 +5,7 @@
package edu.wpi.first.apriltag;
import java.io.IOException;
import java.io.UncheckedIOException;
public enum AprilTagFields {
k2022RapidReact("2022-rapidreact.json"),
@@ -25,9 +26,14 @@ public enum AprilTagFields {
* Get a {@link AprilTagFieldLayout} from the resource JSON.
*
* @return AprilTagFieldLayout of the field
* @throws IOException If the layout does not exist
* @throws UncheckedIOException If the layout does not exist
*/
public AprilTagFieldLayout loadAprilTagLayoutField() throws IOException {
return AprilTagFieldLayout.loadFromResource(m_resourceFile);
public AprilTagFieldLayout loadAprilTagLayoutField() {
try {
return AprilTagFieldLayout.loadFromResource(m_resourceFile);
} catch (IOException e) {
throw new UncheckedIOException(
"Could not load AprilTagFieldLayout from " + m_resourceFile, e);
}
}
}

View File

@@ -8,22 +8,21 @@
#include <units/angle.h>
#include <units/length.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/json.h>
#include <wpi/raw_istream.h>
#include <wpi/raw_ostream.h>
using namespace frc;
AprilTagFieldLayout::AprilTagFieldLayout(std::string_view path) {
std::error_code error_code;
wpi::raw_fd_istream input{path, error_code};
if (error_code) {
std::error_code ec;
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(path, ec);
if (fileBuffer == nullptr || ec) {
throw std::runtime_error(fmt::format("Cannot open file: {}", path));
}
wpi::json json;
input >> json;
wpi::json json = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
for (const auto& tag : json.at("tags").get<std::vector<AprilTag>>()) {
m_apriltags[tag.ID] = tag;

View File

@@ -504,15 +504,14 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseHomography
nullPointerEx.Throw(env, "homography cannot be null");
return nullptr;
}
JDoubleArrayRef harr{env, homography};
JSpan<const jdouble, 9> harr{env, homography};
if (harr.size() != 9) {
illegalArgEx.Throw(env, "homography array must be size 9");
return nullptr;
}
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
return MakeJObject(env, estimator.EstimateHomography(
std::span<const double, 9>{harr.array()}));
return MakeJObject(env, estimator.EstimateHomography(harr));
}
/*
@@ -530,7 +529,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
nullPointerEx.Throw(env, "homography cannot be null");
return nullptr;
}
JDoubleArrayRef harr{env, homography};
JSpan<const jdouble, 9> harr{env, homography};
if (harr.size() != 9) {
illegalArgEx.Throw(env, "homography array must be size 9");
return nullptr;
@@ -541,7 +540,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
nullPointerEx.Throw(env, "corners cannot be null");
return nullptr;
}
JDoubleArrayRef carr{env, corners};
JSpan<const jdouble, 8> carr{env, corners};
if (carr.size() != 8) {
illegalArgEx.Throw(env, "corners array must be size 8");
return nullptr;
@@ -549,9 +548,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePoseOrthogonalIteration
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
return MakeJObject(env,
estimator.EstimateOrthogonalIteration(
std::span<const double, 9>{harr.array()},
std::span<const double, 8>{carr.array()}, nIters));
estimator.EstimateOrthogonalIteration(harr, carr, nIters));
}
/*
@@ -569,7 +566,7 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePose
nullPointerEx.Throw(env, "homography cannot be null");
return nullptr;
}
JDoubleArrayRef harr{env, homography};
JSpan<const jdouble, 9> harr{env, homography};
if (harr.size() != 9) {
illegalArgEx.Throw(env, "homography array must be size 9");
return nullptr;
@@ -580,16 +577,14 @@ Java_edu_wpi_first_apriltag_jni_AprilTagJNI_estimatePose
nullPointerEx.Throw(env, "corners cannot be null");
return nullptr;
}
JDoubleArrayRef carr{env, corners};
JSpan<const jdouble, 8> carr{env, corners};
if (carr.size() != 8) {
illegalArgEx.Throw(env, "corners array must be size 8");
return nullptr;
}
AprilTagPoseEstimator estimator({units::meter_t{tagSize}, fx, fy, cx, cy});
return MakeJObject(
env, estimator.Estimate(std::span<const double, 9>{harr.array()},
std::span<const double, 8>{carr.array()}));
return MakeJObject(env, estimator.Estimate(harr, carr));
}
} // extern "C"

View File

@@ -5,13 +5,10 @@
#pragma once
#include <wpi/SymbolExports.h>
#include <wpi/json_fwd.h>
#include "frc/geometry/Pose3d.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
struct WPILIB_DLLEXPORT AprilTag {

View File

@@ -9,10 +9,9 @@
#include <span>
#include <string_view>
#include <Eigen/Core>
#include <wpi/SymbolExports.h>
#include "frc/EigenCore.h"
namespace frc {
/**

View File

@@ -11,14 +11,11 @@
#include <units/length.h>
#include <wpi/SymbolExports.h>
#include <wpi/json_fwd.h>
#include "frc/apriltag/AprilTag.h"
#include "frc/geometry/Pose3d.h"
namespace wpi {
class json;
} // namespace wpi
namespace frc {
/**
* Class for representing a layout of AprilTags on a field and reading them from

View File

@@ -2,8 +2,9 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include "frc/apriltag/AprilTagDetector.h"
#include "gtest/gtest.h"
using namespace frc;

View File

@@ -4,12 +4,12 @@
#include <vector>
#include <gtest/gtest.h>
#include <wpi/json.h>
#include "frc/apriltag/AprilTag.h"
#include "frc/apriltag/AprilTagFieldLayout.h"
#include "frc/geometry/Pose3d.h"
#include "gtest/gtest.h"
using namespace frc;

View File

@@ -4,12 +4,12 @@
#include <vector>
#include <gtest/gtest.h>
#include <wpi/json.h>
#include "frc/apriltag/AprilTag.h"
#include "frc/apriltag/AprilTagFieldLayout.h"
#include "frc/geometry/Pose3d.h"
#include "gtest/gtest.h"
using namespace frc;

View File

@@ -2,8 +2,9 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include "frc/apriltag/AprilTagFields.h"
#include "gtest/gtest.h"
namespace frc {

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "gtest/gtest.h"
#include <gtest/gtest.h>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);

View File

@@ -24,6 +24,7 @@ plugins {
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
id 'com.diffplug.spotless' version '6.20.0' apply false
id 'com.github.spotbugs' version '5.1.3' apply false
id 'com.google.protobuf' version '0.9.3' apply false
}
wpilibVersioning.buildServerMode = project.hasProperty('buildServer')
@@ -109,8 +110,10 @@ subprojects {
}
plugins.withType(JavaPlugin) {
sourceCompatibility = 11
targetCompatibility = 11
java {
sourceCompatibility = 11
targetCompatibility = 11
}
}
apply from: "${rootDir}/shared/java/javastyle.gradle"
@@ -126,6 +129,7 @@ subprojects {
tasks.withType(JavaCompile) {
options.compilerArgs.add '-XDstringConcat=inline'
options.encoding = 'UTF-8'
}
// Enables UTF-8 support in Javadoc
@@ -167,5 +171,5 @@ ext.getCurrentArch = {
}
wrapper {
gradleVersion = '8.1'
gradleVersion = '8.4'
}

View File

@@ -9,5 +9,5 @@ repositories {
}
}
dependencies {
implementation "edu.wpi.first:native-utils:2024.0.0"
implementation "edu.wpi.first:native-utils:2024.3.1"
}

View File

@@ -9,6 +9,7 @@ import org.gradle.language.base.internal.ProjectLayout;
import org.gradle.language.base.plugins.ComponentModelBasePlugin;
import org.gradle.language.nativeplatform.tasks.AbstractNativeSourceCompileTask;
import org.gradle.model.ModelMap;
import org.gradle.internal.os.OperatingSystem
import edu.wpi.first.toolchain.ToolchainExtension
import org.gradle.model.Mutate;
import org.gradle.api.plugins.ExtensionContainer;
@@ -60,12 +61,16 @@ class MultiBuilds implements Plugin<Project> {
@CompileStatic
void disableReleaseGoogleTest(BinaryContainer binaries, ProjectLayout projectLayout) {
def project = (Project) projectLayout.projectIdentifier
if (project.hasProperty('testRelease')) {
if (project.hasProperty('testOther')) {
return
}
def check_string = 'release'
if (project.hasProperty('buildServer') && !OperatingSystem.current().isWindows()) {
check_string = 'debug'
}
binaries.withType(GoogleTestTestSuiteBinarySpec) { oSpec ->
GoogleTestTestSuiteBinarySpec spec = (GoogleTestTestSuiteBinarySpec) oSpec
if (spec.buildType.name == 'release') {
if (spec.buildType.name == check_string) {
Rules.setBuildableFalseDynamically(spec)
}
}

View File

@@ -13,6 +13,7 @@ repoRootNameOverride {
includeOtherLibs {
^fmt/
^gtest/
^hal/
^networktables/
^opencv2/

View File

@@ -40,13 +40,9 @@ target_link_libraries(cameraserver PUBLIC ntcore cscore wpiutil ${OpenCV_LIBS})
set_property(TARGET cameraserver PROPERTY FOLDER "libraries")
install(TARGETS cameraserver EXPORT cameraserver DESTINATION "${main_lib_dest}")
install(TARGETS cameraserver EXPORT cameraserver)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cameraserver")
if (WITH_JAVA AND MSVC)
install(TARGETS cameraserver RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
if (WITH_FLAT_INSTALL)
set (cameraserver_config_dir ${wpilib_dest})
else()

View File

@@ -18,7 +18,9 @@ ext {
apply from: "${rootDir}/shared/opencv.gradle"
mainClassName = 'edu.wpi.Main'
application {
mainClass = 'edu.wpi.Main'
}
apply plugin: 'com.github.johnrengelman.shadow'

View File

@@ -8,11 +8,12 @@
#include <thread>
#include <vector>
#include <fmt/core.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/StringExtras.h>
#include <wpi/fmt/raw_ostream.h>
#include <wpi/json.h>
#include <wpi/raw_istream.h>
#include <wpi/raw_ostream.h>
#include "cameraserver/CameraServer.h"
@@ -63,10 +64,6 @@ struct CameraConfig {
std::vector<CameraConfig> cameras;
wpi::raw_ostream& ParseError() {
return wpi::errs() << "config error in '" << configFile << "': ";
}
bool ReadCameraConfig(const wpi::json& config) {
CameraConfig c;
@@ -74,7 +71,8 @@ bool ReadCameraConfig(const wpi::json& config) {
try {
c.name = config.at("name").get<std::string>();
} catch (const wpi::json::exception& e) {
ParseError() << "could not read camera name: " << e.what() << '\n';
fmt::print(stderr, "config error in '{}': could not read camera name: {}\n",
configFile, e.what());
return false;
}
@@ -82,8 +80,9 @@ bool ReadCameraConfig(const wpi::json& config) {
try {
c.path = config.at("path").get<std::string>();
} catch (const wpi::json::exception& e) {
ParseError() << "camera '" << c.name
<< "': could not read path: " << e.what() << '\n';
fmt::print(stderr,
"config error in '{}': camera '{}': could not read path: {}\n",
configFile, c.name, e.what());
return false;
}
@@ -96,25 +95,27 @@ bool ReadCameraConfig(const wpi::json& config) {
bool ReadConfig() {
// open config file
std::error_code ec;
wpi::raw_fd_istream is(configFile, ec);
if (ec) {
wpi::errs() << "could not open '" << configFile << "': " << ec.message()
<< '\n';
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(configFile, ec);
if (fileBuffer == nullptr || ec) {
fmt::print(stderr, "could not open '{}': {}\n", configFile, ec.message());
return false;
}
// parse file
wpi::json j;
try {
j = wpi::json::parse(is);
j = wpi::json::parse(fileBuffer->begin(), fileBuffer->end());
} catch (const wpi::json::parse_error& e) {
fmt::print(ParseError(), "byte {}: {}\n", e.byte, e.what());
fmt::print(stderr, "config error in '{}': byte {}: {}\n", configFile,
e.byte, e.what());
return false;
}
// top level must be an object
if (!j.is_object()) {
ParseError() << "must be JSON object\n";
fmt::print(stderr, "config error in '{}': must be JSON object\n",
configFile);
return false;
}
@@ -122,7 +123,8 @@ bool ReadConfig() {
try {
team = j.at("team").get<unsigned int>();
} catch (const wpi::json::exception& e) {
ParseError() << "could not read team number: " << e.what() << '\n';
fmt::print(stderr, "config error in '{}': could not read team number: {}\n",
configFile, e.what());
return false;
}
@@ -135,10 +137,14 @@ bool ReadConfig() {
} else if (wpi::equals_lower(str, "server")) {
server = true;
} else {
ParseError() << "could not understand ntmode value '" << str << "'\n";
fmt::print(
stderr,
"config error in '{}': could not understand ntmode value '{}'\n",
configFile, str);
}
} catch (const wpi::json::exception& e) {
ParseError() << "could not read ntmode: " << e.what() << '\n';
fmt::print(stderr, "config error in '{}': could not read ntmode: {}\n",
configFile, e.what());
}
}
@@ -150,7 +156,8 @@ bool ReadConfig() {
}
}
} catch (const wpi::json::exception& e) {
ParseError() << "could not read cameras: " << e.what() << '\n';
fmt::print(stderr, "config error in '{}': could not read cameras: {}\n",
configFile, e.what());
return false;
}

View File

@@ -717,22 +717,3 @@ void CameraServer::RemoveCamera(std::string_view name) {
std::scoped_lock lock(inst.m_mutex);
inst.m_sources.erase(name);
}
void CameraServer::SetSize(int size) {
auto& inst = ::GetInstance();
std::scoped_lock lock(inst.m_mutex);
if (inst.m_primarySourceName.empty()) {
return;
}
auto it = inst.m_sources.find(inst.m_primarySourceName);
if (it == inst.m_sources.end()) {
return;
}
if (size == kSize160x120) {
it->second.SetResolution(160, 120);
} else if (size == kSize320x240) {
it->second.SetResolution(320, 240);
} else if (size == kSize640x480) {
it->second.SetResolution(640, 480);
}
}

View File

@@ -267,17 +267,6 @@ class CameraServer {
*/
static void RemoveCamera(std::string_view name);
/**
* Sets the size of the image to use. Use the public kSize constants to set
* the correct mode, or set it directly on a camera and call the appropriate
* StartAutomaticCapture method.
*
* @deprecated Use SetResolution on the UsbCamera returned by
* StartAutomaticCapture() instead.
* @param size The size to use
*/
static void SetSize(int size);
private:
CameraServer() = default;
};

View File

@@ -12,4 +12,17 @@ macro(wpilib_target_warnings target)
elseif(UNIX AND APPLE)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-anon-enum-enum-conversion>)
endif()
# Suppress warning "enumeration types with a fixed underlying type are a
# Clang extension"
if(APPLE)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:-Wno-fixed-enum-extension>)
endif()
# Compress debug info with GCC
if ((${CMAKE_BUILD_TYPE} STREQUAL "Debug" OR
${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo") AND
${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
target_compile_options(${target} PRIVATE -gz=zlib)
endif()
endmacro()

View File

@@ -0,0 +1,11 @@
macro(download_and_check source destination)
file(DOWNLOAD ${source} ${destination} STATUS download_status)
list(GET download_status 0 status_code)
list(GET download_status 1 status_message)
if(${status_code} EQUAL 0)
message(VERBOSE "Download of \"${source}\" successful.")
else()
message(FATAL_ERROR "Download of \"${source}\" failed: ${status_message}")
endif()
endmacro()

View File

@@ -1,26 +1,26 @@
set(SCRIPTS_DIR "${CMAKE_CURRENT_LIST_DIR}/../scripts")
MACRO(GENERATE_RESOURCES inputDir outputDir prefix namespace outputFiles)
FILE(GLOB inputFiles ${inputDir}/*)
SET(${outputFiles})
FOREACH(input ${inputFiles})
GET_FILENAME_COMPONENT(inputBase ${input} NAME)
IF("${inputBase}" MATCHES "^\\.")
CONTINUE()
ENDIF()
SET(output "${outputDir}/${inputBase}.cpp")
LIST(APPEND ${outputFiles} "${output}")
set(scripts_dir "${CMAKE_CURRENT_LIST_DIR}/../scripts")
macro(generate_resources inputDir outputDir prefix namespace outputFiles)
file(GLOB inputFiles ${inputDir}/*)
set(${outputFiles})
foreach(input ${inputFiles})
get_filename_component(inputBase ${input} NAME)
if("${inputBase}" MATCHES "^\\.")
continue()
endif()
set(output "${outputDir}/${inputBase}.cpp")
list(APPEND ${outputFiles} "${output}")
ADD_CUSTOM_COMMAND(
add_custom_command(
OUTPUT ${output}
COMMAND ${CMAKE_COMMAND}
"-Dinput=${input}"
"-Doutput=${output}"
"-Dprefix=${prefix}"
"-Dnamespace=${namespace}"
-P "${SCRIPTS_DIR}/GenResource.cmake"
-P "${scripts_dir}/GenResource.cmake"
MAIN_DEPENDENCY ${input}
DEPENDS ${SCRIPTS_DIR}/GenResource.cmake
DEPENDS ${scripts_dir}/GenResource.cmake
VERBATIM
)
ENDFOREACH()
ENDMACRO()
endforeach()
endmacro()

View File

@@ -1,17 +1,17 @@
MACRO(SUBDIR_LIST result curdir)
FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
SET(dirlist "")
FOREACH(child ${children})
IF(IS_DIRECTORY ${curdir}/${child})
LIST(APPEND dirlist ${child})
ENDIF()
ENDFOREACH()
SET(${result} ${dirlist})
ENDMACRO()
macro(subdir_list result curdir)
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
MACRO(ADD_ALL_SUBDIRECTORIES curdir)
SUBDIR_LIST (_SUBPROJECTS ${curdir})
FOREACH (dir ${_SUBPROJECTS})
ADD_SUBDIRECTORY (${dir})
ENDFOREACH ()
ENDMACRO()
macro(add_all_subdirectories curdir)
subdir_list(_SUBPROJECTS ${curdir})
foreach(dir ${_SUBPROJECTS})
add_subdirectory(${dir})
endforeach()
endmacro()

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.3.0)
cmake_minimum_required(VERSION 3.11)
# load settings in case of "try compile"
set(TOOLCHAIN_CONFIG_FILE "${WPILIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain.config.cmake")

View File

@@ -2,13 +2,13 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include <hal/AnalogInput.h>
#include <hal/AnalogOutput.h>
#include <wpi/SmallVector.h>
#include "CrossConnects.h"
#include "LifetimeWrappers.h"
#include "gtest/gtest.h"
using namespace hlt;

View File

@@ -2,12 +2,12 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include <hal/DIO.h>
#include <wpi/SmallVector.h>
#include "CrossConnects.h"
#include "LifetimeWrappers.h"
#include "gtest/gtest.h"
using namespace hlt;

View File

@@ -2,11 +2,11 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include <hal/HAL.h>
#include "CrossConnects.h"
#include "LifetimeWrappers.h"
#include "gtest/gtest.h"
using namespace hlt;

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "gtest/gtest.h"
#include <gtest/gtest.h>
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);

View File

@@ -5,6 +5,7 @@
#include <atomic>
#include <thread>
#include <gtest/gtest.h>
#include <hal/DMA.h>
#include <hal/HAL.h>
#include <wpi/SmallVector.h>
@@ -13,7 +14,6 @@
#include "CrossConnects.h"
#include "LifetimeWrappers.h"
#include "gtest/gtest.h"
using namespace hlt;

View File

@@ -2,13 +2,13 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include <hal/AnalogInput.h>
#include <hal/Relay.h>
#include <wpi/SmallVector.h>
#include "CrossConnects.h"
#include "LifetimeWrappers.h"
#include "gtest/gtest.h"
using namespace hlt;

View File

@@ -2,12 +2,12 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include <hal/Relay.h>
#include <wpi/SmallVector.h>
#include "CrossConnects.h"
#include "LifetimeWrappers.h"
#include "gtest/gtest.h"
using namespace hlt;

View File

@@ -6,9 +6,9 @@
#include <thread>
#include <fmt/core.h>
#include <gtest/gtest.h>
#include <hal/HAL.h>
#include "gtest/gtest.h"
#include "mockds/MockDS.h"
using namespace std::chrono_literals;

View File

@@ -36,6 +36,7 @@ repoRootNameOverride {
includeOtherLibs {
^fmt/
^gtest/
^opencv2/
^support/
^tcpsockets/

View File

@@ -40,7 +40,7 @@ target_link_libraries(cscore PUBLIC wpinet wpiutil ${OpenCV_LIBS})
set_property(TARGET cscore PROPERTY FOLDER "libraries")
install(TARGETS cscore EXPORT cscore DESTINATION "${main_lib_dest}")
install(TARGETS cscore EXPORT cscore)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/cscore")
if (WITH_FLAT_INSTALL)
@@ -53,7 +53,7 @@ configure_file(cscore-config.cmake.in ${WPILIB_BINARY_DIR}/cscore-config.cmake )
install(FILES ${WPILIB_BINARY_DIR}/cscore-config.cmake DESTINATION ${cscore_config_dir})
install(EXPORT cscore DESTINATION ${cscore_config_dir})
SUBDIR_LIST(cscore_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples")
subdir_list(cscore_examples "${CMAKE_CURRENT_SOURCE_DIR}/examples")
foreach(example ${cscore_examples})
file(GLOB cscore_example_src examples/${example}/*.cpp)
unset(add_libs)
@@ -102,12 +102,7 @@ if (WITH_JAVA)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
set(CMAKE_JNI_TARGET true)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(CMAKE_JAVA_COMPILE_FLAGS "-h" "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
add_jar(cscore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE} OUTPUT_NAME cscore)
else()
add_jar(cscore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE} OUTPUT_NAME cscore GENERATE_NATIVE_HEADERS cscore_jni_headers)
endif()
add_jar(cscore_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar ${OPENCV_JAR_FILE} OUTPUT_NAME cscore GENERATE_NATIVE_HEADERS cscore_jni_headers)
get_property(CSCORE_JAR_FILE TARGET cscore_jar PROPERTY JAR_FILE)
install(FILES ${CSCORE_JAR_FILE} DESTINATION "${java_lib_dest}")
@@ -131,19 +126,10 @@ if (WITH_JAVA)
set_property(TARGET cscorejni PROPERTY FOLDER "libraries")
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
target_include_directories(cscorejni PRIVATE ${JNI_INCLUDE_DIRS})
target_include_directories(cscorejni PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
else()
target_link_libraries(cscorejni PRIVATE cscore_jni_headers)
endif()
target_link_libraries(cscorejni PRIVATE cscore_jni_headers)
add_dependencies(cscorejni cscore_jar)
if (MSVC)
install(TARGETS cscorejni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
install(TARGETS cscorejni EXPORT cscorejni DESTINATION "${main_lib_dest}")
install(TARGETS cscorejni EXPORT cscorejni)
endif()

View File

@@ -219,13 +219,9 @@ model {
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
sources {
cpp {
source {
srcDirs 'examples/' + "${key}"
include '**/*.cpp'
}
}
sources.cpp.source {
srcDirs 'examples/' + "${key}"
include '**/*.cpp'
}
}
}
@@ -240,13 +236,9 @@ model {
nativeUtils.useRequiredLibrary(it, 'ni_link_libraries', 'ni_runtime_libraries')
}
}
sources {
cpp {
source {
srcDirs 'examples/' + "${key}"
include '**/*.cpp'
}
}
sources.cpp.source {
srcDirs 'examples/' + "${key}"
include '**/*.cpp'
}
}
}

View File

@@ -193,7 +193,8 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
auto [mediaType, contentType] = wpi::split(conn->contentType.str(), ';');
mediaType = wpi::trim(mediaType);
if (mediaType != "multipart/x-mixed-replace") {
SWARNING("\"{}\": unrecognized Content-Type \"{}\"", req.host, mediaType);
SWARNING("\"{}\": unrecognized Content-Type \"{}\"", req.host.str(),
mediaType);
std::scoped_lock lock(m_mutex);
m_streamConn = nullptr;
return nullptr;
@@ -216,7 +217,8 @@ wpi::HttpConnection* HttpCameraImpl::DeviceStreamConnect(
}
if (boundary.empty()) {
SWARNING("\"{}\": empty multi-part boundary or no Content-Type", req.host);
SWARNING("\"{}\": empty multi-part boundary or no Content-Type",
req.host.str());
std::scoped_lock lock(m_mutex);
m_streamConn = nullptr;
return nullptr;
@@ -281,8 +283,8 @@ bool HttpCameraImpl::DeviceStreamFrame(wpi::raw_istream& is,
// Check the content type (if present)
if (!contentTypeBuf.str().empty() &&
!wpi::starts_with(contentTypeBuf, "image/jpeg")) {
auto errMsg =
fmt::format("received unknown Content-Type \"{}\"", contentTypeBuf);
auto errMsg = fmt::format("received unknown Content-Type \"{}\"",
contentTypeBuf.str());
SWARNING("{}", errMsg);
PutError(errMsg, wpi::Now());
return false;

View File

@@ -400,12 +400,12 @@ void MjpegServerImpl::ConnThread::SendHTML(wpi::raw_ostream& os,
fmt::print(os,
"<input id=\"{0}{1}\" type=\"radio\" name=\"{0}\" "
"value=\"{2}\" onclick=\"update('{0}', {1})\"",
name, j, ch_name);
name, j, ch_name.str());
if (j == valE) {
os << " checked";
}
fmt::print(os, " /><label for=\"{}{}\">{}</label>\n", name, j,
ch_name);
ch_name.str());
}
break;
}
@@ -543,7 +543,7 @@ void MjpegServerImpl::ConnThread::SendJSON(wpi::raw_ostream& os,
for (char ch : *choice) {
ch_name.push_back(std::isprint(ch) ? ch : ' ');
}
fmt::print(os, "\"{}\": \"{}\"", j, ch_name);
fmt::print(os, "\"{}\": \"{}\"", j, ch_name.str());
}
os << "}\n";
}

View File

@@ -14,6 +14,7 @@
#include <vector>
#include <wpi/StringMap.h>
#include <wpi/json_fwd.h>
#include <wpi/mutex.h>
#include "PropertyImpl.h"
@@ -23,7 +24,6 @@ namespace wpi {
class Logger;
template <typename T>
class SmallVectorImpl;
class json;
} // namespace wpi
namespace cs {

View File

@@ -10,14 +10,11 @@
#include <string_view>
#include <wpi/Logger.h>
#include <wpi/json_fwd.h>
#include <wpi/mutex.h>
#include "SourceImpl.h"
namespace wpi {
class json;
} // namespace wpi
namespace cs {
class Frame;

View File

@@ -14,6 +14,7 @@
#include <wpi/Logger.h>
#include <wpi/condition_variable.h>
#include <wpi/json_fwd.h>
#include <wpi/mutex.h>
#include "Frame.h"
@@ -22,10 +23,6 @@
#include "PropertyContainer.h"
#include "cscore_cpp.h"
namespace wpi {
class json;
} // namespace wpi
namespace cs {
class Notifier;

View File

@@ -14,6 +14,7 @@
#include <vector>
#include <wpi/SmallVector.h>
#include <wpi/json_fwd.h>
#include "cscore_c.h"
@@ -23,10 +24,6 @@
#pragma warning(disable : 26495)
#endif
namespace wpi {
class json;
} // namespace wpi
/** CameraServer (cscore) namespace */
namespace cs {

View File

@@ -486,7 +486,7 @@ void UsbCameraImpl::CameraThreadMain() {
// If the name is what we expect...
std::string_view name{raw_name.c_str()};
SDEBUG4("got event on '{}' ({}) compare to '{}' ({}) mask {}", name,
name.size(), base, base.size(), event.mask);
name.size(), base.str(), base.size(), event.mask);
if (name == base) {
if ((event.mask & IN_DELETE) != 0) {
wasStreaming = m_streaming;

View File

@@ -2,8 +2,9 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <gtest/gtest.h>
#include "cscore.h"
#include "gtest/gtest.h"
namespace cs {

View File

@@ -2,7 +2,7 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "gtest/gtest.h"
#include <gtest/gtest.h>
int main(int argc, char** argv) {
::testing::InitGoogleTest(&argc, argv);

View File

@@ -5,7 +5,7 @@ include(GenResources)
include(LinkMacOSGUI)
configure_file(src/main/generate/WPILibVersion.cpp.in WPILibVersion.cpp)
GENERATE_RESOURCES(src/main/native/resources generated/main/cpp DLT dlt datalogtool_resources_src)
generate_resources(src/main/native/resources generated/main/cpp DLT dlt datalogtool_resources_src)
file(GLOB datalogtool_src src/main/native/cpp/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)

View File

@@ -1,126 +1,123 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena')) {
description = "roboRIO Team Number Setter"
apply plugin: 'cpp'
apply plugin: 'c'
apply plugin: 'google-test-test-suite'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
ext {
nativeName = 'datalogtool'
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/libssh.gradle"
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
outputs.file wpilibVersionFileOutput
inputs.file wpilibVersionFileInput
if (wpilibVersioning.releaseMode) {
outputs.upToDateWhen { false }
}
// We follow a simple set of checks to determine whether we should generate a new version file:
// 1. If the release type is not development, we generate a new version file
// 2. If there is no generated version number, we generate a new version file
// 3. If there is a generated build number, and the release type is development, then we will
// only generate if the publish task is run.
doLast {
def version = wpilibVersioning.version.get()
println "Writing version ${version} to $wpilibVersionFileOutput"
if (wpilibVersionFileOutput.exists()) {
wpilibVersionFileOutput.delete()
}
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
wpilibVersionFileOutput.write(read)
}
}
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
def willPublish = graph.hasTask(publish)
if (willPublish) {
generateCppVersion.outputs.upToDateWhen { false }
}
}
def generateTask = createGenerateResourcesTask('main', 'DLT', 'dlt', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
dependsOn generateCppVersion
}
model {
components {
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
"${nativeName}"(NativeExecutableSpec) {
baseName = 'datalogtool'
sources {
cpp {
source {
srcDirs 'src/main/native/cpp', "$buildDir/generated/main/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc {
source {
srcDirs 'src/main/native/win'
include '*.rc'
}
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
it.cppCompiler.define("LIBSSH_STATIC")
lib project: ':glass', library: 'glass', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui', 'libssh')
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << 'ws2_32.lib' << 'advapi32.lib' << 'crypt32.lib' << 'user32.lib'
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
it.linker.args << '-framework' << 'Kerberos'
} else {
it.linker.args << '-lX11'
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
}
}
}
}
}
}
apply from: 'publish.gradle'
if (project.hasProperty('onlylinuxathena')) {
return;
}
description = "roboRIO Team Number Setter"
apply plugin: 'cpp'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
ext {
nativeName = 'datalogtool'
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
def wpilibVersionFileInput = file("src/main/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/main/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/libssh.gradle"
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
outputs.file wpilibVersionFileOutput
inputs.file wpilibVersionFileInput
if (wpilibVersioning.releaseMode) {
outputs.upToDateWhen { false }
}
// We follow a simple set of checks to determine whether we should generate a new version file:
// 1. If the release type is not development, we generate a new version file
// 2. If there is no generated version number, we generate a new version file
// 3. If there is a generated build number, and the release type is development, then we will
// only generate if the publish task is run.
doLast {
def version = wpilibVersioning.version.get()
println "Writing version ${version} to $wpilibVersionFileOutput"
if (wpilibVersionFileOutput.exists()) {
wpilibVersionFileOutput.delete()
}
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
wpilibVersionFileOutput.write(read)
}
}
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
def willPublish = graph.hasTask(publish)
if (willPublish) {
generateCppVersion.outputs.upToDateWhen { false }
}
}
def generateTask = createGenerateResourcesTask('main', 'DLT', 'dlt', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
dependsOn generateCppVersion
}
model {
components {
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
"${nativeName}"(NativeExecutableSpec) {
baseName = 'datalogtool'
sources {
cpp {
source {
srcDirs 'src/main/native/cpp', "$buildDir/generated/main/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc.source {
srcDirs 'src/main/native/win'
include '*.rc'
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
it.cppCompiler.define("LIBSSH_STATIC")
lib project: ':glass', library: 'glass', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'imgui', 'libssh')
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << 'ws2_32.lib' << 'advapi32.lib' << 'crypt32.lib' << 'user32.lib'
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
it.linker.args << '-framework' << 'Kerberos'
} else {
it.linker.args << '-lX11'
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
}
}
}
}
}
}
apply from: 'publish.gradle'

View File

@@ -7,16 +7,16 @@
#include <memory>
#include <string_view>
#include <libssh/libssh.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <glass/Context.h>
#include <glass/MainMenuBar.h>
#include <glass/Storage.h>
#include <libssh/libssh.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui_internal.h>
#include <wpigui.h>
#include <wpigui_openurl.h>
#include "Downloader.h"
#include "Exporter.h"
@@ -93,6 +93,15 @@ static void DisplayMainMenu() {
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Docs")) {
if (ImGui::MenuItem("Online documentation")) {
wpi::gui::OpenURL(
"https://docs.wpilib.org/en/stable/docs/software/telemetry/"
"datalog.html");
}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
if (about) {

View File

@@ -4,6 +4,7 @@
#pragma once
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
void SetNextWindowPos(const ImVec2& pos, ImGuiCond cond = 0,

View File

@@ -427,7 +427,7 @@ void Downloader::ThreadMain() {
continue;
}
lock.lock();
err : {}
err: {}
}
if (m_state == kDownload) {
m_state = kDownloadDone;

View File

@@ -121,7 +121,13 @@ doxygen {
exclude 'wpinet/uv/**'
// json
exclude 'wpi/adl_serializer.h'
exclude 'wpi/byte_container_with_subtype.h'
exclude 'wpi/detail/**'
exclude 'wpi/json.h'
exclude 'wpi/json_fwd.h'
exclude 'wpi/ordered_map.h'
exclude 'wpi/thirdparty/**'
// memory
exclude 'wpi/memory/**'
@@ -136,6 +142,8 @@ doxygen {
//TODO: building memory docs causes search to break
exclude 'wpi/memory/**'
exclude '*.pb.h'
aliases 'effects=\\par <i>Effects:</i>^^',
'notes=\\par <i>Notes:</i>^^',
'requires=\\par <i>Requires:</i>^^',
@@ -209,7 +217,7 @@ apply from: "${rootDir}/shared/opencv.gradle"
task generateJavaDocs(type: Javadoc) {
classpath += project(":wpimath").sourceSets.main.compileClasspath
options.links("https://docs.oracle.com/en/java/javase/11/docs/api/")
options.links("https://docs.oracle.com/en/java/javase/17/docs/api/")
options.addStringOption("tag", "pre:a:Pre-Condition")
options.addBooleanOption("Xdoclint:html,missing,reference,syntax", true)
options.addBooleanOption('html5', true)

View File

@@ -22,7 +22,7 @@ if (WITH_JAVA)
endif()
GENERATE_RESOURCES(src/main/native/resources/edu/wpi/first/fields generated/main/cpp FIELDS fields field_images_resources_src)
generate_resources(src/main/native/resources/edu/wpi/first/fields generated/main/cpp FIELDS fields field_images_resources_src)
add_library(fieldImages src/main/native/cpp/fields.cpp ${field_images_resources_src})

View File

@@ -1,76 +1,69 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena')) {
if (project.hasProperty('onlylinuxathena')) {
return;
}
apply plugin: 'cpp'
apply plugin: 'c'
apply plugin: 'java'
apply plugin: 'google-test-test-suite'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
apply plugin: 'cpp'
apply plugin: 'java'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
dependencies {
implementation "com.fasterxml.jackson.core:jackson-annotations:2.15.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.15.2"
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.2"
}
dependencies {
implementation "com.fasterxml.jackson.core:jackson-annotations:2.15.2"
implementation "com.fasterxml.jackson.core:jackson-core:2.15.2"
implementation "com.fasterxml.jackson.core:jackson-databind:2.15.2"
}
ext {
nativeName = 'fieldImages'
baseId = nativeName
groupId = 'edu.wpi.first.fieldImages'
devMain = "edu.wpi.first.fieldImages.DevMain"
}
ext {
nativeName = 'fieldImages'
baseId = nativeName
groupId = 'edu.wpi.first.fieldImages'
devMain = "edu.wpi.first.fieldImages.DevMain"
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
apply from: "${rootDir}/shared/java/javacommon.gradle"
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
apply from: "${rootDir}/shared/java/javacommon.gradle"
def generateTask = createGenerateResourcesTask('main', 'FIELDS', 'fields', project)
def generateTask = createGenerateResourcesTask('main', 'FIELDS', 'fields', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
}
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
}
sourceSets {
main {
resources {
srcDirs 'src/main/native/resources'
}
}
}
sourceSets.main.resources {
srcDirs 'src/main/native/resources'
}
model {
components {
"${nativeName}"(NativeLibrarySpec) {
baseName = 'fieldImages'
sources {
cpp {
source {
srcDirs 'src/main/native/cpp', "$buildDir/generated/main/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
model {
components {
"${nativeName}"(NativeLibrarySpec) {
baseName = 'fieldImages'
sources {
cpp {
source {
srcDirs 'src/main/native/cpp', "$buildDir/generated/main/cpp"
include '**/*.cpp'
}
if (OperatingSystem.current().isWindows()) {
rc {
source {
srcDirs 'src/main/native/win'
include '*.rc'
}
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc.source {
srcDirs 'src/main/native/win'
include '*.rc'
}
}
}
}
}
apply from: 'publish.gradle'
}
apply from: 'publish.gradle'

View File

@@ -24,6 +24,7 @@ includeOtherLibs {
^fmt/
^fields/
^frc/
^google/
^imgui
^networktables/
^ntcore

View File

@@ -22,7 +22,7 @@ target_include_directories(libglass PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/lib/native/include>
$<INSTALL_INTERFACE:${include_dest}/glass>)
install(TARGETS libglass EXPORT libglass DESTINATION "${main_lib_dest}")
install(TARGETS libglass EXPORT libglass)
install(DIRECTORY src/lib/native/include/ DESTINATION "${include_dest}/glass")
#
@@ -43,7 +43,7 @@ target_include_directories(libglassnt PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/libnt/native/include>
$<INSTALL_INTERFACE:${include_dest}/glass>)
install(TARGETS libglassnt EXPORT libglassnt DESTINATION "${main_lib_dest}")
install(TARGETS libglassnt EXPORT libglassnt)
install(DIRECTORY src/libnt/native/include/ DESTINATION "${include_dest}/glass")
#
@@ -51,7 +51,7 @@ install(DIRECTORY src/libnt/native/include/ DESTINATION "${include_dest}/glass")
#
configure_file(src/app/generate/WPILibVersion.cpp.in WPILibVersion.cpp)
GENERATE_RESOURCES(src/app/native/resources generated/app/cpp GLASS glass glass_resources_src)
generate_resources(src/app/native/resources generated/app/cpp GLASS glass glass_resources_src)
file(GLOB glass_src src/app/native/cpp/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)
@@ -65,6 +65,7 @@ endif()
add_executable(glass ${glass_src} ${glass_resources_src} ${glass_rc} ${APP_ICON_MACOSX})
wpilib_link_macos_gui(glass)
wpilib_target_warnings(glass)
target_link_libraries(glass libglassnt libglass)
if (WIN32)

View File

@@ -1,208 +1,201 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena')) {
description = "A different kind of dashboard"
apply plugin: 'cpp'
apply plugin: 'c'
apply plugin: 'google-test-test-suite'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
ext {
nativeName = 'glass'
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
def wpilibVersionFileInput = file("src/app/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/app/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
outputs.file wpilibVersionFileOutput
inputs.file wpilibVersionFileInput
if (wpilibVersioning.releaseMode) {
outputs.upToDateWhen { false }
}
// We follow a simple set of checks to determine whether we should generate a new version file:
// 1. If the release type is not development, we generate a new version file
// 2. If there is no generated version number, we generate a new version file
// 3. If there is a generated build number, and the release type is development, then we will
// only generate if the publish task is run.
doLast {
def version = wpilibVersioning.version.get()
println "Writing version ${version} to $wpilibVersionFileOutput"
if (wpilibVersionFileOutput.exists()) {
wpilibVersionFileOutput.delete()
}
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
wpilibVersionFileOutput.write(read)
}
}
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
def willPublish = graph.hasTask(publish)
if (willPublish) {
generateCppVersion.outputs.upToDateWhen { false }
}
}
def generateTask = createGenerateResourcesTask('app', 'GLASS', 'glass', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
dependsOn generateCppVersion
}
nativeUtils.exportsConfigs {
glass {
x64ExcludeSymbols = [
'_CT??_R0?AV_System_error',
'_CT??_R0?AVexception',
'_CT??_R0?AVfailure',
'_CT??_R0?AVruntime_error',
'_CT??_R0?AVsystem_error',
'_CTA5?AVfailure',
'_TI5?AVfailure',
'_CT??_R0?AVout_of_range',
'_CTA3?AVout_of_range',
'_TI3?AVout_of_range',
'_CT??_R0?AVbad_cast'
]
}
}
model {
components {
"${nativeName}"(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs 'src/lib/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/lib/native/include'
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
if (it instanceof SharedLibraryBinarySpec) {
it.buildable = false
return
}
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui')
}
appendDebugPathToBinaries(binaries)
}
"${nativeName}nt"(NativeLibrarySpec) {
sources {
cpp {
source {
srcDirs = ['src/libnt/native/cpp']
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/libnt/native/include'
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
if (it instanceof SharedLibraryBinarySpec) {
it.buildable = false
return
}
lib library: nativeName, linkage: 'static'
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui')
}
appendDebugPathToBinaries(binaries)
}
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
"${nativeName}App"(NativeExecutableSpec) {
baseName = 'glass'
sources {
cpp {
source {
srcDirs 'src/app/native/cpp', "$buildDir/generated/app/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/app/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc {
source {
srcDirs 'src/app/native/win'
}
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
lib project: ':cscore', library: 'cscore', linkage: 'static'
lib library: 'glassnt', linkage: 'static'
lib library: nativeName, linkage: 'static'
project(':ntcore').addNtcoreDependency(it, 'static')
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'opencv_static')
nativeUtils.useRequiredLibrary(it, 'imgui')
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
} else {
it.linker.args << '-lX11'
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
}
}
}
}
}
}
apply from: 'publish.gradle'
if (project.hasProperty('onlylinuxathena')) {
return;
}
description = "A different kind of dashboard"
apply plugin: 'cpp'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
ext {
nativeName = 'glass'
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
def wpilibVersionFileInput = file("src/app/generate/WPILibVersion.cpp.in")
def wpilibVersionFileOutput = file("$buildDir/generated/app/cpp/WPILibVersion.cpp")
apply from: "${rootDir}/shared/imgui.gradle"
task generateCppVersion() {
description = 'Generates the wpilib version class'
group = 'WPILib'
outputs.file wpilibVersionFileOutput
inputs.file wpilibVersionFileInput
if (wpilibVersioning.releaseMode) {
outputs.upToDateWhen { false }
}
// We follow a simple set of checks to determine whether we should generate a new version file:
// 1. If the release type is not development, we generate a new version file
// 2. If there is no generated version number, we generate a new version file
// 3. If there is a generated build number, and the release type is development, then we will
// only generate if the publish task is run.
doLast {
def version = wpilibVersioning.version.get()
println "Writing version ${version} to $wpilibVersionFileOutput"
if (wpilibVersionFileOutput.exists()) {
wpilibVersionFileOutput.delete()
}
def read = wpilibVersionFileInput.text.replace('${wpilib_version}', version)
wpilibVersionFileOutput.write(read)
}
}
gradle.taskGraph.addTaskExecutionGraphListener { graph ->
def willPublish = graph.hasTask(publish)
if (willPublish) {
generateCppVersion.outputs.upToDateWhen { false }
}
}
def generateTask = createGenerateResourcesTask('app', 'GLASS', 'glass', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
dependsOn generateCppVersion
}
nativeUtils.exportsConfigs {
glass {
x64ExcludeSymbols = [
'_CT??_R0?AV_System_error',
'_CT??_R0?AVexception',
'_CT??_R0?AVfailure',
'_CT??_R0?AVruntime_error',
'_CT??_R0?AVsystem_error',
'_CTA5?AVfailure',
'_TI5?AVfailure',
'_CT??_R0?AVout_of_range',
'_CTA3?AVout_of_range',
'_TI3?AVout_of_range',
'_CT??_R0?AVbad_cast'
]
}
}
model {
components {
"${nativeName}"(NativeLibrarySpec) {
sources.cpp {
source {
srcDirs 'src/lib/native/cpp'
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/lib/native/include'
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
if (it instanceof SharedLibraryBinarySpec) {
it.buildable = false
return
}
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui')
}
appendDebugPathToBinaries(binaries)
}
"${nativeName}nt"(NativeLibrarySpec) {
sources.cpp {
source {
srcDirs = ['src/libnt/native/cpp']
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/libnt/native/include'
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
if (it instanceof SharedLibraryBinarySpec) {
it.buildable = false
return
}
lib library: nativeName, linkage: 'static'
project(':ntcore').addNtcoreDependency(it, 'shared')
lib project: ':wpinet', library: 'wpinet', linkage: 'shared'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'shared'
lib project: ':wpimath', library: 'wpimath', linkage: 'shared'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'shared'
nativeUtils.useRequiredLibrary(it, 'imgui')
}
appendDebugPathToBinaries(binaries)
}
// By default, a development executable will be generated. This is to help the case of
// testing specific functionality of the library.
"${nativeName}App"(NativeExecutableSpec) {
baseName = 'glass'
sources {
cpp {
source {
srcDirs 'src/app/native/cpp', "$buildDir/generated/app/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/app/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc.source {
srcDirs 'src/app/native/win'
}
}
}
binaries.all {
if (it.targetPlatform.name == nativeUtils.wpi.platforms.roborio) {
it.buildable = false
return
}
lib project: ':cscore', library: 'cscore', linkage: 'static'
lib library: 'glassnt', linkage: 'static'
lib library: nativeName, linkage: 'static'
project(':ntcore').addNtcoreDependency(it, 'static')
lib project: ':wpinet', library: 'wpinet', linkage: 'static'
lib project: ':wpiutil', library: 'wpiutil', linkage: 'static'
lib project: ':wpimath', library: 'wpimath', linkage: 'static'
lib project: ':wpigui', library: 'wpigui', linkage: 'static'
lib project: ':fieldImages', library: 'fieldImages', linkage: 'static'
nativeUtils.useRequiredLibrary(it, 'opencv_static')
nativeUtils.useRequiredLibrary(it, 'imgui')
if (it.targetPlatform.operatingSystem.isWindows()) {
it.linker.args << 'Gdi32.lib' << 'Shell32.lib' << 'd3d11.lib' << 'd3dcompiler.lib'
it.linker.args << '/DELAYLOAD:MF.dll' << '/DELAYLOAD:MFReadWrite.dll' << '/DELAYLOAD:MFPlat.dll' << '/delay:nobind'
} else if (it.targetPlatform.operatingSystem.isMacOsX()) {
it.linker.args << '-framework' << 'Metal' << '-framework' << 'MetalKit' << '-framework' << 'Cocoa' << '-framework' << 'IOKit' << '-framework' << 'CoreFoundation' << '-framework' << 'CoreVideo' << '-framework' << 'QuartzCore'
} else {
it.linker.args << '-lX11'
if (it.targetPlatform.name.startsWith('linuxarm')) {
it.linker.args << '-lGL'
}
}
}
}
}
}
apply from: 'publish.gradle'

View File

@@ -84,51 +84,8 @@ model {
def applicationPath = binary.executable.file
def icon = file("$project.projectDir/src/app/native/mac/glass.icns")
// Create the macOS bundle.
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/$binary.targetPlatform.architecture.name/Glass.app/Contents"))
into("MacOS") {
with copySpec {
from binary.executable.file
}
}
into("Resources") {
with copySpec {
from icon
}
}
inputs.property "HasDeveloperId", project.hasProperty("developerID")
doLast {
if (project.hasProperty("developerID")) {
// Get path to binary.
exec {
workingDir rootDir
def args = [
"sh",
"-c",
"codesign --force --strict --deep " +
"--timestamp --options=runtime " +
"--verbose -s ${project.findProperty("developerID")} " +
"$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/Glass.app/"
]
commandLine args
}
}
}
}
// Reset the application path if we are creating a bundle.
if (binary.targetPlatform.operatingSystem.isMacOsX()) {
applicationPath = file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name")
project.build.dependsOn bundleTask
}
// Create the ZIP.
def task = project.tasks.create("copyGlassExecutable" + binary.targetPlatform.architecture.name, Zip) {
def task = project.tasks.create("copyGlassExecutable" + binary.targetPlatform.operatingSystem.name + binary.targetPlatform.architecture.name, Zip) {
description("Copies the Glass executable to the outputs directory.")
destinationDirectory = outputsFolder
@@ -153,6 +110,47 @@ model {
}
if (binary.targetPlatform.operatingSystem.isMacOsX()) {
// Create the macOS bundle.
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/$binary.targetPlatform.architecture.name/Glass.app/Contents"))
into("MacOS") {
with copySpec {
from binary.executable.file
}
}
into("Resources") {
with copySpec {
from icon
}
}
inputs.property "HasDeveloperId", project.hasProperty("developerID")
doLast {
if (project.hasProperty("developerID")) {
// Get path to binary.
exec {
workingDir rootDir
def args = [
"sh",
"-c",
"codesign --force --strict --deep " +
"--timestamp --options=runtime " +
"--verbose -s ${project.findProperty("developerID")} " +
"$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name/Glass.app/"
]
commandLine args
}
}
}
}
// Reset the application path if we are creating a bundle.
applicationPath = file("$project.buildDir/outputs/bundles/$binary.targetPlatform.architecture.name")
project.build.dependsOn bundleTask
bundleTask.dependsOn binary.tasks.link
task.dependsOn(bundleTask)
}

View File

@@ -8,7 +8,9 @@
#include <fmt/format.h>
#include <imgui.h>
#include <ntcore_cpp.h>
#include <wpi/StringExtras.h>
#include <wpigui.h>
#include <wpigui_openurl.h>
#include "glass/Context.h"
#include "glass/MainMenuBar.h"
@@ -281,6 +283,15 @@ int main(int argc, char** argv) {
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Docs")) {
if (ImGui::MenuItem("Online documentation")) {
wpi::gui::OpenURL(
"https://docs.wpilib.org/en/stable/docs/software/dashboards/"
"glass/");
}
ImGui::EndMenu();
}
});
gui::AddLateExecute([] {
@@ -317,11 +328,13 @@ int main(int argc, char** argv) {
char nameBuf[32];
const char* name = glfwGetKeyName(*gEnterKey, 0);
if (!name) {
std::snprintf(nameBuf, sizeof(nameBuf), "%d", *gEnterKey);
wpi::format_to_n_c_str(nameBuf, sizeof(nameBuf), "{}", *gEnterKey);
name = nameBuf;
}
std::snprintf(editLabel, sizeof(editLabel), "%s###edit",
gKeyEdit ? "(press key)" : name);
wpi::format_to_n_c_str(editLabel, sizeof(editLabel), "{}###edit",
gKeyEdit ? "(press key)" : name);
if (ImGui::SmallButton(editLabel)) {
gKeyEdit = true;
}

View File

@@ -6,18 +6,16 @@
#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <filesystem>
#include <fmt/format.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <imgui_stdlib.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/StringExtras.h>
#include <wpi/fs.h>
#include <wpi/json.h>
#include <wpi/json_serializer.h>
#include <wpi/raw_istream.h>
#include <wpi/raw_ostream.h>
#include <wpi/timestamp.h>
#include <wpigui.h>
@@ -131,14 +129,17 @@ static bool JsonToWindow(const wpi::json& jfile, const char* filename) {
static bool LoadWindowStorageImpl(const std::string& filename) {
std::error_code ec;
wpi::raw_fd_istream is{filename, ec};
if (ec) {
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(filename, ec);
if (fileBuffer == nullptr || ec) {
ImGui::LogText("error opening %s: %s", filename.c_str(),
ec.message().c_str());
return false;
} else {
try {
return JsonToWindow(wpi::json::parse(is), filename.c_str());
return JsonToWindow(
wpi::json::parse(fileBuffer->begin(), fileBuffer->end()),
filename.c_str());
} catch (wpi::json::parse_error& e) {
ImGui::LogText("Error loading %s: %s", filename.c_str(), e.what());
return false;
@@ -149,8 +150,9 @@ static bool LoadWindowStorageImpl(const std::string& filename) {
static bool LoadStorageRootImpl(Context* ctx, const std::string& filename,
std::string_view rootName) {
std::error_code ec;
wpi::raw_fd_istream is{filename, ec};
if (ec) {
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(filename, ec);
if (fileBuffer == nullptr || ec) {
ImGui::LogText("error opening %s: %s", filename.c_str(),
ec.message().c_str());
return false;
@@ -162,7 +164,9 @@ static bool LoadStorageRootImpl(Context* ctx, const std::string& filename,
createdStorage = true;
}
try {
storage->FromJson(wpi::json::parse(is), filename.c_str());
storage->FromJson(
wpi::json::parse(fileBuffer->begin(), fileBuffer->end()),
filename.c_str());
} catch (wpi::json::parse_error& e) {
ImGui::LogText("Error loading %s: %s", filename.c_str(), e.what());
if (createdStorage) {
@@ -533,7 +537,8 @@ void glass::PushID(const char* str_id_begin, const char* str_id_end) {
void glass::PushID(int int_id) {
char buf[16];
std::snprintf(buf, sizeof(buf), "%d", int_id);
wpi::format_to_n_c_str(buf, sizeof(buf), "{}", int_id);
PushStorageStack(buf);
ImGui::PushID(int_id);
}

View File

@@ -4,9 +4,8 @@
#include "glass/MainMenuBar.h"
#include <cstdio>
#include <imgui.h>
#include <wpi/StringExtras.h>
#include <wpigui.h>
#include "glass/Context.h"
@@ -52,11 +51,11 @@ void MainMenuBar::Display() {
#if 0
char str[64];
std::snprintf(str, sizeof(str), "%.3f ms/frame (%.1f FPS)",
1000.0f / ImGui::GetIO().Framerate,
ImGui::GetIO().Framerate);
ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::CalcTextSize(str).x -
10);
wpi::format_to_n_c_str(str, sizeof(str), "{:.3f} ms/frame ({:.1f} FPS)",
1000.0f / ImGui::GetIO().Framerate,
ImGui::GetIO().Framerate);
ImGui::SameLine(ImGui::GetWindowWidth() - ImGui::CalcTextSize(str).x - 10);
ImGui::Text("%s", str);
#endif
ImGui::EndMainMenuBar();

View File

@@ -56,9 +56,12 @@ void Window::Display() {
}
char label[128];
std::snprintf(label, sizeof(label), "%s###%s",
m_name.empty() ? m_defaultName.c_str() : m_name.c_str(),
m_id.c_str());
if (m_name.empty()) {
wpi::format_to_n_c_str(label, sizeof(label), "{}###{}", m_defaultName,
m_id);
} else {
wpi::format_to_n_c_str(label, sizeof(label), "{}###{}", m_name, m_id);
}
if (Begin(label, &m_visible, m_flags)) {
if (m_renamePopupEnabled || m_view->HasSettings()) {

View File

@@ -4,6 +4,8 @@
#include "glass/hardware/AnalogGyro.h"
#include <wpi/StringExtras.h>
#include "glass/DataSource.h"
#include "glass/other/DeviceTree.h"
@@ -11,7 +13,8 @@ using namespace glass;
void glass::DisplayAnalogGyroDevice(AnalogGyroModel* model, int index) {
char name[32];
std::snprintf(name, sizeof(name), "AnalogGyro[%d]", index);
wpi::format_to_n_c_str(name, sizeof(name), "AnalogGyro[{}]", index);
if (BeginDevice(name)) {
// angle
if (auto angleData = model->GetAngleData()) {

View File

@@ -5,6 +5,7 @@
#include "glass/hardware/AnalogInput.h"
#include <imgui.h>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -22,9 +23,9 @@ void glass::DisplayAnalogInput(AnalogInputModel* model, int index) {
std::string& name = GetStorage().GetString("name");
char label[128];
if (!name.empty()) {
std::snprintf(label, sizeof(label), "%s [%d]###name", name.c_str(), index);
wpi::format_to_n_c_str(label, sizeof(label), "{} [{}]###name", name, index);
} else {
std::snprintf(label, sizeof(label), "In[%d]###name", index);
wpi::format_to_n_c_str(label, sizeof(label), "In[{}]###name", index);
}
if (model->IsGyro()) {

View File

@@ -4,6 +4,8 @@
#include "glass/hardware/AnalogOutput.h"
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
#include "glass/Storage.h"
@@ -30,9 +32,9 @@ void glass::DisplayAnalogOutputsDevice(AnalogOutputsModel* model) {
std::string& name = GetStorage().GetString("name");
char label[128];
if (!name.empty()) {
std::snprintf(label, sizeof(label), "%s [%d]###name", name.c_str(), i);
wpi::format_to_n_c_str(label, sizeof(label), "{} [{}]###name", name, i);
} else {
std::snprintf(label, sizeof(label), "Out[%d]###name", i);
wpi::format_to_n_c_str(label, sizeof(label), "Out[{}]###name", i);
}
double value = analogOutData->GetValue();

View File

@@ -6,6 +6,7 @@
#include <fmt/format.h>
#include <imgui.h>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -70,10 +71,11 @@ void glass::DisplayEncoder(EncoderModel* model) {
std::string& name = GetStorage().GetString("name");
char label[128];
if (!name.empty()) {
std::snprintf(label, sizeof(label), "%s [%d,%d]###header", name.c_str(),
chA, chB);
wpi::format_to_n_c_str(label, sizeof(label), "{} [{},{}]###header", name,
chA, chB);
} else {
std::snprintf(label, sizeof(label), "Encoder[%d,%d]###header", chA, chB);
wpi::format_to_n_c_str(label, sizeof(label), "Encoder[{},{}]###header", chA,
chB);
}
// header

View File

@@ -5,12 +5,13 @@
#include "glass/hardware/Gyro.h"
#include <cmath>
#include <numbers>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui_internal.h>
#include <numbers>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -65,7 +66,8 @@ void glass::DisplayGyro(GyroModel* m) {
color, 1.2f);
if (major) {
char txt[16];
std::snprintf(txt, sizeof(txt), "%d°", i);
wpi::format_to_n_c_str(txt, sizeof(txt), "{}°", i);
draw->AddText(
center + (direction * radius * 1.25) - ImGui::CalcTextSize(txt) * 0.5,
primaryColor, txt, nullptr);

View File

@@ -9,6 +9,7 @@
#include <imgui.h>
#include <wpi/SmallVector.h>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -46,10 +47,10 @@ bool glass::DisplayPCMSolenoids(PCMModel* model, int index,
std::string& name = GetStorage().GetString("name");
char label[128];
if (!name.empty()) {
std::snprintf(label, sizeof(label), "%s [%d]###header", name.c_str(),
index);
wpi::format_to_n_c_str(label, sizeof(label), "{} [{}]###header", name,
index);
} else {
std::snprintf(label, sizeof(label), "PCM[%d]###header", index);
wpi::format_to_n_c_str(label, sizeof(label), "PCM[{}]###header", index);
}
// header
@@ -111,7 +112,8 @@ void glass::DisplayCompressorDevice(PCMModel* model, int index,
void glass::DisplayCompressorDevice(CompressorModel* model, int index,
bool outputsEnabled) {
char name[32];
std::snprintf(name, sizeof(name), "Compressor[%d]", index);
wpi::format_to_n_c_str(name, sizeof(name), "Compressor[{}]", index);
if (BeginDevice(name)) {
// output enabled
if (auto runningData = model->GetRunningData()) {

View File

@@ -5,6 +5,7 @@
#include "glass/hardware/PWM.h"
#include <imgui.h>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -22,9 +23,9 @@ void glass::DisplayPWM(PWMModel* model, int index, bool outputsEnabled) {
std::string& name = GetStorage().GetString("name");
char label[128];
if (!name.empty()) {
std::snprintf(label, sizeof(label), "%s [%d]###name", name.c_str(), index);
wpi::format_to_n_c_str(label, sizeof(label), "{} [{}]###name", name, index);
} else {
std::snprintf(label, sizeof(label), "PWM[%d]###name", index);
wpi::format_to_n_c_str(label, sizeof(label), "PWM[{}]###name", index);
}
int led = model->GetAddressableLED();

View File

@@ -5,9 +5,9 @@
#include "glass/hardware/PowerDistribution.h"
#include <algorithm>
#include <cstdio>
#include <imgui.h>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/DataSource.h"
@@ -36,7 +36,8 @@ static float DisplayChannel(PowerDistributionModel& pdp, int channel) {
void glass::DisplayPowerDistribution(PowerDistributionModel* model, int index) {
char name[128];
std::snprintf(name, sizeof(name), "PowerDistribution[%d]", index);
wpi::format_to_n_c_str(name, sizeof(name), "PowerDistribution[{}]", index);
if (CollapsingHeader(name)) {
// temperature
if (auto tempData = model->GetTemperatureData()) {

View File

@@ -7,6 +7,7 @@
#include <cinttypes>
#include <imgui.h>
#include <wpi/StringExtras.h>
#include "glass/Context.h"
#include "glass/ContextInternal.h"
@@ -53,8 +54,11 @@ bool glass::BeginDevice(const char* id, ImGuiTreeNodeFlags flags) {
// build label
std::string& name = GetStorage().GetString("name");
char label[128];
std::snprintf(label, sizeof(label), "%s###header",
name.empty() ? id : name.c_str());
if (name.empty()) {
wpi::format_to_n_c_str(label, sizeof(label), "{}###header", id);
} else {
wpi::format_to_n_c_str(label, sizeof(label), "{}###header", name);
}
bool open = CollapsingHeader(label, flags);
PopupEditName("header", &name);

View File

@@ -24,12 +24,12 @@
#include <portable-file-dialogs.h>
#include <units/angle.h>
#include <units/length.h>
#include <wpi/MemoryBuffer.h>
#include <wpi/SmallString.h>
#include <wpi/StringExtras.h>
#include <wpi/StringMap.h>
#include <wpi/fs.h>
#include <wpi/json.h>
#include <wpi/raw_istream.h>
#include <wpigui.h>
#include "glass/Context.h"
@@ -238,7 +238,7 @@ class FieldInfo {
private:
void Reset();
bool LoadImageImpl(const std::string& fn);
bool LoadJson(wpi::raw_istream& is, std::string_view filename);
bool LoadJson(std::span<const char> is, std::string_view filename);
void LoadJsonFile(std::string_view jsonfile);
std::unique_ptr<pfd::open_file> m_fileOpener;
@@ -423,12 +423,11 @@ void FieldInfo::LoadImage() {
for (auto&& field : fields::GetFields()) {
if (field.name == m_builtin) {
auto jsonstr = field.getJson();
wpi::raw_mem_istream is{jsonstr.data(), jsonstr.size()};
auto imagedata = field.getImage();
auto texture = gui::Texture::CreateFromImage(
reinterpret_cast<const unsigned char*>(imagedata.data()),
imagedata.size());
if (texture && LoadJson(is, {})) {
if (texture && LoadJson({jsonstr.data(), jsonstr.size()}, {})) {
m_texture = std::move(texture);
m_imageWidth = m_texture.GetWidth();
m_imageHeight = m_texture.GetHeight();
@@ -445,7 +444,7 @@ void FieldInfo::LoadImage() {
}
}
bool FieldInfo::LoadJson(wpi::raw_istream& is, std::string_view filename) {
bool FieldInfo::LoadJson(std::span<const char> is, std::string_view filename) {
// parse file
wpi::json j;
try {
@@ -532,12 +531,15 @@ bool FieldInfo::LoadJson(wpi::raw_istream& is, std::string_view filename) {
void FieldInfo::LoadJsonFile(std::string_view jsonfile) {
std::error_code ec;
wpi::raw_fd_istream f(jsonfile, ec);
if (ec) {
std::unique_ptr<wpi::MemoryBuffer> fileBuffer =
wpi::MemoryBuffer::GetFile(jsonfile, ec);
if (fileBuffer == nullptr || ec) {
std::fputs("GUI: could not open field JSON file\n", stderr);
return;
}
LoadJson(f, jsonfile);
LoadJson(
{reinterpret_cast<const char*>(fileBuffer->begin()), fileBuffer->size()},
jsonfile);
}
bool FieldInfo::LoadImageImpl(const std::string& fn) {

View File

@@ -8,7 +8,6 @@
#include <algorithm>
#include <atomic>
#include <cstdio>
#include <cstring>
#include <memory>
#include <string>
@@ -16,6 +15,7 @@
#include <vector>
#include <fmt/format.h>
#include <wpi/StringExtras.h>
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
@@ -321,8 +321,8 @@ PlotSeries::Action PlotSeries::EmitPlot(PlotView& view, double now, size_t i,
CheckSource();
char label[128];
std::snprintf(label, sizeof(label), "%s###name%d_%d", GetName(),
static_cast<int>(i), static_cast<int>(plotIndex));
wpi::format_to_n_c_str(label, sizeof(label), "{}###name{}_{}", GetName(),
static_cast<int>(i), static_cast<int>(plotIndex));
int size = m_size;
int offset = m_offset;
@@ -580,8 +580,9 @@ void Plot::EmitPlot(PlotView& view, double now, bool paused, size_t i) {
}
char label[128];
std::snprintf(label, sizeof(label), "%s###plot%d", m_name.c_str(),
static_cast<int>(i));
wpi::format_to_n_c_str(label, sizeof(label), "{}###plot{}", m_name,
static_cast<int>(i));
ImPlotFlags plotFlags = (m_legend ? 0 : ImPlotFlags_NoLegend) |
(m_crosshairs ? ImPlotFlags_Crosshairs : 0) |
(m_mousePosition ? 0 : ImPlotFlags_NoMouseText);
@@ -937,14 +938,15 @@ void PlotView::Settings() {
char name[64];
if (!plot->GetName().empty()) {
std::snprintf(name, sizeof(name), "%s", plot->GetName().c_str());
wpi::format_to_n_c_str(name, sizeof(name), "{}", plot->GetName().c_str());
} else {
std::snprintf(name, sizeof(name), "Plot %d", static_cast<int>(i));
wpi::format_to_n_c_str(name, sizeof(name), "Plot {}",
static_cast<int>(i));
}
char label[90];
std::snprintf(label, sizeof(label), "%s###header%d", name,
static_cast<int>(i));
wpi::format_to_n_c_str(label, sizeof(label), "{}###header{}", name,
static_cast<int>(i));
bool open = ImGui::CollapsingHeader(label);
@@ -1013,7 +1015,8 @@ void PlotProvider::DisplayMenu() {
char id[32];
size_t numWindows = m_windows.size();
for (size_t i = 0; i <= numWindows; ++i) {
std::snprintf(id, sizeof(id), "Plot <%d>", static_cast<int>(i));
wpi::format_to_n_c_str(id, sizeof(id), "Plot <{}>", static_cast<int>(i));
bool match = false;
for (size_t j = 0; j < numWindows; ++j) {
if (m_windows[j]->GetId() == id) {

View File

@@ -4,9 +4,8 @@
#include "glass/support/ExtraGuiWidgets.h"
#include <imgui.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui_internal.h>
#include "glass/DataSource.h"

View File

@@ -4,9 +4,6 @@
#include "glass/support/NameSetting.h"
#include <cstdio>
#include <cstring>
#include <imgui_internal.h>
#include <imgui_stdlib.h>
#include <wpi/StringExtras.h>
@@ -16,75 +13,80 @@ using namespace glass;
void NameSetting::GetName(char* buf, size_t size,
const char* defaultName) const {
if (!m_name.empty()) {
std::snprintf(buf, size, "%s", m_name.c_str());
wpi::format_to_n_c_str(buf, size, "{}", m_name);
} else {
std::snprintf(buf, size, "%s", defaultName);
wpi::format_to_n_c_str(buf, size, "{}", defaultName);
}
}
void NameSetting::GetName(char* buf, size_t size, const char* defaultName,
int index) const {
if (!m_name.empty()) {
std::snprintf(buf, size, "%s [%d]", m_name.c_str(), index);
wpi::format_to_n_c_str(buf, size, "{} [{}]", m_name, index);
} else {
std::snprintf(buf, size, "%s[%d]", defaultName, index);
wpi::format_to_n_c_str(buf, size, "{}[{}]", defaultName, index);
}
}
void NameSetting::GetName(char* buf, size_t size, const char* defaultName,
int index, int index2) const {
if (!m_name.empty()) {
std::snprintf(buf, size, "%s [%d,%d]", m_name.c_str(), index, index2);
wpi::format_to_n_c_str(buf, size, "{} [{},{}]", m_name, index, index2);
} else {
std::snprintf(buf, size, "%s[%d,%d]", defaultName, index, index2);
wpi::format_to_n_c_str(buf, size, "{}[{},{}]", defaultName, index, index2);
}
}
void NameSetting::GetLabel(char* buf, size_t size,
const char* defaultName) const {
if (!m_name.empty()) {
std::snprintf(buf, size, "%s###Name%s", m_name.c_str(), defaultName);
wpi::format_to_n_c_str(buf, size, "{}###Name{}", m_name, defaultName);
} else {
std::snprintf(buf, size, "%s###Name%s", defaultName, defaultName);
wpi::format_to_n_c_str(buf, size, "{}###Name{}", defaultName, defaultName);
}
}
void NameSetting::GetLabel(char* buf, size_t size, const char* defaultName,
int index) const {
if (!m_name.empty()) {
std::snprintf(buf, size, "%s [%d]###Name%d", m_name.c_str(), index, index);
wpi::format_to_n_c_str(buf, size, "{} [{}]###Name{}", m_name, index, index);
} else {
std::snprintf(buf, size, "%s[%d]###Name%d", defaultName, index, index);
wpi::format_to_n_c_str(buf, size, "{}[{}]###Name{}", defaultName, index,
index);
}
}
void NameSetting::GetLabel(char* buf, size_t size, const char* defaultName,
int index, int index2) const {
if (!m_name.empty()) {
std::snprintf(buf, size, "%s [%d,%d]###Name%d", m_name.c_str(), index,
index2, index);
wpi::format_to_n_c_str(buf, size, "{} [{},{}]###Name{}", m_name, index,
index2, index);
} else {
std::snprintf(buf, size, "%s[%d,%d]###Name%d", defaultName, index, index2,
index);
wpi::format_to_n_c_str(buf, size, "{}[{},{}]###Name{}", defaultName, index,
index2, index);
}
}
void NameSetting::PushEditNameId(int index) {
char id[64];
std::snprintf(id, sizeof(id), "Name%d", index);
wpi::format_to_n_c_str(id, sizeof(id), "Name{}", index);
ImGui::PushID(id);
}
void NameSetting::PushEditNameId(const char* name) {
char id[128];
std::snprintf(id, sizeof(id), "Name%s", name);
wpi::format_to_n_c_str(id, sizeof(id), "Name{}", name);
ImGui::PushID(id);
}
bool NameSetting::PopupEditName(int index) {
bool rv = false;
char id[64];
std::snprintf(id, sizeof(id), "Name%d", index);
wpi::format_to_n_c_str(id, sizeof(id), "Name{}", index);
if (ImGui::BeginPopupContextItem(id)) {
ImGui::Text("Edit name:");
if (InputTextName("##edit")) {
@@ -101,8 +103,10 @@ bool NameSetting::PopupEditName(int index) {
bool NameSetting::PopupEditName(const char* name) {
bool rv = false;
char id[128];
std::snprintf(id, sizeof(id), "Name%s", name);
wpi::format_to_n_c_str(id, sizeof(id), "Name{}", name);
if (ImGui::BeginPopupContextItem(id)) {
ImGui::Text("Edit name:");
if (InputTextName("##edit")) {

View File

@@ -16,10 +16,7 @@
#include <wpi/StringMap.h>
#include <wpi/iterator_range.h>
namespace wpi {
class json;
} // namespace wpi
#include <wpi/json_fwd.h>
namespace glass {

View File

@@ -9,6 +9,7 @@
#include <string_view>
#include <utility>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include "glass/View.h"

View File

@@ -10,6 +10,8 @@
#include <frc/geometry/Pose2d.h>
#include <frc/geometry/Rotation2d.h>
#include <frc/geometry/Translation2d.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <wpi/function_ref.h>

View File

@@ -6,6 +6,8 @@
#include <frc/geometry/Rotation2d.h>
#include <frc/geometry/Translation2d.h>
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <wpi/function_ref.h>

View File

@@ -4,6 +4,7 @@
#pragma once
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
namespace glass {

File diff suppressed because it is too large Load Diff

View File

@@ -18,6 +18,8 @@
#include <ntcore_cpp.h>
#include <wpi/DenseMap.h>
#include <wpi/json.h>
#include <wpi/protobuf/ProtobufMessageDatabase.h>
#include <wpi/struct/DynamicStruct.h>
#include "glass/Model.h"
#include "glass/View.h"
@@ -31,7 +33,7 @@ class NetworkTablesModel : public Model {
struct EntryValueTreeNode;
struct ValueSource {
void UpdateFromValue(nt::Value&& v, std::string_view name,
void UpdateFromValue(NetworkTablesModel& model, std::string_view name,
std::string_view typeStr);
/** The latest value. */
@@ -40,6 +42,9 @@ class NetworkTablesModel : public Model {
/** String representation of the value (for arrays / complex values). */
std::string valueStr;
/** Data type */
std::string typeStr;
/** Data source (for numeric values). */
std::unique_ptr<DataSource> source;
@@ -48,6 +53,15 @@ class NetworkTablesModel : public Model {
/** Whether or not the children represent a map */
bool valueChildrenMap = false;
private:
void UpdateDiscreteSource(std::string_view name, double value, int64_t time,
bool digital = false);
template <typename T, typename MakeValue>
void UpdateDiscreteArray(std::string_view name, std::span<const T> arr,
int64_t time, MakeValue makeValue,
bool digital = false);
};
struct EntryValueTreeNode : public ValueSource {
@@ -64,6 +78,10 @@ class NetworkTablesModel : public Model {
Entry& operator=(const Entry&) = delete;
~Entry();
void UpdateFromValue(NetworkTablesModel& model) {
ValueSource::UpdateFromValue(model, info.name, info.type_str);
}
void UpdateTopic(nt::Event&& event) {
if (std::holds_alternative<nt::TopicInfo>(event.data)) {
UpdateInfo(std::get<nt::TopicInfo>(std::move(event.data)));
@@ -149,6 +167,9 @@ class NetworkTablesModel : public Model {
Entry* GetEntry(std::string_view name);
Entry* AddEntry(NT_Topic topic);
wpi::StructDescriptorDatabase& GetStructDatabase() { return m_structDb; }
wpi::ProtobufMessageDatabase& GetProtobufDatabase() { return m_protoDb; }
private:
void RebuildTree();
void RebuildTreeImpl(std::vector<TreeNode>* tree, int category);
@@ -168,6 +189,9 @@ class NetworkTablesModel : public Model {
std::map<std::string, Client, std::less<>> m_clients;
Client m_server;
wpi::StructDescriptorDatabase m_structDb;
wpi::ProtobufMessageDatabase m_protoDb;
};
using NetworkTablesFlags = int;

View File

@@ -19,3 +19,5 @@ endif()
target_compile_features(gtest PUBLIC cxx_std_20)
target_compile_features(gtest_main PUBLIC cxx_std_20)
target_compile_features(gmock PUBLIC cxx_std_20)
target_compile_features(gmock_main PUBLIC cxx_std_20)

Binary file not shown.

View File

@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

22
gradlew vendored
View File

@@ -83,7 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
@@ -130,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
@@ -141,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
@@ -149,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
@@ -198,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \

View File

@@ -32,6 +32,7 @@ includeOtherLibs {
^FRC_FPGA_ChipObject/
^FRC_NetworkCommunication/
^fmt/
^gtest/
^i2clib/
^llvm/
^opencv2/

View File

@@ -55,7 +55,7 @@ target_link_libraries(hal PUBLIC wpiutil)
set_property(TARGET hal PROPERTY FOLDER "libraries")
install(TARGETS hal EXPORT hal DESTINATION "${main_lib_dest}")
install(TARGETS hal EXPORT hal)
install(DIRECTORY src/main/native/include/ DESTINATION "${include_dest}/hal")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/gen/ DESTINATION "${include_dest}/hal")
@@ -85,12 +85,7 @@ if (WITH_JAVA)
src/main/java/*.java)
set(CMAKE_JNI_TARGET true)
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
set(CMAKE_JAVA_COMPILE_FLAGS "-h" "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
add_jar(hal_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME wpiHal)
else()
add_jar(hal_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME wpiHal GENERATE_NATIVE_HEADERS hal_jni_headers)
endif()
add_jar(hal_jar ${JAVA_SOURCES} INCLUDE_JARS wpiutil_jar OUTPUT_NAME wpiHal GENERATE_NATIVE_HEADERS hal_jni_headers)
get_property(HAL_JAR_FILE TARGET hal_jar PROPERTY JAR_FILE)
install(FILES ${HAL_JAR_FILE} DESTINATION "${java_lib_dest}")
@@ -110,19 +105,10 @@ if (WITH_JAVA)
set_property(TARGET haljni PROPERTY FOLDER "libraries")
if(${CMAKE_VERSION} VERSION_LESS "3.11.0")
target_include_directories(haljni PRIVATE ${JNI_INCLUDE_DIRS})
target_include_directories(haljni PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/jniheaders")
else()
target_link_libraries(haljni PRIVATE hal_jni_headers)
endif()
target_link_libraries(haljni PRIVATE hal_jni_headers)
add_dependencies(haljni hal_jar)
if (MSVC)
install(TARGETS haljni RUNTIME DESTINATION "${jni_lib_dest}" COMPONENT Runtime)
endif()
install(TARGETS haljni EXPORT haljni DESTINATION "${main_lib_dest}")
install(TARGETS haljni EXPORT haljni)
endif()

View File

@@ -190,6 +190,14 @@ public final class HAL extends JNIWrapper {
*/
public static native boolean getRSLState();
/**
* Gets if the system time is valid.
*
* @return True if the system time is valid, false otherwise
* @see "HAL_GetSystemTimeValid"
*/
public static native boolean getSystemTimeValid();
/**
* Gets a port handle for a specific channel and module.
*

View File

@@ -61,6 +61,14 @@ public final class HALUtil extends JNIWrapper {
*/
public static native String getComments();
/**
* Returns the team number configured for the robot controller.
*
* @return team number, or 0 if not found.
* @see "HAL_GetTeamNumber"
*/
public static native int getTeamNumber();
/**
* Reads the microsecond-resolution timer on the FPGA.
*

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