Squashed 'third_party/allwpilib/' changes from f1a82828fe..ce550705d7
ce550705d7 [ntcore] Fix client "received unknown id -1" (#6186)
3989617bde [ntcore] NetworkTable::GetStruct: Add I template param (#6183)
f1836e1321 [fieldImages] Fix 2024 field json (#6179)
d05f179a9a [build] Fix running apriltagsvision Java example (#6173)
b1b03bed85 [wpilib] Update MotorControllerGroup deprecation message (#6171)
fa63fbf446 LICENSE.md: Bump year to 2024 (#6169)
4809f3d0fc [apriltag] Add 2024 AprilTag locations (#6168)
dd90965362 [wpiutil] Fix RawFrame.setInfo() NPE (#6167)
8659372d08 [fieldImages] Add 2024 field image (#6166)
a2e4d0b15d [docs] Fix docs for SysID routine (#6164)
0a46a3a618 [wpilib] Make ADXL345 default I2C address public (#6163)
7c26bc70ab [sysid] Load DataLog files directly for analysis (#6103)
f94e3d81b9 [docs] Fix SysId routine JavaDoc warnings (#6159)
6bed82a18e [wpilibc] Clean up C++ SysId routine (#6160)
4595f84719 [wpilib] Report LiveWindow-enabled-in-test (#6158)
707cb06105 [wpilib] Add SysIdRoutine logging utility and command factory (#6033)
3e40b9e5da [wpilib] Correct SmartDashboard usage reporting (#6157)
106518c3f8 [docs] Fix wpilibj JavaDoc warnings (#6154)
19cb2a8eb4 [wpilibj] Make class variables private to match C++ (#6153)
13f4460e00 [docs] Add missing docs to enum fields (NFC) (#6150)
4210f5635d [docs] Fix warnings about undocumented default constructors (#6151)
0f060afb55 [ntcore] Disable WebSocket fragmentation (#6149)
f29a7d2e50 [docs] Add missing JavaDocs (#6146)
6e58db398d [commands] Make Java fields private (#6148)
4ac0720385 [build] Clean up CMake files (#6141)
44db3e0ac0 [sysid] Make constexpr variables outside class scope inline (#6145)
73c7d87db7 [glass] NTStringChooser: Properly set retained (#6144)
25636b712f [build] Remove unnecessary native dependencies in wpilibjExamples (#6143)
01fb98baaa [docs] Add Missing JNI docs from C++ (NFC) (#6139)
5c424248c4 [wpilibj] Remove unused AnalogTriggerException (#6142)
c486972c55 [wpimath] Make ExponentialProfile.State mutable (#6138)
783acb9b72 [wpilibj] Store long preferences as integers (#6136)
99ab836894 [wpiutil] Add missing JavaDocs (NFC) (#6132)
ad0859a8c9 [docs] Add missing JavaDocs (#6125)
5579219716 [docs] Exclude quickbuf files and proto/struct packages from doclint (#6128)
98f06911c7 [sysid] Use eigenvector component instead of eigenvalue for fit quality check (#6131)
e1d49b975c [wpimath] Add LinearFilter reset() overload to initialize input and output buffers (#6133)
8a0bf2b7a4 [hal] Add CANAPITypes to java (#6121)
91d8837c11 [wpilib] Make protected fields in accelerometers/gyros private (#6134)
e7c9f27683 [wpilib] Add functional interface equivalents to MotorController (#6053)
8aca706217 [glass] Add type information to SmartDashboard menu (#6117)
7d3e4ddba9 [docs] Add warning about using user button to docs (NFC) (#6129)
ec3cb3dcba [build] Disable clang-tidy warning about test case names (#6127)
495585b25d [examples] Update april tag family to 36h11 (#6126)
f9aabc5ab2 [wpilib] Throw early when EventLoop is modified while running (#6115)
c16946c0ec [hal] Add CANJNI docs (NFC) (#6120)
b7f4eb2811 [doc] Update maven artifacts for units and apriltags (NFC) (#6123)
f419a62b38 [doc] Update maintainers.md (NFC) (#6124)
938bf45fd9 [wpiutil] Remove type param from ProtobufSerializable and StructSerializable (#6122)
c34debe012 [docs] Link to external OpenCV docs (#6119)
07183765de [hal] Fix formatting of HAL_ENUM enums (NFC) (#6114)
af46034b7f [wpilib] Document only first party controllers are guaranteed to have correct mapping (#6112)
636ef58d94 [hal] Properly error check readCANStreamSession (#6108)
cc631d2a69 [build] Fix generated source set location in the HAL (#6113)
09f76b32c2 [wpimath] Compile with UTF-8 encoding (#6111)
47c5fd8620 [sysid] Check data quality before OLS (#6110)
24a76be694 [hal] Add method to detect if the CAN Stream has overflowed (#6105)
9333951736 [hal] Allocate CANStreamMessage in JNI if null (#6107)
6a2d3c30a6 [wpiutil] Struct: Add info template parameter pack (#6086)
e07de37e64 [commands] Mark ParallelDeadlineGroup.setDeadline() final (#6102)
141241d2d6 [wpilib] Fix usage reporting for static classes (#6090)
f2c2bab7dc [sysid] Fix adjusted R² calculation (#6101)
5659038443 [wpiutil,cscore,apriltag] Fix RawFrame (#6098)
8aeee03626 [commands] Improve error message when composing commands twice in same composition (#6091)
55508706ff [wpiutil,cscore] Move VideoMode.PixelFormat to wpiutil (#6097)
ab78b930e9 [wpilib] ADIS16470: Add access to all 3 axes (#6074)
795d4be9fd [wpilib] Fix precision issue in Color round-and-clamp (#6100)
7aa9ad44b8 [commands] Deprecate C++ TransferOwnership() (#6095)
92c81d0791 [ci] Update pregenerate workflow to actions/checkout@v4 (#6094)
1ce617be07 [ci] Update artifact actions to v4 (#6092)
2441b57156 [wpilib] Add PWMSparkFlex MotorController (#6089)
21d1972d7a [wpiutil] DataLog: Ensure file is written on shutdown (#6087)
c29e8c66cf [wpiutil] DataLog: Fix UB in AppendImpl (#6088)
ab309e34ef [glass] Fix order of loading window settings (#6056)
22a322c9f3 [wpimath] Report error on negative PID gains (#6055)
1dba26c937 [wpilib] Add method to get breaker fault at a specific channel in PowerDistribution[Sticky]Faults (#5521)
ef1cb3f41e [commands] Fix compose-while-scheduled issue and test all compositions (#5581)
aeb1a4aa33 [wpiutil] Add serializable marker interfaces (#6060)
c1178d5add [wpilib] Add StadiaController and command wrapper (#6083)
4e4a468d4d [wpimath] Make feedforward classes throw exceptions for negative Kv or Ka (#6084)
d1793f077d [build] cmake: Add NO_WERROR option to disable -Werror (#6071)
43fb6e9f87 [glass] Add Profiled PID controller support & IZone Support (#5959)
bcef6c5398 [apriltag] Fix Java generation functions (#6063)
4059e0cd9f [hal,wpilib] Add function to control "Radio" LED (#6073)
0b2cfb3abc [dlt] Change datalogtool default folder to logs folder (#6079)
df5e439b0c [wpilib] PS4Controller: enable usage reporting (#6081)
0ff7478968 [cscore] Fix RawFrame class not being loaded in JNI (#6077)
6f23d32fe1 [wpilib] AddressableLED: Update warning about single driver (NFC) (#6069)
35a1c52788 [build] Upgrade quickbuf to 1.3.3 (#6072)
e4e2bafdb1 [sysid] Document timestamp units (#6065)
3d201c71f7 [ntcore] Fix overlapping subscriber handling (#6067)
f02984159f [glass] Check for null entries when updating struct/proto (#6059)
a004c9e05f [commands] SubsystemBase: allow setting name in constructor (#6052)
0b4c6a1546 [wpimath] Add more docs to SimulatedAnnealing (NFC) (#6054)
ab15dae887 [wpilib] ArcadeDrive: Fix max output handling (#6051)
9599c1f56f [hal] Add usage reporting ids from 2024v2 image (#6041)
f87c64af8a [wpimath] MecanumDriveWheelSpeeds: Fix desaturate() (#6040)
8798700cec [wpilibcExamples] Add inline specifier to constexpr constants (#6049)
85c9ae6eff [wpilib] Fix PS5 Controller mappings (#6050)
7c8b7a97ad [wpiutil] Zero out roborio system timestamp (#6042)
d9b504bc84 [wpilib] DataLogManager: Change sim location to logs subdir (#6039)
906b810136 [build] cmake: Fix ntcore generated header install (#6038)
56e5b404d1 Update to final 2024 V2 image (#6034)
8723ee5c39 [ntcore] Add cached topic property (#5494)
192a28af47 Fix JDK 21 warnings (#6028)
d40bdd70ba [build] Upgrade to spotbugs Gradle plugin 6.0.2 (#6027)
7bfadf32e5 [wpilibj] Joystick: make remainder of get axis methods final (#6024)
a770110438 [commands] CommandCompositionError: Include stacktrace of original composition (#5984)
54a55b8b53 [wpiutil,hal] Update image; init Rio Now() HMB with a FPGA session (#6016)
7d4e515a6b [wpimath] Simplify calculation of C for DARE precondition (#6022)
5200316c14 [ntcore] Update transmit period on topic add/remove (#6021)
ddf79a25d4 [wpiunits] Overload Measure.per(Time) to return Measure<Velocity> (#6018)
a71adef316 [wpiutil] Clean up circular_buffer iterator syntax (#6020)
39a0bf4b98 [examples] Call resetOdometry() when controller command is executed (#5905)
f5fc101fda [build] cmake: Export jars and clean up jar installs (#6014)
38bf024c96 [build] Update to Gradle 8.5 (#6007)
9d11544c18 [wpimath] Rotate traveling salesman solution so input and solution have same initial pose (#6015)
28deba20f5 [wpimath] Commit generated quickbuf Java files (#5994)
c2971c0bb3 [build] cmake: Export apriltag and wpimath (#6012)
41cfc961e4 gitattributes: Add linguist-generated locations (#6004)
14c3ade155 [wpimath] Struct cleanup (#6011)
90757b9e90 [wpilib] Make Color::HexString() constexpr (#5985)
2676b77873 Fix compilation issues that occur when building with bazel (#6008)
d32c10487c [examples] Update C++ examples to use CommandPtr (#5988)
9bc5fcf886 [build] cmake: Default WITH_JAVA_SOURCE to WITH_JAVA (#6005)
d431abba3b [upstream_utils] Fix GCEM namespace usage and add hypot(x, y, z) (#6002)
2bb1409b82 Clean up Java style (#5990)
66172ab288 Remove submodule (#6003)
e8f8c0ceb0 [upstream_utils] Update to latest Eigen HEAD (#5996)
890992a849 [hal] Commit generated usage reporting files (#5993)
a583ca01e1 [wpiutil] Change Struct to allow non-constexpr implementation (#5992)
ca272de400 [build] Fix Gradle compile_commands.json and clang-tidy warnings (#5977)
76ae090570 [wpiutil] type_traits: Add is_constexpr() (#5997)
5172ab8fd0 [commands] C++ CommandPtr: Prevent null initialization (#5991)
96914143ba [build] Bump native-utils to fix compile_commands.json (#5989)
464e6121ef [ci] Report failed status to Azure on failed tests (#2654)
5dad46cd45 [wpimath] Commit generated files (#5986)
54ab65a63a [ntcore] Commit generated files (#5962)
7ed900ae3a [wpilib] Add hex string constructor to Color and Color8Bit (#5063)
74b85b76a9 [wpimath] Make gcem call std functions if not constant-evaluated (#5983)
30816111db [wpimath] Fix TimeInterpolatableBuffer crash (#5972)
5cc923de33 [wpilib] DataLogManager: Use logs subdirectory on USB drives (#5975)
1144115da0 [commands] Add GetName to Subsystem, use in Scheduler tracer epochs (#5836)
ac7d726ac3 [wpimath] Add simulated annealing (#5961)
e09be72ee0 [wpimath] Remove unused SimpleMatrixUtils class (#5979)
0f9ebe92d9 [wpimath] Add generic circular buffer class to Java (#5969)
9fa28eb07a [ci] Bump actions/checkout to v4 (#5736)
ca684ac207 [hal] Add capability to read power distribution data as a stream (#4983)
51eecef2bd [wpimath] Optimize 2nd derivative of quintic splines (#3292)
4fcf0b25a1 [build] Apply a formatter for CMake files (#5973)
9b8011aa67 [build] Pin wpiformat version (#5982)
e00a0e84c1 [build] cmake: fix protobuf dependency finding for certain distributions (#5981)
23dd591394 [upstream_utils] Remove libuv patch that adjusts whitespace (#5976)
b0719942f0 [wpiutil] Timestamp: Report errors on Rio HMB init failure (#5974)
7bc89c4322 [wpilib] Update getAlliance() docs (NFC) (#5971)
841ea682d1 [upstream_utils] Upgrade to LLVM 17.0.5 (#5970)
a74db52dae [cameraserver] Add getVideo() pixelFormat overload (#5966)
a7eb422662 [build] Update native utils for new compile commands files (#5968)
544b231d4d [sysid] Add missing cassert include (#5967)
31cd015970 [wpimath] Add SysId doc links to LinearSystemId in C++ (NFC) (#5960)
9280054eab Revert "[build] Export wpimath protobuf symbols (#5952)"
2aba97c610 Export pb files from wpimath
c80b2d2017 [build] Export wpimath protobuf symbols (#5952)
3c0652c18a [cscore] Replace CS_PixelFormat with WPI_PixelFormat (#5954)
95716eb0cb [wpiunits] Documentation improvements (#5932)
423fd75fa8 [wpilib] Default LiveWindowEnabledInTest to false (#5950)
dfdea9c992 [wpimath] Make KalmanFilter variant for asymmetric updates (#5951)
ca81ced409 [wpiutil] Move RawFrame to wpiutil; add generation of RawFrame for AprilTags (#5923)
437cc91af5 [cscore] CvSink: Allow specifying output PixelFormat (#5943)
25b7dca46b [build] Remove CMake flat install option (#5944)
bb05e20247 [wpimath] Add protobuf/struct for trivial types (#5935)
35744a036e [wpimath] Move struct/proto classes to separate files (#5918)
80d7ad58ea [build] Declare platform launcher dependency explicitly (#5909)
f8d983b154 [ntcore] Protobuf/Struct: Use atomic_bool instead of atomic_flag (#5946)
4a44210ee3 [ntcore] NetworkTableInstance: Suppress unused lambda capture warning (#5947)
bdc8620d55 [upstream_utils] Fix fmt compilation errors on Windows (#5948)
0ca1e9b5f9 [wpimath] Add basic wpiunits support (#5821)
cc30824409 [ntcore] Increase client meta-topic decoding limit (#5934)
b1fad062f7 [wpilib] Use RKDP in DifferentialDrivetrainSim (#5931)
ead9ae5a69 [build] Add generateProto dependency to test and dev (#5933)
cfbff32185 [wpiutil] timestamp: Fix startup race on Rio (#5930)
7d90d0bcc3 [wpimath] Clean up StateSpaceUtil (#5891)
7755e45aac [build] Add generated protobuf headers to C++ test include path (#5926)
3985c031da [ntcore] ProtobufSubscriber: Fix typos (#5928)
7a87fe4b60 [ntcore] ProtobufSubscriber: Make mutex and msg mutable (#5927)
09f3ed6a5f [commands] Add static Trigger factories for robot mode changes (#5902)
79dd795bc0 [wpimath] Clean up VecBuilder and MatBuilder (#5906)
e117274a67 [wpilib] Change default Rio log dir from /home/lvuser to /home/lvuser/logs (#5899)
a8b80ca256 [upstream_utils] Update to libuv 1.47.0 (#5889)
b3a9c3e96b [build] Bump macOS deployment target to 12 (#5890)
0f8129677b [build] Distribute wpimath protobuf headers (#5925)
d105f9e3e9 [wpiutil] ProtobufBuffer: Fix buffer reallocation (#5924)
c5f2f6a0fb [fieldImages] Fix typo in field images artifact name (#5922)
c1a57e422a [commands] Clean up make_vector.h (#5917)
78ebc6e9ec [wpimath] change G to gearing in LinearSystemId factories (#5834)
9ada181866 [hal] DriverStation.h: Add stddef.h include (#5897)
95fa5ec72f [wpilibc,ntcoreffi] DataLogManager: join on Stop() call (#5910)
b6f2d3cc14 [build] Remove usage of Version.parse (#5911)
cc2cbeb04c [examples] Replace gyro rotation with poseEstimator rotation (#5900)
fa6b171e1c [wpiutil] Suppress protobuf warning false positives on GCC 13 (#5907)
d504639bbe [apriltag] Improve AprilTag docs (#5895)
3a1194be40 Replace static_cast<void>() with [[maybe_unused]] attribute (#5892)
70392cbbcb [build] cmake: Add protobuf dependency to wpiutil-config (#5886)
17c1bd5a83 [ntcore] Use json_fwd (#5881)
e69a9efeba [wpilibcExamples] Match array parameter bounds (#5880)
14dcd0d26f Use char instead of uint8_t for json::parse (#5877)
ec1d261984 [hal] Fix garbage data for match info before DS connection (#5879)
63dbf5c614 [wpiutil] MemoryBuffer: Fix normal read and file type check (#5875)
b2e7be9250 [ntcore] Only datalog meta-topics if specifically requested (#5873)
201a42a3cd [wpimath] Reorder TrapezoidProfile.calculate() arguments (#5874)
04a781b4d7 [apriltag] Add GetTags to C++ version of AprilTagFieldLayout (#5872)
87a8a1ced4 [docs] Exclude eigen and protobuf from doxygen (#5871)
git-subtree-dir: third_party/allwpilib
git-subtree-split: ce550705d7cdab117c0153a202973fc026a81274
Signed-off-by: Maxwell Henderson <mxwhenderson@gmail.com>
Change-Id: Ic8645d0551d62b411b0a816c493f0f33291896a1
diff --git a/glass/CMakeLists.txt b/glass/CMakeLists.txt
index b949fc0..36f94f5 100644
--- a/glass/CMakeLists.txt
+++ b/glass/CMakeLists.txt
@@ -18,9 +18,12 @@
wpilib_target_warnings(libglass)
target_link_libraries(libglass PUBLIC wpigui wpimath wpiutil fieldImages)
-target_include_directories(libglass PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/lib/native/include>
- $<INSTALL_INTERFACE:${include_dest}/glass>)
+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)
install(DIRECTORY src/lib/native/include/ DESTINATION "${include_dest}/glass")
@@ -39,9 +42,12 @@
wpilib_target_warnings(libglassnt)
target_link_libraries(libglassnt PUBLIC ntcore libglass)
-target_include_directories(libglassnt PUBLIC
- $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/libnt/native/include>
- $<INSTALL_INTERFACE:${include_dest}/glass>)
+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)
install(DIRECTORY src/libnt/native/include/ DESTINATION "${include_dest}/glass")
@@ -55,7 +61,7 @@
file(GLOB glass_src src/app/native/cpp/*.cpp ${CMAKE_CURRENT_BINARY_DIR}/WPILibVersion.cpp)
-if (WIN32)
+if(WIN32)
set(glass_rc src/app/native/win/glass.rc)
elseif(APPLE)
set(MACOSX_BUNDLE_ICON_FILE glass.icns)
@@ -68,18 +74,8 @@
wpilib_target_warnings(glass)
target_link_libraries(glass libglassnt libglass)
-if (WIN32)
+if(WIN32)
set_target_properties(glass PROPERTIES WIN32_EXECUTABLE YES)
elseif(APPLE)
set_target_properties(glass PROPERTIES MACOSX_BUNDLE YES OUTPUT_NAME "Glass")
endif()
-
-#if (MSVC OR FLAT_INSTALL_WPILIB)
-# set (wpigui_config_dir ${wpilib_dest})
-#else()
-# set (wpigui_config_dir share/wpigui)
-#endif()
-
-#configure_file(wpigui-config.cmake.in ${CMAKE_BINARY_DIR}/wpigui-config.cmake )
-#install(FILES ${CMAKE_BINARY_DIR}/wpigui-config.cmake DESTINATION ${wpigui_config_dir})
-#install(EXPORT wpigui DESTINATION ${wpigui_config_dir})
diff --git a/glass/src/app/generate/WPILibVersion.cpp.in b/glass/src/app/generate/WPILibVersion.cpp.in
index b0a4490..cfe2441 100644
--- a/glass/src/app/generate/WPILibVersion.cpp.in
+++ b/glass/src/app/generate/WPILibVersion.cpp.in
@@ -1,4 +1,4 @@
-/*
+/**
* Autogenerated file! Do not manually edit this file. This version is regenerated
* any time the publish task is run, or when this file is deleted.
*/
diff --git a/glass/src/lib/native/cpp/Context.cpp b/glass/src/lib/native/cpp/Context.cpp
index e09a86e..5adcd94 100644
--- a/glass/src/lib/native/cpp/Context.cpp
+++ b/glass/src/lib/native/cpp/Context.cpp
@@ -137,9 +137,8 @@
return false;
} else {
try {
- return JsonToWindow(
- wpi::json::parse(fileBuffer->begin(), fileBuffer->end()),
- filename.c_str());
+ return JsonToWindow(wpi::json::parse(fileBuffer->GetCharBuffer()),
+ filename.c_str());
} catch (wpi::json::parse_error& e) {
ImGui::LogText("Error loading %s: %s", filename.c_str(), e.what());
return false;
@@ -164,9 +163,8 @@
createdStorage = true;
}
try {
- storage->FromJson(
- wpi::json::parse(fileBuffer->begin(), fileBuffer->end()),
- filename.c_str());
+ storage->FromJson(wpi::json::parse(fileBuffer->GetCharBuffer()),
+ filename.c_str());
} catch (wpi::json::parse_error& e) {
ImGui::LogText("Error loading %s: %s", filename.c_str(), e.what());
if (createdStorage) {
@@ -180,8 +178,6 @@
static bool LoadStorageImpl(Context* ctx, std::string_view dir,
std::string_view name) {
- WorkspaceResetImpl();
-
bool rv = true;
for (auto&& root : ctx->storageRoots) {
std::string filename;
@@ -423,6 +419,7 @@
bool glass::LoadStorage(std::string_view dir) {
SaveStorage();
SetStorageDir(dir);
+ WorkspaceResetImpl();
LoadWindowStorageImpl((fs::path{gContext->storageLoadDir} /
fmt::format("{}-window.json", gContext->storageName))
.string());
diff --git a/glass/src/lib/native/cpp/other/PIDController.cpp b/glass/src/lib/native/cpp/other/PIDController.cpp
index 3c83b11..8aa5e1f 100644
--- a/glass/src/lib/native/cpp/other/PIDController.cpp
+++ b/glass/src/lib/native/cpp/other/PIDController.cpp
@@ -29,6 +29,16 @@
callback(*v);
}
};
+ // Workaround to allow for the input of inf, -inf, and nan
+ auto createTuningParameterNoFilter =
+ [flag](const char* name, double* v,
+ std::function<void(double)> callback) {
+ ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
+ if (ImGui::InputScalar(name, ImGuiDataType_Double, v, NULL, NULL,
+ "%.3f", flag)) {
+ callback(*v);
+ }
+ };
if (auto p = m->GetPData()) {
double value = p->GetValue();
@@ -47,6 +57,11 @@
createTuningParameter("Setpoint", &value,
[=](auto v) { m->SetSetpoint(v); });
}
+ if (auto s = m->GetIZoneData()) {
+ double value = s->GetValue();
+ createTuningParameterNoFilter("IZone", &value,
+ [=](auto v) { m->SetIZone(v); });
+ }
} else {
ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
ImGui::Text("Unknown PID Controller");
diff --git a/glass/src/lib/native/cpp/other/ProfiledPIDController.cpp b/glass/src/lib/native/cpp/other/ProfiledPIDController.cpp
new file mode 100644
index 0000000..8113c8c
--- /dev/null
+++ b/glass/src/lib/native/cpp/other/ProfiledPIDController.cpp
@@ -0,0 +1,69 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#include "glass/other/ProfiledPIDController.h"
+
+#include <string>
+
+#include <imgui.h>
+
+#include "glass/Context.h"
+#include "glass/DataSource.h"
+
+using namespace glass;
+
+void glass::DisplayProfiledPIDController(ProfiledPIDControllerModel* m) {
+ if (auto name = m->GetName()) {
+ ImGui::Text("%s", name);
+ ImGui::Separator();
+ }
+
+ if (m->Exists()) {
+ auto flag = m->IsReadOnly() ? ImGuiInputTextFlags_ReadOnly
+ : ImGuiInputTextFlags_None;
+ auto createTuningParameter = [flag](const char* name, double* v,
+ std::function<void(double)> callback) {
+ ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
+ if (ImGui::InputDouble(name, v, 0.0, 0.0, "%.3f", flag)) {
+ callback(*v);
+ }
+ };
+ // Workaround to allow for the input of inf, -inf, and nan
+ auto createTuningParameterNoFilter =
+ [flag](const char* name, double* v,
+ std::function<void(double)> callback) {
+ ImGui::SetNextItemWidth(ImGui::GetFontSize() * 4);
+ if (ImGui::InputScalar(name, ImGuiDataType_Double, v, NULL, NULL,
+ "%.3f", flag)) {
+ callback(*v);
+ }
+ };
+
+ if (auto p = m->GetPData()) {
+ double value = p->GetValue();
+ createTuningParameter("P", &value, [=](auto v) { m->SetP(v); });
+ }
+ if (auto i = m->GetIData()) {
+ double value = i->GetValue();
+ createTuningParameter("I", &value, [=](auto v) { m->SetI(v); });
+ }
+ if (auto d = m->GetDData()) {
+ double value = d->GetValue();
+ createTuningParameter("D", &value, [=](auto v) { m->SetD(v); });
+ }
+ if (auto s = m->GetGoalData()) {
+ double value = s->GetValue();
+ createTuningParameter("Goal", &value, [=](auto v) { m->SetGoal(v); });
+ }
+ if (auto s = m->GetIZoneData()) {
+ double value = s->GetValue();
+ createTuningParameterNoFilter("IZone", &value,
+ [=](auto v) { m->SetIZone(v); });
+ }
+ } else {
+ ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
+ ImGui::Text("Unknown PID Controller");
+ ImGui::PopStyleColor();
+ }
+}
diff --git a/glass/src/lib/native/cpp/support/DataLogReaderThread.cpp b/glass/src/lib/native/cpp/support/DataLogReaderThread.cpp
new file mode 100644
index 0000000..9d90bb3
--- /dev/null
+++ b/glass/src/lib/native/cpp/support/DataLogReaderThread.cpp
@@ -0,0 +1,124 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#include "glass/support/DataLogReaderThread.h"
+
+#include <utility>
+
+#include <fmt/format.h>
+#include <wpi/StringExtras.h>
+
+using namespace glass;
+
+DataLogReaderThread::~DataLogReaderThread() {
+ if (m_thread.joinable()) {
+ m_active = false;
+ m_thread.join();
+ }
+}
+
+void DataLogReaderThread::ReadMain() {
+ wpi::SmallDenseMap<
+ int, std::pair<DataLogReaderEntry*, std::span<const uint8_t>>, 8>
+ schemaEntries;
+
+ for (auto recordIt = m_reader.begin(), recordEnd = m_reader.end();
+ recordIt != recordEnd; ++recordIt) {
+ auto& record = *recordIt;
+ if (!m_active) {
+ break;
+ }
+ ++m_numRecords;
+ if (record.IsStart()) {
+ DataLogReaderEntry data;
+ if (record.GetStartData(&data)) {
+ std::scoped_lock lock{m_mutex};
+ auto& entryPtr = m_entriesById[data.entry];
+ if (entryPtr) {
+ fmt::print("...DUPLICATE entry ID, overriding\n");
+ }
+ auto [it, isNew] = m_entriesByName.emplace(data.name, data);
+ if (isNew) {
+ it->second.ranges.emplace_back(recordIt, recordEnd);
+ }
+ entryPtr = &it->second;
+ if (data.type == "structschema" ||
+ data.type == "proto:FileDescriptorProto") {
+ schemaEntries.try_emplace(data.entry, entryPtr,
+ std::span<const uint8_t>{});
+ }
+ sigEntryAdded(data);
+ } else {
+ fmt::print("Start(INVALID)\n");
+ }
+ } else if (record.IsFinish()) {
+ int entry;
+ if (record.GetFinishEntry(&entry)) {
+ std::scoped_lock lock{m_mutex};
+ auto it = m_entriesById.find(entry);
+ if (it == m_entriesById.end()) {
+ fmt::print("...ID not found\n");
+ } else {
+ it->second->ranges.back().m_end = recordIt;
+ m_entriesById.erase(it);
+ }
+ } else {
+ fmt::print("Finish(INVALID)\n");
+ }
+ } else if (record.IsSetMetadata()) {
+ wpi::log::MetadataRecordData data;
+ if (record.GetSetMetadataData(&data)) {
+ std::scoped_lock lock{m_mutex};
+ auto it = m_entriesById.find(data.entry);
+ if (it == m_entriesById.end()) {
+ fmt::print("...ID not found\n");
+ } else {
+ it->second->metadata = data.metadata;
+ }
+ } else {
+ fmt::print("SetMetadata(INVALID)\n");
+ }
+ } else if (record.IsControl()) {
+ fmt::print("Unrecognized control record\n");
+ } else {
+ auto it = schemaEntries.find(record.GetEntry());
+ if (it != schemaEntries.end()) {
+ it->second.second = record.GetRaw();
+ }
+ }
+ }
+
+ // build schema databases
+ for (auto&& schemaPair : schemaEntries) {
+ auto name = schemaPair.second.first->name;
+ auto data = schemaPair.second.second;
+ if (data.empty()) {
+ continue;
+ }
+ if (wpi::starts_with(name, "NT:")) {
+ name = wpi::drop_front(name, 3);
+ }
+ if (wpi::starts_with(name, "/.schema/struct:")) {
+ auto typeStr = wpi::drop_front(name, 16);
+ std::string_view schema{reinterpret_cast<const char*>(data.data()),
+ data.size()};
+ std::string err;
+ auto desc = m_structDb.Add(typeStr, schema, &err);
+ if (!desc) {
+ fmt::print("could not decode struct '{}' schema '{}': {}\n", name,
+ schema, err);
+ }
+ } else if (wpi::starts_with(name, "/.schema/proto:")) {
+ // protobuf descriptor handling
+ auto filename = wpi::drop_front(name, 15);
+ if (!m_protoDb.Add(filename, data)) {
+ fmt::print("could not decode protobuf '{}' filename '{}'\n", name,
+ filename);
+ }
+ }
+ }
+
+ sigDone();
+ m_done = true;
+}
diff --git a/glass/src/lib/native/include/glass/other/PIDController.h b/glass/src/lib/native/include/glass/other/PIDController.h
index ab0dcb3..8c11c59 100644
--- a/glass/src/lib/native/include/glass/other/PIDController.h
+++ b/glass/src/lib/native/include/glass/other/PIDController.h
@@ -16,11 +16,13 @@
virtual DataSource* GetIData() = 0;
virtual DataSource* GetDData() = 0;
virtual DataSource* GetSetpointData() = 0;
+ virtual DataSource* GetIZoneData() = 0;
virtual void SetP(double value) = 0;
virtual void SetI(double value) = 0;
virtual void SetD(double value) = 0;
virtual void SetSetpoint(double value) = 0;
+ virtual void SetIZone(double value) = 0;
};
void DisplayPIDController(PIDControllerModel* m);
} // namespace glass
diff --git a/glass/src/lib/native/include/glass/other/ProfiledPIDController.h b/glass/src/lib/native/include/glass/other/ProfiledPIDController.h
new file mode 100644
index 0000000..bebf3ab
--- /dev/null
+++ b/glass/src/lib/native/include/glass/other/ProfiledPIDController.h
@@ -0,0 +1,28 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#pragma once
+
+#include "glass/Model.h"
+
+namespace glass {
+class DataSource;
+class ProfiledPIDControllerModel : public Model {
+ public:
+ virtual const char* GetName() const = 0;
+
+ virtual DataSource* GetPData() = 0;
+ virtual DataSource* GetIData() = 0;
+ virtual DataSource* GetDData() = 0;
+ virtual DataSource* GetGoalData() = 0;
+ virtual DataSource* GetIZoneData() = 0;
+
+ virtual void SetP(double value) = 0;
+ virtual void SetI(double value) = 0;
+ virtual void SetD(double value) = 0;
+ virtual void SetGoal(double value) = 0;
+ virtual void SetIZone(double value) = 0;
+};
+void DisplayProfiledPIDController(ProfiledPIDControllerModel* m);
+} // namespace glass
diff --git a/glass/src/lib/native/include/glass/support/DataLogReaderThread.h b/glass/src/lib/native/include/glass/support/DataLogReaderThread.h
new file mode 100644
index 0000000..bcbc962
--- /dev/null
+++ b/glass/src/lib/native/include/glass/support/DataLogReaderThread.h
@@ -0,0 +1,101 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#pragma once
+
+#include <atomic>
+#include <functional>
+#include <map>
+#include <string>
+#include <string_view>
+#include <thread>
+#include <utility>
+#include <vector>
+
+#include <wpi/DataLogReader.h>
+#include <wpi/DenseMap.h>
+#include <wpi/Signal.h>
+#include <wpi/mutex.h>
+#include <wpi/protobuf/ProtobufMessageDatabase.h>
+#include <wpi/struct/DynamicStruct.h>
+
+namespace glass {
+
+class DataLogReaderRange {
+ public:
+ DataLogReaderRange(wpi::log::DataLogReader::iterator begin,
+ wpi::log::DataLogReader::iterator end)
+ : m_begin{begin}, m_end{end} {}
+
+ wpi::log::DataLogReader::iterator begin() const { return m_begin; }
+ wpi::log::DataLogReader::iterator end() const { return m_end; }
+
+ wpi::log::DataLogReader::iterator m_begin;
+ wpi::log::DataLogReader::iterator m_end;
+};
+
+class DataLogReaderEntry : public wpi::log::StartRecordData {
+ public:
+ std::vector<DataLogReaderRange> ranges; // ranges where this entry is valid
+};
+
+class DataLogReaderThread {
+ public:
+ explicit DataLogReaderThread(wpi::log::DataLogReader reader)
+ : m_reader{std::move(reader)}, m_thread{[this] { ReadMain(); }} {}
+ ~DataLogReaderThread();
+
+ bool IsDone() const { return m_done; }
+ std::string_view GetBufferIdentifier() const {
+ return m_reader.GetBufferIdentifier();
+ }
+ unsigned int GetNumRecords() const { return m_numRecords; }
+ unsigned int GetNumEntries() const {
+ std::scoped_lock lock{m_mutex};
+ return m_entriesByName.size();
+ }
+
+ // Passes Entry& to func
+ template <typename T>
+ void ForEachEntryName(T&& func) {
+ std::scoped_lock lock{m_mutex};
+ for (auto&& kv : m_entriesByName) {
+ func(kv.second);
+ }
+ }
+
+ const DataLogReaderEntry* GetEntry(std::string_view name) const {
+ std::scoped_lock lock{m_mutex};
+ auto it = m_entriesByName.find(name);
+ if (it == m_entriesByName.end()) {
+ return nullptr;
+ }
+ return &it->second;
+ }
+
+ wpi::StructDescriptorDatabase& GetStructDatabase() { return m_structDb; }
+ wpi::ProtobufMessageDatabase& GetProtobufDatabase() { return m_protoDb; }
+
+ const wpi::log::DataLogReader& GetReader() const { return m_reader; }
+
+ // note: these are called on separate thread
+ wpi::sig::Signal_mt<const DataLogReaderEntry&> sigEntryAdded;
+ wpi::sig::Signal_mt<> sigDone;
+
+ private:
+ void ReadMain();
+
+ wpi::log::DataLogReader m_reader;
+ mutable wpi::mutex m_mutex;
+ std::atomic_bool m_active{true};
+ std::atomic_bool m_done{false};
+ std::atomic<unsigned int> m_numRecords{0};
+ std::map<std::string, DataLogReaderEntry, std::less<>> m_entriesByName;
+ wpi::DenseMap<int, DataLogReaderEntry*> m_entriesById;
+ wpi::StructDescriptorDatabase m_structDb;
+ wpi::ProtobufMessageDatabase m_protoDb;
+ std::thread m_thread;
+};
+
+} // namespace glass
diff --git a/glass/src/libnt/native/cpp/NTPIDController.cpp b/glass/src/libnt/native/cpp/NTPIDController.cpp
index 1dde27d..9796f6d 100644
--- a/glass/src/libnt/native/cpp/NTPIDController.cpp
+++ b/glass/src/libnt/native/cpp/NTPIDController.cpp
@@ -23,10 +23,12 @@
m_d{inst.GetDoubleTopic(fmt::format("{}/d", path)).GetEntry(0)},
m_setpoint{
inst.GetDoubleTopic(fmt::format("{}/setpoint", path)).GetEntry(0)},
+ m_iZone{inst.GetDoubleTopic(fmt::format("{}/izone", path)).GetEntry(0)},
m_pData{fmt::format("NTPIDCtrlP:{}", path)},
m_iData{fmt::format("NTPIDCtrlI:{}", path)},
m_dData{fmt::format("NTPIDCtrlD:{}", path)},
m_setpointData{fmt::format("NTPIDCtrlStpt:{}", path)},
+ m_iZoneData{fmt::format("NTPIDCtrlIZone:{}", path)},
m_nameValue{wpi::rsplit(path, '/').second} {}
void NTPIDControllerModel::SetP(double value) {
@@ -44,6 +46,9 @@
void NTPIDControllerModel::SetSetpoint(double value) {
m_setpoint.Set(value);
}
+void NTPIDControllerModel::SetIZone(double value) {
+ m_iZone.Set(value);
+}
void NTPIDControllerModel::Update() {
for (auto&& v : m_name.ReadQueue()) {
@@ -61,6 +66,9 @@
for (auto&& v : m_setpoint.ReadQueue()) {
m_setpointData.SetValue(v.value, v.time);
}
+ for (auto&& v : m_iZone.ReadQueue()) {
+ m_iZoneData.SetValue(v.value, v.time);
+ }
for (auto&& v : m_controllable.ReadQueue()) {
m_controllableValue = v.value;
}
diff --git a/glass/src/libnt/native/cpp/NTProfiledPIDController.cpp b/glass/src/libnt/native/cpp/NTProfiledPIDController.cpp
new file mode 100644
index 0000000..bae069b
--- /dev/null
+++ b/glass/src/libnt/native/cpp/NTProfiledPIDController.cpp
@@ -0,0 +1,80 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#include "glass/networktables/NTProfiledPIDController.h"
+
+#include <fmt/format.h>
+#include <wpi/StringExtras.h>
+
+using namespace glass;
+
+NTProfiledPIDControllerModel::NTProfiledPIDControllerModel(
+ std::string_view path)
+ : NTProfiledPIDControllerModel(nt::NetworkTableInstance::GetDefault(),
+ path) {}
+
+NTProfiledPIDControllerModel::NTProfiledPIDControllerModel(
+ nt::NetworkTableInstance inst, std::string_view path)
+ : m_inst{inst},
+ m_name{inst.GetStringTopic(fmt::format("{}/.name", path)).Subscribe("")},
+ m_controllable{inst.GetBooleanTopic(fmt::format("{}/.controllable", path))
+ .Subscribe(false)},
+ m_p{inst.GetDoubleTopic(fmt::format("{}/p", path)).GetEntry(0)},
+ m_i{inst.GetDoubleTopic(fmt::format("{}/i", path)).GetEntry(0)},
+ m_d{inst.GetDoubleTopic(fmt::format("{}/d", path)).GetEntry(0)},
+ m_goal{inst.GetDoubleTopic(fmt::format("{}/goal", path)).GetEntry(0)},
+ m_iZone{inst.GetDoubleTopic(fmt::format("{}/izone", path)).GetEntry(0)},
+ m_pData{fmt::format("NTPIDCtrlP:{}", path)},
+ m_iData{fmt::format("NTPIDCtrlI:{}", path)},
+ m_dData{fmt::format("NTPIDCtrlD:{}", path)},
+ m_goalData{fmt::format("NTPIDCtrlGoal:{}", path)},
+ m_iZoneData{fmt::format("NTPIDCtrlIZone:{}", path)},
+ m_nameValue{wpi::rsplit(path, '/').second} {}
+
+void NTProfiledPIDControllerModel::SetP(double value) {
+ m_p.Set(value);
+}
+
+void NTProfiledPIDControllerModel::SetI(double value) {
+ m_i.Set(value);
+}
+
+void NTProfiledPIDControllerModel::SetD(double value) {
+ m_d.Set(value);
+}
+
+void NTProfiledPIDControllerModel::SetGoal(double value) {
+ m_goal.Set(value);
+}
+void NTProfiledPIDControllerModel::SetIZone(double value) {
+ m_iZone.Set(value);
+}
+
+void NTProfiledPIDControllerModel::Update() {
+ for (auto&& v : m_name.ReadQueue()) {
+ m_nameValue = std::move(v.value);
+ }
+ for (auto&& v : m_p.ReadQueue()) {
+ m_pData.SetValue(v.value, v.time);
+ }
+ for (auto&& v : m_i.ReadQueue()) {
+ m_iData.SetValue(v.value, v.time);
+ }
+ for (auto&& v : m_d.ReadQueue()) {
+ m_dData.SetValue(v.value, v.time);
+ }
+ for (auto&& v : m_goal.ReadQueue()) {
+ m_goalData.SetValue(v.value, v.time);
+ }
+ for (auto&& v : m_iZone.ReadQueue()) {
+ m_iZoneData.SetValue(v.value, v.time);
+ }
+ for (auto&& v : m_controllable.ReadQueue()) {
+ m_controllableValue = v.value;
+ }
+}
+
+bool NTProfiledPIDControllerModel::Exists() {
+ return m_goal.Exists();
+}
diff --git a/glass/src/libnt/native/cpp/NTStringChooser.cpp b/glass/src/libnt/native/cpp/NTStringChooser.cpp
index b892a2c..26074fc 100644
--- a/glass/src/libnt/native/cpp/NTStringChooser.cpp
+++ b/glass/src/libnt/native/cpp/NTStringChooser.cpp
@@ -5,6 +5,7 @@
#include "glass/networktables/NTStringChooser.h"
#include <fmt/format.h>
+#include <wpi/json.h>
using namespace glass;
@@ -16,17 +17,17 @@
: m_inst{inst},
m_default{
m_inst.GetStringTopic(fmt::format("{}/default", path)).Subscribe("")},
- m_selected{
- m_inst.GetStringTopic(fmt::format("{}/selected", path)).GetEntry("")},
+ m_selected{m_inst.GetStringTopic(fmt::format("{}/selected", path))
+ .Subscribe("")},
+ m_selectedPub{m_inst.GetStringTopic(fmt::format("{}/selected", path))
+ .PublishEx("string", {{"retained", true}})},
m_active{
m_inst.GetStringTopic(fmt::format("{}/active", path)).Subscribe("")},
m_options{m_inst.GetStringArrayTopic(fmt::format("{}/options", path))
- .Subscribe({})} {
- m_selected.GetTopic().SetRetained(true);
-}
+ .Subscribe({})} {}
void NTStringChooserModel::SetSelected(std::string_view val) {
- m_selected.Set(val);
+ m_selectedPub.Set(val);
}
void NTStringChooserModel::Update() {
diff --git a/glass/src/libnt/native/cpp/NetworkTables.cpp b/glass/src/libnt/native/cpp/NetworkTables.cpp
index 57469a2..71ff843 100644
--- a/glass/src/libnt/native/cpp/NetworkTables.cpp
+++ b/glass/src/libnt/native/cpp/NetworkTables.cpp
@@ -879,7 +879,10 @@
} else if (desc->IsValid()) {
// loop over all entries with this type and update
for (auto&& entryPair : m_entries) {
- auto ts = entryPair.second->info.type_str;
+ if (!entryPair.second) {
+ continue;
+ }
+ std::string_view ts = entryPair.second->info.type_str;
if (!wpi::starts_with(ts, "struct:")) {
continue;
}
@@ -901,7 +904,10 @@
} else {
// loop over all protobuf entries and update (conservatively)
for (auto&& entryPair : m_entries) {
- auto& ts = entryPair.second->info.type_str;
+ if (!entryPair.second) {
+ continue;
+ }
+ std::string_view ts = entryPair.second->info.type_str;
if (wpi::starts_with(ts, "proto:")) {
entryPair.second->UpdateFromValue(*this);
}
diff --git a/glass/src/libnt/native/cpp/NetworkTablesProvider.cpp b/glass/src/libnt/native/cpp/NetworkTablesProvider.cpp
index 413899e..61bac02 100644
--- a/glass/src/libnt/native/cpp/NetworkTablesProvider.cpp
+++ b/glass/src/libnt/native/cpp/NetworkTablesProvider.cpp
@@ -83,6 +83,18 @@
// FIXME: enabled?
// data is the last item, so is guaranteed to be null-terminated
ImGui::MenuItem(path.back().data(), nullptr, &visible, true);
+ // Add type label to smartdashboard sendables
+ if (wpi::starts_with(entry->name, "/SmartDashboard/")) {
+ auto typeEntry = m_typeCache.FindValue(entry->name);
+ if (typeEntry) {
+ ImGui::SameLine();
+ ImGui::PushStyleColor(ImGuiCol_Text, IM_COL32(96, 96, 96, 255));
+ ImGui::Text("%s", typeEntry->stringVal.c_str());
+ ImGui::PopStyleColor();
+ ImGui::SameLine();
+ ImGui::Dummy(ImVec2(10.0f, 0.0f));
+ }
+ }
if (!wasVisible && visible) {
Show(entry.get(), entry->window);
} else if (wasVisible && !visible && entry->window) {
diff --git a/glass/src/libnt/native/cpp/StandardNetworkTables.cpp b/glass/src/libnt/native/cpp/StandardNetworkTables.cpp
index ef61025..9031873 100644
--- a/glass/src/libnt/native/cpp/StandardNetworkTables.cpp
+++ b/glass/src/libnt/native/cpp/StandardNetworkTables.cpp
@@ -14,6 +14,7 @@
#include "glass/networktables/NTMechanism2D.h"
#include "glass/networktables/NTMotorController.h"
#include "glass/networktables/NTPIDController.h"
+#include "glass/networktables/NTProfiledPIDController.h"
#include "glass/networktables/NTStringChooser.h"
#include "glass/networktables/NTSubsystem.h"
#include "glass/networktables/NetworkTablesProvider.h"
@@ -142,6 +143,18 @@
});
});
provider.Register(
+ NTProfiledPIDControllerModel::kType,
+ [](nt::NetworkTableInstance inst, const char* path) {
+ return std::make_unique<NTProfiledPIDControllerModel>(inst, path);
+ },
+ [](Window* win, Model* model, const char* path) {
+ win->SetFlags(ImGuiWindowFlags_AlwaysAutoResize);
+ return MakeFunctionView([=] {
+ DisplayProfiledPIDController(
+ static_cast<NTProfiledPIDControllerModel*>(model));
+ });
+ });
+ provider.Register(
NTMotorControllerModel::kType,
[](nt::NetworkTableInstance inst, const char* path) {
return std::make_unique<NTMotorControllerModel>(inst, path);
diff --git a/glass/src/libnt/native/include/glass/networktables/NTPIDController.h b/glass/src/libnt/native/include/glass/networktables/NTPIDController.h
index f901f72..d19dcea 100644
--- a/glass/src/libnt/native/include/glass/networktables/NTPIDController.h
+++ b/glass/src/libnt/native/include/glass/networktables/NTPIDController.h
@@ -29,11 +29,13 @@
DataSource* GetIData() override { return &m_iData; }
DataSource* GetDData() override { return &m_dData; }
DataSource* GetSetpointData() override { return &m_setpointData; }
+ DataSource* GetIZoneData() override { return &m_iZoneData; }
void SetP(double value) override;
void SetI(double value) override;
void SetD(double value) override;
void SetSetpoint(double value) override;
+ void SetIZone(double value) override;
void Update() override;
bool Exists() override;
@@ -47,11 +49,13 @@
nt::DoubleEntry m_i;
nt::DoubleEntry m_d;
nt::DoubleEntry m_setpoint;
+ nt::DoubleEntry m_iZone;
DataSource m_pData;
DataSource m_iData;
DataSource m_dData;
DataSource m_setpointData;
+ DataSource m_iZoneData;
std::string m_nameValue;
bool m_controllableValue = false;
diff --git a/glass/src/libnt/native/include/glass/networktables/NTProfiledPIDController.h b/glass/src/libnt/native/include/glass/networktables/NTProfiledPIDController.h
new file mode 100644
index 0000000..e968f79
--- /dev/null
+++ b/glass/src/libnt/native/include/glass/networktables/NTProfiledPIDController.h
@@ -0,0 +1,64 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+#pragma once
+
+#include <string>
+#include <string_view>
+
+#include <networktables/BooleanTopic.h>
+#include <networktables/DoubleTopic.h>
+#include <networktables/NetworkTableInstance.h>
+#include <networktables/StringTopic.h>
+
+#include "glass/DataSource.h"
+#include "glass/other/ProfiledPIDController.h"
+
+namespace glass {
+class NTProfiledPIDControllerModel : public ProfiledPIDControllerModel {
+ public:
+ static constexpr const char* kType = "ProfiledPIDController";
+
+ explicit NTProfiledPIDControllerModel(std::string_view path);
+ NTProfiledPIDControllerModel(nt::NetworkTableInstance inst,
+ std::string_view path);
+
+ const char* GetName() const override { return m_nameValue.c_str(); }
+
+ DataSource* GetPData() override { return &m_pData; }
+ DataSource* GetIData() override { return &m_iData; }
+ DataSource* GetDData() override { return &m_dData; }
+ DataSource* GetGoalData() override { return &m_goalData; }
+ DataSource* GetIZoneData() override { return &m_iZoneData; }
+
+ void SetP(double value) override;
+ void SetI(double value) override;
+ void SetD(double value) override;
+ void SetGoal(double value) override;
+ void SetIZone(double value) override;
+
+ void Update() override;
+ bool Exists() override;
+ bool IsReadOnly() override { return !m_controllableValue; }
+
+ private:
+ nt::NetworkTableInstance m_inst;
+ nt::StringSubscriber m_name;
+ nt::BooleanSubscriber m_controllable;
+ nt::DoubleEntry m_p;
+ nt::DoubleEntry m_i;
+ nt::DoubleEntry m_d;
+ nt::DoubleEntry m_goal;
+ nt::DoubleEntry m_iZone;
+
+ DataSource m_pData;
+ DataSource m_iData;
+ DataSource m_dData;
+ DataSource m_goalData;
+ DataSource m_iZoneData;
+
+ std::string m_nameValue;
+ bool m_controllableValue = false;
+};
+} // namespace glass
diff --git a/glass/src/libnt/native/include/glass/networktables/NTStringChooser.h b/glass/src/libnt/native/include/glass/networktables/NTStringChooser.h
index d770a74..49c4802 100644
--- a/glass/src/libnt/native/include/glass/networktables/NTStringChooser.h
+++ b/glass/src/libnt/native/include/glass/networktables/NTStringChooser.h
@@ -39,7 +39,8 @@
private:
nt::NetworkTableInstance m_inst;
nt::StringSubscriber m_default;
- nt::StringEntry m_selected;
+ nt::StringSubscriber m_selected;
+ nt::StringPublisher m_selectedPub;
nt::StringSubscriber m_active;
nt::StringArraySubscriber m_options;