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

Named and type-hint supporting detection results for the python agents. #7174

Open
wants to merge 8 commits into
base: dev
Choose a base branch
from

Conversation

Daraan
Copy link
Contributor

@Daraan Daraan commented Feb 22, 2024

Description

When I worked with the agent functions at first I had some trouble understanding the semantics of the return types of the agent's detection functions (obstacle, traffic lights).

e.g return (False, None, -1)

This PR adds Python <3.6 ( including Python2.7 ) compatible named tuples as return values for these two functions. Adding support for type-hints and improving semantics. Aside from the wrapping of return values into namedtuples this PR changes no functionality of the existing code.

For Python <3.6 it uses collections.namedtuple for Python 3.6+ it uses the typed version typing.NamedTuple . Type checkers running on 3.6+ can successfully pick up the typed version even if the non-typed version is used during runtime.

I think the agents are itself not Python2.7 compatible, so I think it might be overkill.
If stating that the PR is allowed to only support Python3.6+ it could be made much cleaner.


Where has this been tested?

  • Platform(s): Ubuntu 22.04 (Only python code so not relevant)
  • Python version(s): 2.7, 3.8, 3.10
  • Unreal Engine version(s): 4.26

Possible Drawbacks

Seeing None, despite adding one additional file containing the named tuples. They could be added to the BasicAgent.py themselves. In my opinion it would add unnecessary contents the agent file itself.

@Daraan Daraan requested a review from a team as a code owner February 22, 2024 10:27
@Daraan
Copy link
Contributor Author

Daraan commented Feb 22, 2024

A comment if license or copyright information should be added and in which form is appreciated :)

@Daraan Daraan force-pushed the named-detection-results branch 2 times, most recently from 6e7a9de to 152ce10 Compare March 9, 2024 18:17
@Daraan Daraan force-pushed the named-detection-results branch 2 times, most recently from 0fcbd91 to 1b789de Compare April 2, 2024 15:49
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

Successfully merging this pull request may close these issues.

None yet

1 participant