Interface for FlightGear network connections
Project description
FlightGear Python Interface
flightgear-python
is an interface package to the FlightGear flight simulation software aimed at simplicity.
Install: pip3 install flightgear-python
Don't know where to begin? Check out the quick-start documentation.
FDM example, from examples/simple_fdm.py
"""
Simple Flight Dynamics Model (FDM) example that makes the altitude increase and the plane roll in the air.
"""
import time
from flightgear_python.fg_if import FDMConnection
def fdm_callback(fdm_data, event_pipe):
phi_rad_child, = event_pipe.child_recv() # unpack tuple
# set only the data that we need to
fdm_data['phi_rad'] = phi_rad_child # we can force our own values
fdm_data.alt_m = fdm_data.alt_m + 0.5 # or just make a relative change
return fdm_data # return the whole structure
"""
Start FlightGear with `--native-fdm=socket,out,30,,5501,udp --native-fdm=socket,in,30,,5502,udp`
(you probably also want `--fdm=null` and `--max-fps=30` to stop the simulation fighting with
these external commands)
"""
fdm_conn = FDMConnection(fdm_version=24) # May need to change version from 24
fdm_event_pipe = fdm_conn.connect_rx('localhost', 5501, fdm_callback)
fdm_conn.connect_tx('localhost', 5502)
fdm_conn.start() # Start the FDM RX/TX loop
phi_rad_parent = 0.0
while True:
phi_rad_parent += 0.02
# could also do `fdm_conn.event_pipe.parent_send` so you just need to pass around `fdm_conn`
fdm_event_pipe.parent_send((phi_rad_parent,)) # send tuple
time.sleep(0.01)
Supported interfaces:
- Native Protocol (currently only UDP)
- Flight Dynamics Model (
net_fdm.hxx
) - Controls (
net_ctrls.hxx
) - GUI (
net_gui.hxx
)
- Flight Dynamics Model (
- Generic Protocol
- Telnet
- HTTP
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flightgear_python-1.1.0.tar.gz
(10.3 kB
view hashes)
Built Distribution
Close
Hashes for flightgear_python-1.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7412200a3ddfbd346ea44b7102080b924ef06db75c03a9de8750b4fbac0411dd |
|
MD5 | 7508740a4317cb8a2ceb8f4e2a65ce6f |
|
BLAKE2b-256 | b98b32d1f6dd6ece18e36eacb85e7091ca23bebd06d7f796e40510e61c274271 |