Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SysId arm characterization crashes with exception #6421

Closed
calcmogul opened this issue Mar 9, 2024 · 2 comments · Fixed by #6422
Closed

SysId arm characterization crashes with exception #6421

calcmogul opened this issue Mar 9, 2024 · 2 comments · Fixed by #6422
Labels
component: sysid SysId app type: bug Something isn't working.

Comments

@calcmogul
Copy link
Member

calcmogul commented Mar 9, 2024

Arm characterization crashes for the following log file:
FRC_20240309_014038.wpilog.txt

Console output:

[tav@myriad tools]$ ./sysid 
INFO: Updating feedback gains (Analyzer.cpp:82)
INFO: Updating feedback gains (Analyzer.cpp:82)
INFO: Loaded test state dynamic-forward (DataSelector.cpp:108)
INFO: Loaded test state dynamic-reverse (DataSelector.cpp:108)
INFO: Loaded test state quasistatic-forward (DataSelector.cpp:108)
INFO: Loaded test state quasistatic-reverse (DataSelector.cpp:108)
INFO: Loaded 2 tests (DataSelector.cpp:118)
INFO: Preparing data (Analyzer.cpp:270)
INFO: Preprocessing raw data. (AnalysisManager.cpp:119)
INFO: Copying raw data. (AnalysisManager.cpp:121)
INFO: Converting raw data to PreparedData struct. (AnalysisManager.cpp:124)
INFO: SAMPLES 16 (AnalysisManager.cpp:129)
INFO: SAMPLES 9 (AnalysisManager.cpp:129)
INFO: SAMPLES 17 (AnalysisManager.cpp:129)
INFO: SAMPLES 9 (AnalysisManager.cpp:129)
INFO: SAMPLES 23 (AnalysisManager.cpp:129)
INFO: SAMPLES 23 (AnalysisManager.cpp:129)
INFO: SAMPLES 16 (AnalysisManager.cpp:129)
INFO: SAMPLES 23 (AnalysisManager.cpp:129)
INFO: SAMPLES 9 (AnalysisManager.cpp:129)
INFO: SAMPLES 17 (AnalysisManager.cpp:129)
INFO: SAMPLES 16 (AnalysisManager.cpp:129)
INFO: SAMPLES 17 (AnalysisManager.cpp:129)
INFO: Initial trimming and filtering. (AnalysisManager.cpp:139)
INFO: 0 s (AnalysisManager.cpp:144)
INFO: 0.33334300000000283 s (AnalysisManager.cpp:145)
INFO: Acceleration filtering. (AnalysisManager.cpp:147)
INFO: Storing datasets. (AnalysisManager.cpp:150)
INFO: Finished Preparing Data (AnalysisManager.cpp:184)
INFO: Gain calc (Analyzer.cpp:49)
INFO: Calculating Gains (AnalysisManager.cpp:193)
INFO: Graph state (Analyzer.cpp:308)
INFO: Updating feedback gains (Analyzer.cpp:82)
INFO: Updating feedback gains (Analyzer.cpp:82)
INFO: Configuring Params (Analyzer.cpp:185)
INFO: Updating feedback gains (Analyzer.cpp:82)
terminate called after throwing an instance of 'std::domain_error'
  what():  Elements of A aren't finite. This is usually due to model implementation errors.
Aborted (core dumped)

Elements of A aren't finite if Ka = 0 because A = -Kv/Ka.

@calcmogul calcmogul added type: bug Something isn't working. component: sysid SysId app labels Mar 9, 2024
@calcmogul
Copy link
Member Author

We can avoid the exception by making the *Sim classes use a specific discrete model when Ka = 0.

dx/dt = -Kv/Ka x + 1/Ka u - Ks/Ka sgn(x) - Kg/Ka

Ka dx/dt = -Kv x + 1 u - Ks sgn(x) - Kg
0 = -Kv x + u - Ks sgn(x) - Kg
Kv x = u - Ks sgn(x) - Kg
x = 1/Kv u - Ks/Kv sgn(x) - Kg/Kv

@calcmogul
Copy link
Member Author

calcmogul commented Mar 9, 2024

Actually, debugger shows Kv = NaN and Ka = -NaN.

calcmogul added a commit to calcmogul/allwpilib that referenced this issue Mar 9, 2024
PeterJohnson pushed a commit that referenced this issue Mar 9, 2024
DeltaDizzy pushed a commit to DeltaDizzy/allwpilib that referenced this issue Mar 26, 2024
pjreiniger added a commit to bzlmodRio/allwpilib that referenced this issue Apr 24, 2024
* [ci] Upgrade to new macOS runner (wpilibsuite#6328)

* [wpimath] Make units math functions constexpr (wpilibsuite#6345)

* [wpimath] Feed forwards: Use correct 'k' value in error message (wpilibsuite#6360)

* [build] Fix tcpsockets header publishing (wpilibsuite#6367)

* [cscore] Use Raw for CvSink and CvSource (wpilibsuite#6364)

Eventually we want to get to a point where we can remove OpenCV from the internals of cscore. The start to doing that is converting the existing CvSource and CvSink methods to RawFrame.

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

For CvSink, by defaut this change would incur one extra copy, but no extra allocations. A set of direct methods were added to CvSink to add a method to avoid this extra copy.

* [cscore] Add BGRA support (wpilibsuite#6365)

* [apriltag] Fix field length in 2024 JSON (wpilibsuite#6373)

Fixes wpilibsuite#6371

* [wpimath] ExponentialProfile: Return copy of input state (wpilibsuite#6370)

As State is mutable, this avoids accidental modification of the passed-in object by the caller modifying the return value.

* [hal,wpiutil] Error out of HAL_Initialize if SetupRioNow fails (wpilibsuite#6374)

* [ntcore] Don't send value update to client setting value (wpilibsuite#6375)

* [ntcore] Add hidden subscribe option (wpilibsuite#6376)

This allows creating subscribers that aren't communicated with the network.

* [sysid] Relax peak acceleration search (wpilibsuite#6378)

* [apriltag] Add AprilTagFieldLayout.loadField() (wpilibsuite#6377)

* [hal] HAL_RefreshDSData: Zero out control word on DS disconnect, use cache in sim (wpilibsuite#6380)

* [glass] Fix FMS game data display and editing (wpilibsuite#6381)

Also don't require Enter for editing game data or match time.

* [wpiunits] Fix Distance class javadocs to state the correct dimension (NFC) (wpilibsuite#6363)

* [ci] Upgrade wpiformat (wpilibsuite#6395)

* [sysid] Fix position feedback latency compensation (wpilibsuite#6392)

* [ci] Windows cmake: update vcpkg version (wpilibsuite#6397)

We need fmtlib 10.2.1 to work around a compiler bug.

Also, reducing the number of jobs is no longer required with Actions runner upgrades.

* [wpiutil] Rate-limit FPGA error from Now() (wpilibsuite#6394)

* [examples] Remove unused private variables (wpilibsuite#6403)

* [wpiutil, hal] Crash on failure for SetupNowRio() and wpi::Now() when not configured (wpilibsuite#6417)

This is an unrecoverable condition, so always terminate.

* [sysid] Fix arm characterization crash (wpilibsuite#6422)

Fixes wpilibsuite#6421.

* [wpilibj] Call abort() on Rio on caught Java exception (wpilibsuite#6420)

On Rio, we simply want to restart the robot program as quickly as possible,
and don't want to risk a hang somewhere that will keep that from happening.

The main downside of this is it won't wait for threads to finish (e.g. data logs won't get a final flush).

* [wpimath] Add structured data support for DifferentialDriveWheelPositions (wpilibsuite#6412)

* [wpimath] LinearSystemId: Don't throw if Kv = 0 (wpilibsuite#6424)

That's just a system with no back-EMF.

* [sysid] Fix crash on negative feedforward gains (wpilibsuite#6425)

LinearSystemId's linear system factories throw on negative feedforward
gains, but SysId can compute the feedback gains just fine in that case.
Now we construct the system manually instead.

Fixes wpilibsuite#6423.

* [sim] GUI: Use shift to enable docking features (wpilibsuite#6429)

* [hal] Raise SIGKILL instead of calling abort() (wpilibsuite#6427)

We don't need to generate a core dump here if core dumps are enabled.

* [hal] Use SIGKILL instead of SIGILL (wpilibsuite#6431)

Fix typo.

* [docs] Add docs for features not supported on PDH (NFC) (wpilibsuite#6436)

* [sysid] Fix "Sample" docs typo (NFC) (wpilibsuite#6435)

* [sysid] Fix wrong position Kd with unnormalized time (wpilibsuite#6433)

* [ntcore] Fix memory leak in WebSocketConnection (wpilibsuite#6439)

* [commands] Trigger: pass m_loop to new Trigger in composition functions (wpilibsuite#6441)

* [ci] Work around asan actions bug (wpilibsuite#6442)

* [wpiutil] Upgrade to LLVM 18.1.1 (wpilibsuite#6405)

* [glass] Don't limit window name+label to 128 chars (wpilibsuite#6447)

* [build] Upgrade to wpiformat 2024.33 (wpilibsuite#6449)

This upgrades to clang-format and clang-tidy 18.1.1. This has the
constructor attribute formatting fix, so we can remove our
WPI_DEPRECATED macro.

* [ci] Pin wpiformat version in comment command (wpilibsuite#6457)

* [commands] Cache button and POV triggers

This is a common footgun for teams.

* [ci] Pin wpiformat version in comment command (wpilibsuite#6458)

* Run java format (wpilibsuite#6462)

* [wpiutil] DataLog: Don't constantly retry creating logs when low on space (wpilibsuite#6468)



When low on space, a log file won't be created. This is detected as a "deletion", and the DataLog thread will continously try to create a log, fail to do so because of low space, detect it as a "deletion", and do so in a loop.

If there's not enough space, the DataLog will be marked as stopped, preventing this infinite loop. Calls to start() will hit this code path and mark it as stopped again.

* [wpimath] Make more LinearSystemId functions not throw if Kv = 0 (wpilibsuite#6465)

* [wpimath] Add Pair.toString() (wpilibsuite#6463)

* [ci] Fix 2023 docker image usage (wpilibsuite#6459)

* Add reference to development to CONTRIBUTING.md (wpilibsuite#6467)

* Revert "[commands] Cache button and POV triggers"

Also revert the associated formatting commit.  This was an accidental merge.
This reverts commit ff929d4.
This reverts commit 2392c9f.

* [ci] Use mirror repository for liblzma (wpilibsuite#6499)

Uses https://github.com/bminor/xz to work around suspended repository.

We will revert this once vcpkg updates to point to an accessible repo.

* [wpilib] LinearSystemSim: Add missing clamp function and getInput() (wpilibsuite#6493)

* [wpimath] Support formatting Eigen array types (wpilibsuite#6496)

* [wpilibj] Fix EncoderSim.setDistancePerPulse parameter name and comment (NFC) (wpilibsuite#6481)

* MAINTAINERS.md: Remove reference to marketplace (wpilibsuite#6470)

* [ci] Revert "Use mirror repository for liblzma (wpilibsuite#6499)" (wpilibsuite#6506)

This reverts commit c46847b.

* [wpimath] Document ChassisSpeeds::Discretize() math (NFC) (wpilibsuite#6509)

* [build] Add exports to CMake subprojects (wpilibsuite#6505)

This allows consuming allwpilib via FetchContent.

* README.md: Link straight to contributing in contents (wpilibsuite#6525)

Avoids need to click twice to get to contributing.md.

* Update README-CMAKE.md (wpilibsuite#6522)

* [examples] Fix memory over-allocation in Apriltag examples (wpilibsuite#6517)

Change hamming distance to 1, add comment about memory usage.

* [wpimath] Rotation2d: add Measure<Angle> getter (Java) (wpilibsuite#6492)

* [commands] Fix double composition error truncation (wpilibsuite#6501)

* [commands] WrappedCommand: Call wrapped command initSendable (wpilibsuite#6471)

* [wpilibj] DataLogManager: Fix behavior when low on space (wpilibsuite#6486)

Uses getUsableSpace in Java, matching how C++ determines available space (C++ calls it available, but they mean the same thing.) This fixes a bug where logs wouldn't get deleted due to incorrect available space detection.

The DataLog thread now also checks if the state was marked as stopped after a call to StartLogFile.

* [wpilib] Add flash update capability to ADI IMUs (wpilibsuite#6450)

* [wpiunits] Add isNear function implementation (wpilibsuite#6396)

This implementation uses a tolerance in the same units as the measure it checks.

* [commands] WaitCommand: add Measure<Time> overload (wpilibsuite#6386)

Also add waitTime() factory.

* [apriltag] Cache layout loaded from AprilTagFields resource json (wpilibsuite#6385)

* [commands] Add Trigger.onChange() (wpilibsuite#6390)

* [wpiunits] Add Acceleration and MOI Units (wpilibsuite#6495)

---------

Co-authored-by: Tyler Veness <[email protected]>
Co-authored-by: fodfodfod <[email protected]>
Co-authored-by: Joe Wildfong <[email protected]>
Co-authored-by: Thad House <[email protected]>
Co-authored-by: shueja <[email protected]>
Co-authored-by: Peter Johnson <[email protected]>
Co-authored-by: Eli Barnett <[email protected]>
Co-authored-by: Joseph Eng <[email protected]>
Co-authored-by: DeltaDizzy <[email protected]>
Co-authored-by: Dean Brettle <[email protected]>
Co-authored-by: sciencewhiz <[email protected]>
Co-authored-by: Sam Richter <[email protected]>
Co-authored-by: person4268 <[email protected]>
Co-authored-by: Gold856 <[email protected]>
Co-authored-by: Wispy <[email protected]>
Co-authored-by: Isaac Turner <[email protected]>
Co-authored-by: Ryan Blue <[email protected]>
Co-authored-by: Nicholas Armstrong <[email protected]>
Co-authored-by: Carl Hauser <[email protected]>
Co-authored-by: HarryXChen <[email protected]>
Co-authored-by: Starlight220 <[email protected]>
Co-authored-by: Juan Jose Chong <[email protected]>
Co-authored-by: vichik <[email protected]>
Co-authored-by: Jacob Hotz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: sysid SysId app type: bug Something isn't working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant