tasks
cosmic_warp.rl.tasks
RL task interface.
A task supplies the three environment-specific pieces of an RL problem:
the action mapping (normalized policy output -> actuator commands), the
observation packing, and the reward. Termination and truncation are handled
generically by :class:cosmic_warp.rl.env.VecEnv from the simulator's own
termination checker and episode-step counters.
The package defines only the :class:Task protocol; tasks themselves are
application code. examples/attitude_task.py is a reference implementation
(reaction-wheel attitude control) with all packing and reward math in fused
Warp kernels on device.
Task
Bases: Protocol
Minimal task interface consumed by :class:~cosmic_warp.rl.env.VecEnv.
A task exposes its per-environment action/observation widths and three
device-side operations. VecEnv calls bind once at construction,
then ingest_actions / write_reward / write_obs every step.
bind
ingest_actions
write_obs
Pack the observation into obs [N, obs_dim] (f32).
When masked == 1 only rows where reset_env is True are written
(the post-reset rewrite for auto-reset environments); when masked ==
0 every row is written.
Source code in cosmic_warp/rl/tasks.py
write_reward
Write the per-environment reward into reward [N] (f32).
action is the (already ingested) normalized action of the current
step, available for control-effort penalties.