Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Approaching from 5km beneath station
- clearscreen.
- set pi to 3.1415926535897932384626433832795028841971693993751058209749445923.
- set mu to 3.986*(10^14).
- ag1 off.
- set target to "LIESS".
- set lateraloffset to 0.
- set verticaloffset to -5000.
- rcs on.
- sas off.
- gear off.
- lock steering to prograde + r(0,0,180).
- set maneuverSpeed to 1.
- //functions
- function verticaldist {
- set vdist to target:altitude-ship:altitude.
- return vdist.
- }.
- function verticalinputFunction {
- if abs(verticalDistance2+extraH) > 10 {
- set vver to (verticalDistance2-verticalDistance1)/(dt).
- if verticaldistance2+extraH > 0 {
- set ms to -maneuverSpeed.
- }. else {
- set ms to maneuverSpeed.
- }
- set vverError to ms-vver.
- set vertinput to kpv*vverError.
- ///////////////////////////////////////////
- }. else {
- set sverError to (verticaldistance2+extraH).
- set vver to (verticalDistance2-verticalDistance1)/(dt).
- set vertinput to -((kps*sverError)+(kds*vver)).
- }.
- return vertinput.
- }.
- ////////////////////////////////////////////////////////////////////////////////
- //defining values and gains
- set kpv to 1.
- set kps to .1.
- set kds to 2.
- set latinput to 0.
- set verticalinput to 0.
- set extraH to verticaloffset.
- set vver to 0.
- set desireSMA to target:orbit:semimajoraxis-5000.
- set desiredT to 2*pi*sqrt((desireSMA^3)/mu).
- //Sub 5 KM station keeping
- until ag1 {
- if 2 > 1 {
- set verticalDistance1 to verticaldist().
- set t1 to time:seconds.
- print "Vertical Difference "+round(verticalDistance1)+" m".
- print " ".
- print "Vertical Input "+round(100*verticalinput).
- wait 0.2.
- clearscreen.
- set verticalDistance2 to verticaldist().
- set t2 to time:seconds.
- set dt to t2-t1.
- }. //this is just so i can hide it easily
- ////////////////////////////////////////////
- set verticalinput to verticalinputfunction().
- ///////////////////////////////////////////
- set ship:control:top to verticalinput.
- set foreinput to 0.1*(desiredT-ship:orbit:period).
- set ship:control:fore to foreinput.
- print "Foreward Input "+(100*round(foreinput)).
- }.
- ag1 off.
- unlock steering.
- sas on.
- set ang to 2. //between ship and target positions
- set theta to 1.
- until ang < theta {
- set targpos to target:position+ship:body:position.
- set ang to vang(ship:body:position,targpos).
- set dist to 1000*13.8.//m. value obtained from space mech notes
- set theta to (180/pi)*(dist/ship:body:position:mag).
- print "Awaiting Burn".
- print "Loop ends at zero: "+round(1000*(ang-theta)).
- wait 0.1.
- clearscreen.
- }
- set warp to 0.
- sas off.
- lock steering to prograde + r(0,0,180).
- //this is about 1.4 m/s dv prograde
- //foreward acceleration averages .4 m/s2
- set v0 to ship:velocity:orbit:mag.
- set ship:control:fore to 1.
- wait until ship:velocity:orbit:mag>(v0+3.4).
- set ship:control:neutralize to true.
- unlock steering.
- sas on.
- until ag1 {
- print "Altitude Difference: "+round(target:altitude-ship:altitude)+" meters".
- wait 0.1.
- clearscreen.
- }
- ag1 off.
- run twokmclosing.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement