renderer
renderer
¶
2D top-down image renderer for synthetic benchmark tasks.
render_frame
¶
Render a single top-down 2D frame as an RGB image.
Draws obstacles, goal marker, agent trail, agent marker, and an optional context indicator onto a square canvas.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
position
|
ndarray
|
Cartesian agent position (x, y) in [0, 1]x[0, 1]. Shape (2,). |
required |
obstacles
|
list[tuple[float, float, float, float]]
|
Axis-aligned rectangles as (x_min, y_min, x_max, y_max) in [0, 1] coordinates. |
required |
goal
|
ndarray | None
|
Cartesian goal position (x, y) in [0, 1]x[0, 1]. Shape (2,). None to skip drawing the goal marker. |
None
|
image_size
|
int
|
Side length of the square output image in pixels. |
64
|
trail
|
ndarray | None
|
Past Cartesian positions (x, y) for rendering the agent trail. Shape (num_past_steps, 2). None to disable trail. |
None
|
context_color
|
tuple[int, int, int] | None
|
RGB color tuple for the context indicator square drawn in the top-left corner. None to disable. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
RGB image of shape (image_size, image_size, 3), dtype uint8. |
Source code in src/versatil/data/synthetic/renderer.py
render_episode
¶
Render all timestep frames for a full episode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
ndarray
|
Cartesian agent positions (x, y) over time. Shape (num_timesteps, 2), values in [0, 1]. |
required |
obstacles
|
list[tuple[float, float, float, float]]
|
Axis-aligned rectangles as (x_min, y_min, x_max, y_max) in [0, 1] coordinates. |
required |
goal
|
ndarray | None
|
Cartesian goal position (x, y) in [0, 1]x[0, 1]. Shape (2,). None to skip drawing the goal marker. |
None
|
image_size
|
int
|
Side length of the square output image in pixels. |
64
|
show_trail
|
bool
|
Whether to render the trajectory trail up to each frame. |
True
|
context_color
|
tuple[int, int, int] | None
|
RGB color tuple for the context indicator square. None to disable. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
RGB images of shape (num_timesteps, image_size, image_size, 3), |
ndarray
|
dtype uint8. |