Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Hi everyone, my first time here!

I have a specific question on FSUIPC capability:

Is FSUIPC capable of retrieving accurate and up to date values of LAT, LON, ALT, PITCH, BANK and HEADING of a current USER aircraft?

I need this info on sim's every visual frame (as in, not a sim frame - I am not developing any PID or INS-related capabilities). I need this data in order to attach other SimObject to the user aircraft and closely follow it, as in, cargo pallets, external fuel tanks, adventure cargo (kayaks and gear attached to airplanes' floats), other aircraft (such as X-15 under B-52 or Orbiter on SCA 747), and sure, weapons. 

Background: I do this right now using SimConnect, however the data obtained through SimConnect's Request/Set mechanism comes with a certain time lag. As a result, the object attached to user aircraft exhibits a bit of a positional lag, as if it is attached with a rubber band that twitches. I am guessing that, by the time I get the data, it is a few cycles "old" and the user plane has moved up ahead a little. I have managed to improve this by using token variable mechanism in SimConnect, and managed to minimize the lag in Lat and Lon plane, but the altitude data is still showing quite a bit of a lag. So basically, I would need LAT LON ALT, PITCH BANK HEADING values of sim's user object VISUAL model, right after the frame update, so that I can set this to my SimObject and send it to the sim before the next update happens (or, that is my general understanding of SimConnect client/server communication, please feel free to correct me if I am wrong)

I'm a fairly advanced SimConnect programmer. A while ago, I developed a spaceflight physics model (Video Here) for P3D where you can launch into orbit using a rocket made of almost 20 separate components (SimObjects). This was possible because I used SimConnect functionality to freeze position and attitude of all of the objects, and I was in control of position/attitude of every single part of the rocket (including user-controlled capsule). For this application, I have all the object offsetting and alignment math working, but it all relies on an accurate position/attitude data of the user aircraft, which is still under simulator's flight model control. 

I'm attaching a screenshot of the current state of things (a SimConnect/WASM module) - a Space Shuttle Orbiter attached to the default MSFS2020 B747. It works well, except for the vertical object oscillations when the altitude is changing.

Any insight very much appreciated,
Mitch
TerraBuilder Team

image

Posted
7 minutes ago, TerraBuilder Team said:

Is FSUIPC capable of retrieving accurate and up to date values of LAT, LON, ALT, PITCH, BANK and HEADING of a current USER aircraft?

I am not sure what you are asking.... FSUIPC is a simconnect client, and is therefore restricted to the update frequency allowed by simconnect. Different data is requested indifferent frequencies - some in visual frame, some in sim frame, some in second, but always tagged (i.e. only received when changed). 

Most data is requested in sim frame (SIMCONNECT_PERIOD_SIM_FRAME), but also a lot in visual frame (SIMCONNECT_PERIOD_VISUAL_FRAME). If you let me know which offsets/simvars you are interested in. I can let you know the request frequency.

But FSUIPC is a simconnect client, and has the same restrictions as all clients, And in MSFS2020, FSUIPC is an external client, not an embedded dll, so there is always going to be a lag in communication between an external app compared to an embedded dll.

In summary, FSUIPC IS a simconnect client, and can only receive data via this interface. It does have an embedded/WASM component, but that is used only for lvar/hvar/calculator code.

The data update rates are always going to be restricted by the provider, not the client.

John

Posted (edited)

Thanks John,

Ok, got it. I thought FSUIPC was similar to SimConnect, but not its client (since it exists from way back, I believe FS98, long before SimConnect existed)

SimVars I am after are:

    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE LATITUDE",                "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE LONGITUDE",                "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE ALTITUDE",                "meters");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE PITCH DEGREES",            "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE BANK DEGREES",            "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE HEADING DEGREES TRUE",    "degrees");

Ideally, if the SimObject position could be reliably set before the frame update, this would be the only thing needed.

However, I also obtained and applied velocities, in the hope the object motion would be smoothed. It did help to a certain extent. Also, as I mentioned, I switched to using the Token variables, and it seems those are not obtained via SimConnect but by some other mechanism:

MODULE_VAR LAT_var = { PLANE_LATITUDE }; 
LLAGPS.Latitude = GPS_LAT_var.var_value.n * (360.0f / 40007000.0f);

I got better results using the Token vars, but I still can't get rid of the vertical oscillation.

Thanks,
Mitch

Edited by TerraBuilder Team
mispost
Posted
11 minutes ago, TerraBuilder Team said:

I thought FSUIPC was similar to SimConnect, but not its client

Way back in time. FSUIPC hacked into the sim to get the data for the offsets (before my time!), and was instrumental in developing the simconnect API. Once the the API was introduced, it was moved to use this, but also used some hacking for initial simconnect defects. From P3Dv4 and onwards, 95% of functionailiy has been via simconnect, abut some features still used other FS dll functionality, namely via the panels dll. For MSFS2020, everything comes via simconnect, or the embedded FSUIPC WASM module.

21 minutes ago, TerraBuilder Team said:

SimVars I am after are:

    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE LATITUDE",                "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE LONGITUDE",                "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE ALTITUDE",                "meters");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE PITCH DEGREES",            "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE BANK DEGREES",            "degrees");
    hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_USER_AIRCRAFT, "PLANE HEADING DEGREES TRUE",    "degrees");

These are all requested at sim_frame rate in FSUIPC

23 minutes ago, TerraBuilder Team said:

Ideally, if the SimObject position could be reliably set before the frame update, this would be the only thing needed.

How can things possibly work faster than the API allows? And there is always going to be a lag between setting and receiving the updated data - everything is asynchronous - you need to allow for this. Setting/updating are different channels than receiving. And the lg between the two depends on many things,,,

27 minutes ago, TerraBuilder Team said:

However, I also obtained and applied velocities, in the hope the object motion would be smoothed. It did help to a certain extent. Also, as I mentioned, I switched to using the Token variables, and it seems those are not obtained via SimConnect but by some other mechanism:

MODULE_VAR LAT_var = { PLANE_LATITUDE }; 
LLAGPS.Latitude = GPS_LAT_var.var_value.n * (360.0f / 40007000.0f);

I got better results using the Token vars, but I still can't get rid of the vertical oscillation.

Sorry, this is beyond me - what are "Token vars"?

MSFS has various SDKs for different applications - take a look at those, FSUIPC is a 3rd-party simconnect application providing a uniform interface to multiple flight sims for 3rd party developers (amongst other things). We stopped hacking into the sim code after FSUIPC4, as this was a maintenance nightmare....

John

Posted

Hi John,

Most of the variables available through SimConnect's Request event mechanism are also available through WASM/C++ Gauges' Token Variables. However they are not the same as SimVars, but are specific to Gauge API. I am not sure what mechanism they employ, but they do seem to obtain aircraft parameters directly, without the need for a request. 

Thanks for your answers, I really appreciate it as it clarifies most of the things I needed to know!

Cheers,
Mitch

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.