flow.renderer package

Submodules

flow.renderer.pyglet_renderer module

Contains the pyglet renderer class.

class flow.renderer.pyglet_renderer.PygletRenderer(network, mode, save_render=False, path='/home/docs/flow_rendering', sight_radius=50, show_radius=False, pxpm=2, alpha=1.0)[source]

Bases: object

Pyglet Renderer class.

Provide a self-contained renderer module based on pyglet for visualization and pixel-based learning. To run renderer in a headless machine, use xvfb-run.

Attributes

data : list

A list of rendering data to be saved when save_render is set to True.

mode : str or bool

  • False: no rendering

  • True: delegate rendering to sumo-gui for back-compatibility

  • “gray”: static grayscale rendering, which is good for training

  • “dgray”: dynamic grayscale rendering

  • “rgb”: static RGB rendering

  • “drgb”: dynamic RGB rendering, which is good for visualization

save_render : bool

Specify whether to save rendering data to disk

path : str

Specify where to store the rendering data

sight_radius : int

Set the radius of observation for RL vehicles (meter)

show_radius : bool

Specify whether to render the radius of RL observation

time : int

Rendering time that increments by one with every render() call

lane_polys : list

A list of road network polygons

lane_colors : list

A list of [r, g, b] specify colors of each lane in the network

width : int

Width of display window or frame

height : int

Height of display window or frame

x_shift : float

The shift substracted to the input x coordinate

x_scale : float

The scale multiplied to the input x coordinate

y_shift : float

The shift substracted to the input y coordinate

y_scale : float

The scale multiplied to the input y coordinate

window : pyglet.window.Window

A pyglet Window object used to create a display window.

frame : numpy.array

An array of size width x height x channel, where channel = 3 when rendering in rgb mode and channel = 1 when rendering in gray mode

pxpm : int

Specify rendering resolution (pixel / meter)

close()[source]

Terminate the renderer.

get_sight(orientation, veh_id)[source]

Return the local observation of a vehicle.

Parameters

orientation : list

An orientation is a list contains [x, y, angle]

veh_id : str

The vehicle to observe for

render(human_orientations, machine_orientations, human_dynamics, machine_dynamics, human_logs, machine_logs)[source]

Update the rendering frame.

Parameters

human_orientations : list

A list contains orientations of all human vehicles An orientation is a list contains [x, y, angle].

machine_orientations : list

A list contains orientations of all RL vehicles An orientation is a list contains [x, y, angle].

human_dynamics : list

A list contains the speed of all human vehicles normalized by max speed, i.e., speed/max_speed This is used to dynamically color human vehicles based on its velocity.

machine_dynamics : list

A list contains the speed of all RL vehicles normalized by max speed, i.e., speed/max_speed This is used to dynamically color RL vehicles based on its velocity.

human_logs : list

A list contains the timestep (ms), timedelta (ms), and id of all human vehicles

machine_logs : list

A list contains the timestep (ms), timedelta (ms), and id of all RL vehicles