1
0
Fork 0
flightgear/scripts/python/demo.py
mfranz 1d15a9272b George PATTERSON:
"Flightgear.py
- Added the procedures view_next and view_prev

demo.py
- altered the wait five seconds to the new property path and allowed for
the script to be started after five seconds of simulation file
(/sim/time/elapsed-sec).
- the section of code was changed to a pythonism as python does not
support do-while loops, instead you break out of a continuous loop.
- Commented out the fg.wait_for_prop_eq() method as I haven't rewritten
that part of the code yet. Not sure of the best way to do that. Those
lines may not be necessary any more."


mf: removed trailing spaces; I updated the pyc, too, but I really think
    it shouldn't be in CVS at all.(?)
2006-10-29 12:34:26 +00:00

46 lines
1.1 KiB
Python

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()