Finally, code that works to orbit + creates a circ node.

This commit is contained in:
Anna Rose Wiggins 2021-07-19 04:46:05 -04:00
parent 6f9537547f
commit 3101aef1cc
5 changed files with 33 additions and 21 deletions

View file

@ -5,6 +5,7 @@ parameter APOAPSIS_TARGET is 80000.
parameter GRAVITY_TURN_START is 8000.
parameter GRAVITY_PITCH is 75.
parameter INITIAL_PITCH is 85.
parameter MINIMUM_PITCH is 40.
SensorCheck().
// Configure subsystems.
@ -36,15 +37,16 @@ lock STEERING to heading(90,90,270).
stage.
wait until SHIP:ALTITUDE > 200.
lock STEERING to heading(90, GRAVITY_PITCH, 270).
lock STEERING to heading(90, INITIAL_PITCH, 270).
wait until SHIP:ALTITUDE > GRAVITY_TURN_START.
print "Pitching for gravity turn".
// Perform initial pitch...
// Pitch over...
lock STEERING to heading(90, GRAVITY_PITCH, 270).
// Wait until we have rotated to that pitch...
print ("Locked to heading " + STEERINGMANAGER:TARGET). // debug?
// Wait until we have rotated to (approximately) that pitch...
wait until vectorangle(
SHIP:FACING:FOREVECTOR,
STEERINGMANAGER:TARGET:FOREVECTOR)
@ -61,17 +63,21 @@ until SHIP:ORBIT:APOAPSIS > 80000 {
// todo: we may need different values for bodies other than Kerbin.
local newHeading is lookdirup(SHIP:SRFPROGRADE:FOREVECTOR,
heading(90, 0, 270):TOPVECTOR).
if GetPitch(newHeading:FOREVECTOR) < 40 {
set newHeading to heading(90, 40, 270).
if GetPitch(newHeading:FOREVECTOR) < MINIMUM_PITCH {
set newHeading to heading(90, MINIMUM_PITCH, 270).
}
lock STEERING to newHeading.
wait 0.001.
}
SHIP:ADD(CreateCircularizationNode(SHIP:ORBIT:ETA:APOAPSIS)).
lock THROTTLE to 0.0.
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.
wait 0.001.
print "Target apoapsis acquired. Creating maneuver node".
AddCircularizationNode().
print "Releasing controls. Circularization maneuver added. Good luck, Kerman!".
set SHIP:CONTROL:PILOTMAINTHROTTLE to 0.
unlock THROTTLE.
unlock STEERING.
SAS on.