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

[glass] Canvas2D Support #5941

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft

[glass] Canvas2D Support #5941

wants to merge 17 commits into from

Conversation

ohowe1
Copy link
Contributor

@ohowe1 ohowe1 commented Nov 20, 2023

Very in-progress PR. Currently only have lines in Java done and there are currently a few hacks.

If someone would be able to look over the structure of everything before I work on the other drawing types and C++, that would be much appreciated.

myRobot stuff will be removed once dev for this is done.

@ohowe1
Copy link
Contributor Author

ohowe1 commented Nov 30, 2023

@PeterJohnson Before starting to implement C++, do you have any other types you'd like included?

@PeterJohnson
Copy link
Member

Text and image are the main things that's missing that were discussed in the issue. Unfortunately, with the struct based approach, strings are challenging to support unless you have an arbitrary maximum string length (e.g. 16-20 characters).

@calcmogul calcmogul added the component: glass Glass app and backend label Nov 30, 2023
@ohowe1
Copy link
Contributor Author

ohowe1 commented Dec 1, 2023

A possible workaround for the elements with non-constant set sizes is to maybe have another topic serve as a database that the Canvas2DText/Image struct references. What do you think about this?

@PeterJohnson
Copy link
Member

How do you reference it? You can't do something like a string array with numeric indicies because of slicing (out of order updates). I actually don't think a fixed string limitation is that limiting--it might need a bit more work on the dashboard side to e.g. map short font names to system fonts (which we probably want anyway). The actual string limit to the user for text might be more of a constraint, but even there, you can only fit so much text in one line on the screen anyway--if it's something like 32 or 64 characters that should meet almost all use cases.

@ohowe1
Copy link
Contributor Author

ohowe1 commented Dec 1, 2023

Ok, if it isn't two limiting, a set max length sounds good for the string. For images, though, what do you think about this as having a set size would likely be a bit more limiting (and possibly resource-wasteful):

Canvas2DTexture myCoolImage = new Canvas2DTexture("myCoolImage", textureData);

void draw() {
    canvas2d.drawTexture(myCoolImage, x, y, ...);
    canvas2d.finishFrame();
}

The texture struct that also holds the drawn position would hold an identifier given to the myCoolImage. The data for myCoolImage would be held in NT similar to how a FieldObject2d is with its own topic as it would not change much (and likely have the lifetime of the entire robot program).

@PeterJohnson
Copy link
Member

PeterJohnson commented Dec 1, 2023

My original thought for images is a relatively short image name (8-16 characters?). The source for that image would be either a folder on the dashboard side or (potentially) a separate topic in NT if we want to enable it to be sourced from the robot code (or the dashboard could even fetch it via FTP from the Rio's deploy folder, rather than it being via NT).

@ohowe1
Copy link
Contributor Author

ohowe1 commented Dec 4, 2023

Ok, I'll probably just start off with on dashboard side, then.

@ohowe1
Copy link
Contributor Author

ohowe1 commented Dec 26, 2023

/format

@ohowe1
Copy link
Contributor Author

ohowe1 commented Dec 30, 2023

@PeterJohnson
Currently what's left for this is

  • 2D Texture, I'll try to work on this but the amount of time I have has been pretty dwindled by college apps which will likely continue till kickoff :(
  • Warning on large text passed to CanvasText2D, should this throw something? or silently truncate? or warn somehow?
  • Struct Database access in the sim GUI. The NT provider lives in the HALSimGUI, which is initialized before the NetworkTablesSimGui where the model is and the current place for the struct DB. How do you think this should be addressed?

@calcmogul calcmogul linked an issue Oct 14, 2024 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: glass Glass app and backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[glass] Add canvas element for arbitrary drawing
3 participants