SHOW:
|
|
- or go back to the newest paste.
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 | if rotor:part:parent:name:contains("bay") { | |
10 | set baymod to rotor:part:parent:getmodule("ModuleAnimateGeneric"). | |
11 | if baymod:hasevent("open") baymod:doevent("open"). | |
12 | } | |
13 | set rotor["blades"] to list(). | |
14 | for bm in rm:part:ModulesNamed("ModuleControlSurface") { | |
15 | ||
16 | set bladepart to bm:part. | |
17 | local blade to lexicon(). | |
18 | set blade["mod"] to bm. | |
19 | set blade["offset"] to vdot(-bladepart:Facing:starvector, bladepart:position - bladepart:parent:position). | |
20 | set blade["proprad"] to proprad. | |
21 | ||
22 | bm:setfield("deploy", true). | |
23 | ||
24 | - | //preflight checks |
24 | + | |
25 | } | |
26 | ||
27 | rotors:add(rotor). | |
28 | rm:setfield("torque limit(%)", 0). | |
29 | - | rm:setfield("rpm limit",0). |
29 | + | rm:setfield("rpm limit", 460). |
30 | - | rm:setfield("brake",0). |
30 | + | |
31 | - | rm:setfield("motor",1). |
31 | + | |
32 | - | rm:setfield("torque limit(%)", 100). |
32 | + | |
33 | set first to true. | |
34 | set tarbladeaoa to 4.5. | |
35 | set deploycopy to 9. | |
36 | Fuelcells on. | |
37 | ||
38 | //Lock Vars | |
39 | lock torque to throttle * 100. | |
40 | lock deploy to 9. | |
41 | ||
42 | - | set rpmtarget to min(459,max(0, throttle * 460)). |
42 | + | |
43 | set LoopHz to 10. | |
44 | on round(time:seconds * LoopHz ) { | |
45 | ||
46 | set torquecopy to torque. | |
47 | - | set rpmtarget to min(459,max(0, throttle * 460)). |
47 | + | set deploycopy to deploy. |
48 | - | set rpmcopy to rpmtarget. |
48 | + | |
49 | for rotor in rotors { | |
50 | - | local currrpm to rpmcopy. |
50 | + | rotor:mod:setfield("torque limit(%)", torquecopy). |
51 | - | rotor:mod:setfield("rpm limit", rpmcopy ). |
51 | + | for blade in rotor:blades { |
52 | - | set calcAirspeed to (2 * constant:pi * (rotor:blades[0]:proprad + rotor:blades[0]:offset) * currrpm/60). |
52 | + | blade:mod:setfield("deploy angle", deploycopy). |
53 | - | set deploycopy to max(3, tarbladeaoa + arctan2(airspeed, calcAirspeed)). |
53 | + | } |
54 | - | for blade in rotor:blades { |
54 | + | |
55 | - | blade:mod:setfield("deploy angle", deploycopy). |
55 | + | |
56 | ||
57 | - | } |
57 | + | |
58 | return first. | |
59 | } |