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

rendering #92

Merged
merged 42 commits into from
Dec 19, 2023
Merged

rendering #92

merged 42 commits into from
Dec 19, 2023

Conversation

luigiberducci
Copy link
Collaborator

Update rendering with pygame.

Support render modes "human", "human_fast", "rgb_array", "rgb_array_list".
Provide minimal set of callbacks to render racelines, local paths and points.
Two configurations for human time and faster.

update render spec loading params from file,
add rendering steering angle,
remove unused pyglet tests,
update setup dependencies
add fps on bottom-left corner,
add configurable car tickness
move zoom-in in the map renderer and only for render-mode human,
update render_fps in env based on the value of the renderer
move car rendering in separate class,
draw two lines for wheels
move poses, colors, etc in car object
add two rendering configurations,
add test and benchmark script
@luigiberducci luigiberducci linked an issue Sep 14, 2023 that may be closed by this pull request
4 tasks
@luigiberducci luigiberducci changed the base branch from main to v1.0.0 September 14, 2023 17:13
@luigiberducci
Copy link
Collaborator Author

Basic rendering in pygame implemented, removed dependency on pyglet.
Additional features like window centering and colors have been added to the roadmap.

update render spec loading params from file,
add rendering steering angle,
remove unused pyglet tests,
update setup dependencies
add fps on bottom-left corner,
add configurable car tickness
move zoom-in in the map renderer and only for render-mode human,
update render_fps in env based on the value of the renderer
move car rendering in separate class,
draw two lines for wheels
move poses, colors, etc in car object
add two rendering configurations,
add test and benchmark script
# Conflicts:
#	examples/waypoint_follow.py
#	gym/f110_gym/envs/f110_env.py
#	gym/f110_gym/envs/rendering/__init__.py
#	gym/f110_gym/envs/rendering/renderer.py
#	gym/f110_gym/envs/rendering/rendering.yaml
#	gym/f110_gym/envs/rendering/rendering_pygame.py
#	gym/f110_gym/test/test_scan_sim.py
f110 env: set render-fps to match integrator timestep to match real time in human/rgb-array render mode.
refactoring config files renderer
@luigiberducci luigiberducci self-assigned this Nov 24, 2023
@luigiberducci
Copy link
Collaborator Author

Close #88, #92 and #98.

Integrate comments discussed in previous meetings.
Now support for callbacks, automatic centering view on different agents, and handle mouse-click from users.

I think it is good enough to close it.
@hzheng40 @nandantumu please review.

Copy link
Member

@hzheng40 hzheng40 left a comment

Choose a reason for hiding this comment

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

Few minor things, otherwise looks good

examples/waypoint_follow.py Outdated Show resolved Hide resolved
examples/video_recording.py Show resolved Hide resolved
examples/video_recording.py Outdated Show resolved Hide resolved
examples/video_recording.py Outdated Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

This could be refactored to be much simpler:

class TextObject:
    def __init__(self, window_shape, relative_font_size:int = 32, font_name:str = "Arial"):
     ... init stuff is all identical ...

    def _position_resolver(self, position: Union[str, tuple], text, display):
    """ This function takes strings like "bottom center" and converts them into a location for the text to be displayed.
         if position is tuple, then passthrough.
    """

    def render(self, text:str, position, display):
    self.text = self.font.render(...)
    position = self._position_resolver(...)
    display.blit(self.text, position)

Then everything is a simple wrapper around this class, and it should be easier for users to reuse this for custom text.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fine for me, please proceed

setup.py Outdated Show resolved Hide resolved
@nandantumu
Copy link
Member

I'm also noticing that as I zoom in with rendering.yaml, the render speed gets slower? Not sure what's causing this under the hood

fix warning on accessing env.track with env.unwrapped.track
@luigiberducci
Copy link
Collaborator Author

@hzheng40 @nandantumu the minor required changes done.

As soon as the change to TextObject (@nandantumu) is done, we can merge.

@luigiberducci
Copy link
Collaborator Author

I'm also noticing that as I zoom in with rendering.yaml, the render speed gets slower? Not sure what's causing this under the hood

Known issue due to the way the track surface is rendered. As discussed, we let alternative solutions for future work.

@luigiberducci
Copy link
Collaborator Author

@hzheng40 @nandantumu the minor required changes done.

As soon as the change to TextObject (@nandantumu) is done, we can merge.

Implemented TextObject. Merging.

@nandantumu nandantumu self-requested a review December 19, 2023 21:48
@luigiberducci luigiberducci merged commit e949a6a into v1.0.0 Dec 19, 2023
2 of 8 checks passed
@luigiberducci luigiberducci deleted the dev_rendering branch December 19, 2023 21:52
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.

rendering in pygame
3 participants