Advertisement
Guest User

Untitled

a guest
Nov 6th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. sas off.
  2.  
  3. set RADAR_GROUND_HEIGHT to 1.8. //Set this too high and you get negative sqrt and crash.
  4. //Set this too low and you slam into the ground.
  5. set DESCENT_SPEED to 3. // fudgey number. higher is faster
  6. set JET_SPOOL_TIME to 3. // aproximate number of seconds the jet spools.
  7. set SURFACE_SHEAR_CAP to 40. //how many meters per second before we just lock to 45 degrees
  8. //higher means less aggressive reactions to sideways movement.
  9.  
  10. set pt to TIME:SECONDS. //previous time
  11. set pv to 0. //previous velocity
  12.  
  13. until false {
  14. wait 0.1.
  15. CLEARSCREEN.
  16. set surfaceShear to vxcl(up:forevector, velocity:surface).
  17. if surfaceShear:MAG > SURFACE_SHEAR_CAP { SET surfaceShear:MAG to SURFACE_SHEAR_CAP. }
  18. set desiredVelocity to -sqrt(alt:radar-RADAR_GROUND_HEIGHT)*DESCENT_SPEED.
  19. set velocityChange to desiredVelocity-ship:verticalspeed.
  20.  
  21. set dt to TIME:SECONDS - pt.
  22. set dv to ((velocityChange - pv)/dt)*JET_SPOOL_TIME.
  23.  
  24. set baseThrottle to (ship:mass*9.87/ship:maxthrust).
  25. set adjustmentThrottle to (velocityChange+dv)/3.
  26.  
  27. print "Target Descent Speed: " + round(desiredVelocity, 2).
  28. print "Diff From Target : " + round(velocityChange, 2).
  29. print "Diff Rate Of Change : " + round(dv, 2).
  30. print "Surface Shear Speed : " + round(surfaceShear:mag, 2).
  31. print "Neutral Throttle : " + round(baseThrottle, 2).
  32. print "Adjustment Throttle : " + round(adjustmentThrottle, 2).
  33.  
  34. lock throttle to adjustmentThrottle + baseThrottle + surfaceShear:mag/SURFACE_SHEAR_CAP.
  35. lock steering to lookdirup(up:forevector*SURFACE_SHEAR_CAP-surfaceShear, facing:topvector).
  36.  
  37. set pt to TIME:SECONDS.
  38. set pv to velocityChange.
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement