Skip to content

Adapters

Framework adapters that wrap OrbitalGymEnv for Gymnasium, PettingZoo, and POMDPPlanners-shape consumers.

Gymnasium

orbitalgym.adapters.gymnasium.adapter.GymnasiumAdapter

GymnasiumAdapter(env: OrbitalGymEnv, *, seed: int = 0)

Bases: Env

A gymnasium.Env wrapping a SingleAgentView.

PettingZoo

orbitalgym.adapters.pettingzoo.adapter.PettingZooAdapter

PettingZooAdapter(env: OrbitalGymEnv, *, seed: int = 0)

Bases: ParallelEnv

Multi-agent adapter using pettingzoo's Parallel API.

Each vehicle is a separate agent. Agent IDs are <side>_<index> (e.g. 'guard_0', 'bandit_0'). All agents step simultaneously.

POMDPPlanners-shape

(duck-typed protocol, not an external import)

orbitalgym.adapters.pomdp.adapter.POMDPAdapter

POMDPAdapter(
    env: OrbitalGymEnv,
    action_repeat: int = 1,
    discount: float = 1.0,
)

Flat-state-vector adapter conforming to POMDPPlanners-shape.

Pure: every public method is a function of its arguments alone. Safe to drive under jax.vmap / jax.lax.scan / jax.jit.

action_dim_per_side property

action_dim_per_side: int

Per-agent flat action width.

Both sides must agree on the per-agent dim for this property to be meaningful (planners that call this typically assume a single per-agent action width). When sides have different Command shapes, callers should use guard_action_flat_dim / bandit_action_flat_dim directly.

bandit_action_flat_dim property

bandit_action_flat_dim: int

Total flat width of the bandit side's Command pytree.

guard_action_flat_dim property

guard_action_flat_dim: int

Total flat width of the guard side's Command pytree.

states_dim property

states_dim: int

Flat-state width: layout.flat_dim, the (t, step) tail, and the dwell counters.

discount

discount() -> float

Per-macro-step discount: step_discount ** action_repeat.

initialstate

initialstate(key: Array) -> jax.Array

Sample an initial state and return its flat vector.

observation

observation(
    s_flat: Array,
    a_flat: Array,
    s_next_flat: Array,
    side: Side,
) -> jax.Array

Return the side's observation at the next state.

pack

pack(state: EnvState) -> jax.Array

Public alias for _pack. Use this from planners and tests.

reward

reward(
    s_flat: Array,
    a_flat: Array,
    s_next_flat: Array,
    side: Side,
) -> jax.Array

Return the side's reward for the macro step.

With action_repeat = 1 this is the single-step reward over the supplied (s, a, s') triple. With action_repeat = k it is the sum of the k per-substep rewards discounted by step_discount per substep, zero after a terminal substep; the intermediate states are not available from this signature, so the substeps are re-simulated from s_flat and s_next_flat is ignored. Re-simulation is exact: translational and attitude dynamics are deterministic given the state and action, and observation noise keys never enter the reward. Prefer :meth:step, which returns the next state and the reward from one rollout.

step

step(
    s_flat: Array, a_flat: Array, key: Array, side: Side
) -> tuple[jax.Array, jax.Array]

Advance one macro step and return (s_next_flat, reward).

The planner-facing entry point: one rollout serves both the next state and the side's discounted macro-step reward, so a search does not simulate the substeps twice.

transition

transition(
    s_flat: Array, a_flat: Array, key: Array
) -> jax.Array

Apply action_repeat env steps of a_flat.

a_flat is the concatenated guard+bandit action. Every substep goes through the env, so each one applies the env's own per-step delta-v cap: a macro action is k capped burns in one direction, exactly what the env executes when a policy repeats the command. Substep keys are splits of key. Once a substep reports episode_done the state is frozen for the remaining substeps.

unpack

unpack(s_flat: Array) -> EnvState

Public alias for _unpack.