Executing a Burn#
This tutorial circularizes a vehicle’s orbit at its apoapsis. The script plans the burn, and the vehicle’s flight computer executes it, as when the player plans a burn in the game. The vehicle needs an engine and the propellant for the burn.
The complete script is circularize.py.
Planning the Burn#
The vis-viva equation gives the speed at apoapsis now, and the speed of a circular orbit there. We plan a prograde burn of the difference at the apoapsis:
mu = orbit.body.gravitational_parameter
r = orbit.apoapsis
v1 = math.sqrt(mu * (2 / r - 1 / orbit.semi_major_axis))
v2 = math.sqrt(mu / r)
burn = vehicle.add_burn(ksa.ut + orbit.time_to_apoapsis, prograde=v2 - v1)
print(f"Circularization burn: {burn.delta_v:.1f} m/s, {burn.burn_time:.1f} s")
The flight computer works out the burn time from the vehicle’s engines, and centers the burn on its time.
Executing the Burn#
We warp to 30 seconds before ignition, and turn on the auto-burn. The flight computer points the vehicle along the burn, fires the engines at the ignition time and stops once the burn is complete, and then turns the auto-burn off. An event, a server side function, waits for that:
ksa.warp_to(burn.ignition_time - 30)
print("Executing the burn")
auto_pilot.auto_burn = True
finished = conn.add_event(lambda: not auto_pilot.auto_burn)
with finished.condition:
finished.wait()
burn.remove()
The flight computer keeps the last burn it completes, so we remove it.