Advertisement
Guest User

Untitled

a guest
May 3rd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. clearscreen.
  2. set radarOffset to 39. // The value of alt:radar when landed (on gear)
  3. lock trueRadar to alt:radar - radarOffset. // Offset radar to get distance from gear to ground
  4. lock g to constant:g * body:mass / body:radius^2. // Gravity (m/s^2)
  5. lock maxDecel to (ship:availablethrust / ship:mass) - g. // Maximum deceleration possible (m/s^2)
  6. lock stopDist to ship:verticalspeed^2 / (2 * maxDecel). // The distance the burn will require
  7. lock impactTime to trueRadar / abs(ship:verticalspeed). // Time until impact, used for landing gear
  8. WAIT UNTIL ship:verticalspeed < -1.
  9. print "Preparing for hoverslam...".
  10. rcs on.
  11. brakes on.
  12. when impactTime < 3 then {gear on.}
  13.  
  14. WAIT UNTIL trueRadar - 60 < stopDist AND ship:airspeed < 500.
  15. print "Performing hoverslam".
  16. //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  17. lock TAR to (Min((trueRadar / 2), 10) * -1) - 2.8.
  18. stage.
  19.  
  20. Lock P to (TAR - ship:verticalspeed).
  21. Set D to 0.
  22. Set I to 0.
  23. Set P2 to P.
  24.  
  25. Set Kp to 0.1.
  26. Set Ki to 0.
  27. Set Kd to 0.003.
  28.  
  29. Lock Output to Kp * P + Ki * I + Kd * D.
  30.  
  31. Set thot to 0.
  32. Lock THROTTLE to thot.
  33.  
  34. Set StartT to Time:Seconds.
  35. Until stage:liquidFuel < 5 {
  36. Set TimeSinceStart to (Time:Seconds - StartT).
  37. if TimeSinceStart > 0 {
  38. Set I to (I + P * TimeSinceStart).
  39. Set D to ((P - P2) / TimeSinceStart).
  40. Set thot to Max(0, Min(Output, 1)).
  41. Set P2 to P.
  42. Set StartT to Time:Seconds.
  43. }
  44. Wait 0.001.
  45. Clearscreen.
  46. Print "P is : " + (P * Kp).
  47. Print "I is : " + (I * Ki).
  48. Print "D is : " + (D * Kd).
  49. Print "Throttle is : " + thot.
  50. Print "Output Is : " + output.
  51. Print "TAR is :" + TAR.
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement