示例#1
0
from fgclient import FgClient
c = FgClient()
c.ap_pitch_off()

initial_altitide = c.altitude_ft()
integral_error = 0.0
kk = 0
dt = 0.5
while True:
    kk += 1
    c.tic()
    if kk > 10:
        alt_des = initial_altitide + 100
    else:
        alt_des = initial_altitide
    alt = c.altitude_ft()
    vs_des = 0.03*(alt_des - alt)
    vs = c.vertical_speed_fps()
    integral_error = integral_error + dt*(vs_des - vs)
    c.set_elevator(-0.014*((vs_des - vs) + 0.4*integral_error))
    print(alt_des,alt,vs_des,vs)
    c.toc(dt)
示例#2
0
from fgclient import FgClient
c = FgClient()

a_des = c.altitude_ft() + 100.0

int_err = 0.0
kk = 0
while True:
    kk += 1
    c.tic()
    a = c.altitude_ft()
    vs_des = 0.05 * (a_des - a)
    vs = c.vertical_speed_fps()
    err = (vs_des - vs)
    int_err += 0.5 * err
    c.set_elevator(-0.04 * err - 0.02 * int_err)
    print(a_des, a, vs_des, vs)
    c.toc(0.5)
Start up and take off from simulator reset
"""
from fgclient import FgClient
c = FgClient()

c.set_prop('/controls/engines/engine/magnetos', 3)
c.set_prop('/controls/engines/engine/throttle', 0.75)
c.set_prop('/controls/gear/brake-parking', 0)
c.set_prop('/sim/hud/visibility[0]', 1)
c.set_aileron(0.0)
c.set_elevator(0.0)

c.set_prop('/controls/engines/engine/starter', 1)

for kk in range(30):
    c.tic()
    sp = c.get_prop_float('/velocities/airspeed-kt')
    print(sp)
    if sp > 50:
        c.set_elevator(-0.1)
    c.toc(1.0)

for kk in range(30):
    c.tic()
    alt = c.altitude_ft()
    print(alt)
    if alt > 200:
        c.set_elevator(0.0)
        c.ap_roll_hdg(180)
        c.ap_pitch_vs(10)
    c.toc(1.0)