World Composition¶
UniEnv can build an environment from smaller pieces instead of forcing everything into one monolithic class.
The relevant abstractions are:
World: the shared simulator or runtimeWorldNode: one subsystem layered on top of that worldWorldEnv: anEnvthat composes a world and one or more nodes
World¶
World owns the underlying runtime state.
Typical responsibilities:
- stepping the simulator or real-time clock
- resetting or reloading the runtime
- exposing a backend, device, and optional batch size
- coordinating timestep information
UniEnv includes RealWorld, which measures wall-clock elapsed time and is useful for real-time control loops.
WorldNode¶
A WorldNode represents one logical concern inside the world, such as:
- a robot controller
- a sensor
- a reward model
- a termination rule
- an object or scene component
Nodes expose some combination of:
action_spaceobservation_spacecontext_space- reward, termination, and truncation signals
- rendering output
Lifecycle¶
WorldEnv drives a staged lifecycle around the world and its nodes.
Reset flow:
World.reset()- node
reset(...) World.after_reset()- node
after_reset(...) - read context, observation, and info
Reload flow:
World.reload()- node
reload(...) World.after_reload()- node
after_reload(...) - read context, observation, and info
Step flow:
- node receives the next action
- node
pre_environment_step(...) World.step()- node
post_environment_step(...) - read observation, reward, done flags, and info
Priorities¶
Nodes opt into lifecycle callbacks through priority sets such as:
reset_prioritiesreload_prioritiesafter_reset_prioritiesafter_reload_prioritiespre_environment_step_prioritiespost_environment_step_priorities
Higher priorities run earlier.
This lets you coordinate scene setup order, controller updates, reward computation, and sensor refreshes without hard-coding everything into one call site.
Combined Nodes¶
If you pass multiple nodes to WorldEnv, UniEnv wraps them in a CombinedWorldNode.
That gives you:
- one environment surface
- aggregated spaces and signals
- nested node lookup helpers such as
get_node(...)
When To Use World Composition¶
Use the world/node stack when:
- your environment is naturally composed from reusable subsystems
- you need clear ordering around scene construction and runtime updates
- you want one simulator world to power multiple observation or control components
If your environment is simple and self-contained, a direct Env or FuncEnv can still be the better fit.