View difference between Paste ID: qsDNq69S and KpyusXv3
SHOW: | | - or go back to the newest paste.
1-
set x to 90. 
1+
2
3
set taltpid to pidloop(10, 0.7, 1.5, 100, 360). 
4
5
set steeringmanager:pitchtorquefactor to 0.2.
6
set steeringmanager:yawtorquefactor to 0.5.
7
set steeringmanager:rollcontrolanglerange to 180.
8
9
steeringmanager:resetpids().
10-
for rotor in ship:partsdubbedpattern("rotor") rotor:getmodulebyindex(1):setfield("torque limit(%)",100).
10+
lock x to 90. 
11
set p to 0. 
12
set a to 2. 
13
set talt to 300. 
14
lock steering to heading(x,p). 
15-
For b in blades b:getmodule("ModuleControlSurface"):setfield("deploy angle",deploy). 
15+
16-
For s in servos s:getmodule("ModuleRoboticRotationServo"):setfield("target angle",tilt). 
16+
17-
return adjust.
17+
18-
}
18+
19
set rotors to ship:partsdubbedpattern("rotor").
20
lock tilt to 0.
21
for rotor in rotors rotor:getmodulebyindex(1):setfield("torque limit(%)",100).
22
set taltpid:setpoint to talt. 
23
on talt {set taltpid:setpoint to talt. return true. }
24
25
lock rpmlimit to taltpid:update(time:Seconds, altitude).
26
when alt:radar > 100 then { set tilt to 20. lock x to allwaypoints()[2]:geoposition:heading - 90. }
27
set adjust to true. 
28
when true then {
29
	For b in blades b:getmodule("ModuleControlSurface"):setfield("deploy angle",deploy). 
30
	for rotor in rotors rotor:getmodulebyindex(1):setfield("rpm limit",rpmlimit).
31
	For s in servos s:getmodule("ModuleRoboticRotationServo"):setfield("target angle",tilt).
32
	return adjust.
33
}
34
35
set sgp to 0. 
36
set sggo to true. 
37
set sgf to 8. 
38
set sgpr to 4. 
39
function sgd { 
40
	parameter l. 
41
	parameter d. 
42
	If l:length > sgpr set sgpr to l:length. 
43
	print (l:padleft(sgpr) + ": " +round(d,2)):padright(terminal:width) at (0, sgp). 
44
	set sgp to sgp + 1. 
45
}.
46
47
On round(kuniverse:realtime * sgf) { 
48
	set sgp to 0. sgd("vs", ship:verticalspeed). 
49
	sgd("rpmlimit", rpmlimit). 
50
	sgd("output", taltpid:output). 
51
	sgd("error", taltpid:error). 
52
	sgd("setpoint", taltpid:setpoint). 
53
	sgd("P", taltpid:Pterm). 
54
	sgd("I", taltpid:Iterm). 
55
	sgd("D", taltpid:Dterm). 
56
	sgd("kP", taltpid:kp). 
57
	sgd("kI", taltpid:ki). 
58
	sgd("kD", taltpid:kd). 
59
	return sggo. 
60
}
61
62