Skip to content

Reinforcement Learning

Only present in projects with the rl package installed.

Environment

Headless RL stepping API

__all__ module-attribute

__all__: list[str] = ['A2C', 'DDPG', 'DummyVecEnv', 'PPO', 'SAC', 'TD3', 'clear_cache', 'fusion', 'get_action_space', 'get_observation_space', 'get_snapshot', 'gym', 'is_training', 'load_model', 'np', 'os', 'predict', 'reset', 'step']

is_training module-attribute

is_training: bool = False

clear_cache

clear_cache()

get_action_space

get_action_space() -> typing.Any

Returns the gymnasium.spaces.Space configured via AgentComponent.set_action_space() on the scene's first AgentComponent.

get_observation_space

get_observation_space() -> typing.Any

Returns the gymnasium.spaces.Space configured via AgentComponent.set_observation_space(), or None if unset (in which case a default Box inferred from observation length is used).

get_snapshot

get_snapshot(width: SupportsInt | SupportsIndex = 128, height: SupportsInt | SupportsIndex = 128) -> numpy.typing.NDArray[numpy.uint8]

Render the scene off-screen (works even during headless training) and return it as an (height, width, 3) uint8 RGB array.

Example
frame = fusionRL.Environment.get_snapshot(84, 84)
self.agent.add_observation((frame.astype('float32') / 255.0).flatten().tolist())

load_model

load_model(path, algorithm='PPO')

predict

predict(loaded, observation, deterministic=True)

reset

reset() -> list

Reload the editing scene, run one priming tick, and return the initial observation.

step

step(action: Any) -> tuple[list, float, bool]

Advance the simulation by one physics tick with the given action applied (type must match the configured action_space), returning (observation, reward, done).