Rendering Engine
This is the rendering engine using pyglet to visualize the running environment.
- module rendering
Variables
- ZOOM_IN_FACTOR = 1.2
- ZOOM_OUT_FACTOR = 1/ZOOM_IN_FACTOR
- CAR_LENGTH = 0.58
- CAR_WIDTH = 0.31
- EnvRenderer : public Window
A window class inherited from pyglet.window.Window, handles the camera/projection interaction, resizing window, and rendering the environment
Public Functions
- __init__(self, width, height, *args, **kwargs)
Class constructor Args: width (int): width of the window height (int): height of the window Returns: None
- update_map(self, map_path, map_ext)
Update the map being drawn by the renderer. Converts image to a list of 3D points representing each obstacle pixel in the map. Args: map_path (str): absolute path to the map without extensions map_ext (str): extension for the map image file Returns: None
- on_resize(self, width, height)
Callback function on window resize, overrides inherited method, and updates camera values on top of the inherited on_resize() method. Potential improvements on current behavior: zoom/pan resets on window resize. Args: width (int): new width of window height (int): new height of window Returns: None
- on_mouse_drag(self, x, y, dx, dy, buttons, modifiers)
Callback function on mouse drag, overrides inherited method. Args: x (int): Distance in pixels from the left edge of the window. y (int): Distance in pixels from the bottom edge of the window. dx (int): Relative X position from the previous mouse position. dy (int): Relative Y position from the previous mouse position. buttons (int): Bitwise combination of the mouse buttons currently pressed. modifiers (int): Bitwise combination of any keyboard modifiers currently active. Returns: None
- on_mouse_scroll(self, x, y, dx, dy)
Callback function on mouse scroll, overrides inherited method. Args: x (int): Distance in pixels from the left edge of the window. y (int): Distance in pixels from the bottom edge of the window. scroll_x (float): Amount of movement on the horizontal axis. scroll_y (float): Amount of movement on the vertical axis. Returns: None
- on_close(self)
Callback function when the 'x' is clicked on the window, overrides inherited method. Also throws exception to end the python program when in a loop. Args: None Returns: None Raises: Exception: with a message that indicates the rendering window was closed
- on_draw(self)
Function when the pyglet is drawing. The function draws the batch created that includes the map points, the agent polygons, and the information text, and the fps display. Args: None Returns: None
- update_obs(self, obs)
Updates the renderer with the latest observation from the gym environment, including the agent poses, and the information text. Args: obs (dict): observation dict from the gym env Returns: None
- module gl