Skip to content

Increase Data Rate? #123

Description

@PowerBroker2

I'm trying to get real-time location and attitude data, but it seems I can only get a ~5Hz data rate using this lib. I'd prefer to stay in Python and not switch to the C++ SDK, so I figure I'd ask here: Is there a way to speed up the data rate?

Here is my current code for reference:

import sys
from os.path import dirname
from pprint import pprint

import numpy as np
from SimConnect import *

SIM_DIR = dirname(__file__)
SRC_DIR = dirname(SIM_DIR)
sys.path.append(SIM_DIR)
sys.path.append(SRC_DIR)

import rotation
import pilotUtils


sm = SimConnect()
aq = AircraftRequests(sm, _time=0)

while not sm.quit:
    lat = aq.PositionandSpeedData.get('PLANE_LATITUDE')
    lon = aq.PositionandSpeedData.get('PLANE_LONGITUDE')
    alt = aq.PositionandSpeedData.get('PLANE_ALTITUDE') 
    
    alt_agl = aq.PositionandSpeedData.get('PLANE_ALT_ABOVE_GROUND')
    
    roll  = aq.PositionandSpeedData.get('PLANE_BANK_DEGREES')
    pitch = aq.PositionandSpeedData.get('PLANE_PITCH_DEGREES')
    yaw   = aq.PositionandSpeedData.get('PLANE_HEADING_DEGREES_TRUE')
    
    airspeed = aq.FlightInstrumentationData.get('AIRSPEED_TRUE')
    
    if None not in [lat, lon, alt, alt_agl, roll, pitch, yaw, airspeed]:
        lla = np.array([lat,           # dd
                        lon,           # dd
                        alt / 3.2808]) # Ft -> m above MSL

        agl = alt_agl / 3.2808 # Ft -> m above AGL

        B_angles_N = np.rad2deg(np.array([-roll,  # Actually radians
                                          -pitch, # Actually radians
                                          yaw]))  # Actually radians
        B_dcm_N = rotation.angle2dcm(B_angles_N,
                                     pilotUtils.DEGREES,
                                     True,
                                     321).squeeze()

        B_airspeed = np.array([airspeed * 0.514444, # Knots -> m/s
                               0,
                               0])
        N_airspeed = B_dcm_N.T @ B_airspeed
        
        pprint(lla)
        pprint(B_angles_N)
        pprint(B_airspeed)
        pprint(N_airspeed)
        print('')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions