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

Add referee display layer #3337

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

Lmh-java
Copy link
Contributor

@Lmh-java Lmh-java commented Oct 4, 2024

Description

Add a referee info layer to display game state and command.

Testing steps:

  1. turn on "Referee Info" option in the "Layers" dropdown
  2. Expect to see info on the top right corner

Testing Done

  • Thunderscope runs
  • CI

Resolved Issues

resolves #3333
resolves #3289

Demo

Dropdown menu to enable layer image
Game state and command display image
Ball placement visual (ball is not placed correctly) image
Ball placement visual (ball is placed correctly) image

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

@Lmh-java Lmh-java marked this pull request as ready for review October 4, 2024 05:28
@Lmh-java Lmh-java requested review from a team, Mr-Anyone and AadityaSuri and removed request for a team October 4, 2024 05:29
Copy link
Contributor

@williamckha williamckha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Would you also be able to incorporate #3289 into this PR? There's already another PR that never got merged which implements it.

src/software/thunderscope/gl/graphics/gl_label.py Outdated Show resolved Hide resolved
if not referee_proto:
return

referee_msg_dict = MessageToDict(referee_proto)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You actually don't need MessageToDict (I'm not sure why we use it in some of our code). You can just access the fields directly e.g. referee_proto.stage

Copy link
Contributor Author

@Lmh-java Lmh-java Oct 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After testing, I think in this case I might want to keep MessageToDict, since directly acessing referee_proto.stage only gives me the index number (instead of the text)

@Lmh-java
Copy link
Contributor Author

Lmh-java commented Oct 5, 2024

🔥

Would you also be able to incorporate #3289 into this PR? There's already another PR that never got merged which implements it.

Yes, sure. 👍

Co-authored-by: William Ha <60044853+williamckha@users.noreply.github.com>
@Lmh-java
Copy link
Contributor Author

Lmh-java commented Oct 5, 2024

Just a little bit clarification here before I get started, is ball placement visulization supposed to be in the same layer with referee info?

In #3289, that's what being said, but in the associated PR, it seems to be added to a different layer.

@williamckha
Copy link
Contributor

Just a little bit clarification here before I get started, is ball placement visulization supposed to be in the same layer with referee info?

In #3289, that's what being said, but in the associated PR, it seems to be added to a different layer.

I would put the ball placement visualization in the Referee Info layer you created

Copy link
Contributor

@sauravbanna sauravbanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great! really good job on incorporating (+ improving!) my ball placement impl, just some minor nits

:param text_color: The color for rendering the text.
:param offset: The offset (x, y) from the viewport left and top edge
to use when positioning the label.
If x is negative then the x offset is |x| pixels from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: is this necessary? feels like its a bit clearer to just require the offsets to be positive numbers always. from the perspective of someone using this method in the future, the sign flipping feels a bit roundabout

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not a huge deal tho

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol I followed the design of other components on the same level for consistency. But sure, I will clean this up to make it more understandable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some testing here, I found out that the easier way to place the label on the top right corner is just to keep this wired sign flipping, because it takes some code to fetch the width of the viewport before passing into this function. Instead, we can get viewport by whatever calls this function, so we probably need to use a negative sign to denote starting from the right side.

return
self.cached_referee_info = referee_msg_dict

if not self.gamestate_type_text:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: these 2 if statements are pretty identical, could probably pull them out to a new method

Copy link
Contributor Author

@Lmh-java Lmh-java Oct 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two if statements are writting to class fields, I can parametrize relevant parameters, but I don't know how to parametrize class level field so everytime we call this method we write to a different file. It seems taking a lot of code...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can probably parametrize a class-level member with a lambda but that might be overkill since there's only 2

@Lmh-java Lmh-java requested a review from sauravbanna October 19, 2024 07:16
@Lmh-java Lmh-java requested a review from itsarune November 16, 2024 06:50
Copy link
Contributor

@itsarune itsarune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, 2 more minor things

@Lmh-java Lmh-java requested a review from itsarune December 3, 2024 19:19
itsarune
itsarune previously approved these changes Dec 7, 2024
Copy link
Contributor

@itsarune itsarune left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@potatoisagender potatoisagender self-requested a review December 7, 2024 23:21
Copy link
Contributor

github-actions bot commented Jan 7, 2025

This PR is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot added the Stale Inactive pull requests label Jan 7, 2025
@Lmh-java Lmh-java removed the Stale Inactive pull requests label Jan 7, 2025
williamckha
williamckha previously approved these changes Jan 18, 2025
Copy link
Contributor

@williamckha williamckha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, pending merge conflicts

@Lmh-java Lmh-java dismissed stale reviews from itsarune and williamckha via afaf9a9 January 19, 2025 22:41
@Lmh-java
Copy link
Contributor Author

@itsarune @williamckha Merged with master, manual tested and everything LGTM. Please review

Copy link
Contributor

@williamckha williamckha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry this has been in review for so long 😅

@Lmh-java
Copy link
Contributor Author

Thanks William! 🍻

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