Debian Codegraph @

scripts/python/demo.py

raw symbols SCIP
1 #! /usr/bin/env python3
2 # -*- coding: utf-8 -*-
3
4 from FlightGear import FlightGear
5 import time
6
7 def main():
8 fg = FlightGear('localhost', 5500)
9
10 # Wait five seconds for simulator to settle down
11 while 1:
12 if fg['/sim/time/elapsed-sec'] > 5:
13 break
14 time.sleep(1.0)
15 print(fg['/sim/time/elapsed-sec'])
16
17
18 # parking brake on
19 fg['/controls/parking-brake'] = 1
20
21 # heading = fg['/orientation/heading-deg']
22
23 # Switch to external view for for 'walk around'.
24 fg.view_next()
25
26 fg['/sim/current-view/goal-heading-offset-deg'] = 180.0
27 #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 180.0)
28
29 fg['/sim/current-view/goal-heading-offset-deg'] = 90.0
30 #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 90.0)
31
32 fg['/sim/current-view/goal-heading-offset-deg'] = 0.0
33 #fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 0.0)
34
35 time.sleep(2.0)
36
37 # Switch back to cockpit view
38 fg.view_prev()
39
40 time.sleep(2.0)
41
42 # Flaps to take off position
43 fg['/controls/flaps'] = 0.34
44 #fg.wait_for_prop_eq('/surface-positions/flap-pos-norm', 0.34)
45
46 fg.quit()
47
48 if __name__ == '__main__':
49 main()