wpilibsuite / shuffleboard

A modern dashboard for FRC
Other
79 stars 84 forks source link

Field2d widget causes exception every frame #797

Closed feoranis26 closed 3 months ago

feoranis26 commented 4 months ago

Describe the bug
Log file gets spammed with error:

Mar XX, 2024 XX:XX:XX XM edu.wpi.first.shuffleboard.plugin.networktables.sources.CompositeNetworkTableSource lambda$new$0
WARNING: Incomplete data for type Field2d
edu.wpi.first.shuffleboard.api.data.IncompleteDataException: Incomplete data in map: {.name=Odom, .type=Field2d, .controllable=true, Robot=[D@35f5daf9,  Localized=x: 1.4519350881997504, y: -31.02742566505306}
    at edu.wpi.first.shuffleboard.api.data.ComplexDataType.fromMap(ComplexDataType.java:33)
    at edu.wpi.first.shuffleboard.plugin.networktables.sources.CompositeNetworkTableSource.lambda$new$0(CompositeNetworkTableSource.java:58)
    at edu.wpi.first.shuffleboard.plugin.networktables.sources.NetworkTableSource.lambda$setTableListener$0(NetworkTableSource.java:81)
    at edu.wpi.first.shuffleboard.api.util.FxUtils.lambda$runOnFxThread$0(FxUtils.java:64)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
    at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class [D (java.lang.String and [D are in module java.base of loader 'bootstrap')
    at edu.wpi.first.shuffleboard.plugin.base.data.FieldData.<init>(FieldData.java:73)
    at edu.wpi.first.shuffleboard.api.data.ComplexDataType.fromMap(ComplexDataType.java:31)
    ... 10 more

To Reproduce

  1. Send ANY Field2d widget using SmartDashboard from robot code
  2. Exception gets thrown every frame

Expected behavior
No exception gets thrown, and robot pose is correctly displayed

Actual behavior Field2d widget causes exception (every frame?), and robot pose is fixed at 0, 0

Screenshots
Also causes MASSIVE log file spam 10 GB+ log files: image Smaller log file: shuffleboard.2024-03-07-11.44.02.log

Desktop:

Starlight220 commented 4 months ago

My guess is that the widget code doing the parsing doesn't match the Sendable implementation. Can you send how the NT data looks (from any raw NT view)?

PeterJohnson commented 4 months ago

There were several updates to the NT code in 2024.3.1. Can you confirm it still happens on that version or later (2024.3.2 was just released)?

Starlight220 commented 4 months ago

What is the type of Localized? It should be a double[3].

Is it part of the Field2d publishing, or is it an entry you've published to that path?

feoranis26 commented 4 months ago

I don't have access to the robot, or a suitable testing environment right now, as I remembered this issue while doing a disk scan. Will update once I do.

Starlight220 commented 4 months ago

Can you please test a build from #798 and see that the issue doesn't reproduce and no other issues pop up?

SamCarlberg commented 4 months ago

Incomplete data in map: {.name=Odom, .type=Field2d, .controllable=true, Robot=[D@35f5daf9, Localized=x: 1.4519350881997504, y: -31.02742566505306}

Where is this data coming from? That string for the "Localized" key is not a standard format that WPILib sends data in

feoranis26 commented 4 months ago

AFAIK we don't use NetworkTables at all in our robot code so anything there should be stuff published by WPILib. I still haven't had a chance to test #798 yet, but tomorrow I should be able to test it.

Starlight220 commented 4 months ago

At minimum you're sending the Field2d object. What else are you sending? Note that the Shuffleboard and SmartDashboard APIs are NT wrappers...

Please go over your usage of the Shuffleboard API and check if you're publishing anything to the same path as the field.

Searching for "Localized" would also be a good guess to find what is being published and where.

feoranis26 commented 4 months ago

Across our entire SmartDashboard API calls, this line is the only one that includes the word "Localized", which seems suspiciously similar to the format of the data causing the exception. I don't think it's related to this issue though, as it publishes to a separate path, and the pose value in the exception is unlikely to come from this line, the robot would have to see an AprilTag from 30 meters away. We also don't publish anything to the same path of the field.

SmartDashboard.putString("Localized pose", "x: " + robot_actual_pose.getX() + ", y: " + robot_actual_pose.getY());

I'll look into our NT usage deeper once I'm able to work on the robot.