thrusters
cosmic_warp.actuators.thrusters
Thruster models for spacecraft propulsion.
Supports configurable thruster layouts with position and direction vectors. Computes both force and torque contributions from thrust commands.
ThrusterConfig
Configuration for a thruster array (up to 8 thrusters).
Each thruster has:
- Position relative to spacecraft CoM (row of positions)
- Direction (unit vector in body frame, row of directions)
- Maximum thrust magnitude
ThrusterWrench
Combined thruster output over one step.
force/torque are in the body frame; mdot is the total propellant mass flow rate (>= 0), zero when isp <= 0 (ideal thruster, no consumption). All three are already scaled by the step's burn fraction. mass_end is the mass at the step end, the exact solution of the constant-flow mass equation that every integrator stores: exactly the dry mass on the burnout step.
ThrusterManager
Manages thruster configurations for parallel entities (envs * bodies).
A new manager holds the default 6-thruster layout; set_config (or the
body.actuators.thrusters YAML section) changes it.
Initialize thruster manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_envs
|
int
|
Number of parallel environments |
required |
device
|
str
|
Compute device |
'cuda'
|
num_bodies
|
int
|
Number of bodies per environment |
1
|
Source code in cosmic_warp/actuators/thrusters.py
set_config
set_config(
*,
max_thrust: float = None,
isp: float = None,
positions: list = None,
directions: list = None,
env_ids: list = None,
body_ids: list = None,
entity_ids: list = None,
) -> None
Set thruster configuration for all entities or a subset.
Only the fields given are checked and written; None leaves a field unchanged for the selected entities. positions and directions make up the layout and are given together (or both omitted). A new simulator starts with max_thrust 10 N, isp 0 (no propellant use) and the 6-thruster DEFAULT_POSITIONS / DEFAULT_DIRECTIONS layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_thrust
|
float
|
Maximum thrust per thruster [N], >= 0 |
None
|
isp
|
float
|
Specific impulse [s], >= 0 (0 = ideal, no propellant use) |
None
|
positions
|
list
|
Up to 8 position tuples (x, y, z) in metres |
None
|
directions
|
list
|
Direction tuples [(dx,dy,dz), ...], one per position, normalized here; (0,0,0) leaves the slot unused |
None
|
env_ids
|
list
|
List of environment indices to configure (None = all) |
None
|
body_ids
|
list
|
List of body indices to configure (None = all bodies) |
None
|
entity_ids
|
list
|
Optional flat entity indices (env_id * num_bodies + body_id) |
None
|
Source code in cosmic_warp/actuators/thrusters.py
thruster_wrench
thruster_wrench(
config: ThrusterConfig,
cmd: ActuatorCommand,
state: State,
vehicle: VehicleConfig,
dt: float64,
) -> ThrusterWrench
Compute the total thruster force, torque and mass flow over one step.
In the body frame these depend only on the commands, the configuration and the propellant left at the step start, so integrators evaluate them once per step. Struct built once via its constructor (adjoint-safe).
On the step where the propellant runs out, all three are scaled by the burn fraction (the share of the step the propellant lasts at full flow), so the mass reaches the dry mass exactly at the step end. mass_end is then mass_dry itself, not a computed difference: one rounded an ulp above dry would leave a remaining flow that rounds away, so the mass would never reach dry and mass_limit = mass_dry never fire. This only stretches the mass profile in time: with a fixed thrust direction, the delta-v and propellant use are exact, and the position and attitude differ from an exact cutoff by O(dt^2), once per burnout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
ThrusterConfig
|
Thruster configuration |
required |
cmd
|
ActuatorCommand
|
Actuator command with thrust values |
required |
state
|
State
|
Spacecraft state at the step start |
required |
vehicle
|
VehicleConfig
|
Vehicle configuration |
required |
dt
|
float64
|
Step length [s] |
required |
Returns:
| Type | Description |
|---|---|
ThrusterWrench
|
ThrusterWrench with body-frame force [N], torque [N*m], mass flow |
ThrusterWrench
|
rate [kg/s] and step-end mass [kg] |