Advertisement
sumguytwitches

straight prop control

May 21st, 2023 (edited)
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. set steeringmanager:rollcontrolanglerange to 180.
  2. set proprad to 5.8.
  3. set rotormods to ship:modulesnamed("ModuleRoboticServoRotor").
  4. set rotors to list().
  5. for rm in rotormods {
  6. local rotor to lexicon().
  7. set rotor["part"] to rm:part.
  8. set rotor["mod"] to rm.
  9.  
  10. set rotor["blades"] to list().
  11. for bm in rm:part:ModulesNamed("ModuleControlSurface") {
  12. local b to bm:part.
  13.  
  14. local blade to lexicon().
  15. set blade["mod"] to bm.
  16. set blade["offset"] to vdot(-b:Facing:starvector, b:position - b:parent:position).
  17. set blade["proprad"] to proprad.
  18.  
  19. bm:setfield("deploy", true).
  20.  
  21. rotor["blades"]:add(blade).
  22. }
  23.  
  24. rotors:add(rotor).
  25. rm:setfield("torque limit(%)", 100).
  26. }
  27.  
  28. set first to true.
  29. set taraoa to 4.5.
  30. set deploycopy to 9.
  31. Fuelcells on.
  32. set displayIndex to 0.
  33.  
  34. //Lock Vars
  35. set rpmtarget to min(459,max(0, throttle * 460)).
  36.  
  37. //Functions
  38.  
  39. //Control Loop
  40. on round(time:seconds * 10) {
  41. set rpmtarget to min(459,max(0, throttle * 460)).
  42. set rpmcopy to rpmtarget.
  43. for rotor in rotors {
  44. local currrpm to rpmcopy.
  45. rotor:mod:setfield("rpm limit", rpmcopy ).
  46. set calcAirspeed to (2 * constant:pi * (rotor:blades[0]:proprad + rotor:blades[0]:offset) * currrpm/60).
  47. set deploycopy to max(3, taraoa + arctan2(airspeed, calcAirspeed)).
  48. for blade in rotor:blades {
  49. blade:mod:setfield("deploy angle", deploycopy).
  50. }
  51. }
  52.  
  53. return first.
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement