File: demo.py

package info (click to toggle)
flightgear 1.0.0-3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,260 kB
  • ctags: 22,860
  • sloc: cpp: 125,656; ansic: 5,361; sh: 3,628; makefile: 925; perl: 680; python: 109
file content (46 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from FlightGear import FlightGear
import time

def main():
    fg = FlightGear('localhost', 5500)

    # Wait five seconds for simulator to settle down
    while 1:
        if fg['/sim/time/elapsed-sec'] > 5:
            break
        time.sleep(1.0)
        print fg['/sim/time/elapsed-sec']


    # parking brake on
    fg['/controls/parking-brake'] = 1

    heading = fg['/orientation/heading-deg']

    # Switch to external view for for 'walk around'.
    fg.view_next()

    fg['/sim/current-view/goal-heading-offset-deg'] = 180.0
    #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 180.0)

    fg['/sim/current-view/goal-heading-offset-deg'] = 90.0
    #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 90.0)

    fg['/sim/current-view/goal-heading-offset-deg'] = 0.0
    #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 0.0)

    time.sleep(2.0)

    # Switch back to cockpit view
    fg.view_prev()

    time.sleep(2.0)

    # Flaps to take off position
    fg['/controls/flaps'] = 0.34
    #fg.wait_for_prop_eq('/surface-positions/flap-pos-norm', 0.34)

    fg.quit()

if __name__ == '__main__':
    main()