rtgym.arena package

Subpackages

Submodules

rtgym.arena.arena module

class Arena(gym, **kwargs)[source]

Bases: object

Arena environment for spatial navigation.

The Arena defines the physical space where agents navigate, including walls, obstacles, and free space. It manages the spatial layout and provides utilities for position validation and random position generation.

Parameters:
  • gym (RatatouGym) – Parent gym environment.

  • **kwargs – Additional keyword arguments.

spatial_resolution

Spatial resolution in units per pixel.

Type:

float

dimensions

Arena dimensions (height, width).

Type:

tuple

free_space

Coordinates of all free space positions.

Type:

np.ndarray

subscribers

List of objects subscribed to arena changes.

Type:

list

property arena_height

Get arena height.

Returns:

Arena height in pixels.

Return type:

int

property arena_map

Get the arena map.

Returns:

Arena map where 0 represents free space and 1 represents walls.

Return type:

np.ndarray

property arena_width

Get arena width.

Returns:

Arena width in pixels.

Return type:

int

generate_random_pos(size)[source]

Get random positions in the arena

get_specs()[source]

Get specs

init_arena_map(shape, **kwargs)[source]

Set the arena map with a predefined shape.

Parameters:

shape (str) – Shape of the arena map.

property inv_arena_map

Get inverted arena map for visualization.

Returns:

Inverted arena map where 1 is free space, 0 is wall.

Return type:

np.ndarray

load(path)[source]

Load arena map from an npz file

Parameters:

path (str) – Path to the file where the arena map is saved.

property map

Get arena map (alias for arena_map).

Returns:

Arena map where 0 is free space, 1 is wall.

Return type:

np.ndarray

notify_subscribers()[source]

Notify all subscribers of arena changes.

Calls all registered subscriber functions to inform them that the arena has been modified.

print_specs()[source]

Print specs

Parameters:

path (str) – Path to the file where the arena map is saved.

save(path)[source]

Save arena map as an npz file

Parameters:

path (str) – Path to the file where the arena map is saved.

set_arena_map(arena_map)[source]

Set arena map with custom layout.

Automatically pads edges with walls if they contain free space.

Parameters:

arena_map (np.ndarray) – Arena map where 0 is free space, 1 is wall.

Raises:

AssertionError – If arena_map is not a numpy array.

subscribe(subscriber)[source]

Subscribe to arena change notifications.

Parameters:

subscriber (callable) – Function to call when arena changes.

validate_index(pos)[source]

Check if the position is in the arena

vis()[source]

Visualize arena

rtgym.arena.room_editor module

Module contents