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.(?)
This commit is contained in:
parent
cf86ca67f8
commit
1d15a9272b
3 changed files with 24 additions and 11 deletions
|
@ -100,7 +100,7 @@ class FlightGear:
|
||||||
except socket.error, msg:
|
except socket.error, msg:
|
||||||
self.telnet = None
|
self.telnet = None
|
||||||
raise socket.error, msg
|
raise socket.error, msg
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
# Ensure telnet connection is closed cleanly.
|
# Ensure telnet connection is closed cleanly.
|
||||||
self.quit();
|
self.quit();
|
||||||
|
@ -130,7 +130,7 @@ class FlightGear:
|
||||||
return 0
|
return 0
|
||||||
else:
|
else:
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
"""Set a FlightGear property value."""
|
"""Set a FlightGear property value."""
|
||||||
self.telnet.set( key, value )
|
self.telnet.set( key, value )
|
||||||
|
@ -140,3 +140,12 @@ class FlightGear:
|
||||||
if self.telnet:
|
if self.telnet:
|
||||||
self.telnet.quit()
|
self.telnet.quit()
|
||||||
self.telnet = None
|
self.telnet = None
|
||||||
|
|
||||||
|
def view_next(self):
|
||||||
|
#move to next view
|
||||||
|
self.telnet.set( "/command/view/next", "true")
|
||||||
|
|
||||||
|
def view_prev(self):
|
||||||
|
#move to next view
|
||||||
|
self.telnet.set( "/command/view/prev", "true")
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -5,8 +5,12 @@ def main():
|
||||||
fg = FlightGear('localhost', 5500)
|
fg = FlightGear('localhost', 5500)
|
||||||
|
|
||||||
# Wait five seconds for simulator to settle down
|
# Wait five seconds for simulator to settle down
|
||||||
while fg['/sim/time/elapsed-ms'] < 5000:
|
while 1:
|
||||||
|
if fg['/sim/time/elapsed-sec'] > 5:
|
||||||
|
break
|
||||||
time.sleep(1.0)
|
time.sleep(1.0)
|
||||||
|
print fg['/sim/time/elapsed-sec']
|
||||||
|
|
||||||
|
|
||||||
# parking brake on
|
# parking brake on
|
||||||
fg['/controls/parking-brake'] = 1
|
fg['/controls/parking-brake'] = 1
|
||||||
|
@ -17,14 +21,14 @@ def main():
|
||||||
fg.view_next()
|
fg.view_next()
|
||||||
|
|
||||||
fg['/sim/current-view/goal-heading-offset-deg'] = 180.0
|
fg['/sim/current-view/goal-heading-offset-deg'] = 180.0
|
||||||
fg.wait_for_prop_eq('/sim/current-view/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['/sim/current-view/goal-heading-offset-deg'] = 90.0
|
||||||
fg.wait_for_prop_eq('/sim/current-view/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['/sim/current-view/goal-heading-offset-deg'] = 0.0
|
||||||
fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 0.0)
|
#fg.wait_for_prop_eq('/sim/current-view/heading-offset-deg', 0.0)
|
||||||
|
|
||||||
time.sleep(2.0)
|
time.sleep(2.0)
|
||||||
|
|
||||||
# Switch back to cockpit view
|
# Switch back to cockpit view
|
||||||
|
@ -34,9 +38,9 @@ def main():
|
||||||
|
|
||||||
# Flaps to take off position
|
# Flaps to take off position
|
||||||
fg['/controls/flaps'] = 0.34
|
fg['/controls/flaps'] = 0.34
|
||||||
fg.wait_for_prop_eq('/surface-positions/flap-pos-norm', 0.34)
|
#fg.wait_for_prop_eq('/surface-positions/flap-pos-norm', 0.34)
|
||||||
|
|
||||||
fg.quit()
|
fg.quit()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue