Skip to main content

Interface for FlightGear network connections

Project description

FlightGear Python Interface

Documentation Status CircleCI Coverage Status PyPI - Python Version PyPI - Downloads

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.

Flight Dynamics Model (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):
    if event_pipe.child_poll():
        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,localhost,5501,udp --native-fdm=socket,in,30,localhost,5502,udp`
(you probably also want `--fdm=null` and `--max-fps=30` to stop the simulation fighting with
these external commands)
"""
if __name__ == '__main__':  # NOTE: This is REQUIRED on Windows!
    fdm_conn = FDMConnection()
    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.1
        # 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.5)

Supported interfaces:

Project details


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-2.0.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flightgear_python-2.0.1-py3-none-any.whl (16.6 kB view details)

Uploaded Python 3

File details

Details for the file flightgear_python-2.0.1.tar.gz.

File metadata

  • Download URL: flightgear_python-2.0.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.8.20 Linux/5.15.0-1057-aws

File hashes

Hashes for flightgear_python-2.0.1.tar.gz
Algorithm Hash digest
SHA256 22caaa42a4aed3537c0a43880103bf1aaedc17ed9f17c08987c717d37f4e670a
MD5 19068cdbd265bb22d5beaee5ce1e9f92
BLAKE2b-256 92eee25796945aaeea2448817bc5e260aff934043b391e356ee131864dc13d39

See more details on using hashes here.

File details

Details for the file flightgear_python-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: flightgear_python-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 16.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.8.20 Linux/5.15.0-1057-aws

File hashes

Hashes for flightgear_python-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d66f2a360269e2ff8d8dc204598755bfad1a9b57f45e192ad26acb6064baa865
MD5 7553281c13e20854afa40a370178e599
BLAKE2b-256 6859ff1d640c52640178a196ff38a9fed7b0df3e1040aafe8817a107b709b68b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page