sumguytwitches

Nutsy flight controller

Oct 27th, 2020 (edited)
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. set sl to 1.
  2. lock steering to heading(90,90).
  3. set tgt to ship:geoposition.
  4. lock tv to tgt:position:normalized * min(10,(tgt:distance/6) ^ 0.85).
  5. lock steering to heading(90,90).
  6. set talt to 100.
  7. set taltpid to pidloop(4, 1, 2, 0, 460).
  8.  
  9.  
  10. lock deploy to max(3,airspeed^0.7).
  11. lock tilt to max(75,min(90,alt:radar*90/talt)).
  12. set blades to ship:partsdubbedpattern("blade").
  13. Set servos to ship:partsdubbedpattern("servo").
  14. set rotors to ship:partsdubbedpattern("rotor").
  15.  
  16. for rotor in rotors rotor:getmodulebyindex(1):setfield("torque limit(%)",100).
  17. set taltpid:setpoint to talt.
  18. on talt {set taltpid:setpoint to talt. return true. }
  19.  
  20. lock rpmlimit to taltpid:update(time:Seconds, altitude).
  21.  
  22. set adjust to true.
  23. when true then {
  24. For b in blades b:getmodule("ModuleControlSurface"):setfield("deploy angle",deploy).
  25. for rotor in rotors rotor:getmodulebyindex(1):setfield("rpm limit",rpmlimit).
  26. set relVelVec to vxcl(up:vector, tv - velocity:surface) / 3.5.
  27. set relVelVec:mag to min(sl,relVelVec:mag).
  28. lock steering to lookdirup(up:vector * 10 + relVelVec, facing:topvector).
  29. return adjust.
  30. }
  31.  
  32.  
Add Comment
Please, Sign In to add comment