Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase Data Rate? #123

Open
PowerBroker2 opened this issue Sep 25, 2022 · 2 comments
Open

Increase Data Rate? #123

PowerBroker2 opened this issue Sep 25, 2022 · 2 comments

Comments

@PowerBroker2
Copy link

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('')
@TyraelDLee
Copy link

TyraelDLee commented Jun 4, 2024

Have the same concern. But it seems limited by MSFS; when I set the "GLASS COCKPIT REFRESH RATE" to high in the MSFS setting, the sampling rate is increased. All other factors depend on your CPU, I guess. I don't have a very powerful CPU, I just get ~2hz when I set the refresh rate to high (1hz with medium). MSFS is not well optimized for CPU load. If you wish do some optimization on server and client, WebSocket might be helpful.

@PowerBroker2
Copy link
Author

@odwdinc Is this repo abandoned or is it still maintained?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants