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

[Feature] Possibly add a way to display User Code Exceptions on the Dashboard? #153

Open
GraysonTinker opened this issue Jul 18, 2024 · 1 comment

Comments

@GraysonTinker
Copy link
Contributor

GraysonTinker commented Jul 18, 2024

Currently, unlike global errors, User Code Exceptions aren't displayed in any way on the dashboard. This isn't necessarily bad, as the errors are still visible in logcat, but it can be a bit unintuitive to have an opmode suddenly stop without any indication as to why, especially when it occurs as a result of hardwareMap errors during the init phase.

While investigating the possibility of making a PR for this issue, I looked into how Exception data originating from user code travels. The data that is currently acquired and sent to the dashboard comes from RobotLog.getGlobalErrorMessage(), which is set by RobotLog.setGlobalErrorMessage(). However, User Code Exceptions are handled differently: instead, they are simply logged as an error, and have up to 15 lines sent to the Driver Hub via the NetworkConnectionHandler. This occurs inside OpModeManagerImpl.handleUserCodeException().

Here are some potential ways to add this functionality to the Dashboard if this seems like something worth pursuing:

  1. Modify some part of RobotCore to send the Exception to us, potentially raising questions about whether this is possible to do, desirable in the first place, and/or legal.
  2. Attempt to intercept the CMD_SHOW_STACKTRACE Command sent to the Driver Station, and the associated stack trace data.
    • An idea on how this could be done is emulating a Driver Station network connection to localhost. I don't know how realistic that would actually be though.
  3. Attempt to read the system log and parse out errors.
    • It seems like a consistent and unique tag is used, "OpModeManager", so it might not be too hard to filter.
    • This could potentially be expanded into a new Logcat Dashboard element, which might be useful in and of itself.
  4. Don't actually obtain Exception data, but instead display a preconfigured message saying the code crashed and pointing the user to logcat.
    • Potentially this could be done by checking if the opmode lasted less than a certain amount of time, though it wouldn't catch all cases.
  5. Make no changes and leave it how it is currently. It does work fine once you get used to it.

Thanks for reading :)

@rbrott
Copy link
Member

rbrott commented Jul 22, 2024

I agree that it would be nice to show user exceptions as well. Kudos for tracing how the FTC SDK handles those exceptions. If you're interested in pursuing this further, I would open an issue against the SDK repo asking why user exceptions aren't incorporated into the global error message and then dash will automatically get this feature without additional effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants