SHOW:
|
|
- or go back to the newest paste.
| 1 | for i in range(terminal:height-3) Print "":padright(terminal:width). | |
| 2 | ||
| 3 | ||
| 4 | //////////////////// VARS ////////////////// | |
| 5 | ||
| 6 | ||
| 7 | set taralt to 100. | |
| 8 | set currheading to body:geopositionof(ship:facing:vector):heading. | |
| 9 | - | lock x to body:geopositionof(ship:facing:vector):heading. |
| 9 | + | lock x to currheading. |
| 10 | lock p to 15. | |
| 11 | - | lock p to 0. |
| 11 | + | lock throttle to 1. |
| 12 | - | lock roll to 0. |
| 12 | + | lock steering to heading(x,p). |
| 13 | ||
| 14 | lock sl to 0. | |
| 15 | ||
| 16 | - | lock vtolrpmtarget to min(460,max(0,((taralt-alt:radar)-verticalspeed) * 230)). |
| 16 | + | set steeringmanager:rollcontrolanglerange to 180. |
| 17 | - | lock pushrpmtarget to min(460,max(0,throttle * 460)). |
| 17 | + | |
| 18 | - | set speedPID to pidloop(1.5, 0, 0, -5, 5). |
| 18 | + | |
| 19 | - | set steeringmanager:rollcontrolanglerange to 170. |
| 19 | + | |
| 20 | - | set rollim to 30. |
| 20 | + | |
| 21 | set proprad to 5.8. | |
| 22 | set rotormods to ship:modulesnamed("ModuleRoboticServoRotor").
| |
| 23 | set rotors to list(). | |
| 24 | for rm in rotormods {
| |
| 25 | ||
| 26 | local rotor to lexicon(). | |
| 27 | set rotor["part"] to rm:part. | |
| 28 | set rotor["mod"] to rm. | |
| 29 | set rotor["job"] to choose "push" if rm:part:parent:tag:contains("push") else "vtol".
| |
| 30 | print "Found rotor module for job of " + rotor:job. | |
| 31 | set rotor["mode"] to "flight". | |
| 32 | ||
| 33 | set rotor["blades"] to list(). | |
| 34 | for bm in rm:part:ModulesNamed("ModuleControlSurface") {
| |
| 35 | local b to bm:part. | |
| 36 | ||
| 37 | local blade to lexicon(). | |
| 38 | set blade["mod"] to bm. | |
| 39 | set blade["offset"] to vdot(-b:Facing:starvector, b:position - b:parent:position). | |
| 40 | set blade["proprad"] to proprad. | |
| 41 | set blade["angleratio"] to 2 * constant:pi * (blade:proprad + blade:offset)/60. | |
| 42 | ||
| 43 | bm:setfield("deploy", true).
| |
| 44 | ||
| 45 | rotor["blades"]:add(blade). | |
| 46 | } | |
| 47 | ||
| 48 | rotors:add(rotor). | |
| 49 | } | |
| 50 | print "rotors setup". | |
| 51 | ||
| 52 | set deploycopy to 9. | |
| 53 | - | if rm:hasfield("torque limit(%)") rm:setfield("torque limit(%)", 100).
|
| 53 | + | |
| 54 | brakes on. | |
| 55 | gear on. | |
| 56 | set flightmode to "plane". | |
| 57 | - | set aoatopressure to 9. |
| 57 | + | |
| 58 | function SetAngle {
| |
| 59 | - | set taraoa to 4.68. |
| 59 | + | |
| 60 | if flightmode = "debug" print targetangle at (0,0). | |
| 61 | for s in servos if s:hasfield("target angle") s:setfield("target angle", targetangle).
| |
| 62 | - | set takeoff to true. |
| 62 | + | |
| 63 | - | set flightmode to "vtol". |
| 63 | + | |
| 64 | ||
| 65 | function save {
| |
| 66 | print "waiting for valid save state". | |
| 67 | when (ship:Status = "Landed" or ship:status = "Splashed") and ship:velocity:surface:mag < 0.1 then {
| |
| 68 | print "saving". | |
| 69 | kuniverse:quicksaveto(ship:name). | |
| 70 | print "saved to '" + ship:name + "'". | |
| 71 | - | function stop {
|
| 71 | + | |
| 72 | - | print "stopping". |
| 72 | + | |
| 73 | - | lock vtolrpmtarget to throttle * 460. |
| 73 | + | lock torque to throttle * 100. |
| 74 | - | lock pushrpmtarget to 0. |
| 74 | + | lock deploy to 9. |
| 75 | - | ship:partsdubbedpattern("cockpit")[0]:controlfrom().
|
| 75 | + | |
| 76 | - | set x2 to x. |
| 76 | + | set torquecopy to torque. |
| 77 | - | lock p to -verticalspeed * 3. |
| 77 | + | set deploycopy to deploy. |
| 78 | ||
| 79 | - | lock steering to heading(x2,p,-roll). |
| 79 | + | |
| 80 | - | lock throttle to choose 1 if airspeed > 10 else -verticalspeed*3. |
| 80 | + | rotor:mod:setfield("torque limit(%)", torquecopy).
|
| 81 | - | set flightmode to "hover". |
| 81 | + | |
| 82 | - | |
| 82 | + | |
| 83 | - | |
| 83 | + | |
| 84 | - | when groundspeed < 10 then {
|
| 84 | + | |
| 85 | - | lock throttle to -verticalspeed - min(20,alt:Radar/10). |
| 85 | + | |
| 86 | return true. | |
| 87 | } | |
| 88 | ||
| 89 | - | function go {
|
| 89 | + | |
| 90 | - | brakes off. |
| 90 | + | set loop to true. when true then { set dv to airspeed - oldairspeed. set oldairspeed to airspeed. }
|
| 91 | - | print "going". |
| 91 | + | |
| 92 | - | stopping off. |
| 92 | + | autoblade off. wait 0. autoblade on. set dvwiggle to 0.002. when abs(dv) < dvwiggle then { set deploy to deploy + 0.05. return autoblade. } when true then { set dv to airspeed - oldairspeed. set oldairspeed to airspeed. return true. } |