Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; this was converted to code from nodes so is a bit of a mess
- const $mynumber1 = 0.200000
- var $_plane_counter1 = 0
- var $dash = screen("dash1", 0)
- var $battCharge = 0
- var $stabRoll = 0.0
- var $stabPitch = 0.0
- function @pid1($_setpoint:number, $_processvalue:number, $_kp:number, $_ki:number, $_kd:number, $_integral:number, $_prev_error:number) : number
- var $_error = $_setpoint - $_processvalue
- var $_dt = delta_time
- var $_derivative = ($_error - $_prev_error) / $_dt
- $_integral += $_error * $_dt
- $_prev_error = $_error
- return $_kp * $_error + $_ki * $_integral + $_kd * $_derivative
- init
- $dash.blank()
- update
- var $_input_number_9_1 = input_number(9, 1) ; Back/Fwd
- var $_input_number_9_5 = input_number(9, 5) ; Roll
- output_number(2, 0, ($_input_number_9_5 * 0.75))
- output_number(1, 1, ($_input_number_9_5 * -0.75))
- var $_input_number_9_2 = input_number(9, 2) ; Left/Right
- ; moved to stab
- var $_input_number_9_8 = input_number(9, 8) ; Aux 1
- output_number(7, 3, $_input_number_9_8)
- ;var $wheelie = input_number(9,9)
- ;output_number(7, 0, $wheelie)
- var $tilt = input_number("tilt_roll", 0)
- var $pitch = input_number("tilt_pitch", 0)
- var $speed = input_number("speed", 0)
- var $altitude_abs = input_number("altitude", 0)
- var $altitude = input_number("altitude", 1)
- var $stabsw = input_number("dash1", 2)
- if $stabsw == 1
- $stabRoll = $tilt * -2
- output_number(6, 0, -($stabRoll))
- output_number(11, 0, $stabRoll)
- else
- output_number(6, 0, (-($_input_number_9_2 * 0.75)))
- output_number(11, 0, ($_input_number_9_2 * 0.75))
- var $pitchsw = input_number("dash1", 1)
- if $pitchsw == 1
- $stabPitch = @pid1(0.12, $pitch, 0.3,0.2,0.1,0,0)
- output_number(3, 0, $stabPitch)
- else
- output_number(3, 0, ($_input_number_9_1 * -0.75))
- var $_input_number_9_3 = input_number(9, 3) ; Down/Up
- var $_input_number_9_17 = input_number(9, 17) ; Aux 0
- $_plane_counter1 += $_input_number_9_3
- if $_plane_counter1 < 0
- $_plane_counter1 = 0
- if $_plane_counter1 > 100
- $_plane_counter1 = 100
- if $_input_number_9_17
- $_plane_counter1 = 0
- output_number(8, 0, ($_plane_counter1 / 100))
- output_number(8, 1, $mynumber1)
- ; dashboard
- $battCharge = input_number("battery1", 2)*100
- $dash.blank()
- $dash.text_size(0.7)
- $dash.write(2, 2, green, text(" Battery: {0}%", $battCharge))
- $dash.write(2, 12, green, text(" Throttle: {0}", $_plane_counter1))
- $dash.write(2, 22, green, text(" Speed: {0}", $speed))
- $dash.write(2, 32, green, text("Radar Alt: {0}", $altitude))
- $dash.write(2, 42, green, text(" Altitude: {0}k", $altitude_abs/1000))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement