flatland.integrations.interactiveai.interactiveai module#

FlatlandCallbacks for InteractiveAI (AI4REALNET/InteractiveAI).

The callbacks create context and events during a scenario run. If an InteractiveAI instance is up and running, the callbacks send out HTTP POST requests to InteractiveAI contexts and events REST API endpoints. In this notebook, we just log the contexts and events that would be sent out.

  • The agent positions are sent as context, with geo-coordinates for display on a map.

  • Agent malfunctions are sent as events.

class flatland.integrations.interactiveai.interactiveai.FlatlandInteractiveAICallbacks(coordinate_map: Dict[Tuple[int, int], Tuple[float, float]], client_id: str = 'opfab-client', username: str = 'admin', password: str = 'test', token_url: str = 'http://frontend/auth/token', event_api_host='http://localhost:5001', context_api_host='http://localhost:5100', history_api_host='http://localhost:5200', step_to_millis: int = 1000, collect_only: bool = False, now: datetime | None = None)[source]#

Bases: FlatlandCallbacks

connect()[source]#
on_episode_step(*, env: RailEnv | None = None, data_dir: Path | None = None, **kwargs) None[source]#

Called on each episode step (after the action(s) has/have been logged).

This callback is also called after the final step of an episode, meaning when terminated/truncated are returned as True from the env.step() call.

The exact time of the call of this callback is after env.step([action]) and also after the results of this step (observation, reward, terminated, truncated, infos) have been logged to the given episode object.