Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clearscreen.
- set radarOffset to 39. // The value of alt:radar when landed (on gear)
- lock trueRadar to alt:radar - radarOffset. // Offset radar to get distance from gear to ground
- lock g to constant:g * body:mass / body:radius^2. // Gravity (m/s^2)
- lock maxDecel to (ship:availablethrust / ship:mass) - g. // Maximum deceleration possible (m/s^2)
- lock stopDist to ship:verticalspeed^2 / (2 * maxDecel). // The distance the burn will require
- lock impactTime to trueRadar / abs(ship:verticalspeed). // Time until impact, used for landing gear
- WAIT UNTIL ship:verticalspeed < -1.
- print "Preparing for hoverslam...".
- rcs on.
- brakes on.
- when impactTime < 3 then {gear on.}
- WAIT UNTIL trueRadar - 60 < stopDist AND ship:airspeed < 500.
- print "Performing hoverslam".
- //XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- lock TAR to (Min((trueRadar / 2), 10) * -1) - 2.8.
- stage.
- Lock P to (TAR - ship:verticalspeed).
- Set D to 0.
- Set I to 0.
- Set P2 to P.
- Set Kp to 0.1.
- Set Ki to 0.
- Set Kd to 0.003.
- Lock Output to Kp * P + Ki * I + Kd * D.
- Set thot to 0.
- Lock THROTTLE to thot.
- Set StartT to Time:Seconds.
- Until stage:liquidFuel < 5 {
- Set TimeSinceStart to (Time:Seconds - StartT).
- if TimeSinceStart > 0 {
- Set I to (I + P * TimeSinceStart).
- Set D to ((P - P2) / TimeSinceStart).
- Set thot to Max(0, Min(Output, 1)).
- Set P2 to P.
- Set StartT to Time:Seconds.
- }
- Wait 0.001.
- Clearscreen.
- Print "P is : " + (P * Kp).
- Print "I is : " + (I * Ki).
- Print "D is : " + (D * Kd).
- Print "Throttle is : " + thot.
- Print "Output Is : " + output.
- Print "TAR is :" + TAR.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement